Integration of WBlockDSP

This commit is contained in:
Weird Constructor 2022-07-29 21:10:51 +02:00
parent 1b89fed67d
commit 76a0e5cb88
4 changed files with 32 additions and 4 deletions

View file

@ -8,8 +8,8 @@ description = "Comprehensive DSP graph and synthesis library for developing a mo
keywords = ["audio", "music", "real-time", "synthesis", "synthesizer", "dsp", "sound"]
categories = ["multimedia::audio", "multimedia", "algorithms", "mathematics"]
#[features]
#default = [ "hexotk" ]
[features]
default = [ "wblockdsp" ]
[dependencies]
serde = { version = "1.0", features = ["derive"] }
@ -19,6 +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 }
[dev-dependencies]
num-complex = "0.2"

View file

@ -1,4 +1,4 @@
// Copyright (c) 2021 Weird Constructor <weirdconstructor@gmail.com>
// Copyright (c) 2021-2022 Weird Constructor <weirdconstructor@gmail.com>
// This file is a part of HexoDSP. Released under GPL-3.0-or-later.
// See README.md and COPYING for details.
@ -314,6 +314,8 @@ pub mod monitor;
pub mod nodes;
pub mod sample_lib;
pub mod scope_handle;
#[cfg(feature="wblockdsp")]
pub mod wblockdsp;
mod util;
pub use cell_dir::CellDir;

View file

@ -13,6 +13,8 @@ use crate::nodes::drop_thread::DropThread;
use crate::util::AtomicFloat;
use crate::SampleLibrary;
use crate::ScopeHandle;
#[cfg(feature = "wblockdsp")]
use crate::wblockdsp::CodeEngine;
use ringbuf::{Producer, RingBuffer};
use std::collections::HashMap;
@ -254,6 +256,8 @@ impl SharedNodeConf {
graph_update_con: rb_graph_con,
graph_drop_prod: rb_drop_prod,
monitor_backend,
#[cfg(feature = "wblockdsp")]
code_backend: None, // TODO: FILL THIS!
},
)
}

View file

@ -9,6 +9,8 @@ use super::{
use crate::dsp::{Node, NodeContext, NodeId, MAX_BLOCK_SIZE};
use crate::monitor::{MonitorBackend, MON_SIG_CNT};
use crate::util::{AtomicFloat, Smoother};
#[cfg(feature = "wblockdsp")]
use crate::wblockdsp::CodeEngineBackend;
use crate::log;
use std::io::Write;
@ -81,6 +83,9 @@ pub(crate) struct SharedNodeExec {
pub(crate) graph_drop_prod: Producer<DropMsg>,
/// For sending feedback to the frontend thread.
pub(crate) monitor_backend: MonitorBackend,
/// For handing over the [crate::wblockdsp::CodeEngineBackend]
#[cfg(feature = "wblockdsp")]
pub(crate) code_backend: Option<Box<CodeEngineBackend>>,
}
/// Contains audio driver context informations. Such as the number
@ -168,25 +173,41 @@ impl Default for FeedbackBuffer {
/// This is used for instance to implement the feedbackd delay nodes.
pub struct NodeExecContext {
pub feedback_delay_buffers: Vec<FeedbackBuffer>,
#[cfg(feature = "wblockdsp")]
pub code_backend: Option<Box<CodeEngineBackend>>,
}
impl NodeExecContext {
fn new() -> Self {
let mut fbdb = vec![];
fbdb.resize_with(MAX_ALLOCATED_NODES, FeedbackBuffer::new);
Self { feedback_delay_buffers: fbdb }
Self {
feedback_delay_buffers: fbdb,
#[cfg(feature = "wblockdsp")]
code_backend: None
}
}
fn set_sample_rate(&mut self, srate: f32) {
for b in self.feedback_delay_buffers.iter_mut() {
b.set_sample_rate(srate);
}
#[cfg(feature = "wblockdsp")]
if let Some(code_backend) = self.code_backend.as_mut() {
code_backend.set_sample_rate(srate);
}
}
fn clear(&mut self) {
for b in self.feedback_delay_buffers.iter_mut() {
b.clear();
}
#[cfg(feature = "wblockdsp")]
if let Some(code_backend) = self.code_backend.as_mut() {
code_backend.clear();
}
}
}