I m creating an application using C# (Vista + Visual Studio 08) and Fmod.
I need to save into a Wav file the output of my channel.

So I m doing the DSP call back technique.

I saw this thread :

But I dont understand how am I suppose to create, write… the file in C#, because the function SaveToWav() use a FileStream which can write Byte but in the thread’s example, it write Short…
A big mess for me.

Do someone has an example in c#?

This is where I am :

private static RESULT READCALLBACK(ref DSP_STATE dsp_state, IntPtr inbuf, IntPtr outbuf, uint length, int inchannels, int outchannels)


            float* inbuffer = (float*)inbuf.ToPointer();
            float* outbuffer = (float*)outbuf.ToPointer();

            for (int count = 0; count < length; count++)

                for (int count2 = 0; count2 < outchannels; count2++)

                    outbuffer[(count * outchannels) + count2] = inbuffer[(count * inchannels) + count2];

                    float valu = inbuffer[(count * inchannels) + count2] * 32767.0f;

                    //make sure it doesnt round off to a over-max value
                    if (valu > 32767)
                        valu = 32767;
                    if (valu < -32767)
                        valu = -32767;

                     // HERE HERE HERE :§:(:(

        return RESULT.OK;


Thank you[/code]

  • You must to post comments


Hope you’ve had some more luck with this lately. I’ve been developing with FMOD on the iPhone, so I’m not sure if this 100% applies to you. Anyway, in the DSP, the value gets calculated as a short yes, but the file output gets converted to a char as such:

short writ = (short)valu;
fwrite((const char *)&writ, sizeof(writ), 1, outFile);

I hope that helps.

  • George
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.