How to adjust volume of audio recording

#1

Hello all,

As a little side project (I have a lot of those) I’m working on a small voice chat application that may or may not become a larger entity. I have a few stumbling blocks that I’m trying to get passed, and so have some questions:

  1. If I call System::recordStart() and pass it a sound, how do I adjust the input volume of the microphone? Would I need to pass that to a channel, and if so, how would I get the channel volume of the microphone to go back into the sound for transmission over the network?
  2. A related question – is there any way I can add a DSP to an FMOD::Sound object? If I want my chat app to have sound effects on the users voice input stream, this would be very useful to be able to do, which is why I’m asking.
  3. If I receive audio data over the network (in this voice chat client), is it safe to lock the sound, requesting the length to be the size of the packet received, decode the audio, and override ptr1 with the received audio data, then unlock it? Or am I missing something critical?

I’m using the latest version of FMOD to my knowledge (1.10.10).

0 Likes

#2
  1. There isn’t any way to control the volume when recording a sound, there is no processing involved just recording.

  2. You can attach a DSP to either the Channel or ChannelGroup, not the sound itself.
    https://fmod.com/resources/documentation-api?page=content/generated/FMOD_Channel_AddDSP.html#/

  3. You could do that although you would have to treat it as a ring buffer.
    A better, lower latency, way of doing this would be to use a DSP and read from the incoming buffer into the DSP callback, then use System::playDSP.
    We have an example of a custom DSP in our LowLevel API examples.

0 Likes

#3

I am confused:

  1. If there is no way to adjust the recording volume, would I need to send events over the network to act as volume control?
  2. Let’s say I attached a DSP to the channel (making it virtual so that the user wouldn’t feedback). How would I then stream that DSP, together with the original audio (so the full audio plus DSPs is heard) over the network?
  3. If I use your lower-latency option, would I create a mixer DSP, place the decoded audio data into that DSP, and play the DSP over and over?
0 Likes

#4

Sending audio over the network is done by reading from the locked sound buffer in chunks, then pushing it to your network system. DSPs are not involved.

If you want to play back ‘what you hear’ you can play the recording sound (with some delay - we have an example already in the /examples folder which does this) then you control the volume of the playing sound. Not the recorded data itself.

if you have a chat app, we recommend the receiver can use a custom DSP with a read/process callback set, then it pulls data out of the incoming network packets. It is not a mixer DSP, it is a user created DSP. Check /examples for this. ie dsp_custom.cpp. You can call System::playDSP to get this audible.

The dsp read/process callback will ask for 1024 samples at a time, so you’ll have to buffer ahead of time on the network side of things to give fmod enough data as it requires it.

This is the lowest latency way to get audio into playback with FMOD.

0 Likes