fbpx
Skip to main content

MIDI Forum

Only 14 key signatu...
 
Notifications
Clear all

Only 14 key signature allowed in midi?

7 Posts
5 Users
0 Reactions
9,709 Views
Carlos
Posts: 86
Estimable Member
Topic starter
 

[code type=markup]FF 59 02 sf mi Key Signature
sf = -7: 7 flats
sf = -1: 1 flat
sf = 0: key of C
sf = 1: 1 sharp
sf = 7: 7 sharps

mi = 0: major key
mi = 1: minor key
[/code]

According to this there are only 14 combinations and two scales, what about the others? because this meta event could go from -127 to 127 for the first parameter and 255 for the second.

 
Posted : 08/07/2022 4:04 am
Eddie Lotter
Posts: 295
Reputable Member
 

The parameters are 7-bit, which means they can only have 128 unique values, not 256.

Please give an example of a key signature that is not represented and how many sharps or flats are in your example.

 
Posted : 08/07/2022 5:51 am
JohnG
Posts: 225
Estimable Member
 

No, you can have all the key signatures available, both Major and minor.

There follows an example from XGworks.

So the first field goes from 00 to 07 then from FF to F9.
The second field can be either 0 (Major) or 1 (minor)
So 00 00 is C Major and 00 01 is A minor.

Any help?
JohnG.

 
Posted : 08/07/2022 6:05 am
Bavi_H
Posts: 266
Reputable Member
 

[quotePost id=15035]According to this there are only 14 combinations and two scales, what about the others?[/quotePost]
Carlos, be aware your count is off by one. A MIDI file Key Signature Meta Event can represent

15 visually unique key signatures (1 to 7 sharps + 1 to 7 flats + no sharps or flats)
× 2 tonalities (major or minor)
= 30 uniquely named keys in total

But you are correct, the other possible values for those bytes have no defined meaning, and a Key Signature Meta Event can only represent those 30 keys. So, for example, a Key Signature Meta Event can't represent
• keys like D-flat minor ("8" flats), you have to settle for the enharmonically equivalent C-sharp minor (4 sharps)
• modes like the modern Dorian mode from D to D.

(Also note, a one-byte signed value can represent values from -128 to +127.)

[quotePost id=15040]The parameters are 7-bit, which means they can only have 128 unique values, not 256.[/quotePost]
Eddie Lotter: Remember that Meta Events -- FF -- do not get sent out on the MIDI port, they only exist inside the MIDI file for the MIDI file software to see.

• The data of a Meta Event can generally use any byte value decimal 0 to 255 (hex 00 to FF).
• The specification says the number that indicates the type of Meta Event is limited to 0 to 127, however.
• (And, of course, as you know, the is a variable-length quantity, so it can use values decimal 128 to 255 (hex 80 to FF) to enlarge the length of the quantity. But everyone tends to remember that variable-length quantities don't get sent out on a MIDI port and they can use all 8 bits of a byte when needed.)

As Geoff mentioned, in a Key Signature Meta Event, the values of -1 down to -7 mentioned in the specification are represented in two's complement form as decimal 255 down to 249 (hex FF down to F9). So as Carlos mentioned, the first data byte of a Key Signature Meta Event could possibly represent values of -128 to +127 if every possible value were allowed. And the second data byte of a Key Signature Meta Event could possibly represent values of 0 to 255 if every possible value were allowed. But the specification only defines meanings for -7 to +7 and for 0 to 1.

A previous example of Meta Event data bytes using all 8 bits of a byte: In the example Tempo Meta Event shown at the end of the MIDI File Specification document, FF 51 03 07 A1 20 (which represents 120 quarter notes per minute or 500,000 microseconds per quarter note in big-endian hex: 07A120), the A1 byte is possible because the data bytes of a Meta Event can use all 8 bits of a byte.

 
Posted : 08/07/2022 9:29 am
Eddie Lotter
Posts: 295
Reputable Member
 

[quotePost id=15042]Eddie Lotter: Remember that Meta Events -- FF -- do not get sent out on the MIDI port, they only exist inside the MIDI file for the MIDI file software to see.[/quotePost]
You are correct. Thanks for the reminder. I was indeed thinking of messages that go across the wire. :p

 
Posted : 08/07/2022 7:19 pm
Mike Kent
Posts: 86
Trusted Member
 

The Standard MIDI File Working Group is currently defining file specifications to support MIDI 2.0 (or more specifically the Universal MIDI Packet format which supports MIDI 1.0 Protocol and MIDI 2.0 Protocol). We have been discussing Key Signatures expanding from Major and Minor to support Ionian, Dorian, Phrygian, Lydian, Mixolydian, Aeolian and Locrian modes by declaring the number of sharps or flats separately from declaring the tonic note value. We are also making this and other formerly "Meta Events" into MIDI 2.0 messages so they can be sent between devices. Developers who have interest can have input to the new specifications by joining as full members of the MIDI Association here: https://midi.activehosted.com/f/26

Thanks,
Mike.
Chairman of MIDI 2.0 Working Group

Chair of MIDI 2.0 Working Group

 
Posted : 09/07/2022 9:56 am
Carlos
Posts: 86
Estimable Member
Topic starter
 

[quotePost id=15042]
Carlos, be aware your count is off by one. A MIDI file Key Signature Meta Event can represent

15 visually unique key signatures (1 to 7 sharps + 1 to 7 flats + no sharps or flats)
× 2 tonalities (major or minor)
= 30 uniquely named keys in total

But you are correct, the other possible values for those bytes have no defined meaning, and a Key Signature Meta Event can only represent those 30 keys. So, for example, a Key Signature Meta Event can't represent
• keys like D-flat minor ("8" flats), you have to settle for the enharmonically equivalent C-sharp minor (4 sharps)
• modes like the modern Dorian mode from D to D.

(Also note, a one-byte signed value can represent values from -128 to +127.)
[/quotePost]

Thanks, I thought that the others could be missing (I don't know how an answer is accepted) if they had only thought of these 30 combinations, they would be enough with a single byte.

Is -128 per 1000 0000? she had not thought about it, not even that it was negative zero 😀

 
Posted : 10/07/2022 4:54 am
Share: