diff --git a/format/midi/TODO.md b/format/midi/TODO.md index 9369e6d7..d8b521d2 100644 --- a/format/midi/TODO.md +++ b/format/midi/TODO.md @@ -42,10 +42,8 @@ - [x] end of track - [x] tempo - [x] SMPTE offset - - [x] map frame rates - [x] key signature - [x] time signature - - [x] cleanup denominator - [x] sequencer specific event - [x] map manufacturer - [x] check key mappings @@ -69,6 +67,6 @@ - [x] escape - [x] use context struct for casio - [x] map manufacturer ID - - [ ] Decode status as 'sysex' + - [x] Decode status as 'sysex' diff --git a/format/midi/sysex.go b/format/midi/sysex.go index 54beef32..6c6cc503 100644 --- a/format/midi/sysex.go +++ b/format/midi/sysex.go @@ -4,8 +4,14 @@ import ( "fmt" "github.com/wader/fq/pkg/decode" + "github.com/wader/fq/pkg/scalar" ) +var sysex = scalar.UintMapSymStr{ + 0xf0: "F0", + 0xf7: "F7", +} + func decodeSysExEvent(d *decode.D, status uint8, ctx *context) { ctx.running = 0x00 @@ -35,7 +41,7 @@ func decodeSysExEvent(d *decode.D, status uint8, ctx *context) { func decodeSysExMessage(d *decode.D, ctx *context) { d.FieldUintFn("delta", vlq) - d.FieldU8("status") + d.FieldU8("sysex", sysex) var bytes []uint8 d.FieldStrFn("bytes", func(d *decode.D) string { @@ -72,7 +78,7 @@ func decodeSysExMessage(d *decode.D, ctx *context) { func decodeSysExContinuation(d *decode.D, ctx *context) { d.FieldUintFn("delta", vlq) - d.FieldU8("status") + d.FieldU8("sysex", sysex) d.FieldStrFn("data", func(d *decode.D) string { data := vlf(d) @@ -92,7 +98,7 @@ func decodeSysExContinuation(d *decode.D, ctx *context) { func decodeSysExEscape(d *decode.D, ctx *context) { d.FieldUintFn("delta", vlq) - d.FieldU8("status") + d.FieldU8("sysex", sysex) d.FieldStrFn("data", func(d *decode.D) string { data := vlf(d) diff --git a/format/midi/testdata/test.fqtest b/format/midi/testdata/test.fqtest index b0c40f5a..7efd2cfa 100644 --- a/format/midi/testdata/test.fqtest +++ b/format/midi/testdata/test.fqtest @@ -29,7 +29,7 @@ $ ./fq -d midi dv test.mid 0x20| 04 04 02| ...| bytes: "[4 2 24 8]" 0x2d-0x32 (5) 0x30|18 08 |.. | | | | numerator: 4 - | | | denominator: 4 0x32-0x32 (0) + | | | denominator: 4 | | | ticksPerClick: 24 | | | thirtySecondsPerQuarter: 8 | | | [3]{}: EndOfTrack 0x32-0x36 (4)