use synfx-dsp-jit now

This commit is contained in:
Weird Constructor 2022-07-30 23:11:33 +02:00
parent 5571def6dd
commit f5f242041a
6 changed files with 22 additions and 17 deletions

View file

@ -9,7 +9,7 @@ keywords = ["audio", "music", "real-time", "synthesis", "synthesizer", "dsp",
categories = ["multimedia::audio", "multimedia", "algorithms", "mathematics"] categories = ["multimedia::audio", "multimedia", "algorithms", "mathematics"]
[features] [features]
default = [ "wblockdsp" ] default = [ "synfx-dsp-jit" ]
[dependencies] [dependencies]
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
@ -19,7 +19,7 @@ triple_buffer = "5.0.6"
lazy_static = "1.4.0" lazy_static = "1.4.0"
hound = "3.4.0" hound = "3.4.0"
num-traits = "0.2.14" num-traits = "0.2.14"
wblockdsp = { path = "../wblockdsp", optional = true } synfx-dsp-jit = { path = "../synfx-dsp-jit", optional = true }
[dev-dependencies] [dev-dependencies]
num-complex = "0.2" num-complex = "0.2"

View file

@ -964,6 +964,10 @@ impl BlockFun {
} }
} }
pub fn block_language(&self) -> Rc<RefCell<BlockLanguage>> {
self.language.clone()
}
pub fn block_ref(&self, id: usize, x: i64, y: i64) -> Option<&Block> { pub fn block_ref(&self, id: usize, x: i64, y: i64) -> Option<&Block> {
let area = self.areas.get(id)?; let area = self.areas.get(id)?;
area.ref_at(x, y) area.ref_at(x, y)

View file

@ -4,14 +4,14 @@
use crate::dsp::{DspNode, LedPhaseVals, NodeContext, NodeId, ProcBuf, SAtom}; use crate::dsp::{DspNode, LedPhaseVals, NodeContext, NodeId, ProcBuf, SAtom};
use crate::nodes::{NodeAudioContext, NodeExecContext}; use crate::nodes::{NodeAudioContext, NodeExecContext};
#[cfg(feature = "wblockdsp")] #[cfg(feature = "synfx-dsp-jit")]
use crate::wblockdsp::CodeEngineBackend; use crate::wblockdsp::CodeEngineBackend;
use crate::dsp::MAX_BLOCK_SIZE; use crate::dsp::MAX_BLOCK_SIZE;
/// A WBlockDSP code execution node for JIT'ed DSP code /// A WBlockDSP code execution node for JIT'ed DSP code
pub struct Code { pub struct Code {
#[cfg(feature = "wblockdsp")] #[cfg(feature = "synfx-dsp-jit")]
backend: Option<Box<CodeEngineBackend>>, backend: Option<Box<CodeEngineBackend>>,
srate: f64, srate: f64,
} }
@ -31,13 +31,13 @@ impl Clone for Code {
impl Code { impl Code {
pub fn new(_nid: &NodeId) -> Self { pub fn new(_nid: &NodeId) -> Self {
Self { Self {
#[cfg(feature = "wblockdsp")] #[cfg(feature = "synfx-dsp-jit")]
backend: None, backend: None,
srate: 48000.0, srate: 48000.0,
} }
} }
#[cfg(feature = "wblockdsp")] #[cfg(feature = "synfx-dsp-jit")]
pub fn set_backend(&mut self, backend: CodeEngineBackend) { pub fn set_backend(&mut self, backend: CodeEngineBackend) {
self.backend = Some(Box::new(backend)); self.backend = Some(Box::new(backend));
} }
@ -68,14 +68,14 @@ impl DspNode for Code {
fn set_sample_rate(&mut self, srate: f32) { fn set_sample_rate(&mut self, srate: f32) {
self.srate = srate as f64; self.srate = srate as f64;
#[cfg(feature = "wblockdsp")] #[cfg(feature = "synfx-dsp-jit")]
if let Some(backend) = self.backend.as_mut() { if let Some(backend) = self.backend.as_mut() {
backend.set_sample_rate(srate); backend.set_sample_rate(srate);
} }
} }
fn reset(&mut self) { fn reset(&mut self) {
#[cfg(feature = "wblockdsp")] #[cfg(feature = "synfx-dsp-jit")]
if let Some(backend) = self.backend.as_mut() { if let Some(backend) = self.backend.as_mut() {
backend.clear(); backend.clear();
} }
@ -98,7 +98,7 @@ impl DspNode for Code {
// let cmode = at::TSeq::cmode(atoms); // let cmode = at::TSeq::cmode(atoms);
let out = out::Code::sig(outputs); let out = out::Code::sig(outputs);
#[cfg(feature = "wblockdsp")] #[cfg(feature = "synfx-dsp-jit")]
{ {
let backend = if let Some(backend) = &mut self.backend { let backend = if let Some(backend) = &mut self.backend {
backend backend

View file

@ -321,9 +321,10 @@ pub mod monitor;
pub mod nodes; pub mod nodes;
pub mod sample_lib; pub mod sample_lib;
pub mod scope_handle; pub mod scope_handle;
#[cfg(feature="wblockdsp")] #[cfg(feature="synfx-dsp-jit")]
pub mod wblockdsp; pub mod wblockdsp;
pub mod blocklang; pub mod blocklang;
pub mod blocklang_def;
mod util; mod util;
pub use cell_dir::CellDir; pub use cell_dir::CellDir;

View file

@ -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::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;
#[cfg(feature = "wblockdsp")] #[cfg(feature = "synfx-dsp-jit")]
use crate::wblockdsp::CodeEngine; use crate::wblockdsp::CodeEngine;
use crate::SampleLibrary; use crate::SampleLibrary;
use crate::ScopeHandle; use crate::ScopeHandle;
@ -183,7 +183,7 @@ pub struct NodeConfigurator {
/// Holding the scope buffers: /// Holding the scope buffers:
pub(crate) scopes: Vec<Arc<ScopeHandle>>, pub(crate) scopes: Vec<Arc<ScopeHandle>>,
/// Holding the WBlockDSP code engine backends: /// Holding the WBlockDSP code engine backends:
#[cfg(feature = "wblockdsp")] #[cfg(feature = "synfx-dsp-jit")]
pub(crate) code_engines: Vec<CodeEngine>, pub(crate) code_engines: Vec<CodeEngine>,
/// The shared parts of the [NodeConfigurator] /// The shared parts of the [NodeConfigurator]
/// and the [crate::nodes::NodeExecutor]. /// and the [crate::nodes::NodeExecutor].
@ -290,7 +290,7 @@ impl NodeConfigurator {
atom_values: std::collections::HashMap::new(), atom_values: std::collections::HashMap::new(),
node2idx: HashMap::new(), node2idx: HashMap::new(),
trackers: vec![Tracker::new(); MAX_AVAIL_TRACKERS], trackers: vec![Tracker::new(); MAX_AVAIL_TRACKERS],
#[cfg(feature = "wblockdsp")] #[cfg(feature = "synfx-dsp-jit")]
code_engines: vec![CodeEngine::new(); MAX_AVAIL_CODE_ENGINES], code_engines: vec![CodeEngine::new(); MAX_AVAIL_CODE_ENGINES],
scopes, scopes,
}, },
@ -695,12 +695,12 @@ impl NodeConfigurator {
} }
} }
#[cfg(feature = "wblockdsp")] #[cfg(feature = "synfx-dsp-jit")]
if let Node::Code { node } = &mut node { if let Node::Code { node } = &mut node {
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::*; use synfx_dsp_jit::build::*;
cod.upload(stmts(&[ cod.upload(stmts(&[
assign( assign(
"*phase", "*phase",

View file

@ -2,7 +2,7 @@
// This file is a part of HexoDSP. Released under GPL-3.0-or-later. // This file is a part of HexoDSP. Released under GPL-3.0-or-later.
// See README.md and COPYING for details. // See README.md and COPYING for details.
use wblockdsp::*; use synfx_dsp_jit::*;
use ringbuf::{Consumer, Producer, RingBuffer}; use ringbuf::{Consumer, Producer, RingBuffer};
use std::cell::RefCell; use std::cell::RefCell;
@ -40,7 +40,7 @@ impl CodeEngine {
let rb = RingBuffer::new(MAX_RINGBUF_SIZE); let rb = RingBuffer::new(MAX_RINGBUF_SIZE);
let (_return_prod, return_cons) = rb.split(); 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 } Self { lib, dsp_ctx: DSPNodeContext::new_ref(), update_prod, return_cons }
} }