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 -----Original Message----- From: Max Lapshin [mailto:max.lapshin at gmail.com] Sent: Thursday, March 18, 2010 10:57 PM To: Jozsef Vass Cc: speex-dev at xiph.org Subject: Re: [Speex-dev] Speex in flash player: how to work with? On Fri, Mar 19, 2010 at 3:27 AM, Jozsef Vass <jovass at adobe.com> wrote:> First of all, Flash Player can only publish Speex at 16 kHz. 20 ms of audio (320 samples) will result in compressed payload size of 106 bytes (42.4 kbps). When Flash Player sends a TC message, there is 11 bytes TC message header and a single byte of audio message header.So what sample size should I set to work with 106 bytes packets? driver->den = speex_preprocess_state_init(320, 16); ?- so?
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.setSilenceLevel(0); _microphone.codec = SoundCodec.SPEEX; _microphone.encodeQuality = 10; _microphone.rate = 16; _microphone.framesPerPacket = 1; _microphone.gain = 80; _microphone.setUseEchoSuppression(false); 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: speex_bits_init(&driver->bits); 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->sample_rate); driver->den = speex_preprocess_state_init(driver->frame_size, driver->sample_rate); ... 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?
Last result is that no more fails (I've set SPX_SIZE = 320), but this preprocessing destroys sound.
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 Jozsef -----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.setSilenceLevel(0); _microphone.codec = SoundCodec.SPEEX; _microphone.encodeQuality = 10; _microphone.rate = 16; _microphone.framesPerPacket = 1; _microphone.gain = 80; _microphone.setUseEchoSuppression(false); 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: speex_bits_init(&driver->bits); 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->sample_rate); driver->den = speex_preprocess_state_init(driver->frame_size, driver->sample_rate); ... 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?
around line 535: if (strncmp(first_bytes,"RIFF",4)==0 && strncmp(first_bytes,"RIFF",4)==0) why? -- Randy Yates % "And all you had to say Digital Signal Labs % was that you were mailto://yates at ieee.org % gonna stay." http://www.digitalsignallabs.com % Getting To The Point', *Balance of Power*, ELO