fixes and debug logging

This commit is contained in:
Weird Constructor 2021-07-10 10:16:23 +02:00
parent 4b8f3d67e7
commit e423ca22a3
3 changed files with 34 additions and 42 deletions

View file

@ -354,15 +354,18 @@ impl NodeConfigurator {
if let Some(modamt) = &mut nparam.modamt {
mod_idx = Some(modamt.0);
modamt.1 = v.unwrap_or(0.0);
println!("SET NPARAM MOD AMT {:?} {:?} {}", param, mod_idx, modamt.1);
}
}
// Check if the modulation amount was already set, if not, we need
// to reconstruct the graph and upload an updated NodeProg.
// Check if the modulation amount was already set, if not, the caller
// needs to reconstruct the graph and upload an updated NodeProg.
if let Some(_old_modamt) =
self.param_modamt.get(&param).copied().flatten()
{
if v.is_none() {
println!("SET NEW NONE MOD AMT {:?}", param);
self.param_modamt.insert(param, v);
true
@ -371,6 +374,7 @@ impl NodeConfigurator {
self.param_modamt.insert(param, v);
if let Some(mod_idx) = mod_idx {
println!("SET UPD MOD AMT {:?} {:?} {:?}", param, mod_idx, modamt);
let _ =
self.shared.quick_update_prod.push(
QuickMessage::ModamtUpdate { mod_idx, modamt });

View file

@ -318,6 +318,13 @@ impl NodeExecutor {
#[inline]
pub fn get_prog(&self) -> &NodeProg { &self.prog }
#[inline]
fn set_modamt(&mut self, mod_idx: usize, modamt: f32) {
if mod_idx < self.prog.modops.len() {
self.prog.modops[mod_idx].set_amt(modamt);
}
}
#[inline]
fn set_param(&mut self, input_idx: usize, value: f32) {
let prog = &mut self.prog;
@ -398,10 +405,8 @@ impl NodeExecutor {
QuickMessage::ParamUpdate { input_idx, value } => {
self.set_param(input_idx, value);
},
// TODO: MODAMT
// QuickMessage::ModamtUpdate { input_idx, modamt } => {
QuickMessage::ModamtUpdate { .. } => {
// assign to NodeProg
QuickMessage::ModamtUpdate { mod_idx, modamt } => {
self.set_modamt(mod_idx, modamt);
},
QuickMessage::SetMonitor { bufs } => {
self.monitor_signal_cur_inp_indices = bufs;
@ -425,40 +430,18 @@ impl NodeExecutor {
let prog_out_fb = prog.out_feedback.input_buffer();
let nframes = ctx.nframes();
for op in prog.prog.iter() {
let out = op.out_idxlen;
let inp = op.in_idxlen;
let at = op.at_idxlen;
let md = op.mod_idxlen;
let ctx_idx = op.idx as usize * 2;
/* MOD AMOUNT APPLYING PSEUDO CODE:
for (amt, range, modbuf, outbuf, inpbuf) in
prog.mod[mod.0..mod.1].iter()
{
match range {
ModRange::Bipol => {
for frame in 0..ctx.nframes() {
modbuf.write(frame,
modbuf.read(frame)
* ((outbuf.read(frame) + 1.0) * 0.5)
.clamp(0.0, 1.0)
+ inpbuf.read(frame));
for modop in prog.modops[md.0..md.1].iter_mut() {
modop.process(nframes);
}
},
ModRange::Unipol => {
for frame in 0..ctx.nframes() {
modbuf.write(frame,
modbuf.read(frame)
* outbuf.read(frame).clamp(0.0, 1.0)
+ inpbuf.read(frame));
}
},
}
}
*/
nodes[op.idx as usize]
.process(
@ -470,7 +453,7 @@ impl NodeExecutor {
&mut prog.out[out.0..out.1],
&ctx_vals[ctx_idx..ctx_idx + 2]);
let last_frame_idx = ctx.nframes() - 1;
let last_frame_idx = nframes - 1;
for (pb, out_buf_idx) in
prog.out[out.0..out.1].iter()
.zip(out.0..out.1)

View file

@ -33,9 +33,11 @@ impl ModOp {
self.amount = amt;
}
pub fn lock(&mut self, inbuf: ProcBuf, outbuf: ProcBuf) {
pub fn lock(&mut self, inbuf: ProcBuf, outbuf: ProcBuf) -> ProcBuf {
println!("LOCK MA {}", self.amount);
self.inbuf = inbuf;
self.outbuf = outbuf;
self.modbuf
}
pub fn unlock(&mut self) {
@ -49,11 +51,12 @@ impl ModOp {
let inbuf = &mut self.inbuf;
let outbuf = &mut self.outbuf;
println!("PROCMA {}", self.amount);
for frame in 0..nframes {
modbuf.write(frame,
modbuf.read(frame)
* outbuf.read(frame)
+ inbuf.read(frame));
inbuf.read(frame)
+ (self.amount * outbuf.read(frame)));
}
}
}
@ -299,6 +302,7 @@ impl NodeProg {
pub fn assign_outputs(&mut self) {
for op in self.prog.iter() {
println!("ASSIGN OUTPUTS: {}", op);
// First step is copying the ProcBufs to the `cur_inp` current
// input buffer vector. It holds the data for smoothed paramter
// inputs or just constant values since the last smoothing.
@ -328,6 +332,7 @@ impl NodeProg {
input_bufs[io.1] = out_bufs[io.0];
if let Some(idx) = io.2 {
input_bufs[io.1] =
self.modops[idx].lock(self.inp[io.1], out_bufs[io.0]);
}
}