gave all nodes access to NodeExecContext

This commit is contained in:
Weird Constructor 2021-06-02 03:59:21 +02:00
parent 297360e398
commit b7284b6b8a
7 changed files with 35 additions and 22 deletions

View file

@ -62,6 +62,12 @@ pub trait DspNode {
/// The code DSP function.
///
/// * `ctx` is the audio context, which informs the node about
/// the number of samples to process. It also provides input/output
/// ports for the in/out nodes.
/// * `ectx` is the execution context, which provides global stuff
/// for all nodes to potentially use. For instance it's used
/// by the `FbWr` and `FbRd` nodes to share an audio buffer.
/// * `atoms` are un-smoothed parameters. they can hold integer settings,
/// samples or even strings.
/// * `params` are smoother paramters, those who usually have a knob
@ -70,9 +76,9 @@ pub trait DspNode {
/// these inputs might be overwritten by outputs of other nodes.
/// * `outputs` are the output buffers of this node.
fn process<T: NodeAudioContext>(
&mut self, ctx: &mut T, atoms: &[SAtom], params: &[ProcBuf],
inputs: &[ProcBuf], outputs: &mut [ProcBuf],
led: LedPhaseVals);
&mut self, ctx: &mut T, ectx: &mut NodeExecContext,
atoms: &[SAtom], params: &[ProcBuf], inputs: &[ProcBuf],
outputs: &mut [ProcBuf], led: LedPhaseVals);
/// A function factory for generating a graph for the generic node UI.
fn graph_fun() -> Option<GraphFun> { None }
@ -1162,7 +1168,8 @@ impl Node {
match self {
Node::$v1 => {},
$(Node::$variant { node } =>
node.process(ctx, atoms, params, inputs, outputs, led),)+
node.process(ctx, ectx, atoms, params,
inputs, outputs, led),)+
}
}
}

View file

