mirror of
https://github.com/RustAudio/rodio
synced 2024-11-10 14:14:21 +00:00
SampleRateConverter: Document the various tests
This commit is contained in:
parent
566e979203
commit
60e5450d2d
1 changed files with 11 additions and 2 deletions
|
@ -262,7 +262,8 @@ mod test {
|
|||
}
|
||||
|
||||
quickcheck! {
|
||||
fn zero(from: u32, to: u32, n: u16) -> () {
|
||||
/// Check that resampling an empty input produces no output.
|
||||
fn empty(from: u32, to: u32, n: u16) -> () {
|
||||
let from = if from == 0 { return; } else { SampleRate(from) };
|
||||
let to = if to == 0 { return; } else { SampleRate(to) };
|
||||
if n == 0 { return; }
|
||||
|
@ -275,6 +276,7 @@ mod test {
|
|||
assert_eq!(output, []);
|
||||
}
|
||||
|
||||
/// Check that resampling to the same rate does not change the signal.
|
||||
fn identity(from: u32, n: u16, input: Vec<u16>) -> () {
|
||||
let from = if from == 0 { return; } else { SampleRate(from) };
|
||||
if n == 0 { return; }
|
||||
|
@ -286,6 +288,8 @@ mod test {
|
|||
assert_eq!(input, output);
|
||||
}
|
||||
|
||||
/// Check that dividing the sample rate by k (integer) is the same as
|
||||
/// dropping a sample from each channel.
|
||||
fn divide_sample_rate(to: u32, k: u32, input: Vec<u16>, n: u16) -> () {
|
||||
let to = if to == 0 { return; } else { SampleRate(to) };
|
||||
let from = multiply_rate(to, k);
|
||||
|
@ -308,6 +312,8 @@ mod test {
|
|||
output)
|
||||
}
|
||||
|
||||
/// Check that, after multiplying the sample rate by k, every k-th
|
||||
/// sample in the output matches exactly with the input.
|
||||
fn multiply_sample_rate(from: u32, k: u32, input: Vec<u16>, n: u16) -> () {
|
||||
let from = if from == 0 { return; } else { SampleRate(from) };
|
||||
let to = multiply_rate(from, k);
|
||||
|
@ -332,7 +338,10 @@ mod test {
|
|||
}
|
||||
|
||||
#[ignore]
|
||||
fn equal_durations(d: Duration, freq: u32, to: u32) -> () {
|
||||
/// Check that resampling does not change the audio duration,
|
||||
/// except by a negligible amount (± 1ms). Reproduces #316.
|
||||
/// Ignored, pending a bug fix.
|
||||
fn preserve_durations(d: Duration, freq: u32, to: u32) -> () {
|
||||
use crate::source::{SineWave, Source};
|
||||
|
||||
let to = if to == 0 { return; } else { SampleRate(to) };
|
||||
|
|
Loading…
Reference in a new issue