-
public class AudioUtilUtility class for common audio processing functions such as adding comfort noise and applying dynamic range compression. This class provides static methods for audio manipulation and private helper functions for internal calculations.
-
-
Method Summary
Modifier and Type Method Description static voidaddComfortNoise(Array<short> audioData, int inputOffset, int inputLength, ComfortNoiseConfig config)Adds comfort noise to the provided audio data array. static voidapplyDynamicRangeCompression(Array<short> audioData, int inputOffset, int inputLength, DynamicRangeCompressionConfig config)Applies dynamic range compression to the provided audio data. -
-
Method Detail
-
addComfortNoise
static void addComfortNoise(Array<short> audioData, int inputOffset, int inputLength, ComfortNoiseConfig config)
Adds comfort noise to the provided audio data array. This method generatesrandom noise at the specified noise level and adds it to the audio samplesin the specified range. The noise level is defined in the configuration object.The resulting noisy samples are clipped to the valid short range.
- Parameters:
audioData- The short array containing the audio data to process.Each element represents an audio sample to which noise will be added.inputOffset- The starting offset in the audio data array specifying where processing begins.Must be a valid index within the bounds of the array.inputLength- The number of samples to process, starting from the input offset.This defines the range of audio data to which noise will be added.config- The configuration object defining the comfort noise settings,including whether noise addition is enabled and the noise level in decibels.If noise addition is disabled in the configuration, the method returns immediately.
-
applyDynamicRangeCompression
static void applyDynamicRangeCompression(Array<short> audioData, int inputOffset, int inputLength, DynamicRangeCompressionConfig config)
Applies dynamic range compression to the provided audio data. This method processes a portionof the audio data specified by an offset and length, adjusting the amplitude of samplesbased on the provided compression configuration. Samples exceeding the configuredthreshold are compressed using the specified ratio.
- Parameters:
audioData- The short array containing the audio data to process.inputOffset- The starting offset in the audio data array from where processing begins.Must be a valid index within the bounds of the array.inputLength- The number of samples to process, starting from the input offset.This determines the range of data within the audio array for compression.config- The configuration object defining the dynamic range compression settings,including the threshold, ratio, and whether compression is enabled.If compression is disabled in the configuration, no processing occurs.
-
-
-
-