[Speex-dev] Speex in flash player: how to work with?

Jozsef Vass jovass at adobe.com
Wed Mar 31 16:27:38 PDT 2010

What are you trying to accomplish? My code sample was about how Flash Player microphone input in speex.

If you want to do decode, please see speexdec.c


-----Original Message-----
From: Max Lapshin [mailto:max.lapshin at gmail.com] 
Sent: Tuesday, March 30, 2010 8:53 AM
To: Jozsef Vass
Cc: speex-dev at xiph.org
Subject: Re: [Speex-dev] Speex in flash player: how to work with?

On Sat, Mar 20, 2010 at 12:04 AM, Jozsef Vass <jovass at adobe.com> wrote:
> Nicer way:
> void* speexState = speex_encoder_init(&speex_wb_mode);
> int speexFrameSize, speexRate;
> speex_encoder_ctl(speexState, SPEEX_GET_FRAME_SIZE, &speexFrameSize);
> speex_encoder_ctl(speexState, SPEEX_GET_SAMPLING_RATE, &speexRate);
> SpeexPreprocessState* speexPreprocessState = speex_preprocess_state_init(speexFrameSize, speexRate);

Jozsef, would you kindly help me.

Both, this code:

_microphone = Microphone.getMicrophone();
_microphone.codec = SoundCodec.SPEEX;
_microphone.encodeQuality = 10;
_microphone.rate = 16;
_microphone.framesPerPacket = 1;
_microphone.gain = 80;

and this code:

_microphone = Microphone.getMicrophone();
_microphone.codec = SoundCodec.SPEEX;
_microphone.gain = 80;

generate frames, which are 10 or 52 bytes long. I try to parse them on C:

driver->decoder = speex_decoder_init(&speex_wb_mode);
speex_decoder_ctl(driver->decoder, SPEEX_GET_FRAME_SIZE, &driver->frame_size);
speex_decoder_ctl(driver->decoder, SPEEX_GET_SAMPLING_RATE,
driver->den = speex_preprocess_state_init(driver->frame_size,

spx_int16_t rec[SPX_SIZE];   // -- here I copy incoming packets, which
are 10 or 52 bytes long.
speex_preprocess_run(driver->den, rec);  // Here I get segfault.

It is really not clear for me, how speex understand what size of data
is expected.
Maybe I'm doing something wrong?

More information about the Speex-dev mailing list