How to monitor outgoing MIDI messages in CoreMIDI? - ios

Is there a way to take a device's destination endpoint and monitor what messages are being sent to it via CoreMIDI?

This here is a very good free MIDI Monitor
I have also built a MIDI Monitor with Xcode for iMac and iPhone using coreMIDI. The only problem I have is the "MIDIThruConnectionCreate" for MIDI Thru. Of corse I could send the received MIDI data packet to MIDI out, but this is not the right way.

MIDIThruConnection is for this. See MIDIThruConnection.h in CoreMIDI.framework for more details.

Related

MIDI messages are multiplying

I keep running into a strange issue when running AKMIDI on IOS. I also think it may be an IOS problem and not necessarily from Audiokit. I can connect a MIDI controller to IPad and receive messages as expected using the MIDI listener protocol after I open the input. If I disconnect the MIDI controller by cycling the power or unplugging it from the IPad and then reconnect it, I then start receiving two identical messages at each event. If I cycle the power again I start getting three messages, etc. I should also mention that when I detect the device is removed I close the input and clear the listeners. When I detect the new connection I open the input and start over. Does anyone know what can cause this to happen?
I think I have found a workaround for this:
If I only open the midi in and midi out one time, when my device is first detected, it seems to work correctly. I now only close the in and out when the app is terminated. You can cycle the power on the midi controller and it will still communicate with the app when it reconnects. I am also now using the more generic calls openInput(), addListener(self), openOutput().

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

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:
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.
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.
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!
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:
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.
Yes it should. You've opened all outputs, so everything should get the output.
I'm not sure about wireless MIDI as there's nothing specifically done with that in mind in AudioKit. If it doesn't "just work" I can try to replicate.
You might have to explicitly open the bluetooth connection with openOutput("Bluetooth")

OBD-II iOS WiFi Connection

I am trying to write an iOS application that connects to an OBD-II Interface over WiFi (specifically the OBDLink MX WiFi Scan Tool). I have written some basic socket code taken and I am able to open a socket to 192.168.0.10:35000. I receive the NSStreamEventOpenCompleted for both input and output streams.
The first event that fires shortly after is the NSStreamEventHasBytesAvailable. I attempt to read the stream, but the length comes back 0. My question is what is the flow of execution for communicating with these devices? I have tried to issue an ATZ\r command, but nothing is happening (no stream events are firing).
How do I know if if I am connected and the OBD-II interface is ready?
The usual command terminator is ˋ\r\nˋ, so first try sending ˋATZˋ with this command. Only send, after you have received the HasSpace notification from the ˋNSOutputStreamˋ.
Another alternative to communicate with this device would be this Car Diagnostics API, access to the API can be found on
https://github.com/HellaVentures/Car-Diagnostic-API

How can I generate programmatically a MIDI event on iPad

I would like to test a MIDI app and want to generate some MIDI events without attaching a physical keyboard. Any hints?
If you are using CoreMidi, setup your app to use MIDINetworkSessions. Once you advertise your iPad over the network, use any MIDI sequencer etc to connect to it and send messages over WiFi.
That way you can test without constantly unplugging/replugging things, and while still tethered to Xcode which is a huge bonus.
The other option would be to create an artificial MIDIPacketList and send it directly to your handler, but this is a lot less flexible.
If you mean sending a MIDI event to an iPad, then you could use a simple program like Rondo to play a MIDI file to it.
I suppose you need some source codes to generate MIDI events on iPad.
I found this one. It is a wrapper class of CoreMIDI, and it has source codes of sending/receiving some MIDI events.
RCTMidiLib
https://github.com/recotana/RCTMidiLib
I connect iPad and Mac wirelessly, and successfully send/receive MIDI events using the test application on iPad.

Packet Sniffing from a BlackBerry app

I want to develop an app that does basic packet sniffing. So, I would like to know if packet sniffing is feasible from a BlackBerry.
I don't think this is possible. The most you can do is keep track of the number of packets sent and received over the radio, but not see the actual contents. See RadioInfo.getNumberOfPacketsReceived() and RadioInfo.getNumberOfPacketsSent().
This is tagged "blackberry simulator" are you looking for an app in to observe what the simulator is doing or for an app in real world mode?
Intercepting things going in and out of the sim is not to hard, especially if you acted as some kind of intermediary pipe between the bbsim and the mds-cs sim.
Packet sniffing on device though i do not believe is possible at all, except over wifi from a promiscuous node laptop sniffing next to it.

Resources