From f5f242041afa714ec38fe2d0efcc0cd31e40ab68 Mon Sep 17 00:00:00 2001 From: Weird Constructor Date: Sat, 30 Jul 2022 23:11:33 +0200 Subject: [PATCH] use synfx-dsp-jit now --- Cargo.toml | 4 ++-- src/blocklang.rs | 4 ++++ src/dsp/node_code.rs | 14 +++++++------- src/lib.rs | 3 ++- src/nodes/node_conf.rs | 10 +++++----- src/wblockdsp.rs | 4 ++-- 6 files changed, 22 insertions(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2e2a5b6..799d6f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ keywords = ["audio", "music", "real-time", "synthesis", "synthesizer", "dsp", categories = ["multimedia::audio", "multimedia", "algorithms", "mathematics"] [features] -default = [ "wblockdsp" ] +default = [ "synfx-dsp-jit" ] [dependencies] serde = { version = "1.0", features = ["derive"] } @@ -19,7 +19,7 @@ triple_buffer = "5.0.6" lazy_static = "1.4.0" hound = "3.4.0" num-traits = "0.2.14" -wblockdsp = { path = "../wblockdsp", optional = true } +synfx-dsp-jit = { path = "../synfx-dsp-jit", optional = true } [dev-dependencies] num-complex = "0.2" diff --git a/src/blocklang.rs b/src/blocklang.rs index c3be6c8..d95cb36 100644 --- a/src/blocklang.rs +++ b/src/blocklang.rs @@ -964,6 +964,10 @@ impl BlockFun { } } + pub fn block_language(&self) -> Rc> { + self.language.clone() + } + pub fn block_ref(&self, id: usize, x: i64, y: i64) -> Option<&Block> { let area = self.areas.get(id)?; area.ref_at(x, y) diff --git a/src/dsp/node_code.rs b/src/dsp/node_code.rs index 7b444fa..44278c6 100644 --- a/src/dsp/node_code.rs +++ b/src/dsp/node_code.rs @@ -4,14 +4,14 @@ use crate::dsp::{DspNode, LedPhaseVals, NodeContext, NodeId, ProcBuf, SAtom}; use crate::nodes::{NodeAudioContext, NodeExecContext}; -#[cfg(feature = "wblockdsp")] +#[cfg(feature = "synfx-dsp-jit")] use crate::wblockdsp::CodeEngineBackend; use crate::dsp::MAX_BLOCK_SIZE; /// A WBlockDSP code execution node for JIT'ed DSP code pub struct Code { - #[cfg(feature = "wblockdsp")] + #[cfg(feature = "synfx-dsp-jit")] backend: Option>, srate: f64, } @@ -31,13 +31,13 @@ impl Clone for Code { impl Code { pub fn new(_nid: &NodeId) -> Self { Self { - #[cfg(feature = "wblockdsp")] + #[cfg(feature = "synfx-dsp-jit")] backend: None, srate: 48000.0, } } - #[cfg(feature = "wblockdsp")] + #[cfg(feature = "synfx-dsp-jit")] pub fn set_backend(&mut self, backend: CodeEngineBackend) { self.backend = Some(Box::new(backend)); } @@ -68,14 +68,14 @@ impl DspNode for Code { fn set_sample_rate(&mut self, srate: f32) { self.srate = srate as f64; - #[cfg(feature = "wblockdsp")] + #[cfg(feature = "synfx-dsp-jit")] if let Some(backend) = self.backend.as_mut() { backend.set_sample_rate(srate); } } fn reset(&mut self) { - #[cfg(feature = "wblockdsp")] + #[cfg(feature = "synfx-dsp-jit")] if let Some(backend) = self.backend.as_mut() { backend.clear(); } @@ -98,7 +98,7 @@ impl DspNode for Code { // let cmode = at::TSeq::cmode(atoms); let out = out::Code::sig(outputs); - #[cfg(feature = "wblockdsp")] + #[cfg(feature = "synfx-dsp-jit")] { let backend = if let Some(backend) = &mut self.backend { backend diff --git a/src/lib.rs b/src/lib.rs index 160cec6..234960f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -321,9 +321,10 @@ pub mod monitor; pub mod nodes; pub mod sample_lib; pub mod scope_handle; -#[cfg(feature="wblockdsp")] +#[cfg(feature="synfx-dsp-jit")] pub mod wblockdsp; pub mod blocklang; +pub mod blocklang_def; mod util; pub use cell_dir::CellDir; diff --git a/src/nodes/node_conf.rs b/src/nodes/node_conf.rs index 6a589f0..99d7878 100644 --- a/src/nodes/node_conf.rs +++ b/src/nodes/node_conf.rs @@ -11,7 +11,7 @@ use crate::dsp::{node_factory, Node, NodeId, NodeInfo, ParamId, SAtom}; use crate::monitor::{new_monitor_processor, MinMaxMonitorSamples, Monitor, MON_SIG_CNT}; use crate::nodes::drop_thread::DropThread; use crate::util::AtomicFloat; -#[cfg(feature = "wblockdsp")] +#[cfg(feature = "synfx-dsp-jit")] use crate::wblockdsp::CodeEngine; use crate::SampleLibrary; use crate::ScopeHandle; @@ -183,7 +183,7 @@ pub struct NodeConfigurator { /// Holding the scope buffers: pub(crate) scopes: Vec>, /// Holding the WBlockDSP code engine backends: - #[cfg(feature = "wblockdsp")] + #[cfg(feature = "synfx-dsp-jit")] pub(crate) code_engines: Vec, /// The shared parts of the [NodeConfigurator] /// and the [crate::nodes::NodeExecutor]. @@ -290,7 +290,7 @@ impl NodeConfigurator { atom_values: std::collections::HashMap::new(), node2idx: HashMap::new(), trackers: vec![Tracker::new(); MAX_AVAIL_TRACKERS], - #[cfg(feature = "wblockdsp")] + #[cfg(feature = "synfx-dsp-jit")] code_engines: vec![CodeEngine::new(); MAX_AVAIL_CODE_ENGINES], scopes, }, @@ -695,12 +695,12 @@ impl NodeConfigurator { } } - #[cfg(feature = "wblockdsp")] + #[cfg(feature = "synfx-dsp-jit")] if let Node::Code { node } = &mut node { let code_idx = ni.instance(); if let Some(cod) = self.code_engines.get_mut(code_idx) { node.set_backend(cod.get_backend()); - use wblockdsp::build::*; + use synfx_dsp_jit::build::*; cod.upload(stmts(&[ assign( "*phase", diff --git a/src/wblockdsp.rs b/src/wblockdsp.rs index b05490c..0e97cfa 100644 --- a/src/wblockdsp.rs +++ b/src/wblockdsp.rs @@ -2,7 +2,7 @@ // This file is a part of HexoDSP. Released under GPL-3.0-or-later. // See README.md and COPYING for details. -use wblockdsp::*; +use synfx_dsp_jit::*; use ringbuf::{Consumer, Producer, RingBuffer}; use std::cell::RefCell; @@ -40,7 +40,7 @@ impl CodeEngine { let rb = RingBuffer::new(MAX_RINGBUF_SIZE); let (_return_prod, return_cons) = rb.split(); - let lib = get_default_library(); + let lib = get_standard_library(); Self { lib, dsp_ctx: DSPNodeContext::new_ref(), update_prod, return_cons } }