smoother time parameter for the scope
This commit is contained in:
parent
a025c7fbe2
commit
30284e27dc
2 changed files with 28 additions and 9 deletions
|
@ -1215,6 +1215,22 @@ macro_rules! f_lfot {
|
|||
};
|
||||
}
|
||||
|
||||
macro_rules! f_lfoms {
|
||||
($formatter: expr, $v: expr, $denorm_v: expr) => {
|
||||
if $denorm_v < 10.0 {
|
||||
write!($formatter, "{:5.3}ms", $denorm_v)
|
||||
} else if $denorm_v < 250.0 {
|
||||
write!($formatter, "{:4.1}ms", $denorm_v)
|
||||
} else if $denorm_v < 1500.0 {
|
||||
write!($formatter, "{:4.0}ms", $denorm_v)
|
||||
} else if $denorm_v < 10000.0 {
|
||||
write!($formatter, "{:5.2}s", $denorm_v / 1000.0)
|
||||
} else {
|
||||
write!($formatter, "{:5.1}s", $denorm_v / 1000.0)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! f_det {
|
||||
($formatter: expr, $v: expr, $denorm_v: expr) => {{
|
||||
let sign = if $denorm_v < 0.0 { -1.0 } else { 1.0 };
|
||||
|
@ -1412,7 +1428,7 @@ macro_rules! node_list {
|
|||
(0 in1 n_id d_id r_id f_def stp_d -1.0, 1.0, 0.0)
|
||||
(1 in2 n_id d_id r_id f_def stp_d -1.0, 1.0, 0.0)
|
||||
(2 in3 n_id d_id r_id f_def stp_d -1.0, 1.0, 0.0)
|
||||
(3 time n_lfot d_lfot r_lfot f_lfot stp_f 0.0, 1.0, 1000.0)
|
||||
(3 time n_lfot d_lfot r_lfot f_lfoms stp_f 0.0, 1.0, 1000.0)
|
||||
(4 trig n_id d_id r_id f_def stp_d -1.0, 1.0, 0.0)
|
||||
(5 thrsh n_id d_id r_id f_def stp_d -1.0, 1.0, 0.0)
|
||||
(6 off1 n_id d_id r_id f_def stp_d -1.0, 1.0, 0.0)
|
||||
|
|
|
@ -33,7 +33,7 @@ macro_rules! fa_scope_tsrc {
|
|||
pub struct Scope {
|
||||
handle: Arc<ScopeHandle>,
|
||||
idx: usize,
|
||||
frame_count: usize,
|
||||
frame_time: f32,
|
||||
srate_ms: f32,
|
||||
trig: CustomTrigger,
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ impl Scope {
|
|||
handle: ScopeHandle::new_shared(),
|
||||
idx: 0,
|
||||
srate_ms: 44.1,
|
||||
frame_count: 0,
|
||||
frame_time: 0.0,
|
||||
trig: CustomTrigger::new(0.0, 0.0001),
|
||||
}
|
||||
}
|
||||
|
@ -129,11 +129,14 @@ impl DspNode for Scope {
|
|||
|
||||
let time = denorm::Scope::time(time, 0);
|
||||
let samples_per_block = (time * self.srate_ms) / SCOPE_SAMPLES as f32;
|
||||
let time_per_block = time / SCOPE_SAMPLES as f32;
|
||||
let sample_time = 1.0 / self.srate_ms;
|
||||
let threshold = denorm::Scope::thrsh(thrsh, 0);
|
||||
self.trig.set_threshold(threshold, threshold + 0.001);
|
||||
|
||||
let trigger_input = in1;
|
||||
|
||||
//d// println!("TIME time={}; st={}; tpb={}; frame_time={}", time, sample_time, time_per_block, self.frame_time);
|
||||
if samples_per_block < 1.0 {
|
||||
let copy_count = ((1.0 / samples_per_block) as usize).min(SCOPE_SAMPLES);
|
||||
|
||||
|
@ -148,30 +151,30 @@ impl DspNode for Scope {
|
|||
}
|
||||
|
||||
if self.idx >= SCOPE_SAMPLES && self.trig.check_trigger(trigger_input.read(frame)) {
|
||||
self.frame_count = 0;
|
||||
self.frame_time = 0.0;
|
||||
self.idx = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let samples_per_block = samples_per_block as usize;
|
||||
// let samples_per_block = samples_per_block as usize;
|
||||
|
||||
for frame in 0..ctx.nframes() {
|
||||
if self.idx < SCOPE_SAMPLES {
|
||||
if self.frame_count >= samples_per_block {
|
||||
if self.frame_time >= time_per_block {
|
||||
for (i, input) in inputs.iter().enumerate() {
|
||||
let in_val = input.read(frame);
|
||||
self.handle.write(i, self.idx, in_val);
|
||||
}
|
||||
|
||||
self.idx = self.idx.saturating_add(1);
|
||||
self.frame_count = 0;
|
||||
self.frame_time -= time_per_block;
|
||||
}
|
||||
|
||||
self.frame_count += 1;
|
||||
self.frame_time += sample_time;
|
||||
}
|
||||
|
||||
if self.idx >= SCOPE_SAMPLES && self.trig.check_trigger(trigger_input.read(frame)) {
|
||||
self.frame_count = 0;
|
||||
self.frame_time = 0.0;
|
||||
self.idx = 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue