[Speex-dev] Decode file written from JSpeex using C/C++ API?

Clifton Craig clifton.craig at gmail.com
Sat Mar 20 16:47:35 PDT 2010


I'm new to Speex and I'm trying to compress audio using JSpeex in a servlet then play it back on the iPhone. I've managed to get Speex to compile on the iPhone by copying the speex and libspeex folders into XCode. I've read the sample code and the PDF documentation and I have a rough idea how to decode a raw stream. (I'm assuming the sampledec source works with raw speex audio samples and doesn't handle ogg containers.) I've also managed to compress a wave file and output a .spx file using JSpeex and the following Groovy code:
AudioInputStream ais = AudioSystem.getAudioInputStream(new File("16Bitprompt.wav"));
AudioFormat wavFormat = ais.getFormat();
AudioFormat speexFormat = 
    new AudioFormat(SpeexEncoding.SPEEX_Q5,
                wavFormat.getSampleRate(),
                -1, // sample size in bits
                wavFormat.getChannels(),
                -1, // frame size
                -1, // frame rate
                false); // little endian
ais = AudioSystem.getAudioInputStream(speexFormat, ais);
AudioSystem.write(ais, SpeexFileFormatType.SPEEX, new File("speex_output.spx"));

I'm assuming this writes to an ogg container? I have a few obvious questions. First, how would I decompress the above output on the iphone? Do I need to fuss with OGG or can I assume the output is raw? I know enough to write/read wave headers using Java or C but I would feel silly writing speex data to a wave container. Does OGG decoding exist in the libspeex API or do I need supplemental ogg libs? Where could I look for a simple hello-world like example dealing with OGG? As a Java developer writing iPhone code I am much more comfortable with JSpeex. Can somebody here straighten me out?

Clifton Craig
Software Engineer
http://codeforfun.wordpress.com
clifton.craig at gmail.com



More information about the Speex-dev mailing list