AudioKit 5 in Xcode 12 MIDI openInput() not working

Viewed 188

I'm trying to create a simple swift app that receives MIDI inputs, but I can't get the receivedMIDINoteOn() working. i.e. no received a note on was printed in the console.

I tried to debug and found that the inputports has one entry: "key = Int32 1263786875, value = UInt32 0".

What did I missed?

import Foundation
import AudioKit
import CoreMIDI
import Cocoa

class MIDIHardwareListener: MIDIListener {
    
    let midi = AudioKit.MIDI()
    
    init() {
        midi.openInput()
        midi.addListener(self)
        availableInputs = MIDIHardwareListener.listInputs()
        print("available inputs: \(availableInputs)") // this prints out: ["Roland Digital Piano"]
    }

    func receivedMIDINoteOn(noteNumber: MIDINoteNumber, velocity: MIDIVelocity, channel: MIDIChannel, portID: MIDIUniqueID?, offset: MIDITimeStamp) {
        print("received a note on")
    }
    // ...other protocol required functions
}
0 Answers
Related