Exploring MIDI
Let’s dive deeper to find out more about the MIDI devices that are connected to your Mac by opening the Audio MIDI Setup or MIDI Studio as it is also called sometimes.
That is how it looks on my machine:
Every box in the picture represents a MIDI device, this can be a physical device, like a controller. It can also be a software interface, like the network and bluetooth interfaces. Those devices have so-called entities that logically group sources and destinations together. Sources and destinations, also called endpoints, are your MIDI In and Out ports, whether it be with the 5-pin connectors or with USB.
All the above mentioned MIDI objects have properties. Those properties add information to the objects and are provided by the manufacturer, your system or even yourself.
The MIDI Services Reference represents this hierarchy with the following type MIDIObjectRef
and its subtypes MIDIDeviceRef
, MIDIEntityRef
and MIDIEndpointRef
.
I currently have two external devices connected, a Roland A-88 MIDI controller and a Roland Duo-Capture EX audio interface.
The sources and destinations are represented by those little triangles in the picture above. Therefore the A-88 has two entities, one with a source and a destination and another one with a source only. The Duo-Capture has one entity with a source and a destination.
The back side of the Roland A-88 looks like this:
It has one MIDI Out and some other ports for pedals, USB and power. In the last post we have written some code to print all the properties of our devices. Looking at the ones for the Roland A-88 all is clear.
{% gist 48649bba91d1d7cac31e roland-a88.txt %}
There are the two entities again, with a source and a destination. That is the USB port on the device. The MIDI Out port is the single endpoint entity.
Let’s check the Duo-Capture EX as well:
All clear: One entity with a source (MIDI Out) and a destination (MIDI In). This can also be seen in the printout of the properties:
{% gist 48649bba91d1d7cac31e roland-duo-capture-ex.txt %}
Now we are going to dig even deeper to find out how to get to those endpoints, especially the sources.
When I have build MIDI Aid for Mac and for iPad, iPhone and iPod touch, I wanted to grab everything from MIDI Out and feed it into my app to display that output.
Easy task, we just query the system for all sources. In this example, I also show how to get two properties from the sources, the name and the unique ID.
{% gist 48649bba91d1d7cac31e example-2.swift %}
Let’s run this with all my devices being turned on, the output on my Mac is
Number of sources: 3
Session 1: 1652107473
Keyboard: 2124965650
DUO-CAPTURE EX: -904633270
We are one step further in using CoreMIDI and understand how your Mac sees and structures MIDI devices. Plus we know how to get to the information of all those devices.
Done for today!