Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AudioKit MIDI Events - basic questions, sending to external synth, not sure about handling

Tags:

audiokit

I had some more time to play around with AudioKit, yet I have a few questions about MIDI. I tried googling and I also checked the AKMIDI class reference, but this just further confused me.

Let's keep it simple: I have a UIButton that should give out a "C" to an external synth.

import AudioKit
midiOut.openOutput()
midiOut.sendEvent(AKMIDIEvent(noteOn: 72, velocity: 80, channel: 1))
sleep(1)
midiOut.sendEvent(AKMIDIEvent(noteOff: 72, velocity: 0, channel: 1))

Obviously this code is spread over the entire ViewController.swift and the sendEvents are inside an @IBAction, but for the sake of keeping it simple, I merged the LOCs.

So my questions are:

  1. Will this send out MIDI signals to external machines? (I ordered the Lightning Camera Connection Kit, but it will take a few more days to arrive, so I cannot test it yet.) I cannot get anything from the iPhone Simulator, so I take it, this is not working.
  2. Will this send out MIDI signals over wireless MIDI as well? According to what I read on some Google group, you can have Wireless MIDI on macOS. Unfortunately I didn't find anything on if and how you can use this in AudioKit.
  3. What about MIDI over Bluetooth? Will this all be handled by AudioKit automatically or will I have to change anything? I read something about midi.createVirtualPorts(), but I am not sure what this actually does. But the word "virtual" makes me believe this is for testing?

Sorry if these questions are ridiculously noobish, but I really am confused by the exact inner workings of this.

Thanks a lot in advance!

like image 769
casualcoder Avatar asked Nov 08 '22 13:11

casualcoder


1 Answers

You can test your app with simulator as well. Just run your app on simulator and open the Audio MIDI Setup app on your Mac, go to network settings and connect your simulator. Here is a screenshot:

Audio MIDI Setup

You have full control over AKMIDI.
* If you want to open all available outputs, just call midi.openOutput().
* If you want to open a specific one, like a network session, mostly named "Session 1", call midi.openOutput(name: "Session 1").
* You can get all available destinations by midi.destinationNames string array, if you want to prompt a midi dest picker to user, then just open them with their names.
* For closing them midi.endpoints.removeValue(forKey: "Session 1").
* And for virtual outputs, call sequencer.midi.createVirtualOutputPort(name: "App MIDI Out") which is useful to send MIDI to other apps living in your iOS/Mac.
* Also, you can subscribe to AKMIDIListener protocol's receivedMIDISetupChange function to get notified when a MIDI hardware/software available or not to connect.

like image 146
cem olcay Avatar answered Nov 27 '22 18:11

cem olcay