Search in sources :

Example 1 with VorbisStream

use of de.jarnbjo.vorbis.VorbisStream in project jmonkeyengine by jMonkeyEngine.

the class OGGLoader method load.

private AudioData load(InputStream in, boolean readStream, boolean streamCache) throws IOException {
    if (readStream && streamCache) {
        oggStream = new CachedOggStream(in);
    } else {
        oggStream = new UncachedOggStream(in);
    }
    Collection<LogicalOggStream> streams = oggStream.getLogicalStreams();
    loStream = streams.iterator().next();
    //        if (loStream == null){
    //            throw new IOException("OGG File does not contain vorbis audio stream");
    //        }
    vorbisStream = new VorbisStream(loStream);
    streamHdr = vorbisStream.getIdentificationHeader();
    if (!readStream) {
        AudioBuffer audioBuffer = new AudioBuffer();
        audioBuffer.setupFormat(streamHdr.getChannels(), 16, streamHdr.getSampleRate());
        audioBuffer.updateData(readToBuffer());
        return audioBuffer;
    } else {
        AudioStream audioStream = new AudioStream();
        audioStream.setupFormat(streamHdr.getChannels(), 16, streamHdr.getSampleRate());
        // might return -1 if unknown
        float streamDuration = computeStreamDuration();
        audioStream.updateData(readToStream(oggStream.isSeekable()), streamDuration);
        return audioStream;
    }
}
Also used : AudioStream(com.jme3.audio.AudioStream) LogicalOggStream(de.jarnbjo.ogg.LogicalOggStream) VorbisStream(de.jarnbjo.vorbis.VorbisStream) AudioBuffer(com.jme3.audio.AudioBuffer)

Aggregations

AudioBuffer (com.jme3.audio.AudioBuffer)1 AudioStream (com.jme3.audio.AudioStream)1 LogicalOggStream (de.jarnbjo.ogg.LogicalOggStream)1 VorbisStream (de.jarnbjo.vorbis.VorbisStream)1