We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2f2070e commit 3105b7dCopy full SHA for 3105b7d
format/midi/metaevents.go
@@ -385,9 +385,17 @@ func decodeTimeSignature(d *decode.D) {
385
func decodeKeySignature(d *decode.D) {
386
d.FieldUintFn("key", func(d *decode.D) uint64 {
387
data := vlf(d)
388
- key := uint64(data[0]) & 0x00ff
389
- key <<= 8
390
- key |= uint64(data[1]) & 0x00ff
+ key := uint64(0)
+
+ if len(data) > 0 {
391
+ key <<= 8
392
+ key |= uint64(data[0]) & 0x00ff
393
+ }
394
395
+ if len(data) > 1 {
396
397
+ key |= uint64(data[1]) & 0x00ff
398
399
400
return key
401
format/midi/midi.go
@@ -27,6 +27,7 @@ func init() {
27
format.MIDI,
28
&decode.Format{
29
Description: "Standard MIDI file",
30
+ Groups: []*decode.Group{format.Probe},
31
DecodeFn: decodeMIDI,
32
})
33
0 commit comments