Play float array sound


I am trying to use the readspeaker engine, in interaction with FMOD.

Readspeaker is a tool that create audio from string, in real time. Is it possible to play the created sound with FMOD ? The sound is sampled at 16 kHz and given with a float array.

If it’s possible, I would like to add some filters.

Kind regards,

I don’t have access to the ReadSpeaker API, but it seems as if it generates an audio file based on the text and plays it? If that is the case, you can pass use this audio file with the Core API in an FMOD::Sound or use it in a programmer instrument. See the API examples in the API installation directory for how to use audio files in programmer instruments.

Hey there!

I come to you from the future, and I’m also trying to accomplish this!

ReadSpeaker’s Unity integration will let you take a string, and get back a float array representing 16Hz PCM audio data (not being placed into a file first) of that text being read by a synthetic voice. By default, they assume you’re using Unity’s built-in audio system, so they’re able to pipe that through an AudioSource component, but since we’re using FMOD, I’m assuming I need to use a Programmer Instrument and feed it in during the CREATE_PROGRAMMER_INSTRUMENT callback.

Is there any resource or information on how to pass that data into FMOD?

You can load it directly into an FMOD::Sound in the programmer instrument callback by passing the memory pointer to System::createSound, use the FMOD_CREATESOUNDEXINFO to specify the defaultfrequency = 16000, format = FMOD_SOUND_FORMAT_PCMFLOAT, numchannels = 1, cbsize = sizeof(FMOD_CREATESOUNDEXINFO) and length to be its length in bytes.

Thanks so much for the info, Richard!

I feel like I’m on the cusp of getting this, but crashing the editor every time I try. I think the issue is that I might be getting the float[] length to bytes conversion wrong. Do you mean that I need to set length to the length of the float array if it were a byte array?

Do you mean that I need to set length to the length of the float array if it were a byte array?

Yes, that’s right. You need to tell FMOD the length in bytes.