AudioUtil

class AudioUtil

Utility class for audio-related operations.

Functions

Link copied to clipboard
open fun audioLevelToDoubleRange(audioLevel: Double): Double
Converts an audio level to a double in the range [0, 1].
Link copied to clipboard
open fun bytesToShort(b1: Byte, b2: Byte): Short
Converts two bytes to one short.
Link copied to clipboard
open fun bytesToShorts(bytes: Array<Byte>): Array<Short>
Converts an array of bytes to an array of shorts.
Link copied to clipboard
open fun calculateAudioLevel(samples: Array<Byte>, offset: Int, length: Int): Double
Calculates the audio level of a range of bytes.
open fun calculateAudioLevel(samples: Array<Short>, offset: Int, length: Int): Double
Calculates the audio level of a range of shorts.
Link copied to clipboard
open fun calculateAudioLevelFromRMS(rms: Double, sampleCount: Int): Double
Converts RMS and sample count to an audio level.
Link copied to clipboard
Calculates the highest audio level in an array of shorts.
Link copied to clipboard
open fun containsMinAudioLevel(samples: Array<Byte>, minAudioLevel: Double): Boolean
open fun containsMinAudioLevel(samples: Array<Short>, minAudioLevel: Double): Boolean
Checks if any sample audio level is greater than the specified minimum audio level.
Link copied to clipboard
open fun convertToMonoBytes(samples: Array<Short>): Array<Byte>
Converts stereo samples to mono bytes.
Link copied to clipboard
open fun convertToMonoShorts(samples: Array<Short>): Array<Short>
Converts stereo samples to mono shorts.
Link copied to clipboard
open fun dbToMul(db: Double): Double
open fun dbToMul(db: Float): Float
Converts decibels (dB) to a multiplication factor.
Link copied to clipboard
Converts a double in the range [0, 1] to an audio level.
Link copied to clipboard
open fun fadeIn(samples: Array<Short>, channels: Int): Array<Short>
Link copied to clipboard
open fun fadeOut(samples: Array<Short>, channels: Int): Array<Short>
Link copied to clipboard
Converts floats in the range [-1, 1] to shorts.
Link copied to clipboard
open fun floatsToShorts(floats: Array<Float>): Array<Short>
Converts an array of floats to an array of shorts.
Link copied to clipboard
open fun gainCoefficient(sampleRate: Int, time: Float): Float
Calculates the gain coefficient for a given sample rate and time.
Link copied to clipboard
Gets the highest absolute sample value in an array of shorts.
Link copied to clipboard
open fun mulToDB(mul: Float): Float
Converts a multiplication factor to decibels (dB).
Link copied to clipboard
open fun shortsToBytes(shorts: Array<Short>): Array<Byte>
Converts an array of shorts to an array of bytes.
Link copied to clipboard
open fun shortsToFloats(input: Array<Short>): Array<Float>
Converts an array of shorts to an array of floats.
Link copied to clipboard
Converts shorts to floats in the range [-1, 1].
Link copied to clipboard
open fun shortToBytes(s: Short): Array<Byte>
Converts a short to an array of two bytes.