Multiple AudioPlayHeads and AudioProcessorGraph



I’m working on a host that uses multiple playheads, but I’m running into an issue with AudioProcessorGraph. It looks like AudioProcessorGraph wants everything within it to have the same playhead. In addNode, processBlock, and some other areas, it forces the graph’s playhead on all children of the graph.

The structure of the host is something like this:

  • Renderer (main graph)
    • Tracks (each has their own graph)
      • Audio/MIDI Inputs
      • One Instrument plugin
      • Insert plugins
      • Audio Outputs (can go to other tracks that don’t need the same playhead)
    • Sequencer Nodes (I’d like to keep these in the main graph so nodes can be individually patched to Tracks’ MIDI inputs)

What I want to be able to do is set the play head for each Track, depending on what sequencer nodes they’re attached to. I looked into overriding those areas of AudioProcessorGraph, but not all of them are virtual (addNode for example). Do I just need to modify the AudioProcessorGraph code directly and maintain my own version, or is there a workaround I’m missing here?



I mean, I guess the change to AudioProcessorGraph is straightforward. But I’m not sure what else I might break by making it so that setting child playheads is an optional thing. It’s working for me now. A diff of that change is here. If anyone spots a problem, please let me know!


Just to close this one out, here’s what I ended up doing. It appears to be working as I’d hoped.

The graphs are set up like this:

  • AudioProcessorPlayer
    • Main Graph (don’t set playheads for children)
      • TrackGraphs (set playheads for children)
      • Sequencer Nodes

The sequencer nodes are tracked by sequencer “graphs”, which are really just managers with a single clock/playhead and some number of sequencer nodes. They manage the connections of the sequencer nodes to each other and to the tracks. When a sequencer node gets connected to a track, the track gets the playhead from that sequencer graph’s clock. I haven’t decided how to deal with multiple clocks being connected to a track, but I imagine it’ll be something like a dropdown for connected clocks.

This setup makes it so I can still take advantage of the track graphs setting the same playhead for everything in a track, but I can still have different playheads for each track and sequencer chain.

I imagine this isn’t a common problem folks have to solve, but there it is if you need to do that.