0
0

Hi,

I’m new to FMOD. I’m trying to use it in an application i have written to implement pitch detection on small clips of audio. I am using c++.

I want to call System::createSound to create a sound for analysis. Currently the audio to be analysed is already in an array as pcm data. How can i get this into a Sound object? createSound takes a const char * as an argument, but this is for a filename or URL… how can I pass it an array of PCM data?

  • You must to post comments
0
0

OK… so I have made a little progress on this myself, but I am still stuck.

I understand that I have to use the FMOD_MODE "FMOD_OPENMEMORY_POINT" in order to supply a pointer to my pcm data as the first argument for createSound()

I also understand that I need to use a pointer to an "FMOD_CREATESOUNDEXINFO" as the third argument… beyond this though I get stuck.

Here is my code so far:

[code:2gi2a8j6]

//initialise FMOD and result for error checking
FMOD_RESULT result;
FMOD::System *system;
result = System_Create(&system);
errorCheck(result);

//get sound for analysis
FMOD_CREATESOUNDEXINFO *soundExInfo;
soundExInfo->length = samples*sizeof(double); 
soundExInfo->numchannels = 1;
if (bitRate == 8) {
    soundExInfo->format = FMOD_SOUND_FORMAT_PCM8;
} else if (bitRate == 16) {
    soundExInfo->format = FMOD_SOUND_FORMAT_PCM16;
} else if (bitRate == 24) {
    soundExInfo->format = FMOD_SOUND_FORMAT_PCM24;
}
soundExInfo->suggestedsoundtype = FMOD_SOUND_TYPE_RAW;
FMOD::Sound *sound;
result = system->createSound( ??? , FMOD_OPENMEMORY_POINT, soundExInfo, &sound);
errorCheck(result);

[/code:2gi2a8j6]

I currently have the pcm data stored in a double[], how does it need to be for FMOD to interpret it correctly?

  • You must to post comments
0
0

Hi wminor, welcome to the FMOD forums!

You can just cast you data to (const char*) and pass it in as the first argument. The OPEN_MEMORYPOINT flag will tell FMOD that it’s data and not a string.

The types of PCM data supported by FMOD are as follows:
FMOD_SOUND_FORMAT_PCM8
FMOD_SOUND_FORMAT_PCM16
FMOD_SOUND_FORMAT_PCM24
FMOD_SOUND_FORMAT_PCM32
FMOD_SOUND_FORMAT_PCMFLOAT

The PCMFLOAT is the only floating point format which is supported and it is 32-bit floats, so you will probably have to convert your double[] data to float[].

Take a look at the ‘loadfrommemeory’ example that ships with the FMOD API.

  • You must to post comments
0
0

Thanks peter, that’s helpful. I have a feeling I tried casting my array into a const char* but it wouldn’t compile, it was a long day though yesterday so maybe I’m wrong… i’ll give it another go.

Regarding PCM data formats… FMOD_SOUND_FORMAT_PCM16 for example, are these intager PCM formats then?

  • You must to post comments
0
0

Yes all the other types including PCM16 are integer formats.

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.