Skip to content

Commit

Permalink
midi: mapped SysEx event types
Browse files Browse the repository at this point in the history
  • Loading branch information
twystd committed Aug 22, 2024
1 parent 3ed9889 commit 54a0cf1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 1 addition & 3 deletions format/midi/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'


12 changes: 9 additions & 3 deletions format/midi/sysex.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion format/midi/testdata/test.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 54a0cf1

Please sign in to comment.