Skip to content

Commit 3105b7d

Browse files
committed
Added to probe group
1 parent 2f2070e commit 3105b7d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

format/midi/metaevents.go

+11-3
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,17 @@ func decodeTimeSignature(d *decode.D) {
385385
func decodeKeySignature(d *decode.D) {
386386
d.FieldUintFn("key", func(d *decode.D) uint64 {
387387
data := vlf(d)
388-
key := uint64(data[0]) & 0x00ff
389-
key <<= 8
390-
key |= uint64(data[1]) & 0x00ff
388+
key := uint64(0)
389+
390+
if len(data) > 0 {
391+
key <<= 8
392+
key |= uint64(data[0]) & 0x00ff
393+
}
394+
395+
if len(data) > 1 {
396+
key <<= 8
397+
key |= uint64(data[1]) & 0x00ff
398+
}
391399

392400
return key
393401

format/midi/midi.go

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func init() {
2727
format.MIDI,
2828
&decode.Format{
2929
Description: "Standard MIDI file",
30+
Groups: []*decode.Group{format.Probe},
3031
DecodeFn: decodeMIDI,
3132
})
3233

0 commit comments

Comments
 (0)