I have added a listener:
class MIDIReceiver: MIDIListener {
...
}
Where should I put the following code in SwiftUI so that I can use my midi keyboard to change the @State var ?
let midi = MIDI()
midi.openInput()
let receiver = MIDIReceiver()
midi.addListener(receiver)
Thank you
-- Added Oct 28 --
(1) I added the class in https://github.com/AudioKit/Cookbook/blob/main/Cookbook/Cookbook/Recipes/MIDIMonitor.swift but without the view...
After adding @ObservedObject var conductor = MIDIMonitorConductor() in my ContentView, these show in my console.
2020-10-28 00:47:19.646934-0500 AudioKitTrySPM[2998:82471] [midi] MIDI.swift:init():52:Initializing MIDI (MIDI.swift:init():52) 2020-10-28 00:47:19.698885-0500 AudioKitTrySPM[2998:82471] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x600000211300> F8BB1C28-BAE8-11D6-9C31-00039315CD46 2020-10-28 00:47:19.728062-0500 AudioKitTrySPM[2998:82471] HALC_ShellDriverPlugIn::Open: Can't get a pointer to the Open routine
Should I change anything else in the project?
(2) I have an State array in my contentview
@State private var touchKeys: Array<Bool> = [Bool](repeating: false, count: 24)
How do I trigger a function to map the midi signal to update the array?
Thank you