tracktion-engine 3.0-10-g034fdde4aa5
Tracktion Engine — High level data model for audio applications

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_RackNode.h
Go to the documentation of this file.
1 /*
2 ,--. ,--. ,--. ,--.
3 ,-' '-.,--.--.,--,--.,---.| |,-.,-' '-.`--' ,---. ,--,--, Copyright 2024
4 '-. .-'| .--' ,-. | .--'| /'-. .-',--.| .-. || \ Tracktion Software
5 | | | | \ '-' \ `--.| \ \ | | | |' '-' '| || | Corporation
6 `---' `--' `--`--'`---'`--'`--' `---' `--' `---' `--''--' www.tracktion.com
7
8 Tracktion Engine uses a GPL/commercial licence - see LICENCE.md for details.
9*/
10
11#pragma once
12
13namespace tracktion { inline namespace engine
14{
15
16//==============================================================================
17//==============================================================================
19{
20 InputProvider() = default;
21 InputProvider (choc::buffer::ChannelCount numChannelsToUse)
22 : numChannels (numChannelsToUse)
23 {}
24
25 void setInputs (tracktion::graph::Node::AudioAndMidiBuffer newBuffers)
26 {
27 audio = numChannels > 0 ? newBuffers.audio.getFirstChannels (numChannels)
28 : newBuffers.audio;
29 tracktion::graph::sanityCheckView (audio);
30 midi.copyFrom (newBuffers.midi);
31 }
32
34 {
35 tracktion::graph::sanityCheckView (audio);
36 return { audio, midi };
37 }
38
39 void setContext (tracktion::engine::PluginRenderContext* pc)
40 {
41 context = pc;
42 }
43
48 {
49 jassert (context != nullptr);
50 return *context;
51 }
52
53 choc::buffer::ChannelCount numChannels = 0;
54 choc::buffer::ChannelArrayView<float> audio;
56
58};
59
60
61//==============================================================================
62//==============================================================================
67template<typename NodePlayerType>
69{
70public:
73 {
74 nodePlayer.setNode (std::move (nodeToProcess));
75 }
76
79 double sampleRateToUse, int blockSizeToUse)
80 {
81 nodePlayer.setNode (std::move (nodeToProcess), sampleRateToUse, blockSizeToUse);
82 }
83
85 void prepareToPlay (double sampleRate, int blockSize)
86 {
87 jassert (sampleRate != 0.0);
88 jassert (blockSize != 0);
89 nodePlayer.prepareToPlay (sampleRate, blockSize);
90 }
91
92 int getLatencySamples()
93 {
94 return nodePlayer.getNode()->getNodeProperties().latencyNumSamples;
95 }
96
101 {
102 return process (pc, {}, true, false, false);
103 }
104
109 TimeRange editTime, bool isPlaying, bool isScrubbing, bool isRendering)
110 {
111 // The internal nodes won't be interested in the top level audio/midi inputs
112 // They should only be referencing this for time and continuity
114 nullptr, 0.0,
115 editTime, isPlaying, isScrubbing, isRendering, true);
116
117 return nodePlayer.process (pc);
118 }
119
120private:
121 NodePlayerType nodePlayer;
122};
123
124
125//==============================================================================
126//==============================================================================
127namespace RackNodeBuilder
128{
131 double sampleRate, int blockSize,
133 ProcessState&, bool isRendering);
134}
135
136}} // namespace tracktion { inline namespace engine
Simple processor for a Node which uses an InputProvider to pass input in to the graph.
void prepareToPlay(double sampleRate, int blockSize)
Preapres the processor to be played.
RackNodePlayer(std::unique_ptr< tracktion::graph::Node > nodeToProcess, double sampleRateToUse, int blockSizeToUse)
Creates an RackNodePlayer to process an Node with input, sample rate and block size.
int process(const tracktion::graph::Node::ProcessContext &pc, TimeRange editTime, bool isPlaying, bool isScrubbing, bool isRendering)
Processes a block of audio and MIDI data with a given PlayHead and EditTimeRange.
int process(const tracktion::graph::Node::ProcessContext &pc)
Processes a block of audio and MIDI data.
RackNodePlayer(std::unique_ptr< tracktion::graph::Node > nodeToProcess)
Creates an RackNodePlayer to process an Node with input.
Contains the buffers for a processing operation.
Struct to describe a single iteration of a process call.
#define jassert(expression)
tracktion::engine::PluginRenderContext & getContext()
Returns the context currently in use.
The context passed to plugin render methods to provide it with buffers to fill.
Holds the state of a process call.