14namespace tracktion {
inline namespace graph
17namespace node_player_utils
20 static inline bool areNodeIDsUnique (Node& node,
bool ignoreZeroIDs)
23 visitNodes (node, [&] (Node& n) { nodeIDs.
push_back (n.getNodeProperties().nodeID); },
false);
28 [] (
auto nID) { return nID == 0; }),
32 return uniqueEnd == nodeIDs.
end();
43 for (
auto iter = orderedNodes.
begin(); iter != orderedNodes.
end(); ++iter)
48 for (
auto inputNode : node->getDirectInputNodes())
53 if (inputPosition > position)
63 double sampleRate,
int blockSize,
64 std::function<NodeBuffer (choc::buffer::Size)> allocateAudioBuffer =
nullptr,
65 std::function<
void (NodeBuffer&&)> deallocateAudioBuffer =
nullptr,
66 bool nodeMemorySharingEnabled =
false)
73 assert (! areThereAnyCycles (nodeGraph->orderedNodes));
76 const PlaybackInitialisationInfo info { sampleRate, blockSize,
78 allocateAudioBuffer, deallocateAudioBuffer,
79 nodeMemorySharingEnabled };
81 for (
auto n : nodeGraph->orderedNodes)
87 inline void reserveAudioBufferPool (Node* rootNode,
const std::vector<Node*>& allNodes,
88 AudioBufferPool& audioBufferPool,
size_t numThreads,
int blockSize)
90 if (rootNode ==
nullptr)
98 [[ maybe_unused ]]
size_t maxNumChannels = 0, maxNumInputs = 0, numLeafNodes = 0;
104 for (
auto n : allNodes)
106 const auto numInputs = n->getDirectInputNodes().size();
107 const auto props = n->getNodeProperties();
108 maxNumInputs =
std::max (maxNumInputs, numInputs);
109 maxNumChannels =
std::max (maxNumChannels, (
size_t) props.numberOfChannels);
115 const size_t numBuffersRequired =
std::max ((
size_t) 2,
std::min (allNodes.
size(), 1 + numThreads));
116 audioBufferPool.reserve (numBuffersRequired, choc::buffer::Size::create (maxNumChannels, blockSize));
void visitNodes(Node &, Visitor &&, bool preordering)
Should call the visitor for any direct inputs to the node exactly once.
std::unique_ptr< NodeGraph > createNodeGraph(std::unique_ptr< Node >)
Transforms a Node and then returns a NodeGraph of it ready to be initialised.