@ -2,7 +2,7 @@
// This is a part of HexoDSP. Released under (A)GPLv3 or any later.
// See README.md and COPYING for details.
use crate::nodes::NodeAudioContext;
use crate::nodes::{NodeAudioContext, NodeExecContext};
use crate::dsp::{SAtom, ProcBuf, DspNode, LedPhaseVals};
/// A simple amplifier
@ -36,8 +36,9 @@ impl DspNode for Amp {
#[inline]
fn process<T: NodeAudioContext>(
&mut self, ctx: &mut T, atoms: &[SAtom], _params: &[ProcBuf],
inputs: &[ProcBuf], outputs: &mut [ProcBuf], ctx_vals: LedPhaseVals)
&mut self, ctx: &mut T, _ectx: &mut NodeExecContext,
atoms: &[SAtom], _params: &[ProcBuf], inputs: &[ProcBuf],
outputs: &mut [ProcBuf], ctx_vals: LedPhaseVals)
{
use crate::dsp::{out, inp, denorm, denorm_v, inp_dir, at};

View file

@ -2,7 +2,7 @@
// This is a part of HexoDSP. Released under (A)GPLv3 or any later.
// See README.md and COPYING for details.
use crate::nodes::NodeAudioContext;
use crate::nodes::{NodeAudioContext, NodeExecContext};
use crate::dsp::{SAtom, ProcBuf, inp, at, DspNode, LedPhaseVals};
/// The (stereo) output port of the plugin
@ -52,8 +52,9 @@ impl DspNode for Out {
#[inline]
fn process<T: NodeAudioContext>(
&mut self, ctx: &mut T, atoms: &[SAtom], _params: &[ProcBuf],
inputs: &[ProcBuf], _outputs: &mut [ProcBuf], ctx_vals: LedPhaseVals)
&mut self, ctx: &mut T, _ectx: &mut NodeExecContext,
atoms: &[SAtom], _params: &[ProcBuf], inputs: &[ProcBuf],
_outputs: &mut [ProcBuf], ctx_vals: LedPhaseVals)
{
let in1 = inp::Out::ch1(inputs);

View file

@ -2,7 +2,7 @@
// This is a part of HexoDSP. Released under (A)GPLv3 or any later.
// See README.md and COPYING for details.
use crate::nodes::NodeAudioContext;
use crate::nodes::{NodeAudioContext, NodeExecContext};
use crate::dsp::{SAtom, ProcBuf, DspNode, LedPhaseVals};
use crate::dsp::{out, at, inp, denorm}; //, inp, denorm, denorm_v, inp_dir, at};
use super::helpers::Trigger;
@ -240,8 +240,9 @@ impl DspNode for Sampl {
#[inline]
fn process<T: NodeAudioContext>(
&mut self, ctx: &mut T, atoms: &[SAtom], _params: &[ProcBuf],
inputs: &[ProcBuf], outputs: &mut [ProcBuf], ctx_vals: LedPhaseVals)
&mut self, ctx: &mut T, _ectx: &mut NodeExecContext,
atoms: &[SAtom], _params: &[ProcBuf], inputs: &[ProcBuf],
outputs: &mut [ProcBuf], ctx_vals: LedPhaseVals)
{
let sample = at::Sampl::sample(atoms);
let pmode = at::Sampl::pmode(atoms);

View file

@ -2,7 +2,7 @@
// This is a part of HexoDSP. Released under (A)GPLv3 or any later.
// See README.md and COPYING for details.
use crate::nodes::NodeAudioContext;
use crate::nodes::{NodeAudioContext, NodeExecContext};
use crate::dsp::{SAtom, ProcBuf, denorm, out, inp, DspNode, LedPhaseVals};
use crate::dsp::helpers::fast_sin;
@ -44,8 +44,9 @@ impl DspNode for Sin {
#[inline]
fn process<T: NodeAudioContext>(
&mut self, ctx: &mut T, _atoms: &[SAtom], _params: &[ProcBuf],
inputs: &[ProcBuf], outputs: &mut [ProcBuf], ctx_vals: LedPhaseVals)
&mut self, ctx: &mut T, _ectx: &mut NodeExecContext,
_atoms: &[SAtom], _params: &[ProcBuf], inputs: &[ProcBuf],
outputs: &mut [ProcBuf], ctx_vals: LedPhaseVals)
{
let o = out::Sin::sig(outputs);
let freq = inp::Sin::freq(inputs);

View file

@ -2,7 +2,7 @@
// This is a part of HexoDSP. Released under (A)GPLv3 or any later.
// See README.md and COPYING for details.
use crate::nodes::NodeAudioContext;
use crate::nodes::{NodeAudioContext, NodeExecContext};
use crate::dsp::{SAtom, ProcBuf, GraphFun, GraphAtomData, DspNode, LedPhaseVals};
/// A simple amplifier
@ -31,8 +31,9 @@ impl DspNode for Test {
#[inline]
fn process<T: NodeAudioContext>(
&mut self, _ctx: &mut T, _atoms: &[SAtom], _params: &[ProcBuf],
_inputs: &[ProcBuf], _outputs: &mut [ProcBuf], _led: LedPhaseVals)
&mut self, _ctx: &mut T, _ectx: &mut NodeExecContext,
_atoms: &[SAtom], _params: &[ProcBuf], _inputs: &[ProcBuf],
_outputs: &mut [ProcBuf], _led: LedPhaseVals)
{
// use crate::dsp::out;
// use crate::dsp::inp;

View file

@ -2,7 +2,7 @@
// This is a part of HexoDSP. Released under (A)GPLv3 or any later.
// See README.md and COPYING for details.
use crate::nodes::NodeAudioContext;
use crate::nodes::{NodeAudioContext, NodeExecContext};
use crate::dsp::helpers::TriggerClock;
use crate::dsp::{SAtom, ProcBuf, DspNode, LedPhaseVals};
use crate::dsp::tracker::TrackerBackend;
@ -70,8 +70,9 @@ impl DspNode for TSeq {
#[inline]
fn process<T: NodeAudioContext>(
&mut self, ctx: &mut T, atoms: &[SAtom], _params: &[ProcBuf],
inputs: &[ProcBuf], outputs: &mut [ProcBuf], ctx_vals: LedPhaseVals)
&mut self, ctx: &mut T, _ectx: &mut NodeExecContext,
atoms: &[SAtom], _params: &[ProcBuf], inputs: &[ProcBuf],
outputs: &mut [ProcBuf], ctx_vals: LedPhaseVals)
{
use crate::dsp::{out, inp, at};
let clock = inp::TSeq::clock(inputs);