Browse Source

AudioProcessorGraph: Allow nodes with ID 0 to be added

develop
Anthony Nicholls 2 years ago
parent
commit
b91fec7787
3 changed files with 28 additions and 4 deletions
  1. +24
    -0
      BREAKING_CHANGES.md
  2. +3
    -3
      modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp
  3. +1
    -1
      modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h

+ 24
- 0
BREAKING_CHANGES.md View File

@@ -2,6 +2,30 @@

# develop

## Change

The NodeID argument to AudioProcessorGraph::addNode() has been changed to take
a std::optional<NodeID>.

**Possible Issues**

The behavior of any code calling AudioProcessorGraph::addNode(), that explicitly
passes a default constructed NodeID or a NodeID constructed with a value of 0,
will change. Previously these values would have been treated as a null value
resulting in the actual NodeID being automatically determined. These will now
be treated as requests for an explicit value.

**Workaround**

Either remove the explicit NodeID argument and rely on the default argument or
pass a std::nullopt instead.

**Rationale**

The previous version prevented users from specifying a NodeID of 0 and resulted
in unexpected behavior.


## Change

The signature of DynamicObject::writeAsJSON() has been changed to accept a


+ 3
- 3
modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp View File

@@ -1694,7 +1694,7 @@ public:
}
Node::Ptr addNode (std::unique_ptr<AudioProcessor> newProcessor,
const NodeID nodeID,
std::optional<NodeID> nodeID,
UpdateKind updateKind)
{
if (newProcessor.get() == owner)
@@ -1703,7 +1703,7 @@ public:
return nullptr;
}
const auto idToUse = nodeID == NodeID() ? NodeID { ++(lastNodeID.uid) } : nodeID;
const auto idToUse = nodeID.value_or (NodeID { lastNodeID.uid + 1 });
auto added = nodes.addNode (std::move (newProcessor), idToUse);
@@ -1957,7 +1957,7 @@ bool AudioProcessorGraph::isAnInputTo (const Node& source, const Node& destinati
bool AudioProcessorGraph::isAnInputTo (NodeID source, NodeID destination) const noexcept { return pimpl->isAnInputTo (source, destination); }
AudioProcessorGraph::Node::Ptr AudioProcessorGraph::addNode (std::unique_ptr<AudioProcessor> newProcessor,
NodeID nodeId,
std::optional<NodeID> nodeId,
UpdateKind updateKind)
{
return pimpl->addNode (std::move (newProcessor), nodeId, updateKind);


+ 1
- 1
modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h View File

@@ -252,7 +252,7 @@ public:
If this succeeds, it returns a pointer to the newly-created node.
*/
Node::Ptr addNode (std::unique_ptr<AudioProcessor> newProcessor, NodeID nodeId = {}, UpdateKind = UpdateKind::sync);
Node::Ptr addNode (std::unique_ptr<AudioProcessor> newProcessor, std::optional<NodeID> nodeId = std::nullopt, UpdateKind = UpdateKind::sync);
/** Deletes a node within the graph which has the specified ID.
This will also delete any connections that are attached to this node.


Loading…
Cancel
Save