Skip to content

Commit

Permalink
midi: decoded chunk tags as FieldUTF8
Browse files Browse the repository at this point in the history
  • Loading branch information
twystd committed Aug 18, 2024
1 parent 0ef3304 commit 9099a3e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
15 changes: 5 additions & 10 deletions format/midi/TODO.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
# TODO

- [x] update forked master branch
- [x] move delta into events
- [x] Use FieldUTF8 for MIDI chunk tags
- [ ] discard unknown chunks
- [ ] fix gaps
- [ ] assert available bytes
- [ ] tests
- [ ] format 0
- [ ] format 1
- [ ] format 2
- [x] move delta into events
- [ ] fix gaps
- (?) warn only for e.g. invalid format tracks
- (?) add to probe group
- (?) example queries
- tempo changes
- key changes
- notes

- formats
- [ ] format 0
- [ ] format 1
- [ ] format 2
- (?) add to probe group

- meta events
- [x] sequence number
Expand All @@ -41,7 +37,6 @@
- [x] sequencer specific event
- [x] map manufacturer
- [ ] check key mappings
- [ ] Use FieldUTF8String
- [ ] Combine status + event into metaevent field

- midi events
Expand Down
4 changes: 2 additions & 2 deletions format/midi/midi.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func decodeMThd(d *decode.D) {
}

d.FieldArray("header", func(d *decode.D) {
d.FieldUTF8NullFixedLen("tag", 4)
d.FieldUTF8("tag", 4)
length := d.FieldU32("length")

d.FramedFn(int64(length)*8, func(d *decode.D) {
Expand Down Expand Up @@ -85,7 +85,7 @@ func decodeMTrk(d *decode.D) {
d.Errorf("no MTrk marker")
}

d.FieldUTF8NullFixedLen("tag", 4)
d.FieldUTF8("tag", 4)
length := d.FieldU32("length")

d.FieldArray("events", func(d *decode.D) {
Expand Down
16 changes: 8 additions & 8 deletions format/midi/testdata/test.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ $ ./fq -d midi dv test.mid
| | | [2]{}: NoteOn 0x54-0x58 (4)
0x50| 00 | . | delta: 0 0x54-0x55 (1)
0x50| 90 | . | channel: 0 0x55-0x56 (1)
0x50| 30 | 0 | note: 48 0x56-0x57 (1)
0x50| 30 | 0 | note: "C3" (48) 0x56-0x57 (1)
0x50| 48 | H | velocity: 72 0x57-0x58 (1)
| | | [3]{}: KeySignature 0x58-0x5b (3)
0x50| 00 | . | delta: 0 0x58-0x59 (1)
Expand All @@ -79,37 +79,37 @@ $ ./fq -d midi dv test.mid
| | | [7]{}: NoteOff 0x6a-0x6f (5)
0x60| 83 60 | .` | delta: 480 0x6a-0x6c (2)
0x60| 80 | . | channel: 0 0x6c-0x6d (1)
0x60| 30 | 0 | note: 48 0x6d-0x6e (1)
0x60| 30 | 0 | note: "C3" (48) 0x6d-0x6e (1)
0x60| 40 | @ | velocity: 64 0x6e-0x6f (1)
| | | [8]{}: NoteOn 0x6f-0x73 (4)
0x60| 00| .| delta: 0 0x6f-0x70 (1)
0x70|90 |. | channel: 0 0x70-0x71 (1)
0x70| 32 | 2 | note: 50 0x71-0x72 (1)
0x70| 32 | 2 | note: "D3" (50) 0x71-0x72 (1)
0x70| 48 | H | velocity: 72 0x72-0x73 (1)
| | | [9]{}: NoteOff 0x73-0x78 (5)
0x70| 83 60 | .` | delta: 480 0x73-0x75 (2)
0x70| 80 | . | channel: 0 0x75-0x76 (1)
0x70| 32 | 2 | note: 50 0x76-0x77 (1)
0x70| 32 | 2 | note: "D3" (50) 0x76-0x77 (1)
0x70| 40 | @ | velocity: 64 0x77-0x78 (1)
| | | [10]{}: NoteOn 0x78-0x7c (4)
0x70| 00 | . | delta: 0 0x78-0x79 (1)
0x70| 90 | . | channel: 0 0x79-0x7a (1)
0x70| 34 | 4 | note: 52 0x7a-0x7b (1)
0x70| 34 | 4 | note: "E3" (52) 0x7a-0x7b (1)
0x70| 48 | H | velocity: 72 0x7b-0x7c (1)
| | | [11]{}: NoteOff 0x7c-0x81 (5)
0x70| 83 60 | .` | delta: 480 0x7c-0x7e (2)
0x70| 80 | . | channel: 0 0x7e-0x7f (1)
0x70| 34| 4| note: 52 0x7f-0x80 (1)
0x70| 34| 4| note: "E3" (52) 0x7f-0x80 (1)
0x80|40 |@ | velocity: 64 0x80-0x81 (1)
| | | [12]{}: NoteOn 0x81-0x85 (4)
0x80| 00 | . | delta: 0 0x81-0x82 (1)
0x80| 90 | . | channel: 0 0x82-0x83 (1)
0x80| 35 | 5 | note: 53 0x83-0x84 (1)
0x80| 35 | 5 | note: "F3" (53) 0x83-0x84 (1)
0x80| 48 | H | velocity: 72 0x84-0x85 (1)
| | | [13]{}: NoteOff 0x85-0x8a (5)
0x80| 83 60 | .` | delta: 480 0x85-0x87 (2)
0x80| 80 | . | channel: 0 0x87-0x88 (1)
0x80| 35 | 5 | note: 53 0x88-0x89 (1)
0x80| 35 | 5 | note: "F3" (53) 0x88-0x89 (1)
0x80| 40 | @ | velocity: 64 0x89-0x8a (1)
| | | [14]{}: EndOfTrack 0x8a-0x8d (3)
0x80| 00 | . | delta: 0 0x8a-0x8b (1)
Expand Down

0 comments on commit 9099a3e

Please sign in to comment.