0
0

how to read pcm array?

Filled structure FMOD_CREATESOUNDEXINFO

[code:19iczh23]FMOD_CREATESOUNDEXINFO exinfo;

memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));

exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
exinfo.decodebuffersize = 44100;
exinfo.length = 44100 * 2 * sizeof(signed short) * 20;
exinfo.numchannels = 2;
exinfo.defaultfrequency = 44100;
exinfo.format = FMOD_SOUND_FORMAT_PCM16;
exinfo.pcmreadcallback = pcmreadcallback;
[/code:19iczh23]

Creates a stream

[code:19iczh23]result = system->createStream(NULL, FMOD_OPENUSER, &exinfo, &sound);
system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
[/code:19iczh23]

function callback

[code:19iczh23]FMOD_RESULT pcmreadcallback(FMOD_SOUND *sound, void *data, unsigned int datalen)
{

SInt16 * buffer = (SInt16 *)data;

for (int bufferCount=0; bufferCount < audioBufferList.mNumberBuffers; bufferCount++) {
SInt16 * samples = (SInt16 *)audioBufferList.mBuffers[bufferCount].mData;
for (int i=0; i < numSamplesInBuffer; i++)
{
*buffer = samples[i];
}

}

return FMOD_OK;
}

[/code:19iczh23]

In the callback function through the cycle of trying to set the variable ‘date’ sample. The sound does not play

  • You must to post comments
0
0

Can you confirm that your callback code is providing all the bytes ‘datalen’ required by FMOD?

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.