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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_SimpleNodePlayer.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
13
14namespace tracktion { inline namespace graph
15{
16
17//==============================================================================
18//==============================================================================
24{
25public:
28 double sampleRateToUse, int blockSizeToUse)
29 {
30 assert (nodeToPlay);
31 graph = node_player_utils::prepareToPlay (std::move (nodeToPlay), nullptr, sampleRateToUse, blockSizeToUse);
32 }
33
36 {
37 // Prepare all nodes for the next block
38 for (auto node : graph->orderedNodes)
39 node->prepareForNextBlock (pc.referenceSampleRange);
40
41 // Then process them all in sequence
42 for (auto node : graph->orderedNodes)
43 node->process (pc.numSamples, pc.referenceSampleRange);
44
45 // Finally copy the output from the root Node to our player buffers
46 auto output = graph->rootNode->getProcessedOutput();
47 auto numAudioChannels = std::min (output.audio.getNumChannels(),
48 pc.buffers.audio.getNumChannels());
49
50 if (numAudioChannels > 0)
51 add (pc.buffers.audio.getFirstChannels (numAudioChannels),
52 output.audio.getFirstChannels (numAudioChannels));
53
54 pc.buffers.midi.mergeFrom (output.midi);
55 }
56
57private:
59};
60
61}}
assert
Struct to describe a single iteration of a process call.
SimpleNodePlayer(std::unique_ptr< Node > nodeToPlay, double sampleRateToUse, int blockSizeToUse)
Creates a player to play a Node at a given sample rate and block size.
void process(const Node::ProcessContext &pc)
Processes a block of audio and MIDI data.
T min(T... args)