mirror of
https://github.com/RustAudio/rodio
synced 2024-12-12 13:12:30 +00:00
Implementation of synth waveforms, tests
This commit is contained in:
parent
eef2edaa3d
commit
107454efde
1 changed files with 14 additions and 6 deletions
|
@ -106,6 +106,7 @@ impl Source for SynthWaveform {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::source::synth::*;
|
use crate::source::synth::*;
|
||||||
|
use approx::assert_abs_diff_eq;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn square() {
|
fn square() {
|
||||||
|
@ -165,10 +166,17 @@ mod tests {
|
||||||
assert_eq!(wf.next(), Some(-1.0f32));
|
assert_eq!(wf.next(), Some(-1.0f32));
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[test]
|
#[test]
|
||||||
// fn sine() {
|
fn sine() {
|
||||||
// let mut wf =
|
let mut wf =
|
||||||
// SynthWaveform::new(cpal::SampleRate(1000), 100f32, SynthWaveformFunction::Sine);
|
SynthWaveform::new(cpal::SampleRate(1000), 100f32, SynthWaveformFunction::Sine);
|
||||||
//
|
|
||||||
// }
|
assert_abs_diff_eq!(wf.next().unwrap(), 0.0f32);
|
||||||
|
assert_abs_diff_eq!(wf.next().unwrap(), 0.58778525f32);
|
||||||
|
assert_abs_diff_eq!(wf.next().unwrap(), 0.95105652f32);
|
||||||
|
assert_abs_diff_eq!(wf.next().unwrap(), 0.95105652f32);
|
||||||
|
assert_abs_diff_eq!(wf.next().unwrap(), 0.58778525f32);
|
||||||
|
assert_abs_diff_eq!(wf.next().unwrap(), 0.0f32);
|
||||||
|
assert_abs_diff_eq!(wf.next().unwrap(), -0.58778554f32);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue