-
Notifications
You must be signed in to change notification settings - Fork 45
Controlling volume
All actors of the engine that allow volume control (e.g. AudioEvents, AudioChannels or the engine itself) accept a linear floating point value between 0 - 1. Under the hood however, this value is scaled against a logarithmic scale.
The reason for using a logarithmic ratio is that it gives a much better approximation to the human perception of relative loudness than a linear scale. This is because the human ear responds to the logarithmic change in level, which corresponds to the decibel scale, where the dB is a logarithmic way of describing a ratio which can be expressed as power, sound pressure, voltage or intensity, etc.
There is a VolumeUtil that provides convenience methods to convert a value from a linear scale to a logarithmic scale and vice versa, but under the hood MWEngine happily accepts linear values and converts them automatically when setting volume.
When summing audio signals it is important to understand you are adding numbers. When these numbers exceed their maximum (+1.0) the resulting sound will play back with digital clipping as audio has exceeded the total headroom's "ceiling". Needless to say this is very unpleasant to listen to.
MWEngine will automatically scale all AudioChannels to leave headroom for all other available channels. It is however possible that certain AudioChannels will have very hot signals (for instance: a SynthInstruments channel being filled with multiple AudioEvents playing back simultaneously or a channel that has a distortion effect in its processing chain).
You will need to balance these channels against the others to prevent clipping from occurring, as such you are responsible for setting the volume levels of either the AudioEvents or AudioChannels appropriately for your use case.
MWEngine will keep all output within the -1.0 to +1.0 range to prevent buffer overflow, but this can still result in clipping signals. You can use a compressor or limiter as a bus processor to automatically catch the peaks in your output signal and adjust the output accordingly.