fbpx
Skip to main content

MIDI Forum

Swift: Sending a Sy...
 
Notifications
Clear all

Swift: Sending a System Exclusive Message

2 Posts
2 Users
0 Reactions
2,917 Views
Bruno
Posts: 1
New Member
Topic starter
 

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:

##################################
SINGLE NOTE TUNING CHANGE (REAL-TIME)
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 08 02 tt ll [kk xx yy zz] F7

F0 7F: Universal Real Time SysEx header
: 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)
F7: EOX

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).

 
Posted : 11/03/2023 3:18 am
Clemens Ladisch
Posts: 324
 

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.

 
Posted : 11/03/2023 5:41 am
Share: