net.sf.fmj.media.codec
Class JavaSoundCodec

java.lang.Object
  extended by net.sf.fmj.media.AbstractControls
      extended by net.sf.fmj.media.AbstractPlugIn
          extended by net.sf.fmj.media.AbstractCodec
              extended by net.sf.fmj.media.codec.JavaSoundCodec
All Implemented Interfaces:
Codec, Controls, PlugIn

public class JavaSoundCodec
extends AbstractCodec

Converts formats that JavaSound can convert. This has to do some tricks because of the delay in getting data from the converted audio output stream. The streams are designed as streams, not buffer-based, so all our threading and buffer queue tricks mean that we don't get an output buffer right away for an input one. The missing output buffers build up. And then we get EOM, and if the graph processing isn't done right, most of the output buffers never make it to the renderer. TODO: if this is put ahead of com.ibm.media.codec.audio.PCMToPCM in the registry, there are problems playing the safexmas movie. TODO: this should perhaps be in the net.sf.fmj.media.codec.audio package.

Author:
Ken Larson

Field Summary
 
Fields inherited from class net.sf.fmj.media.AbstractCodec
inputFormat, inputFormats, opened, outputFormat
 
Fields inherited from interface javax.media.PlugIn
BUFFER_PROCESSED_FAILED, BUFFER_PROCESSED_OK, INPUT_BUFFER_NOT_CONSUMED, OUTPUT_BUFFER_NOT_FILLED, PLUGIN_TERMINATED
 
Constructor Summary
JavaSoundCodec()
           
 
Method Summary
static byte[] createWavHeader(javax.sound.sampled.AudioFormat f)
          See http://ccrma.stanford.edu/courses/422/projects/WaveFormat/.
static void encodeShortBE(short value, byte[] ba, int offset)
           
static void encodeShortLE(short value, byte[] ba, int offset)
           
 Format[] getSupportedOutputFormats(Format input)
           
 void open()
           
 int process(Buffer input, Buffer output)
           
 
Methods inherited from class net.sf.fmj.media.AbstractCodec
checkInputBuffer, dump, getInputFormat, getOutputFormat, getSupportedInputFormats, isEOM, propagateEOM, setInputFormat, setOutputFormat
 
Methods inherited from class net.sf.fmj.media.AbstractPlugIn
close, getName, reset
 
Methods inherited from class net.sf.fmj.media.AbstractControls
addControl, getControl, getControls, removeControl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.media.PlugIn
close, getName, reset
 
Methods inherited from interface javax.media.Controls
getControl, getControls
 

Constructor Detail

JavaSoundCodec

public JavaSoundCodec()
Method Detail

getSupportedOutputFormats

public Format[] getSupportedOutputFormats(Format input)
Specified by:
getSupportedOutputFormats in interface Codec
Specified by:
getSupportedOutputFormats in class AbstractCodec

open

public void open()
          throws ResourceUnavailableException
Specified by:
open in interface PlugIn
Overrides:
open in class AbstractPlugIn
Throws:
ResourceUnavailableException

process

public int process(Buffer input,
                   Buffer output)
Specified by:
process in interface Codec
Specified by:
process in class AbstractCodec

createWavHeader

public static byte[] createWavHeader(javax.sound.sampled.AudioFormat f)
See http://ccrma.stanford.edu/courses/422/projects/WaveFormat/.

Parameters:
f -
Returns:
the header for the wav

encodeShortLE

public static void encodeShortLE(short value,
                                 byte[] ba,
                                 int offset)

encodeShortBE

public static void encodeShortBE(short value,
                                 byte[] ba,
                                 int offset)