When an AUv3 plugin is loaded from a session in AUM, this is the order of things that happens:
- If there already was a session loaded, it's saved to a hidden file (for Restore Last State).
- Wait for above state save to finish.
- The new AUM session is read from file, loading session title, notes, etc.
- Reads and sets session properties like sample rate, minimumLatency, metronome, and state for all HW and Mix busses.
- Empty channel objects are created for all channels in the session.
- Wait for this to finish.
- Loads the nodes for all channels:
- Create the node object.
- For AUv3 plugins, instantiate the AUAudioUnit object.
- Enable all inputBusses of the AU, also set shouldAllocateBuffer to NO.
- Enable all outputBusses of the AU, also set shouldAllocateBuffer to NO.
- Set sample rate for all busses.
- Set the AU transportStateBlock, musicalContextBlock and MIDIOutputEventBlock.
- Call AU allocateRenderResources, failing if it returns false or if renderResourcesAllocated is not set after the call.
- Grab the AU renderBlock and scheduleParameterBlock.
- Add observer for kAudioComponentInstanceInvalidationNotification,
- Get the current values of all AUParameters to store their default values.
- Set AU fullStateForDocument with the state data stored in the session.
- Get the list of AUParameters with kAudioUnitParameterFlag_IsWritable from AU, creating MIDI Controls for them.
- Add observers for latency, audioUnitShortName, parameterTree and currentPreset.
- Implement an iOS bug hackaround: get and show the view for the plugin, hidden from the user, and then close it again.
- Setup MIDI outputs for each name in the AU MIDIOutputNames array.
- Grab the AU scheduleMIDIEventBlock.
- Setup MIDI inputs for each MIDI input. virtualMIDICableCount is checked to know the number of inputs, but if it says 0 we assume the AU has 1 MIDI input if isMusicDeviceOrEffect is true.
- Repeat for the next node.
- Wait for the above to finish for all nodes and channels.
- For each channel, refresh the list of nodes on the audio thread.
- Load the MIDI matrix state (setting up MIDI routings)
- Load the MIDI Controls state (setting up all MIDI parameter bindings)
- Refresh the list of channels on the audio thread, this brings them into the actual audio render process, and will start calling their renderBlocks.
- Wait for the channel list refresh to finish, then reset the Transport Clock.
This is pretty cool, thanks for sharing.