Decoding live streamed mp3 data with low-level API?

With our “live streaming” method, we are trying to achieve the following:

  1. The sender captures PCM data coming through microphone
  2. Encode this data to MP3 directly in memory
  3. Send this MP3 data through network
  4. The receiver will get this MP3 data
  5. Decode this data to PCM directly in memory
  6. Output through speaker

As you can see, the encode/decode process must be done in real time without saving the data to file.
It seems that the encode process can be done simply with the function: beEncodeChunk().
However, decoding doesn’t look as simple as the encoding process as it required a FILE* parameter.

If there is an api to achieve such functionality, could you tell us where to find it?

Thank you

There’s an FMOD plugin examples under examples\plugins called output_mp3.cpp which shows encoding PCM data into mp3. It writes it to file but that’s optional.

on the decode side, it would be possible to have fmod decode the data if you wrote far enough ahead with Sound::lock/Sound::unlock and used FMOD_CREATECOMPRESSEDSAMPLE, or just use FMOD_OPENMEMORY_POINT and FMOD_CREATECOMPRESSEDSAMPLE to play a looping buffer that you write to in front of the play cursor.

Thank you sir, it works well :slight_smile: