From b48d423b5ad68d1999794948aeead503c46856d9 Mon Sep 17 00:00:00 2001 From: Weird Constructor Date: Sun, 4 Jul 2021 13:37:37 +0200 Subject: [PATCH] sketch out mod amount changes --- src/nodes/node_exec.rs | 28 ++++++++++++++++++++++++++++ src/nodes/node_prog.rs | 41 +++++++++++++++++------------------------ 2 files changed, 45 insertions(+), 24 deletions(-) diff --git a/src/nodes/node_exec.rs b/src/nodes/node_exec.rs index 6df99ec..7b30b19 100644 --- a/src/nodes/node_exec.rs +++ b/src/nodes/node_exec.rs @@ -427,6 +427,34 @@ impl NodeExecutor { 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)); + } + }, + 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( ctx, diff --git a/src/nodes/node_prog.rs b/src/nodes/node_prog.rs index c4eef3b..c26ce7e 100644 --- a/src/nodes/node_prog.rs +++ b/src/nodes/node_prog.rs @@ -164,44 +164,32 @@ impl NodeProg { } self.prog.push(node_op); + // TODO: MOD AMOUNT: + // self.mods.push(Option>) } + // TODO: MOD AMOUNT CHANGE: pub fn append_edge( &mut self, node_op: NodeOp, inp_index: usize, - out_index: usize) + out_index: usize) // mod_amt: Option<(f32, sigtype)> { + // If we have a modulation: + // self.mod_bufs.push(ProcBuf::new()) + // modbuf_idx = self.mod_bufs.len(); for n_op in self.prog.iter_mut() { if n_op.idx == node_op.idx { - n_op.inputs.push((out_index, inp_index)); + n_op.inputs.push((out_index, inp_index + /* Option<(f32, sigtype, modbuf_idx>*/)); return; } } } - pub fn append_with_inputs( - &mut self, - mut node_op: NodeOp, - inp1: Option<(usize, usize)>, - inp2: Option<(usize, usize)>, - inp3: Option<(usize, usize)>) - { - for n_op in self.prog.iter_mut() { - if n_op.idx == node_op.idx { - if let Some(inp1) = inp1 { n_op.inputs.push(inp1); } - if let Some(inp2) = inp2 { n_op.inputs.push(inp2); } - if let Some(inp3) = inp3 { n_op.inputs.push(inp3); } - return; - } - } - - if let Some(inp1) = inp1 { node_op.inputs.push(inp1); } - if let Some(inp2) = inp2 { node_op.inputs.push(inp2); } - if let Some(inp3) = inp3 { node_op.inputs.push(inp3); } - self.prog.push(node_op); - } - pub fn initialize_input_buffers(&mut self) { for param_idx in 0..self.params.len() { let param_val = self.params[param_idx]; @@ -262,8 +250,13 @@ impl NodeProg { input_bufs[inp.0..inp.1] .copy_from_slice(&self.inp[inp.0..inp.1]); + // TODO: self.mods.clear() (ProcBufs are in modbufs) + // Second step (assign outputs): for io in op.inputs.iter() { + // TODO: MOD AMOUNT: take from mod_bufs assign to input_bufs, + // add entry to self.mods???? we need indices...?! + // Create mods entries which contain all the info for node_exec. input_bufs[io.1] = out_bufs[io.0]; } }