ToneAnalysis

Measures how much of one frequency a block of decoded audio carries.

A mix test needs to say which source a level belongs to, and two sources at different frequencies are told apart here by their own frequency, where peak amplitude only reports the sum. The measurement is one Goertzel recurrence for the one frequency wanted, a single pass with three accumulators.

Every backend's export test shares this, so four measurements of one fade cannot disagree about what they measured.

Properties

Link copied to clipboard
const val MEASURED_GAIN_TOLERANCE: Float = 0.05f

How far a level measured out of a written file may sit from the gain the plan folded.

Functions

Link copied to clipboard
fun amplitudeOf(samples: FloatArray, frequencyHz: Int, sampleRate: Int): Float

The amplitude of frequencyHz in samples, on the same scale the samples are.

Link copied to clipboard
fun amplitudeOver(samples: FloatArray, from: Int, length: Int, frequencyHz: Int, sampleRate: Int): Float

The amplitude of frequencyHz over the length samples starting at from.

Link copied to clipboard
fun toMono(interleaved: FloatArray, channels: Int): FloatArray

Interleaved channels samples reduced to mono by averaging.