0
0

I’ve been scouring the internet and these forums for a few days now while I try to work through integrating Speex with FMOD for sending microphone data between clients. Needless to say I’m having a few problems.

I think I’m fine with the FMOD portion of it. I’ve written a few programs that take the raw sound data and play it back. My big test at the moment is to do the following:

1) Write the microphone data into a file without the .wav header (ie just the raw sound data). This is basically a minor modification of the recordtodisk examples

2) Run a very slightly modified sampleenc.c from http://www.speex.org/docs/manual/speex- … ample-code . The only real difference is that instead of writing to stdout, i write to another file.

3) Run a very slightly modified sampledec.c on the file written by #2, and have that data write out to another file as per the example.

4) Read the raw-data-only files output from #1 or #3 and play it back.

Both #1 and #4 work together. When i try adding #2 and #3 I have the issue.

My output file from #1 is 272KB, and the encoder goes through about 6 loops before it thinks it’s at the EOF. Then needless to say the decoding doesn’t work at all.

My guess is that the data that’s written to the file from #1 is written not in the format the speex expects, so I’m looking to the FMOD community to help me understand what i’m doing wrong. I have changed the fwrite function to work There are three fwrite lines below which have each been used in different tests to write the data (and the playback program, #4, can work with each of their outputs).

[code:27a50c4t]short* to_write1 = (short*) ptr1;
if (ptr1 && len1)
{
datalength += fwrite(to_write1, sizeof(short), len1, fp);
//datalength += fwrite(ptr1, sizeof(short), len1/sizeof(short), fp);
//datalength += fwrite(ptr1, 1, len1, fp);
}[/code:27a50c4t]

Unfortunately, lots of things I see on help for Speex always starts with "try it with the given sample code first and work from there", and doing that isn’t working for me.

Can anyone help me understand what I’m doing wrong? Or perhaps are there any good tutorials or have any code that demonstrates how to properly integrate FMOD and Speex?

Thanks

  • You must to post comments
0
0

The sample uses speex_encode() function, which accepts float input, with samples in range of -32768.f – 32767.f
As FMOD’s input has short integer format, you need speex_encode_int() function.

  • You must to post comments
0
0

Yes, but the speex code expects short* and does a conversion to float* in the incode, and then back from float to short in the decode. Unless this code simply doesn’t work like speex thinks it should.

[code:1kgqaanj]/Copy the 16 bits values to float so Speex can work on them/
for (i=0;i<FRAME_SIZE;i++)
input[i]=in[i];[/code:1kgqaanj]

[code:1kgqaanj]
/Copy from float to short (16 bits) for output/
for (i=0;i<FRAME_SIZE;i++)
out[i]=output[i];
[/code:1kgqaanj]

  • You must to post comments
0
0

[quote:1y1bish6]short* to_write1 = (short*) ptr1;
if (ptr1 && len1)
{
datalength += fwrite(to_write1, sizeof(short), len1, fp);
//datalength += fwrite(ptr1, sizeof(short), len1/sizeof(short), fp);
//datalength += fwrite(ptr1, 1, len1, fp);
} [/quote:1y1bish6]

This code looks quite dubious. firstly you’re using a c-style cast to (short) on ptr1. If ptr 1 is a float then this definitely wont work. Also, from that code I can’t work out what causes that loop to terminate. As far as i can see ptr1 and len1 are unchanged inside the loop.

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.