Hello,

While writing a MIDI logging app for iOS I found out that the timestamps 
received in MIDI packets via Bluetooth are unchanged until I pause events for 
about 3 seconds.
I assumed the timestamps of each packet are accurate with at least milliseconds 
precision.
Since these timestamps are eventually shown in the UI it looks odd in my app 
because equal timestamps are displayed even though the events are clearly apart 
in time.

When receiving packets via Wifi (Network Session, initiated from the Mac) the 
timestamps are different with each packet, as expected.

This log (by means of NSLog()), copied from Xcode output console, shows the 
problem:

2017-12-27 16:19:25.051 MIDI Sniffer[233:13563] midiproc ts=58424376000 
status=0x90 d1=0x43 d2=0x35
2017-12-27 16:19:25.171 MIDI Sniffer[233:13563] midiproc ts=58424376000 
status=0x80 d1=0x43 d2=0x26
2017-12-27 16:19:27.257 MIDI Sniffer[233:13563] midiproc ts=58424376000 
status=0x90 d1=0x45 d2=0x36
2017-12-27 16:19:27.406 MIDI Sniffer[233:13563] midiproc ts=58424376000 
status=0x80 d1=0x45 d2=0x17
2017-12-27 16:19:28.246 MIDI Sniffer[233:13563] midiproc ts=58424376000 
status=0x90 d1=0x47 d2=0x39
2017-12-27 16:19:28.365 MIDI Sniffer[233:13563] midiproc ts=58424376000 
status=0x80 d1=0x47 d2=0x2b
2017-12-27 16:19:31.922 MIDI Sniffer[233:13563] midiproc ts=58588752000 
status=0x90 d1=0x48 d2=0x1d
2017-12-27 16:19:32.101 MIDI Sniffer[233:13563] midiproc ts=58588752000 
status=0x80 d1=0x48 d2=0x0b

Setup: MIDI keyboard -> Mac with Sierra (Logic Pro X as MIDI router) -> 
Bluetooth -> iPad

Note that the NSLog() timestamp prefix shows the actual time of day as I play 
the notes on the MIDI keyboard.
Here you can see how much time passed between events.
The timestamp printed after "ts=" is the one from the MIDIPacket struct. It 
does not change in the first 6 events above.
It changes only if I wait approx. 3 seconds, see the last 2 events.

The code in the midiReadProc callback looks like this:

NSLog(@"midiproc ts=%llu status=%#04x d1=%#04x d2=%#04x", packet->timeStamp, c, 
d1, midiBytes[2]);

(c, d1, and midiBytes are local variables that contain the 3-byte MIDI message 
from the packet)

I observed this on an iPad mini 1 with iOS 9.3.5 and also on an iPad Air 2 with 
iOS 11.
Is this something that cannot be avoided with Bluetooth? 

I would prefer to simply read the packet timestamp instead of capturing my own 
mach timestamp from the system in the MIDI callback.

Thanks for any ideas. If encouraged I could file a bug report with Apple.

Best,
Sven
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/coreaudio-api/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to