C & Fmod Ex - real-time PCM array / buffer playback

I use an array to process the radio signal and receive the raw PCM sound. I am desperately trying to play this sound with Fmod Ex.

Basically, could I create a thread that matches my circular buffer, which I could get in a thread-safe way? Any basic information on which methods to use would be greatly appreciated.

If not, can any other Windows 7 API do the trick and how? (ASIO, Wasapi ...)

thanks ° - °

+3
source share
1 answer

, ( ), FMOD, , . API- FMOD. , createoundexinfo, , FMOD_OPENMEMORY createSound name_or_data. :

FMOD_CREATESOUNDEXINFO, , CreateStream. , , , , FMOD_OPENUSER, FMOD_OPENMEMORY name_or_data:

FMOD_CREATESOUNDEXINFO exinfo;

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

exinfo.cbsize            = sizeof(FMOD_CREATESOUNDEXINFO);              /* required. */
exinfo.decodebuffersize  = 44100;                                       /* Chunk size of stream update in samples.  This will be the amount of data passed to the user callback. */
exinfo.length            = 44100 * channels * sizeof(signed short) * 5; /* Length of PCM data in bytes of whole song (for Sound::getLength) */
exinfo.numchannels       = channels;                                    /* Number of channels in the sound. */
exinfo.defaultfrequency  = 44100;                                       /* Default playback rate of sound. */
exinfo.format            = FMOD_SOUND_FORMAT_PCM16;                     /* Data format of sound. */
exinfo.pcmreadcallback   = pcmreadcallback;                             /* User callback for reading. */
exinfo.pcmsetposcallback = pcmsetposcallback;                           /* User callback for seeking. */

result = system->createStream(NULL, FMOD_OPENUSER, &exinfo, &sound);
ERRCHECK(result);

, PCM16 44khz, , FMOD , , - :

FMOD_RESULT F_CALLBACK pcmreadcallback(FMOD_SOUND *sound, void *data, unsigned int datalen)
{
    // Read from your buffer here...
    return FMOD_OK;
}


FMOD_RESULT F_CALLBACK pcmsetposcallback(FMOD_SOUND *sound, int subsound, unsigned int position, FMOD_TIMEUNIT postype)
{
    // Seek to a location in your data, may not be required for what you want to do
    return FMOD_OK;
}

, , FMOD .

+2

Source: https://habr.com/ru/post/1773657/


All Articles