Adjusted the trigger threshold
This commit is contained in:
parent
a9ac7ec1e8
commit
6651d06f45
9 changed files with 152 additions and 128 deletions
|
@ -527,7 +527,14 @@ pub fn sqrt4_to_pow4(x: f32, v: f32) -> f32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A-100 Eurorack states, that a trigger is usually 2-10 milliseconds.
|
/// A-100 Eurorack states, that a trigger is usually 2-10 milliseconds.
|
||||||
const TRIG_SIGNAL_LENGTH_MS : f32 = 2.0;
|
pub const TRIG_SIGNAL_LENGTH_MS : f32 = 2.0;
|
||||||
|
|
||||||
|
/// The lower threshold for the schmidt trigger to reset.
|
||||||
|
pub const TRIG_LOW_THRES : f32 = 0.25;
|
||||||
|
/// The threshold, once reached, will cause a trigger event and signals
|
||||||
|
/// a logical '1'. Anything below this is a logical '0'.
|
||||||
|
pub const TRIG_HIGH_THRES : f32 = 0.5;
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct TrigSignal {
|
pub struct TrigSignal {
|
||||||
|
@ -590,13 +597,13 @@ impl Trigger {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn check_trigger(&mut self, input: f32) -> bool {
|
pub fn check_trigger(&mut self, input: f32) -> bool {
|
||||||
if self.triggered {
|
if self.triggered {
|
||||||
if input <= 0.25 {
|
if input <= TRIG_LOW_THRES {
|
||||||
self.triggered = false;
|
self.triggered = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
false
|
false
|
||||||
|
|
||||||
} else if input > 0.75 {
|
} else if input > TRIG_HIGH_THRES {
|
||||||
self.triggered = true;
|
self.triggered = true;
|
||||||
true
|
true
|
||||||
|
|
||||||
|
@ -640,11 +647,11 @@ impl TriggerPhaseClock {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn next_phase(&mut self, clock_limit: f64, trigger_in: f32) -> f64 {
|
pub fn next_phase(&mut self, clock_limit: f64, trigger_in: f32) -> f64 {
|
||||||
if self.prev_trigger {
|
if self.prev_trigger {
|
||||||
if trigger_in <= 0.25 {
|
if trigger_in <= TRIG_LOW_THRES {
|
||||||
self.prev_trigger = false;
|
self.prev_trigger = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if trigger_in > 0.75 {
|
} else if trigger_in > TRIG_HIGH_THRES {
|
||||||
self.prev_trigger = true;
|
self.prev_trigger = true;
|
||||||
|
|
||||||
if self.clock_samples > 0 {
|
if self.clock_samples > 0 {
|
||||||
|
@ -689,11 +696,11 @@ impl TriggerSampleClock {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn next(&mut self, trigger_in: f32) -> u32 {
|
pub fn next(&mut self, trigger_in: f32) -> u32 {
|
||||||
if self.prev_trigger {
|
if self.prev_trigger {
|
||||||
if trigger_in <= 0.25 {
|
if trigger_in <= TRIG_LOW_THRES {
|
||||||
self.prev_trigger = false;
|
self.prev_trigger = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if trigger_in > 0.75 {
|
} else if trigger_in > TRIG_HIGH_THRES {
|
||||||
self.prev_trigger = true;
|
self.prev_trigger = true;
|
||||||
self.clock_samples = self.counter;
|
self.clock_samples = self.counter;
|
||||||
self.counter = 0;
|
self.counter = 0;
|
||||||
|
|
|
@ -223,6 +223,7 @@ impl DspNode for TSeq {
|
||||||
denorm::TSeq::trig(trig, frame))
|
denorm::TSeq::trig(trig, frame))
|
||||||
{
|
{
|
||||||
time.clock.sync();
|
time.clock.sync();
|
||||||
|
println!("CLOCK SYNC");
|
||||||
}
|
}
|
||||||
|
|
||||||
let phase =
|
let phase =
|
||||||
|
@ -235,8 +236,6 @@ impl DspNode for TSeq {
|
||||||
phase_out[frame] = phase as f32;
|
phase_out[frame] = phase as f32;
|
||||||
}
|
}
|
||||||
|
|
||||||
// println!("PHASE {}", phase_out[0]);
|
|
||||||
|
|
||||||
let mut col_out : [f32; MAX_BLOCK_SIZE] =
|
let mut col_out : [f32; MAX_BLOCK_SIZE] =
|
||||||
[0.0; MAX_BLOCK_SIZE];
|
[0.0; MAX_BLOCK_SIZE];
|
||||||
let mut col_out_gate : [f32; MAX_BLOCK_SIZE] =
|
let mut col_out_gate : [f32; MAX_BLOCK_SIZE] =
|
||||||
|
|
|
@ -772,22 +772,19 @@ fn check_matrix_tseq() {
|
||||||
// Take some real samples:
|
// Take some real samples:
|
||||||
let samples = run_and_undersample(&mut node_exec, 2000.0, 10);
|
let samples = run_and_undersample(&mut node_exec, 2000.0, 10);
|
||||||
|
|
||||||
assert_float_eq!(samples[0], 0.3157);
|
assert_vec_feq!(samples, vec![
|
||||||
assert_float_eq!(samples[1], 0.209);
|
0.5322106, 0.4255343, 0.318858, 0.21218172, 0.105505496, 0.017571526,
|
||||||
assert_float_eq!(samples[2], 0.1024);
|
// then start at the beginning:
|
||||||
assert_float_eq!(samples[3], 0.0648);
|
0.958819, 0.8521427, 0.7454664, 0.63879013
|
||||||
assert_float_eq!(samples[4], 0.95566);
|
]);
|
||||||
assert_float_eq!(samples[5], 0.84899);
|
|
||||||
assert_float_eq!(samples[6], 0.74231);
|
|
||||||
assert_float_eq!(samples[7], 0.6356);
|
|
||||||
assert_float_eq!(samples[8], 0.5289);
|
|
||||||
assert_float_eq!(samples[9], 0.42228);
|
|
||||||
|
|
||||||
// switch to row trigger:
|
// switch to row trigger:
|
||||||
pset_s(&mut matrix, tsq, "cmode", 0);
|
pset_s(&mut matrix, tsq, "cmode", 0);
|
||||||
let samples = run_and_undersample(&mut node_exec, 2000.0, 5);
|
let samples = run_and_undersample(&mut node_exec, 2000.0, 5);
|
||||||
|
|
||||||
assert_vec_feq!(samples, vec![0.70411, 0.90413, 0.99306, 0.97972, 0.966387]);
|
assert_vec_feq!(samples, vec![
|
||||||
|
0.5011433, 0.7011613, 0.9011793, 0.9932535, 0.97991896
|
||||||
|
]);
|
||||||
|
|
||||||
// set to phase mode:
|
// set to phase mode:
|
||||||
pset_s(&mut matrix, tsq, "cmode", 2);
|
pset_s(&mut matrix, tsq, "cmode", 2);
|
||||||
|
@ -840,31 +837,22 @@ fn check_matrix_tseq_trig() {
|
||||||
// Take some real samples:
|
// Take some real samples:
|
||||||
let samples = run_and_undersample(&mut node_exec, 2000.0, 10);
|
let samples = run_and_undersample(&mut node_exec, 2000.0, 10);
|
||||||
|
|
||||||
assert_float_eq!(samples[0], 0.3157);
|
assert_vec_feq!(samples, vec![
|
||||||
assert_float_eq!(samples[1], 0.209);
|
0.5322106, 0.4255343, 0.318858, 0.21218172, 0.105505496,
|
||||||
assert_float_eq!(samples[2], 0.1024);
|
0.017571526, 0.958819, 0.8521427, 0.7454664, 0.63879013
|
||||||
assert_float_eq!(samples[3], 0.0648);
|
]);
|
||||||
assert_float_eq!(samples[4], 0.95566);
|
|
||||||
assert_float_eq!(samples[5], 0.84899);
|
|
||||||
assert_float_eq!(samples[6], 0.74231);
|
|
||||||
assert_float_eq!(samples[7], 0.6356);
|
|
||||||
assert_float_eq!(samples[8], 0.5289);
|
|
||||||
assert_float_eq!(samples[9], 0.42228);
|
|
||||||
|
|
||||||
pset_n(&mut matrix, tsq, "trig", 1.0);
|
pset_n(&mut matrix, tsq, "trig", 1.0);
|
||||||
|
|
||||||
// Take some real samples:
|
// Take some real samples:
|
||||||
let samples = run_and_undersample(&mut node_exec, 2000.0, 10);
|
let samples = run_and_undersample(&mut node_exec, 2000.0, 10);
|
||||||
|
|
||||||
assert_float_eq!(samples[0], 0.3157);
|
assert_vec_feq!(samples, vec![
|
||||||
// trigger hits:
|
0.5321138,
|
||||||
assert_float_eq!(samples[1], 0.9639);
|
// Then trigger happens:
|
||||||
assert_float_eq!(samples[2], 0.8572);
|
0.96263915, 0.8559629, 0.74928665, 0.6426103, 0.53593403, 0.42925775,
|
||||||
assert_float_eq!(samples[3], 0.7506);
|
0.32258147, 0.21590519, 0.109228894
|
||||||
assert_float_eq!(samples[4], 0.6439);
|
]);
|
||||||
assert_float_eq!(samples[5], 0.5372);
|
|
||||||
assert_float_eq!(samples[6], 0.4305);
|
|
||||||
assert_float_eq!(samples[7], 0.3239);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -920,26 +908,13 @@ fn check_matrix_tseq_gate() {
|
||||||
|
|
||||||
// Take some real samples:
|
// Take some real samples:
|
||||||
let samples = run_and_undersample(&mut node_exec, 2000.0, 2000);
|
let samples = run_and_undersample(&mut node_exec, 2000.0, 2000);
|
||||||
|
let changes = collect_gates(&samples[..]);
|
||||||
|
|
||||||
assert_float_eq!(samples[117], 0.0);
|
assert_eq!(changes, vec![
|
||||||
for i in 118..243 {
|
(524, 126), (775, 8),
|
||||||
assert_float_eq!(samples[i], 1.0);
|
(1033, 1), (1041, 1), (1049, 1), (1080, 1),
|
||||||
}
|
(1088, 1), (1119, 1), (1127, 1), (1135, 1)
|
||||||
assert_float_eq!(samples[243], 0.0);
|
]);
|
||||||
|
|
||||||
assert_float_eq!(samples[367], 0.0);
|
|
||||||
for i in 368..376 {
|
|
||||||
assert_float_eq!(samples[i], 1.0);
|
|
||||||
}
|
|
||||||
assert_float_eq!(samples[376], 0.0);
|
|
||||||
|
|
||||||
assert_float_eq!(samples[680], 0.0);
|
|
||||||
assert_float_eq!(samples[681], 1.0);
|
|
||||||
assert_float_eq!(samples[682], 0.0);
|
|
||||||
|
|
||||||
assert_float_eq!(samples[688], 0.0);
|
|
||||||
assert_float_eq!(samples[689], 1.0);
|
|
||||||
assert_float_eq!(samples[690], 0.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -249,6 +249,50 @@ pub fn collect_signal_changes(inp: &[f32], thres: i64) -> Vec<(usize, i64)> {
|
||||||
return idxs_big;
|
return idxs_big;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn collect_non_zero(inp: &[f32]) -> Vec<(usize, usize)> {
|
||||||
|
let mut idxs = vec![];
|
||||||
|
let mut start_idx = 0;
|
||||||
|
let mut length = 0;
|
||||||
|
for i in 0..inp.len() {
|
||||||
|
if inp[i].abs() > 0.00001 {
|
||||||
|
if length == 0 {
|
||||||
|
start_idx = i;
|
||||||
|
}
|
||||||
|
length += 1;
|
||||||
|
} else {
|
||||||
|
if length > 0 {
|
||||||
|
idxs.push((start_idx, length));
|
||||||
|
length = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return idxs;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn collect_gates(inp: &[f32]) -> Vec<(usize, usize)> {
|
||||||
|
let mut idxs = vec![];
|
||||||
|
let mut start_idx = 0;
|
||||||
|
let mut length = 0;
|
||||||
|
for i in 0..inp.len() {
|
||||||
|
if inp[i].abs() > 0.1 {
|
||||||
|
if length == 0 {
|
||||||
|
start_idx = i;
|
||||||
|
}
|
||||||
|
length += 1;
|
||||||
|
} else {
|
||||||
|
if length > 0 {
|
||||||
|
idxs.push((start_idx, length));
|
||||||
|
length = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return idxs;
|
||||||
|
}
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! assert_rmsmima {
|
macro_rules! assert_rmsmima {
|
||||||
($rms:expr, $b:expr) => {
|
($rms:expr, $b:expr) => {
|
||||||
|
|
|
@ -23,24 +23,25 @@ fn check_node_ad_1() {
|
||||||
matrix.set_param(trig_p, SAtom::param(1.0));
|
matrix.set_param(trig_p, SAtom::param(1.0));
|
||||||
let res = run_for_ms(&mut node_exec, 25.0);
|
let res = run_for_ms(&mut node_exec, 25.0);
|
||||||
assert_decimated_slope_feq!(res.0, 50, vec![
|
assert_decimated_slope_feq!(res.0, 50, vec![
|
||||||
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
|
0.0, 0.0, 0.0, 0.0, 0.0,
|
||||||
// 44.1 per ms, attack is default 3.0ms (roughly 3 * 50 samples):
|
// 44.1 per ms, attack is default 3.0ms (roughly 3 * 50 samples):
|
||||||
0.007558584, 0.007558584, 0.007558584,
|
0.007558584, 0.007558584, 0.007558584,
|
||||||
// 44.1 per ms, decay is default 10.0ms (=> roughly 9 * 50 samples):
|
// 44.1 per ms, decay is default 10.0ms (=> roughly 9 * 50 samples):
|
||||||
-0.002267599, -0.0022675395, -0.002267599, -0.0022675395,
|
-0.002267599, -0.0022675395, -0.002267599, -0.0022675395,
|
||||||
-0.0022675693, -0.0022675693, -0.0022675842, -0.0022675693,
|
-0.0022675693, -0.0022675693, -0.0022675842, -0.0022675693,
|
||||||
-0.0022675726,
|
|
||||||
0.0, 0.0, 0.0, 0.0
|
0.0, 0.0, 0.0, 0.0
|
||||||
]);
|
]);
|
||||||
|
|
||||||
matrix.set_param(trig_p, SAtom::param(0.0));
|
matrix.set_param(trig_p, SAtom::param(0.0));
|
||||||
run_for_ms(&mut node_exec, 10.0);
|
run_for_ms(&mut node_exec, 10.0);
|
||||||
matrix.set_param(trig_p, SAtom::param(1.0));
|
matrix.set_param(trig_p, SAtom::param(1.0));
|
||||||
|
|
||||||
let res = run_for_ms(&mut node_exec, 25.0);
|
let res = run_for_ms(&mut node_exec, 25.0);
|
||||||
//d// println!("RES: {:?}", res);
|
let c = collect_non_zero(&res.0[..]);
|
||||||
let start = res.0[330];
|
// start index at 220, length of the env: 573
|
||||||
assert_float_eq!(start, 0.0075585);
|
assert_eq!(c, vec![(220, 573)]);
|
||||||
let peak = res.0[330 + ((44.1_f64 * 3.0).floor() as usize)];
|
|
||||||
|
let peak = res.0[220 + ((44.1_f64 * 3.0).floor() as usize)];
|
||||||
assert_float_eq!(peak, 1.0);
|
assert_float_eq!(peak, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,14 +158,12 @@ fn check_node_ad_inp_sin() {
|
||||||
|
|
||||||
// check if we have any frequencies resembling 440Hz
|
// check if we have any frequencies resembling 440Hz
|
||||||
matrix.set_param(trig_p, SAtom::param(1.0));
|
matrix.set_param(trig_p, SAtom::param(1.0));
|
||||||
run_for_ms(&mut node_exec, 7.0);
|
run_for_ms(&mut node_exec, 4.0);
|
||||||
|
|
||||||
let fft = run_and_get_fft4096_now(&mut node_exec, 6);
|
let fft = run_and_get_fft4096_now(&mut node_exec, 6);
|
||||||
assert_eq!(fft[0], (420, 6));
|
assert_eq!(fft, vec![
|
||||||
assert_eq!(fft[1], (431, 6));
|
(409, 6), (420, 7), (431, 7), (441, 7), (452, 7), (463, 7), (474, 6)
|
||||||
assert_eq!(fft[2], (441, 6));
|
]);
|
||||||
assert_eq!(fft[3], (452, 6));
|
|
||||||
assert_eq!(fft[4], (463, 6));
|
|
||||||
|
|
||||||
// Next we test if lengthening the attack has
|
// Next we test if lengthening the attack has
|
||||||
// effect on the captured frequencies.
|
// effect on the captured frequencies.
|
||||||
|
@ -173,11 +172,10 @@ fn check_node_ad_inp_sin() {
|
||||||
|
|
||||||
matrix.set_param(atk_p, SAtom::param(atk_p.norm(40.0)));
|
matrix.set_param(atk_p, SAtom::param(atk_p.norm(40.0)));
|
||||||
matrix.set_param(trig_p, SAtom::param(1.0));
|
matrix.set_param(trig_p, SAtom::param(1.0));
|
||||||
run_for_ms(&mut node_exec, 7.0);
|
|
||||||
|
|
||||||
let fft = run_and_get_fft4096_now(&mut node_exec, 300);
|
let fft = run_and_get_fft4096_now(&mut node_exec, 300);
|
||||||
assert_eq!(fft[0], (431, 322));
|
assert_eq!(fft, vec![
|
||||||
assert_eq!(fft[1], (441, 360));
|
(431, 318), (441, 354)
|
||||||
|
]);
|
||||||
|
|
||||||
matrix.set_param(trig_p, SAtom::param(0.0));
|
matrix.set_param(trig_p, SAtom::param(0.0));
|
||||||
run_for_ms(&mut node_exec, 8.0);
|
run_for_ms(&mut node_exec, 8.0);
|
||||||
|
@ -192,9 +190,9 @@ fn check_node_ad_inp_sin() {
|
||||||
run_for_ms(&mut node_exec, 7.0);
|
run_for_ms(&mut node_exec, 7.0);
|
||||||
|
|
||||||
let fft = run_and_get_fft4096_now(&mut node_exec, 300);
|
let fft = run_and_get_fft4096_now(&mut node_exec, 300);
|
||||||
assert_eq!(fft[0], (431, 489));
|
assert_eq!(fft[0], (431, 477));
|
||||||
assert_eq!(fft[1], (441, 647));
|
assert_eq!(fft[1], (441, 628));
|
||||||
assert_eq!(fft[2], (452, 398));
|
assert_eq!(fft[2], (452, 389));
|
||||||
|
|
||||||
matrix.set_param(trig_p, SAtom::param(0.0));
|
matrix.set_param(trig_p, SAtom::param(0.0));
|
||||||
run_for_ms(&mut node_exec, 8.0);
|
run_for_ms(&mut node_exec, 8.0);
|
||||||
|
@ -219,14 +217,13 @@ fn check_node_ad_shp_log() {
|
||||||
|
|
||||||
let res = run_for_ms(&mut node_exec, 25.0);
|
let res = run_for_ms(&mut node_exec, 25.0);
|
||||||
assert_decimated_slope_feq!(res.0, 50, vec![
|
assert_decimated_slope_feq!(res.0, 50, vec![
|
||||||
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
|
0.0, 0.0, 0.0, 0.0, 0.0,
|
||||||
// 44.1 per ms, attack is default 3.0ms (roughly 3 * 50 samples):
|
// 44.1 per ms, attack is default 3.0ms (roughly 3 * 50 samples):
|
||||||
0.009243369, 0.003936231, 0.0020142794,
|
0.008391023, 0.0045030117, 0.0026732683,
|
||||||
// 44.1 per ms, decay is default 10.0ms (=> roughly 9 * 50 samples):
|
// 44.1 per ms, decay is default 10.0ms (=> roughly 9 * 50 samples):
|
||||||
-0.0006071329, -0.00067061186, -0.000752151, -0.0008612871,
|
-0.0005967021, -0.000685215, -0.0007713437, -0.0008877516,
|
||||||
-0.0010163188, -0.0012571216, -0.0016934872, -0.0027971864,
|
-0.0010555983, -0.0013227463, -0.0018290281, -0.0032775402,
|
||||||
-0.027684271,
|
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
|
||||||
0.0, 0.0, 0.0, 0.0
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,14 +246,13 @@ fn check_node_ad_shp_exp() {
|
||||||
|
|
||||||
let res = run_for_ms(&mut node_exec, 25.0);
|
let res = run_for_ms(&mut node_exec, 25.0);
|
||||||
assert_decimated_slope_feq!(res.0, 50, vec![
|
assert_decimated_slope_feq!(res.0, 50, vec![
|
||||||
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
|
0.0, 0.0, 0.0, 0.0, 0.0,
|
||||||
// 44.1 per ms, attack is default 3.0ms (roughly 3 * 50 samples):
|
// 44.1 per ms, attack is default 3.0ms (roughly 3 * 50 samples):
|
||||||
0.0009576017, 0.0044435486, 0.023418367,
|
0.0029080845, 0.007420212, 0.023684025,
|
||||||
// 44.1 per ms, decay is default 10.0ms (=> roughly 9 * 50 samples):
|
// 44.1 per ms, decay is default 10.0ms (=> roughly 9 * 50 samples):
|
||||||
-0.0068960786, -0.004632175, -0.002927363, -0.0017025322,
|
-0.006719053, -0.004248917, -0.0026466101, -0.0015081167,
|
||||||
-0.00087817386, -0.0003750762, -0.000113890506, -0.0000153047,
|
-0.00075439364, -0.00030602422, -0.00008370355, -0.000008119583,
|
||||||
-0.0000000017186217,
|
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
|
||||||
0.0, 0.0, 0.0, 0.0
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,13 +277,12 @@ fn check_node_ad_eoet() {
|
||||||
let res = run_for_ms(&mut node_exec, 25.0);
|
let res = run_for_ms(&mut node_exec, 25.0);
|
||||||
// just make sure we are running an env:
|
// just make sure we are running an env:
|
||||||
assert_decimated_slope_feq!(res.0, 50, vec![
|
assert_decimated_slope_feq!(res.0, 50, vec![
|
||||||
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
|
0.0, 0.0, 0.0, 0.0, 0.0,
|
||||||
// 44.1 per ms, attack is default 3.0ms (roughly 3 * 50 samples):
|
// 44.1 per ms, attack is default 3.0ms (roughly 3 * 50 samples):
|
||||||
0.007558584, 0.007558584, 0.007558584,
|
0.007558584, 0.007558584, 0.007558584,
|
||||||
// 44.1 per ms, decay is default 10.0ms (=> roughly 9 * 50 samples):
|
// 44.1 per ms, decay is default 10.0ms (=> roughly 9 * 50 samples):
|
||||||
-0.002267599, -0.0022675395, -0.002267599, -0.0022675395,
|
-0.002267599, -0.0022675395, -0.002267599, -0.0022675395,
|
||||||
-0.0022675693, -0.0022675693, -0.0022675842, -0.0022675693,
|
-0.0022675693, -0.0022675693, -0.0022675842, -0.0022675693,
|
||||||
-0.0022675726,
|
|
||||||
0.0, // <- EOET expected here
|
0.0, // <- EOET expected here
|
||||||
0.0, 0.0, 0.0
|
0.0, 0.0, 0.0
|
||||||
]);
|
]);
|
||||||
|
@ -299,9 +294,8 @@ fn check_node_ad_eoet() {
|
||||||
0.0, 0.0, 0.0,
|
0.0, 0.0, 0.0,
|
||||||
// 44.1 per ms, decay is default 10.0ms (=> roughly 9 * 50 samples):
|
// 44.1 per ms, decay is default 10.0ms (=> roughly 9 * 50 samples):
|
||||||
0.0, 0.0, 0.0, 0.0,
|
0.0, 0.0, 0.0, 0.0,
|
||||||
0.0, 0.0, 0.0, 0.0,
|
0.0, 0.0,
|
||||||
0.0,
|
1.0, 1.0, // <- End of envelope!
|
||||||
1.0, // <- End of envelope!
|
|
||||||
0.0, 0.0, 0.0
|
0.0, 0.0, 0.0
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -391,7 +385,7 @@ fn check_node_ad_mult() {
|
||||||
-0.000022709, -0.000022709, -0.000022709, -0.000022709, -0.000022709,
|
-0.000022709, -0.000022709, -0.000022709, -0.000022709, -0.000022709,
|
||||||
-0.000022709, -0.000022709, -0.000022709, -0.000022709, -0.000022709,
|
-0.000022709, -0.000022709, -0.000022709, -0.000022709, -0.000022709,
|
||||||
-0.000022709, -0.000022709, -0.000022709, -0.000022709, -0.000022709,
|
-0.000022709, -0.000022709, -0.000022709, -0.000022709, -0.000022709,
|
||||||
-0.000022709, -0.000022709, -0.000022709, -0.000022709, -0.000022709,
|
-0.000022709, -0.000022709, -0.000022709, -0.000022709,
|
||||||
0.0, 0.0, 0.0, 0.0, 0.0,
|
0.0, 0.0, 0.0, 0.0, 0.0,
|
||||||
0.0, 0.0, 0.0, 0.0, 0.0,
|
0.0, 0.0, 0.0, 0.0, 0.0,
|
||||||
0.0, 0.0, 0.0, 0.0, 0.0,
|
0.0, 0.0, 0.0, 0.0, 0.0,
|
||||||
|
|
|
@ -34,18 +34,18 @@ fn check_node_delay_1() {
|
||||||
let res = run_for_ms(&mut node_exec, 500.0);
|
let res = run_for_ms(&mut node_exec, 500.0);
|
||||||
// 441 decimation => 10ms resolution
|
// 441 decimation => 10ms resolution
|
||||||
assert_decimated_feq!(res.0, 441, vec![
|
assert_decimated_feq!(res.0, 441, vec![
|
||||||
// 10ms smoothing time
|
// smoothing time:
|
||||||
0.0,
|
0.0,
|
||||||
// burst of sine for 100ms:
|
// burst of sine for 100ms:
|
||||||
0.018362517, -0.12481441, 0.2199288, -0.19472688, 0.00005349703,
|
0.04741215, -0.17181772, 0.2669262, -0.22376089, 0.000030220208,
|
||||||
0.27544498, -0.3506383, 0.2555645, -0.09918582, 0.000012852717,
|
0.24654882, -0.30384964, 0.20876096, -0.070250794, 0.0000024548233,
|
||||||
// 150ms silence:
|
// 150ms silence:
|
||||||
0.0, 0.0, 0.0, 0.0, 0.0,
|
0.0, 0.0, 0.0, 0.0, 0.0,
|
||||||
0.0, 0.0, 0.0, 0.0, 0.0,
|
0.0, 0.0, 0.0, 0.0, 0.0,
|
||||||
0.0, 0.0, 0.0, 0.0, 0.0,
|
0.0, 0.0, 0.0, 0.0, 0.0,
|
||||||
// delayed burst of sine for 100ms:
|
// delayed burst of sine for 100ms:
|
||||||
0.018362517, -0.12481441, 0.2199288, -0.19472688, 0.00005349703,
|
0.047408286, -0.17181452, 0.2669317, -0.22377986, 0.000059626997,
|
||||||
0.27544498, -0.3506383, 0.2555645, -0.09918582, 0.000012852717,
|
0.24652793, -0.30384338, 0.2087649, -0.070256576, 0.000003647874,
|
||||||
// silence afterwards:
|
// silence afterwards:
|
||||||
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
|
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -19,14 +19,14 @@ fn check_node_rndwk_def_trig() {
|
||||||
matrix.sync().unwrap();
|
matrix.sync().unwrap();
|
||||||
|
|
||||||
pset_n(&mut matrix, rwk, "trig", 1.0);
|
pset_n(&mut matrix, rwk, "trig", 1.0);
|
||||||
run_for_ms(&mut node_exec, 7.0); // wait for trigger...
|
run_for_ms(&mut node_exec, 4.2); // wait for trigger...
|
||||||
|
|
||||||
let (out_l, _) = run_for_ms(&mut node_exec, 20.0);
|
let (out_l, _) = run_for_ms(&mut node_exec, 20.0);
|
||||||
assert_decimated_feq!(out_l, 40, vec![
|
assert_decimated_feq!(out_l, 40, vec![
|
||||||
0.0, // start value
|
0.0, // start value
|
||||||
// slew ramp:
|
// slew ramp:
|
||||||
0.00574452, 0.017838247, 0.029931974, 0.0420257, 0.054119427,
|
0.001814059, 0.0139077855, 0.026001511, 0.03809524, 0.050188966,
|
||||||
0.06621315, 0.078306876, 0.09040061, 0.10249433,
|
0.062282693, 0.07437642, 0.08647014, 0.09856387, 0.110657595,
|
||||||
// end value:
|
// end value:
|
||||||
0.11378352, 0.11378352, 0.11378352, 0.11378352, 0.11378352,
|
0.11378352, 0.11378352, 0.11378352, 0.11378352, 0.11378352,
|
||||||
]);
|
]);
|
||||||
|
@ -34,12 +34,12 @@ fn check_node_rndwk_def_trig() {
|
||||||
pset_n(&mut matrix, rwk, "trig", 0.0);
|
pset_n(&mut matrix, rwk, "trig", 0.0);
|
||||||
pset_d_wait(&mut matrix, &mut node_exec, rwk, "slew", 10.0);
|
pset_d_wait(&mut matrix, &mut node_exec, rwk, "slew", 10.0);
|
||||||
pset_n(&mut matrix, rwk, "trig", 1.0);
|
pset_n(&mut matrix, rwk, "trig", 1.0);
|
||||||
run_for_ms(&mut node_exec, 7.0); // wait for trigger...
|
run_for_ms(&mut node_exec, 4.0); // wait for trigger...
|
||||||
|
|
||||||
let (out_l, _) = run_for_ms(&mut node_exec, 20.0);
|
let (out_l, _) = run_for_ms(&mut node_exec, 20.0);
|
||||||
assert_decimated_feq!(out_l, 15, vec![
|
assert_decimated_feq!(out_l, 15, vec![
|
||||||
0.11378352, 0.11378352, // last value
|
0.11378352, 0.11378352, 0.11378352, // last value
|
||||||
0.13419169, 0.16820529, 0.20221889, 0.2362325,
|
0.11831867, 0.15233228, 0.18634588, 0.22035949, 0.2543731,
|
||||||
0.26017055, 0.26017055, // end value
|
0.26017055, 0.26017055, // end value
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ fn check_node_rndwk_step() {
|
||||||
matrix.sync().unwrap();
|
matrix.sync().unwrap();
|
||||||
|
|
||||||
pset_n(&mut matrix, rwk, "trig", 1.0);
|
pset_n(&mut matrix, rwk, "trig", 1.0);
|
||||||
run_for_ms(&mut node_exec, 7.0); // wait for trigger...
|
run_for_ms(&mut node_exec, 4.51); // wait for trigger...
|
||||||
|
|
||||||
let (out_l, _) = run_for_ms(&mut node_exec, 50.0);
|
let (out_l, _) = run_for_ms(&mut node_exec, 50.0);
|
||||||
assert_decimated_feq!(out_l, 200, vec![
|
assert_decimated_feq!(out_l, 200, vec![
|
||||||
|
@ -90,7 +90,7 @@ fn check_node_rndwk_offs() {
|
||||||
matrix.sync().unwrap();
|
matrix.sync().unwrap();
|
||||||
|
|
||||||
pset_n(&mut matrix, rwk, "trig", 1.0);
|
pset_n(&mut matrix, rwk, "trig", 1.0);
|
||||||
run_for_ms(&mut node_exec, 7.0); // wait for trigger...
|
run_for_ms(&mut node_exec, 4.51); // wait for trigger...
|
||||||
|
|
||||||
let (out_l, _) = run_for_ms(&mut node_exec, 20.0);
|
let (out_l, _) = run_for_ms(&mut node_exec, 20.0);
|
||||||
assert_decimated_feq!(out_l, 60, vec![
|
assert_decimated_feq!(out_l, 60, vec![
|
||||||
|
@ -121,7 +121,7 @@ fn check_node_rndwk_offs_neg() {
|
||||||
matrix.sync().unwrap();
|
matrix.sync().unwrap();
|
||||||
|
|
||||||
pset_n(&mut matrix, rwk, "trig", 1.0);
|
pset_n(&mut matrix, rwk, "trig", 1.0);
|
||||||
run_for_ms(&mut node_exec, 7.0); // wait for trigger...
|
run_for_ms(&mut node_exec, 4.51); // wait for trigger...
|
||||||
|
|
||||||
let (out_l, _) = run_for_ms(&mut node_exec, 20.0);
|
let (out_l, _) = run_for_ms(&mut node_exec, 20.0);
|
||||||
assert_decimated_feq!(out_l, 60, vec![
|
assert_decimated_feq!(out_l, 60, vec![
|
||||||
|
@ -150,7 +150,7 @@ fn check_node_rndwk_max() {
|
||||||
matrix.sync().unwrap();
|
matrix.sync().unwrap();
|
||||||
|
|
||||||
pset_n(&mut matrix, rwk, "trig", 1.0);
|
pset_n(&mut matrix, rwk, "trig", 1.0);
|
||||||
run_for_ms(&mut node_exec, 7.0); // wait for trigger...
|
run_for_ms(&mut node_exec, 4.51); // wait for trigger...
|
||||||
|
|
||||||
let (out_l, _) = run_for_ms(&mut node_exec, 50.0);
|
let (out_l, _) = run_for_ms(&mut node_exec, 50.0);
|
||||||
assert_decimated_feq!(out_l, 200, vec![
|
assert_decimated_feq!(out_l, 200, vec![
|
||||||
|
@ -181,7 +181,7 @@ fn check_node_rndwk_min() {
|
||||||
matrix.sync().unwrap();
|
matrix.sync().unwrap();
|
||||||
|
|
||||||
pset_n(&mut matrix, rwk, "trig", 1.0);
|
pset_n(&mut matrix, rwk, "trig", 1.0);
|
||||||
run_for_ms(&mut node_exec, 7.0); // wait for trigger...
|
run_for_ms(&mut node_exec, 4.51); // wait for trigger...
|
||||||
|
|
||||||
let (out_l, _) = run_for_ms(&mut node_exec, 100.0); // 75ms slew time default
|
let (out_l, _) = run_for_ms(&mut node_exec, 100.0); // 75ms slew time default
|
||||||
assert_decimated_feq!(out_l, 400, vec![
|
assert_decimated_feq!(out_l, 400, vec![
|
||||||
|
|
|
@ -336,13 +336,13 @@ fn check_node_sampl_trigger_reset_phase() {
|
||||||
|
|
||||||
matrix.set_param(trig_p, (1.0).into());
|
matrix.set_param(trig_p, (1.0).into());
|
||||||
let rmsvec = run_and_get_each_rms_mimax(&mut node_exec, 100.0);
|
let rmsvec = run_and_get_each_rms_mimax(&mut node_exec, 100.0);
|
||||||
assert_minmax_of_rms!(rmsvec[0], (0.0, 0.092496));
|
assert_minmax_of_rms!(rmsvec[0], (0.0, 0.09499));
|
||||||
assert_minmax_of_rms!(rmsvec[2], (0.19252, 0.29250));
|
assert_minmax_of_rms!(rmsvec[2], (0.1950, 0.2949));
|
||||||
|
|
||||||
// lower trigger level, for retrigger later
|
// lower trigger level, for retrigger later
|
||||||
matrix.set_param(trig_p, (0.0).into());
|
matrix.set_param(trig_p, (0.0).into());
|
||||||
let rmsvec = run_and_get_each_rms_mimax(&mut node_exec, 10.0);
|
let rmsvec = run_and_get_each_rms_mimax(&mut node_exec, 10.0);
|
||||||
assert_minmax_of_rms!(rmsvec[2], (0.31252, 0.32250));
|
assert_minmax_of_rms!(rmsvec[2], (0.3150, 0.32499));
|
||||||
|
|
||||||
// retrigger the phase sample
|
// retrigger the phase sample
|
||||||
matrix.set_param(trig_p, (1.0).into());
|
matrix.set_param(trig_p, (1.0).into());
|
||||||
|
@ -354,8 +354,8 @@ fn check_node_sampl_trigger_reset_phase() {
|
||||||
// this is the last value of the previous triggering
|
// this is the last value of the previous triggering
|
||||||
assert_float_eq!(max, 0.32998);
|
assert_float_eq!(max, 0.32998);
|
||||||
|
|
||||||
assert_minmax_of_rms!(rmsvec[1], (0.09251, 0.19249));
|
assert_minmax_of_rms!(rmsvec[1], (0.0950, 0.19499));
|
||||||
assert_minmax_of_rms!(rmsvec[2], (0.19252, 0.29250));
|
assert_minmax_of_rms!(rmsvec[2], (0.1950, 0.29499));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -386,8 +386,8 @@ fn check_node_sampl_trigger_loop_reset_phase() {
|
||||||
|
|
||||||
matrix.set_param(trig_p, (1.0).into());
|
matrix.set_param(trig_p, (1.0).into());
|
||||||
let rmsvec = run_and_get_each_rms_mimax(&mut node_exec, 100.0);
|
let rmsvec = run_and_get_each_rms_mimax(&mut node_exec, 100.0);
|
||||||
assert_minmax_of_rms!(rmsvec[0], (0.0, 0.3074));
|
assert_minmax_of_rms!(rmsvec[0], (0.0, 0.3050));
|
||||||
assert_minmax_of_rms!(rmsvec[2], (0.1925, 0.2925));
|
assert_minmax_of_rms!(rmsvec[2], (0.1950, 0.2949));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -453,7 +453,7 @@ fn check_node_sampl_offs_len_zero_crash() {
|
||||||
|
|
||||||
matrix.set_param(trig_p, (1.0).into());
|
matrix.set_param(trig_p, (1.0).into());
|
||||||
let rmsvec = run_and_get_each_rms_mimax(&mut node_exec, 50.0);
|
let rmsvec = run_and_get_each_rms_mimax(&mut node_exec, 50.0);
|
||||||
assert_minmax_of_rms!(rmsvec[0], (0.0, 0.9979));
|
assert_minmax_of_rms!(rmsvec[0], (0.0, 0.9981));
|
||||||
|
|
||||||
// Select part 0.5 to 0.75 of the sample:
|
// Select part 0.5 to 0.75 of the sample:
|
||||||
matrix.set_param(offs_p, SAtom::param(0.9));
|
matrix.set_param(offs_p, SAtom::param(0.9));
|
||||||
|
@ -525,7 +525,7 @@ fn check_node_sampl_declick() {
|
||||||
matrix.set_param(dcms_p, SAtom::param(dcms_p.norm(3.14)));
|
matrix.set_param(dcms_p, SAtom::param(dcms_p.norm(3.14)));
|
||||||
matrix.set_param(trig_p, (1.0).into());
|
matrix.set_param(trig_p, (1.0).into());
|
||||||
|
|
||||||
let rmsvec = run_and_get_each_rms_mimax(&mut node_exec, 5.0);
|
let rmsvec = run_and_get_each_rms_mimax(&mut node_exec, 3.0);
|
||||||
|
|
||||||
assert_minmax_of_rms!(rmsvec[0], (0.0, 0.0));
|
assert_minmax_of_rms!(rmsvec[0], (0.0, 0.0));
|
||||||
assert_minmax_of_rms!(rmsvec[1], (0.0, 1.0));
|
assert_minmax_of_rms!(rmsvec[1], (0.0, 1.0));
|
||||||
|
@ -538,7 +538,7 @@ fn check_node_sampl_declick() {
|
||||||
matrix.set_param(dclick_p, SAtom::setting(1));
|
matrix.set_param(dclick_p, SAtom::setting(1));
|
||||||
matrix.set_param(trig_p, (1.0).into());
|
matrix.set_param(trig_p, (1.0).into());
|
||||||
// let the trigger appear in the sampler:
|
// let the trigger appear in the sampler:
|
||||||
run_for_ms(&mut node_exec, 7.5);
|
run_for_ms(&mut node_exec, 5.0);
|
||||||
// now the de-click should run:
|
// now the de-click should run:
|
||||||
let rmsvec = run_and_get_each_rms_mimax(&mut node_exec, 1.0);
|
let rmsvec = run_and_get_each_rms_mimax(&mut node_exec, 1.0);
|
||||||
|
|
||||||
|
@ -579,15 +579,16 @@ fn check_node_sampl_declick_offs_len() {
|
||||||
matrix.set_param(len_p, SAtom::param(0.008));
|
matrix.set_param(len_p, SAtom::param(0.008));
|
||||||
|
|
||||||
// trigger:
|
// trigger:
|
||||||
run_for_ms(&mut node_exec, 7.5);
|
run_for_ms(&mut node_exec, 5.0);
|
||||||
|
|
||||||
let res = run_for_ms(&mut node_exec, 12.0);
|
let res = run_for_ms(&mut node_exec, 12.0);
|
||||||
|
|
||||||
assert_decimated_feq!(res.0, 15, vec![
|
assert_decimated_feq!(res.0, 15, vec![
|
||||||
0.0, 0.10955164, 0.21910328, 0.32865492, 0.43820655, 0.54775816, 0.65730983,
|
0.0,
|
||||||
0.76686144, 0.8764131, 0.97491217,
|
0.11080169, 0.22160338, 0.33240506, 0.44320676, 0.5540084, 0.6648101,
|
||||||
|
0.7756118, 0.8864135, 0.98414195,
|
||||||
1.0, 1.0, 1.0, 1.0, 1.0,
|
1.0, 1.0, 1.0, 1.0, 1.0,
|
||||||
0.92436117, 0.8160376, 0.707714, 0.59939045, 0.49106687, 0.3827433,
|
0.9331123, 0.82376325, 0.7144141, 0.59939045, 0.49106687, 0.3827433,
|
||||||
0.27441972, 0.16609615, 0.057772573,
|
0.27441972, 0.16609615, 0.057772573,
|
||||||
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
|
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -80,7 +80,9 @@ fn check_node_tslfo_trig_slopes() {
|
||||||
(out_l[0] - out_l[1]).abs(),
|
(out_l[0] - out_l[1]).abs(),
|
||||||
ramp_slope as f32);
|
ramp_slope as f32);
|
||||||
assert_decimated_feq!(out_l, 50, vec![
|
assert_decimated_feq!(out_l, 50, vec![
|
||||||
0.7513184, 0.8648106, 0.9783028, 0.09079399, 0.20428619, 0.3177784
|
0.00000022911095, 0.11349243, 0.22698463, 0.34047684, 0.45396903,
|
||||||
|
0.56746125, 0.68095344, 0.79444563, 0.9079378, 0.020429054,
|
||||||
|
0.13392125, 0.24741346, 0.36090568, 0.47439787
|
||||||
]);
|
]);
|
||||||
|
|
||||||
pset_d_wait(&mut matrix, &mut node_exec, tsl, "trig", 0.0);
|
pset_d_wait(&mut matrix, &mut node_exec, tsl, "trig", 0.0);
|
||||||
|
@ -92,9 +94,11 @@ fn check_node_tslfo_trig_slopes() {
|
||||||
let (out_l, _) = run_for_ms(&mut node_exec, 15.0);
|
let (out_l, _) = run_for_ms(&mut node_exec, 15.0);
|
||||||
let ramp_slope = 1.0_f64 / ((10.0 / 1000.0) * 44100.0);
|
let ramp_slope = 1.0_f64 / ((10.0 / 1000.0) * 44100.0);
|
||||||
assert_float_eq!(
|
assert_float_eq!(
|
||||||
(out_l[0] - out_l[1]).abs(),
|
(out_l[1] - out_l[2]).abs(),
|
||||||
ramp_slope as f32);
|
ramp_slope as f32);
|
||||||
assert_decimated_feq!(out_l, 50, vec![
|
assert_decimated_feq!(out_l, 50, vec![
|
||||||
0.24945788, 0.13606784, 0.022677781, 0.90938777, 0.7959977
|
0.0022888184, 0.88670975, 0.77331966, 0.65992963, 0.5465396,
|
||||||
|
0.43314955, 0.3197595, 0.20636943, 0.09297939, 0.97968936,
|
||||||
|
0.8662993, 0.75290924, 0.6395192, 0.5261291
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue