Howdy
I'm trying to subclass the AVAudioUnitMIDIInstrument 'abstract class', so I can have another type of synth to respond to an AVAudioSequencer.
What exactly do I need to override to create my own behavior for a sequencer who is pointing at this instrument?
I've tried overriding the startNote and stopNote methods, but they don't ever get called.
public override func startNote(note: UInt8, withVelocity velocity: UInt8, onChannel channel: UInt8) {
super.startNote(note, withVelocity: velocity, onChannel: channel)
print("Play \(note) with velocity \(velocity)") //I never see this
}
I've got the unit connected and created just fine, the sequencer outputs sinewaves so I know it is triggering something, somewhere, I'm just not sure how to get into that functionality.
Thank yall
For what it's worth, I init the custom class like this:
var description = AudioComponentDescription()
description.componentType = kAudioUnitType_MusicDevice
description.componentSubType = kAudioUnitSubType_MIDISynth
description.componentManufacturer = kAudioUnitManufacturer_Apple
description.componentFlags = 0
description.componentFlagsMask = 0
super.init(audioComponentDescription: description)
In general, these classes are customized by initializing them with the AudioComponentDescription for a different Audio Unit (one which shares the componentType). The outer AVAudioUnitMIDIInstrument functions primarily as a wrapper around the full functionality built into the AU. Your example of "init'ing the custom class" initialized the AVAudioUnitMIDIInstrument to contain an instance of the MIDISynth Audio Unit.
I am not sure what you mean by "getting into that functionality". Could you describe in more detail what you are trying to do, please?
-DS