Struct hexodsp::global::NodeGlobalData
source · [−]pub struct NodeGlobalData {
scopes: HashMap<usize, Arc<ScopeHandle>>,
feedback: HashMap<usize, SharedFeedback>,
trackers: HashMap<usize, Tracker>,
code_engines: HashMap<usize, CodeEngine>,
block_functions: HashMap<usize, (u64, Arc<Mutex<BlockFun>>)>,
dyn_nodes1x1: HashMap<usize, DynNodeHandle<Box<dyn DynamicNode1x1>>>,
}
Expand description
This structure holds any global state that may be shared among crate::dsp::DspNode instances.
This structure is provided to you by the crate::Matrix and resides in crate::NodeConfigurator.
These may be things like feedback buffers that are shared among FbWr
and FbRd
nodes, or the crate::dsp::tracker::Tracker that drives the TSeq
sequencers.
Also the crate::ScopeHandle instances used to connect the Scope
nodes to the
frontend are exchanged through this structure.
Fields
scopes: HashMap<usize, Arc<ScopeHandle>>
Holding the scope buffers
feedback: HashMap<usize, SharedFeedback>
Holds the shared feedback buffers
trackers: HashMap<usize, Tracker>
Holds the handles to the tracker sequencers
code_engines: HashMap<usize, CodeEngine>
Holding the synfx-dsp-jit code engine backends (which are used for the WBlockDSP block functions, but can also be directly used):
block_functions: HashMap<usize, (u64, Arc<Mutex<BlockFun>>)>
Holds the block functions that are JIT compiled to DSP code
for the Code
nodes. The code is then sent via the CodeEngine
in [NodeConfigurator::check_block_function].
dyn_nodes1x1: HashMap<usize, DynNodeHandle<Box<dyn DynamicNode1x1>>>
Holds the communication handles to send crate::dsp::DynamicNode1x1 instances
to their corresponding Rust1x1
DSP nodes.
Implementations
sourceimpl NodeGlobalData
impl NodeGlobalData
pub fn new_ref() -> NodeGlobalRef
pub fn get_scope_handle(&mut self, scope: usize) -> Arc<ScopeHandle>
pub fn get_feedback_reader(
&mut self,
instance: usize
) -> Box<SharedFeedbackReader>
pub fn get_feedback_writer(
&mut self,
instance: usize
) -> Box<SharedFeedbackWriter>
sourcepub fn get_pattern_data(&mut self, index: usize) -> Arc<Mutex<PatternData>>
pub fn get_pattern_data(&mut self, index: usize) -> Arc<Mutex<PatternData>>
Returns the PatternData handle for the tracker index
.
Implicitly allocates the Tracker instance.
sourcepub fn has_tracker(&self, index: usize) -> bool
pub fn has_tracker(&self, index: usize) -> bool
Returns true, if the tracker and patterndata for index
has already been allocated.
sourcepub fn get_tracker_backend(&mut self, index: usize) -> TrackerBackend
pub fn get_tracker_backend(&mut self, index: usize) -> TrackerBackend
Returns the TrackerBackend handle for the tracker index
.
Implicitly allocates the Tracker instance.
The returned TrackerBackend will invalidate the other backend handles
for the corresponding tracker index
.
sourcepub fn check_pattern_data(&mut self, index: usize)
pub fn check_pattern_data(&mut self, index: usize)
Checks if there are any updates to send for the pattern data that belongs to the
tracker index
. Call this repeatedly, eg. once per frame in a GUI, in case the user
modified the pattern data. It will make sure that the modifications are sent to the
audio thread.
sourcepub fn get_code_engine(&mut self, index: usize) -> &mut CodeEngine
pub fn get_code_engine(&mut self, index: usize) -> &mut CodeEngine
Gives you direct access to the CodeEngine for index
instance of
the corresponding Code
DSP node. You can also get the corresponding
BlockFun via [NodeGlobalData::get_block_fun]. But in case of
eg. [SynthConstructor] you can use the CodeEngine directly too!
This function only returns None
if there is no synfx-dsp-jit
feature enabled!
Make sure to call NodeGlobalData::check_code regularily!
sourcepub fn has_code_engine(&mut self, index: usize) -> bool
pub fn has_code_engine(&mut self, index: usize) -> bool
Returns true if there was the CodeEngine index
already used.
sourcepub fn get_code_engine_backend(&mut self, index: usize) -> CodeEngineBackend
pub fn get_code_engine_backend(&mut self, index: usize) -> CodeEngineBackend
Returns the [synfx-dsp::CodeEngineBackend] for the corresponding code engine at index
.
Any call of this function clears the connection of the corresponding CodeEngine to the previously returned CodeEngineBackend.
sourcepub fn get_block_function(&mut self, id: usize) -> Option<Arc<Mutex<BlockFun>>>
pub fn get_block_function(&mut self, id: usize) -> Option<Arc<Mutex<BlockFun>>>
Retrieve a handle to the block function id
. In case you modify the block function,
make sure to call NodeGlobalData::check_code.
Only returns None
if the feature synfx-dsp-jit
is disabled!
sourcepub fn check_code(&mut self, id: usize) -> Result<(), BlkJITCompileError>
pub fn check_code(&mut self, id: usize) -> Result<(), BlkJITCompileError>
Checks the CodeEngine and block function for the id id
. If the block function did change,
updates are then sent to the audio thread.
See also NodeGlobalData::get_block_function.
sourcepub fn send_dynamic_node1x1(&mut self, id: usize, node: Box<dyn DynamicNode1x1>)
pub fn send_dynamic_node1x1(&mut self, id: usize, node: Box<dyn DynamicNode1x1>)
Updates the dynamic node for the Rust1x1 nodes. The id
refers to the
instance NodeId::Rust1x1(id)
. The new DSP code is preserved for the first use
of that node, and can also be swapped out at runtime anytime while the DSP graph is working.
sourcepub(crate) fn get_dynamic_node1x1_buffer(
&mut self,
id: usize
) -> DynNodeBuffer<Box<dyn DynamicNode1x1>>
pub(crate) fn get_dynamic_node1x1_buffer(
&mut self,
id: usize
) -> DynNodeBuffer<Box<dyn DynamicNode1x1>>
This method is to be used by the Rust1x1
node, to receive the dynamic node buffer.
Attention: If the buffer was already requested by a Rust1x1 constructor, a new internal buffer will be allocated and the previous DynNodeBuffer won’t receive any more updates. That means, after construction of a new Rust1x1, you should update the DynamicNode1x1 using NodeGlobalData::send_dynamic_node1x1. This will be very relevant to do after [crate::NodeConfigurator::set_sample_rate].