1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

AudioProcessorGraph: Allow extracting nodes

This commit is contained in:
reuk 2018-11-01 14:02:35 +00:00 committed by ed
parent 748d0e203f
commit 55fb6e1bb1
2 changed files with 10 additions and 9 deletions

View file

@ -961,31 +961,32 @@ AudioProcessorGraph::Node::Ptr AudioProcessorGraph::addNode (std::unique_ptr<Aud
return n;
}
bool AudioProcessorGraph::removeNode (NodeID nodeId)
std::unique_ptr<AudioProcessor> AudioProcessorGraph::removeNode (NodeID nodeId)
{
const ScopedLock sl (getCallbackLock());
for (int i = nodes.size(); --i >= 0;)
{
if (nodes.getUnchecked(i)->nodeID == nodeId)
if (nodes.getUnchecked (i)->nodeID == nodeId)
{
disconnectNode (nodeId);
auto internalProcessor = nodes[i] != nullptr ? std::move (nodes[i]->processor) : nullptr;
nodes.remove (i);
topologyChanged();
return true;
return internalProcessor;
}
}
return false;
return nullptr;
}
bool AudioProcessorGraph::removeNode (Node* node)
std::unique_ptr<AudioProcessor> AudioProcessorGraph::removeNode (Node* node)
{
if (node != nullptr)
return removeNode (node->nodeID);
jassertfalse;
return false;
return nullptr;
}
//==============================================================================

View file

@ -135,7 +135,7 @@ public:
bool operator== (const Connection&) const noexcept;
};
const std::unique_ptr<AudioProcessor> processor;
std::unique_ptr<AudioProcessor> processor;
Array<Connection> inputs, outputs;
bool isPrepared = false;
std::atomic<bool> bypassed { false };
@ -231,12 +231,12 @@ public:
/** Deletes a node within the graph which has the specified ID.
This will also delete any connections that are attached to this node.
*/
bool removeNode (NodeID);
std::unique_ptr<AudioProcessor> removeNode (NodeID);
/** Deletes a node within the graph.
This will also delete any connections that are attached to this node.
*/
bool removeNode (Node*);
std::unique_ptr<AudioProcessor> removeNode (Node*);
/** Returns the list of connections in the graph. */
std::vector<Connection> getConnections() const;