Search in sources :

Example 91 with AudioInputStream

use of javax.sound.sampled.AudioInputStream in project lwjgl by LWJGL.

the class WaveDataTest method executeMidStreamCreationTest.

private void executeMidStreamCreationTest() {
    try {
        AudioInputStream ais = AudioSystem.getAudioInputStream(WaveDataTest.class.getClassLoader().getResource(filePath));
        int totalSize = ais.getFormat().getChannels() * (int) ais.getFrameLength() * ais.getFormat().getSampleSizeInBits() / 8;
        // skip 1/4 of the stream
        int skip = totalSize / 4;
        long skipped = ais.skip(skip);
        WaveData wd = WaveData.create(ais);
        if (wd == null) {
            System.out.println("executeMidStreamCreationTest::success");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : AudioInputStream(javax.sound.sampled.AudioInputStream) WaveData(org.lwjgl.util.WaveData) LWJGLException(org.lwjgl.LWJGLException)

Example 92 with AudioInputStream

use of javax.sound.sampled.AudioInputStream in project lwjgl by LWJGL.

the class WaveDataTest method executeStreamCreationTest.

private void executeStreamCreationTest() {
    try {
        AudioInputStream ais = AudioSystem.getAudioInputStream(new File(filePath));
        WaveData wd = WaveData.create(ais);
        if (wd == null) {
            System.out.println("executeMidStreamCreationTest::success");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : AudioInputStream(javax.sound.sampled.AudioInputStream) File(java.io.File) WaveData(org.lwjgl.util.WaveData) LWJGLException(org.lwjgl.LWJGLException)

Aggregations

AudioInputStream (javax.sound.sampled.AudioInputStream)92 IOException (java.io.IOException)44 AudioFormat (javax.sound.sampled.AudioFormat)41 UnsupportedAudioFileException (javax.sound.sampled.UnsupportedAudioFileException)27 InputStream (java.io.InputStream)24 ByteArrayInputStream (java.io.ByteArrayInputStream)19 LineUnavailableException (javax.sound.sampled.LineUnavailableException)19 File (java.io.File)18 SourceDataLine (javax.sound.sampled.SourceDataLine)14 Clip (javax.sound.sampled.Clip)13 AudioFileFormat (javax.sound.sampled.AudioFileFormat)12 DataLine (javax.sound.sampled.DataLine)12 FileInputStream (java.io.FileInputStream)11 BufferedInputStream (java.io.BufferedInputStream)10 URL (java.net.URL)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 DataInputStream (java.io.DataInputStream)5 SequenceInputStream (java.io.SequenceInputStream)5 LineEvent (javax.sound.sampled.LineEvent)5 AudioSynthesizer (com.sun.media.sound.AudioSynthesizer)4