-
Re: Connecting iOS to MacOS via Audio MIDI Setup & Sending MIDI
KMT Apr 21, 2019 5:21 PM (in response to Smashbrose)>have a feeling that I am missing a network connection
Did your process include adding your iOS device via Audio MIDI Setup?
Try this if not...
- Attach your iOS device via Lightning cable (direct, not thru a hub, drive, etc.)
- Run Audio MIDI Setup (/Applications/Utilities), then use the menu Window > Show iOS Device Browser
Audio Devices. Select/enable your iOS device on the left.
- Open Preferences → Audio, then choose the IOS device as an audio input device
Also see: https://support.apple.com/guide/audio-midi-setup/set-up-midi-devices-ams875bae1e0/mac
-
Re: Connecting iOS to MacOS via Audio MIDI Setup & Sending MIDI
Smashbrose Apr 21, 2019 4:16 PM (in response to KMT)Hey KMT, thanks for the quick reply. When I connect my device via lightning, there is no option within Audio MIDI Setup that prompts a window for iOS Device Browser, I only have (1) Show Audio Devices, (2) Hide MIDI Studio, and (3) Show Network Device Broswer. In my iOS swift application on XCode I have been able to initiate a client on my iPad using Core MIDI, have been able to hit connect on my macbook to my recognized iPad, but am stuck from there trying to figure out how to send MIDI between the devices. I think I have to somehow recognize my computer as a source and send that data through that as a reference point but am stuck trying to figure that out.
I have tried following the Apple Developer Core MIDI page for MIDI Send but am stuck with that since It does not seem like any MIDI is getting from my iPad to my computer.
Below is some of the code I have been writing to try and figure out a connection, it is a little messy from everything I have been trying, but any help would be great!
This is a class I created that I've been trying to use to send MIDI to my computer.
import Foundation
import CoreMIDI
var midi1 = MidiOutClass()
class MidiOutClass{
var midiClient = MIDIClientRef()
var midiSource = MIDIEndpointRef()
// var midiFound = MIDIObjectType(rawValue: <#Int32#>)
var outputPort = MIDIPortRef()
var endPoint = MIDIObjectRef()
var ent = MIDIEntityRef()
func openClient(){
MIDIClientCreate("Gregs iPad" as CFString, nil, nil, &midiClient) // this sets up the iPad in the Directory of Audio MIDI Setup
//MIDISourceCreate(midiClient, "MIDI Source" as CFString, &midiSource)
MIDIOutputPortCreate(midiClient, "Output" as CFString, &outputPort)
// let midiSource = MIDIGetSource(1)
// MIDIEndpointGetEntity(midiSource, &ent)
print(midiClient)
print(midiSource)
print(ent)
print(outputPort)
// print(endPoint)
print("midi out opened") // should do this if successful
}
//
// func createPort(){
// var result = MIDIOutputPortCreate(midiClient, "Output" as CFString, &outputPort)
// print(result)
// result = MIDIObjectFindByUniqueID(MIDIUniqueID.init(), &endPoint, &midiSourceType!)
// }
func midiSend(status: Int, controlID: Int, value: Int){
var packet = UnsafeMutablePointer<MIDIPacket>.allocate(capacity: 1)
let packetList = UnsafeMutablePointer<MIDIPacketList>.allocate(capacity: 1)
let midiDataToSend:[UInt8] = [UInt8(status), UInt8(controlID), UInt8(value)];
packet = MIDIPacketListInit(packetList);
packet = MIDIPacketListAdd(packetList, 1024, packet, 0, 3, midiDataToSend);
MIDISend(outputPort, midiSource, packetList)
print("MIDI Send")
print(packetList)
// MIDIReceived(midiSource, packetList)
// MIDISend(<#T##port: MIDIPortRef##MIDIPortRef#>, <#T##dest: MIDIEndpointRef##MIDIEndpointRef#>, <#T##pktlist: UnsafePointer<MIDIPacketList>##UnsafePointer<MIDIPacketList>#>)
// MIDIDeviceGetEntity(<#T##device: MIDIDeviceRef##MIDIDeviceRef#>, <#T##entityIndex0: Int##Int#>)
// packet.deallocate()
// packetList.deallocate()
}
Thank you again for the help,
- Greg
-
Re: Connecting iOS to MacOS via Audio MIDI Setup & Sending MIDI
KMT Apr 21, 2019 5:49 PM (in response to Smashbrose)>When I connect my device via lightning
Sorry, w/AMS Mojave, use the menu Window/(Show/Hide)Audio Devices - then see if your iPad is listed on the left...'Enabled' allows it to be an audio input device & you to send/receive MIDI messages via cable.
If you don't see your iPad via AMS, I'd find a different cable.
-
Re: Connecting iOS to MacOS via Audio MIDI Setup & Sending MIDI
Smashbrose Apr 22, 2019 4:07 PM (in response to KMT)Hi KMT,
That worked great thank you! Do you have any ideas as to how I now use MIDISend?
Thank you,
- Greg
-
Re: Connecting iOS to MacOS via Audio MIDI Setup & Sending MIDI
KMT Apr 22, 2019 5:27 PM (in response to Smashbrose)Greg:
You're welcome.
> have any ideas
MIDI is messy, what can I say - if clang likes it, it's ok by me, anything else is just one person's style. Good luck w/the class.
Ken
-
-
-