I am trying to create a sequencer that takes notes from a midi file.
I am currently using AudioKit to process music data. I would like to know how I can get data / event notes from a midi file using AudioKit.
I tried using an AKSequencer and output to AKMIDINode to listen for a MIDI event, but it seems that nothing can get from it.
class CustomMIDINode: AKMIDINode { override init(node: AKPolyphonicNode) { print("Node create") // OK super.init(node: node) } func receivedMIDINoteOff(noteNumber: MIDINoteNumber, velocity: MIDIVelocity, channel: MIDIChannel) { print("midi note off") // Not printed } func receivedMIDISetupChange() { print("midi setup changed") // Not printed } override func receivedMIDINoteOn(_ noteNumber: MIDINoteNumber, velocity: MIDIVelocity, channel: MIDIChannel) { print("receivedMIDINoteOn") // Not printed } } func setupSynth() { oscBank.attackDuration = 0.05 oscBank.decayDuration = 0.1 oscBank.sustainLevel = 0.1 oscBank.releaseDuration = 0.1 } let seq = AKSequencer(filename: "music") let oscBank = AKOscillatorBank() var midi = AKMIDI() let midiNode = CustomMIDINode(node: oscBank) setupSynth() midi.openInput() midi.addListener(midiNode) seq.tracks.forEach { (track) in track.setMIDIOutput(midiNode.midiIn) } AudioKit.output = midiNode AudioKit.start() seq.play()
ios swift audiokit
Tony Fung Choi Fung
source share