Example usage for javax.sound.sampled AudioSystem isConversionSupported

List of usage examples for javax.sound.sampled AudioSystem isConversionSupported

Introduction

In this page you can find the example usage for javax.sound.sampled AudioSystem isConversionSupported.

Prototype

public static boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat) 

Source Link

Document

Indicates whether an audio input stream of a specified format can be obtained from an audio input stream of another specified format.

Usage

From source file:marytts.tests.junit4.EnvironmentTest.java

@Test
public void testMP3Available() throws Exception {
    AudioFormat mp3af = new AudioFormat(new AudioFormat.Encoding("MPEG1L3"), AudioSystem.NOT_SPECIFIED,
            AudioSystem.NOT_SPECIFIED, 1, AudioSystem.NOT_SPECIFIED, AudioSystem.NOT_SPECIFIED, false);
    AudioInputStream waveStream = AudioSystem
            .getAudioInputStream(this.getClass().getResourceAsStream("test.wav"));
    // Now attempt conversion:
    if (MaryRuntimeUtils.canCreateMP3()) {
        assertTrue(AudioSystem.isConversionSupported(mp3af, waveStream.getFormat()));
        AudioInputStream mp3Stream = AudioSystem.getAudioInputStream(mp3af, waveStream);
    } else {/*from  ww w . j av  a2s. c o  m*/
        assertFalse(AudioSystem.isConversionSupported(mp3af, waveStream.getFormat()));
    }
}