The MIDI Forum

  Saturday, 11 March 2023
  1 Replies
  1.2K Visits
Can anyone help me how to send this message with Swift?

I am writing a code in Swift and want my software midi-instrument (an AVAudioUnitSampler) to use another scale then the normal equal tempered. For this I want to change the frequency of some notes in the scale which MIDI is using, so that I have just for those notes a different frequency which automatically is played when I call the note with my midi-instrument.

I think this should be possible when I send a System Exclusive Message, but I donˋt know, how to do that in Swift.
I also don‘t understand what I have to write for the Device-ID (my instrument is AVAudioUnitSampler)

Why to send a System Exclusive Message?
A found the following in „The Complete MIDI 1.0 Detailed Specification“ on PDF-page 81:

The single note tuning change message (Exclusive Real Time sub-ID#1 = 08) permits on-the-fly adjustments to any tuning stored in the instrument’s memory. These changes should take effect immediately, and should occur without audible artifacts if any affected notes are sounding when the message is received.

F0 7F <device ID> 08 02 tt ll [kk xx yy zz] F7

F0 7F: Universal Real Time SysEx header
<device ID>: ID of target device
08: sub-ID#1 (MIDI Tuning Standard )
02: sub-ID#2 ( 02H, note change)
tt: tuning program number (0 – 127)
ll: number of changes (1 change = 1 set of [kk xx yy zz])
[kk: MIDI key number
xx yy zz]: frequency data for that key (repeated ‘ll’ number of times)

This message also permits (but does not require) multiple changes to be embedded in one message, for the purpose of maximizing bandwidth. The number of changes following is indicated by the byte ll; the total length of the message equals 8 + (ll x 4) bytes.
If an instrument does not support the full range of 128 MIDI key numbers, it should ignore data associated with un-playable notes on reception.
This message can be used to make changes in inactive (background) tunings as well. This message may also, at the discretion of the manufacturer, be transmitted by the instrument under particular circumstances (for example, while holding down one or more keys and pressing a “send-single-note- tuning” front panel button).
See, for example, stackoverflow.com/questions/44410914/sending-a-system-exclusive-message-using-coremidi.

For most devices, the device ID is 0x10. But note that not all devices might support this message.
Bruno set the type of the post as  How To Question — 2 months ago
  • Page :
  • 1
There are no replies made for this post yet.