I am building an app which listens to incoming MIDI using AudioKit v5.
I have an AudioKit MIDI shared instance in my AppDelegate and I have a class which conforms to MIDIListener.
The application is a Document Based application, and when the user closes the document, in order to release all references to my MIDIListener class instances, I need to remove each instance from the listeners array of my AudioKit MIDI shared instance. However, whenever I call appDelegate.midi.removeListener(self) from within my MIDIListener class instance, I experience a crash at the following line in the MIDIListener protocol:
func == (lhs: MIDIListener, rhs: MIDIListener) -> Bool {
return lhs.isEqualTo(rhs)
}
Calling appDelegate.midi.clearListeners() does not cause a crash, but is unsuitable for me, as the user may have other open documents with MIDIListener instances which do not want to be removed from the shared instance Listeners array.
Am I doing something wrong, or could this be a bug with AudioKit MIDI implementation?