Struct decibel::AmplitudeRatio
[−]
[src]
pub struct AmplitudeRatio<T: Copy>(pub T);
An amplitude value.
Methods
impl<T: Copy> AmplitudeRatio<T>
[src]
fn amplitude_value(&self) -> T
Returns the wrapped amplitude value.
Trait Implementations
impl From<DecibelRatio<f32>> for AmplitudeRatio<f32>
[src]
Converts from a decibel value into an amplitude.
Example
Let's say we want to scale our audio by 10dB. To figure out how much we need to scale each sample by, let's convert this into an amplitude ratio:
extern crate decibel; use decibel::{AmplitudeRatio, DecibelRatio}; fn main() { // A +10dB gain should require us to scale each sample by around // 3.1622776601683795. let result: AmplitudeRatio<_> = DecibelRatio(10.0).into(); let expected_amplitude = 3.1622776601683795; assert!(result.amplitude_value() >= expected_amplitude - 0.001 && result.amplitude_value() <= expected_amplitude + 0.001); }
To scale our audio by 10dB, we need to scale each sample by approximately 3.162 times.
fn from(decibels: DecibelRatio<f32>) -> AmplitudeRatio<f32>
Performs the conversion.