0
0

I want to save a playing stream to a WAV-File. I’ve created a DSP-Callback function but I dont know how to save the buffers to a correct wave file.

Any ideas?

  • You must to post comments
0
0

See the record example in the “samples” directory.

  • You must to post comments
0
0

I’ve had a look at the examples, but I still have problems. I had insert the SaveToWav-code into my dsp-unit but i cannot play the resulted wave-file anywhere – even if i listen to it as raw data i only hear noises.

Here ist my source (I have delete all checks, so that it won’t be to long for this forum, you know). Would be absolutly great if someone has a suggestion for me.

[code:2xdatbn0]

include <stdio.h>

include <windows.h>

include <conio.h>

include "fmod.h"

include "fmod_errors.h"

void * F_CALLBACKAPI DSP_WriteOutput (void *originalbuffer, void *newbuffer, int length, int param)
{
printf("DSP-Unit called!\n\r");

/* TODO: WRITE OUTPUT TO WAVE FILE */

return newbuffer;

}

int main(int argc, char *argv[])
{

FSOUND_STREAM *stream;
FSOUND_DSPUNIT *dsp1;

char key;
int channel;


FSOUND_Init(44100, 32, 0);

stream = FSOUND_Stream_Open(&quot;c:\\1.mp3&quot;, FSOUND_NORMAL, 0, 0);

dsp1 = FSOUND_DSP_Create(DSP_WriteOutput,1, 0);
if (dsp1)
{
    printf(&quot;DSP init successful...\n\r&quot;);
}
FSOUND_DSP_SetActive(dsp1,true);

printf(&quot;\nPress ESC to quit...\n\n&quot;);

key = 0;

do
{
    if (kbhit())
    {
        key = getch();
    }

    /*
        Play the stream if it's not already playing
    */

    if (channel &lt; 0)
    {
        channel = FSOUND_Stream_Play(FSOUND_FREE, stream);
        FSOUND_SetPaused(channel, FALSE);

    }

} while (key != 27);

printf(&quot;\n&quot;);

FSOUND_Stream_Close(stream);
FSOUND_Close();

return 0;

}
[/code:2xdatbn0]

  • You must to post comments
0
0

1st : Here’s a good overview of the WAV-format:
http://www.sonicspot.com/guide/wavefiles.html
To create a valid WAV-File you’d have to write the header after record-stop to set the length-depending-parameters.

2nd : Perhaps you have fmod’s mixer initialized as an FPU-Mixer? Then in your DSP there are no 16-Bit-signed-INT but 32-Bit-Floats which you have to convert for the normal WAV-format.

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.