0
0

include <stdio.h>

include <stdlib.h>

if defined(WIN32) || defined(WATCOMC)

#include &lt;windows.h&gt;
#include &lt;conio.h&gt;

include <math.h>

else

#include "../../api/inc/wincompat.h"

endif

include “../../api/inc/fmod.h”

include “../../api/inc/fmod_errors.h” /* optional */

int main()
{
double samples[44099];

FSOUND_SAMPLE *mysample;
//***************************************************

for (int i = 0; i < 44100; ++i) {

samples[i] = (10000sin( 2(3.141592)880(i/44100.0)) );

}

mysample = FSOUND_Sample_Alloc(FSOUND_FREE, 44100,FSOUND_NORMAL, 44100, 255, 128, 255);

FSOUND_Sample_Upload(mysample,samples,FSOUND_NORMAL);

FSOUND_PlaySound(FSOUND_FREE, mysample);
//***************************************************

return 15;
}


This code doesn`t work why?

  • You must to post comments
0
0

You haven’t studied the example programs why? 😆

But seriously, for a start you need to call FSOUND_Init at the start of your program and FSOUND_Close at the end.

You can’t use double for the type of your sample data. Make it unsigned short if you intended to use 16bit samples.

Finally, your program exits as soon as it’s called FSOUND_PlaySound. If you want to hear your sound you’ll have to wait for it to play by calling Sleep() or something after FSOUND_PlaySound.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.