Struct decibel::AmplitudeRatio [] [src]

pub struct AmplitudeRatio<T: Float>(pub T);

An amplitude value.

Methods

impl<T: Float> AmplitudeRatio<T>
[src]

Returns the wrapped amplitude value.

Trait Implementations

impl<T: Copy + Float> Copy for AmplitudeRatio<T>
[src]

impl<T: Clone + Float> Clone for AmplitudeRatio<T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T: Debug + Float> Debug for AmplitudeRatio<T>
[src]

Formats the value using the given formatter.

impl<T: PartialEq + Float> PartialEq for AmplitudeRatio<T>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<T: Float + Constants> From<DecibelRatio<T>> for AmplitudeRatio<T>
[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.

Performs the conversion.