rough PoC for Code node
This commit is contained in:
parent
4fc1dc75fd
commit
89c1ffe79e
3 changed files with 26 additions and 18 deletions
|
@ -96,6 +96,7 @@ impl DspNode for Code {
|
||||||
// let clock = inp::TSeq::clock(inputs);
|
// let clock = inp::TSeq::clock(inputs);
|
||||||
// let trig = inp::TSeq::trig(inputs);
|
// let trig = inp::TSeq::trig(inputs);
|
||||||
// let cmode = at::TSeq::cmode(atoms);
|
// let cmode = at::TSeq::cmode(atoms);
|
||||||
|
let out = out::Code::sig(outputs);
|
||||||
|
|
||||||
#[cfg(feature = "wblockdsp")]
|
#[cfg(feature = "wblockdsp")]
|
||||||
{
|
{
|
||||||
|
@ -109,6 +110,7 @@ impl DspNode for Code {
|
||||||
|
|
||||||
for frame in 0..ctx.nframes() {
|
for frame in 0..ctx.nframes() {
|
||||||
let (s1, s2, ret) = backend.process(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
|
let (s1, s2, ret) = backend.process(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
|
||||||
|
out.write(frame, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx_vals[0].set(0.0);
|
ctx_vals[0].set(0.0);
|
||||||
|
|
|
@ -3,18 +3,18 @@
|
||||||
// See README.md and COPYING for details.
|
// See README.md and COPYING for details.
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
FeedbackFilter, GraphMessage, NodeOp, NodeProg, MAX_ALLOCATED_NODES, MAX_AVAIL_TRACKERS,
|
FeedbackFilter, GraphMessage, NodeOp, NodeProg, MAX_ALLOCATED_NODES, MAX_AVAIL_CODE_ENGINES,
|
||||||
MAX_INPUTS, MAX_SCOPES, UNUSED_MONITOR_IDX, MAX_AVAIL_CODE_ENGINES
|
MAX_AVAIL_TRACKERS, MAX_INPUTS, MAX_SCOPES, UNUSED_MONITOR_IDX,
|
||||||
};
|
};
|
||||||
use crate::dsp::tracker::{PatternData, Tracker};
|
use crate::dsp::tracker::{PatternData, Tracker};
|
||||||
use crate::dsp::{node_factory, Node, NodeId, NodeInfo, ParamId, SAtom};
|
use crate::dsp::{node_factory, Node, NodeId, NodeInfo, ParamId, SAtom};
|
||||||
use crate::monitor::{new_monitor_processor, MinMaxMonitorSamples, Monitor, MON_SIG_CNT};
|
use crate::monitor::{new_monitor_processor, MinMaxMonitorSamples, Monitor, MON_SIG_CNT};
|
||||||
use crate::nodes::drop_thread::DropThread;
|
use crate::nodes::drop_thread::DropThread;
|
||||||
use crate::util::AtomicFloat;
|
use crate::util::AtomicFloat;
|
||||||
use crate::SampleLibrary;
|
|
||||||
use crate::ScopeHandle;
|
|
||||||
#[cfg(feature = "wblockdsp")]
|
#[cfg(feature = "wblockdsp")]
|
||||||
use crate::wblockdsp::CodeEngine;
|
use crate::wblockdsp::CodeEngine;
|
||||||
|
use crate::SampleLibrary;
|
||||||
|
use crate::ScopeHandle;
|
||||||
|
|
||||||
use ringbuf::{Producer, RingBuffer};
|
use ringbuf::{Producer, RingBuffer};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
@ -700,6 +700,19 @@ impl NodeConfigurator {
|
||||||
let code_idx = ni.instance();
|
let code_idx = ni.instance();
|
||||||
if let Some(cod) = self.code_engines.get_mut(code_idx) {
|
if let Some(cod) = self.code_engines.get_mut(code_idx) {
|
||||||
node.set_backend(cod.get_backend());
|
node.set_backend(cod.get_backend());
|
||||||
|
use wblockdsp::build::*;
|
||||||
|
cod.upload(stmts(&[
|
||||||
|
assign(
|
||||||
|
"*phase",
|
||||||
|
op_add(var("*phase"), op_mul(literal(440.0), var("israte"))),
|
||||||
|
),
|
||||||
|
_if(
|
||||||
|
op_gt(var("*phase"), literal(1.0)),
|
||||||
|
assign("*phase", op_sub(var("*phase"), literal(1.0))),
|
||||||
|
None,
|
||||||
|
),
|
||||||
|
var("*phase"),
|
||||||
|
]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,20 +42,10 @@ impl CodeEngine {
|
||||||
|
|
||||||
let lib = get_default_library();
|
let lib = get_default_library();
|
||||||
|
|
||||||
Self {
|
Self { lib, dsp_ctx: DSPNodeContext::new_ref(), update_prod, return_cons }
|
||||||
lib,
|
|
||||||
dsp_ctx: DSPNodeContext::new_ref(),
|
|
||||||
update_prod,
|
|
||||||
return_cons,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn upload(
|
pub fn upload(&mut self, ast: Box<ASTNode>) -> Result<(), JITCompileError> {
|
||||||
&mut self,
|
|
||||||
code_instance: usize,
|
|
||||||
ast: Box<ASTNode>,
|
|
||||||
) -> Result<(), JITCompileError> {
|
|
||||||
|
|
||||||
let jit = JIT::new(self.lib.clone(), self.dsp_ctx.clone());
|
let jit = JIT::new(self.lib.clone(), self.dsp_ctx.clone());
|
||||||
let fun = jit.compile(ASTFun::new(ast))?;
|
let fun = jit.compile(ASTFun::new(ast))?;
|
||||||
self.update_prod.push(CodeUpdateMsg::UpdateFun(fun));
|
self.update_prod.push(CodeUpdateMsg::UpdateFun(fun));
|
||||||
|
@ -97,7 +87,6 @@ impl Drop for CodeEngine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub struct CodeEngineBackend {
|
pub struct CodeEngineBackend {
|
||||||
sample_rate: f32,
|
sample_rate: f32,
|
||||||
function: Box<DSPFunction>,
|
function: Box<DSPFunction>,
|
||||||
|
@ -106,7 +95,11 @@ pub struct CodeEngineBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CodeEngineBackend {
|
impl CodeEngineBackend {
|
||||||
fn new(function: Box<DSPFunction>, update_cons: Consumer<CodeUpdateMsg>, return_prod: Producer<CodeReturnMsg>) -> Self {
|
fn new(
|
||||||
|
function: Box<DSPFunction>,
|
||||||
|
update_cons: Consumer<CodeUpdateMsg>,
|
||||||
|
return_prod: Producer<CodeReturnMsg>,
|
||||||
|
) -> Self {
|
||||||
Self { sample_rate: 0.0, function, update_cons, return_prod }
|
Self { sample_rate: 0.0, function, update_cons, return_prod }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue