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"]
[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"

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> {
let area = self.areas.get(id)?;
area.ref_at(x, y)

View file

@ -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<Box<CodeEngineBackend>>,
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

View file

@ -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;

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::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<Arc<ScopeHandle>>,
/// Holding the WBlockDSP code engine backends:
#[cfg(feature = "wblockdsp")]
#[cfg(feature = "synfx-dsp-jit")]
pub(crate) code_engines: Vec<CodeEngine>,
/// 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",

View file

@ -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 }
}