Expand description
Loudness analysis conforming to ITU-R BS.1770-4.
This library offers the building blocks to perform BS.1770 loudness measurements, but you need to put the pieces together yourself.
§Stereo integrated loudness example
let sample_rate_hz = 44_100;
let bits_per_sample = 16;
let channel_samples: [Vec<i16>; 2] = load_stereo_audio();
// When converting integer samples to float, note that the maximum amplitude
// is `1 << (bits_per_sample - 1)`, one bit is the sign bit.
let normalizer = 1.0 / (1_u64 << (bits_per_sample - 1)) as f32;
let channel_power: Vec<_> = channel_samples.iter().map(|samples| {
let mut meter = bs1770::ChannelLoudnessMeter::new(sample_rate_hz);
meter.push(samples.iter().map(|&s| s as f32 * normalizer));
meter.into_100ms_windows()
}).collect();
let stereo_power = bs1770::reduce_stereo(
channel_power[0].as_ref(),
channel_power[1].as_ref(),
);
let gated_power = bs1770::gated_mean(stereo_power.as_ref());
println!("Integrated loudness: {:.1} LUFS", gated_power.loudness_lkfs());
Structs§
- Channel
Loudness Meter - Measures K-weighted power of non-overlapping 100ms windows of a single channel of audio.
- Power
- The mean of the squares of the K-weighted samples in a window of time.
- Windows100ms
- A
T
value for non-overlapping windows of audio, 100ms in length.
Functions§
- gated_
mean - Perform gating and averaging for a BS.1770-4 integrated loudness measurement.
- reduce_
stereo - Combine power for multiple channels by taking a weighted sum.
- reduce_
stereo_ in_ place - In-place version of
reduce_stereo
that stores the result in the former left channel.