use fundsp::prelude::*;
use insta_fun::prelude::*;
fn main() {
const CHART_SAMPLES: usize = 2000;
const ONE_SECOND_SAMPLES: usize = fundsp::DEFAULT_SR as usize;
let chart_cfg = || {
SnapshotConfigBuilder::default()
.num_samples(CHART_SAMPLES)
.with_inputs(true)
.build()
.unwrap()
};
let wav_cfg = || {
SnapshotConfigBuilder::default()
.output_mode(WavOutput::Wav16)
.num_samples(ONE_SECOND_SAMPLES)
.build()
.unwrap()
};
let input = Box::new(
sine_hz::<f32>(110.0)
+ sine_hz::<f32>(220.0)
+ sine_hz::<f32>(440.0)
+ sine_hz::<f32>(880.0),
) as Box<dyn AudioUnit>;
assert_audio_unit_snapshot!(
"filter_svf_lowpass_1k_q0_707",
lowpass_hz(1_000.0, 0.707),
InputSource::Unit(input.clone()),
chart_cfg()
);
assert_audio_unit_snapshot!(
"filter_svf_lowpass_1k_q0_707",
lowpass_hz(1_000.0, 0.707),
InputSource::Unit(input.clone()),
wav_cfg()
);
assert_audio_unit_snapshot!(
"filter_svf_highpass_1k_q0_707",
highpass_hz(1_000.0, 0.707),
InputSource::Unit(input.clone()),
chart_cfg()
);
assert_audio_unit_snapshot!(
"filter_svf_highpass_1k_q0_707",
highpass_hz(1_000.0, 0.707),
InputSource::Unit(input.clone()),
wav_cfg()
);
assert_audio_unit_snapshot!(
"filter_svf_bandpass_1k_q1_0",
bandpass_hz(1_000.0, 1.0),
InputSource::Unit(input.clone()),
chart_cfg()
);
assert_audio_unit_snapshot!(
"filter_svf_bandpass_1k_q1_0",
bandpass_hz(1_000.0, 1.0),
InputSource::Unit(input.clone()),
wav_cfg()
);
assert_audio_unit_snapshot!(
"filter_svf_notch_1k_q1_0",
notch_hz(1_000.0, 1.0),
InputSource::Unit(input.clone()),
chart_cfg()
);
assert_audio_unit_snapshot!(
"filter_svf_notch_1k_q1_0",
notch_hz(1_000.0, 1.0),
InputSource::Unit(input.clone()),
wav_cfg()
);
assert_audio_unit_snapshot!(
"filter_peak_1k_q1_0",
peak_hz(1_000.0, 1.0),
InputSource::Unit(input.clone()),
chart_cfg()
);
assert_audio_unit_snapshot!(
"filter_peak_1k_q1_0",
peak_hz(1_000.0, 1.0),
InputSource::Unit(input.clone()),
wav_cfg()
);
assert_audio_unit_snapshot!(
"filter_bell_1k_q0_707_gain1_5",
bell_hz(1_000.0, 0.707, 1.5),
InputSource::Unit(input.clone()),
chart_cfg()
);
assert_audio_unit_snapshot!(
"filter_bell_1k_q0_707_gain1_5",
bell_hz(1_000.0, 0.707, 1.5),
InputSource::Unit(input.clone()),
wav_cfg()
);
assert_audio_unit_snapshot!(
"filter_lowshelf_500hz_q0_707_gain1_5",
lowshelf_hz(500.0, 0.707, 1.5),
InputSource::Unit(input.clone()),
chart_cfg()
);
assert_audio_unit_snapshot!(
"filter_lowshelf_500hz_q0_707_gain1_5",
lowshelf_hz(500.0, 0.707, 1.5),
InputSource::Unit(input.clone()),
wav_cfg()
);
assert_audio_unit_snapshot!(
"filter_highshelf_2k_q0_707_gain1_5",
highshelf_hz(2_000.0, 0.707, 1.5),
InputSource::Unit(input.clone()),
chart_cfg()
);
assert_audio_unit_snapshot!(
"filter_highshelf_2k_q0_707_gain1_5",
highshelf_hz(2_000.0, 0.707, 1.5),
InputSource::Unit(input.clone()),
wav_cfg()
);
assert_audio_unit_snapshot!(
"filter_moog_lowpass_1k_q0_5",
moog_hz(1_000.0, 0.5),
InputSource::Unit(input.clone()),
chart_cfg()
);
assert_audio_unit_snapshot!(
"filter_moog_lowpass_1k_q0_5",
moog_hz(1_000.0, 0.5),
InputSource::Unit(input.clone()),
wav_cfg()
);
assert_audio_unit_snapshot!(
"filter_lowrez_lowpass_1k_q1_0",
lowrez_hz(1_000.0, 1.0),
InputSource::Unit(input.clone()),
chart_cfg()
);
assert_audio_unit_snapshot!(
"filter_lowrez_lowpass_1k_q1_0",
lowrez_hz(1_000.0, 1.0),
InputSource::Unit(input.clone()),
wav_cfg()
);
assert_audio_unit_snapshot!(
"filter_bandrez_bandpass_1k_q3_0",
bandrez_hz(1_000.0, 3.0),
InputSource::Unit(input.clone()),
chart_cfg()
);
assert_audio_unit_snapshot!(
"filter_bandrez_bandpass_1k_q3_0",
bandrez_hz(1_000.0, 3.0),
InputSource::Unit(input.clone()),
wav_cfg()
);
assert_audio_unit_snapshot!(
"filter_lowpole_800hz",
lowpole_hz(800.0),
InputSource::Unit(input.clone()),
chart_cfg()
);
assert_audio_unit_snapshot!(
"filter_lowpole_800hz",
lowpole_hz(800.0),
InputSource::Unit(input.clone()),
wav_cfg()
);
assert_audio_unit_snapshot!(
"filter_highpole_300hz",
highpole_hz(300.0),
InputSource::Unit(input.clone()),
chart_cfg()
);
assert_audio_unit_snapshot!(
"filter_highpole_300hz",
highpole_hz(300.0),
InputSource::Unit(input.clone()),
wav_cfg()
);
assert_audio_unit_snapshot!(
"filter_morph_lowpass_1k_q0_8",
morph_hz(1_000.0, 0.8, -1.0),
InputSource::Unit(input.clone()),
chart_cfg()
);
assert_audio_unit_snapshot!(
"filter_morph_lowpass_1k_q0_8",
morph_hz(1_000.0, 0.8, -1.0),
InputSource::Unit(input.clone()),
wav_cfg()
);
assert_audio_unit_snapshot!(
"filter_dcblock_10hz",
dcblock_hz(10.0),
InputSource::Unit(input.clone()),
chart_cfg()
);
assert_audio_unit_snapshot!(
"filter_dcblock_10hz",
dcblock_hz(10.0),
InputSource::Unit(input.clone()),
wav_cfg()
);
assert_audio_unit_snapshot!(
"filter_allpass_1k_q0_707",
allpass_hz(1_000.0, 0.707),
InputSource::Unit(input.clone()),
chart_cfg()
);
assert_audio_unit_snapshot!(
"filter_allpass_1k_q0_707",
allpass_hz(1_000.0, 0.707),
InputSource::Unit(input.clone()),
wav_cfg()
);
assert_audio_unit_snapshot!(
"filter_butter_lowpass_1k",
butterpass_hz(1_000.0),
InputSource::Unit(input.clone()),
chart_cfg()
);
assert_audio_unit_snapshot!(
"filter_butter_lowpass_1k",
butterpass_hz(1_000.0),
InputSource::Unit(input.clone()),
wav_cfg()
);
assert_audio_unit_snapshot!(
"filter_fir3_gain0_50_white",
fir3(0.50),
InputSource::Unit(Box::new(white())),
chart_cfg()
);
assert_audio_unit_snapshot!(
"filter_fir3_gain0_50_white",
fir3(0.50),
InputSource::Unit(Box::new(white())),
wav_cfg()
);
assert_audio_unit_snapshot!(
"filter_pinkpass_white",
pinkpass::<f32>(),
InputSource::Unit(Box::new(white())),
chart_cfg()
);
assert_audio_unit_snapshot!(
"filter_pinkpass_white",
pinkpass::<f32>(),
InputSource::Unit(Box::new(white())),
wav_cfg()
);
}