1
1
mirror of https://github.com/wader/fq.git synced 2024-11-22 15:45:45 +03:00

midi: reworked metaevent decoding for PR comments

- fixed remaining snake-cased event names in tests and examples (cf. https://github.com/wader/fq/pull/1004#discussion_r1737054466)
- report 'status' and 'event' seperately (cf. https://github.com/wader/fq/pull/1004#discussion_r1737085013)
- decoded TimeSignature metaevent as length + byte fields (cf. https://github.com/wader/fq/pull/1004#discussion_r1737105173)
- decoded SequencerSpecificEvent metaevent as length + byte fields (cf. https://github.com/wader/fq/pull/1004#discussion_r1737111253)
- reworked Errorf's as Fatalf's for data reads (cf. https://github.com/wader/fq/pull/1004#discussion_r1737123374)
This commit is contained in:
twystd 2024-08-29 18:14:57 -07:00
parent 7950dd651f
commit e940f4766f
16 changed files with 405 additions and 291 deletions

View File

@ -7,48 +7,46 @@ import (
"github.com/wader/fq/pkg/scalar"
)
type MetaEventType uint8
const (
TypeSequenceNumber MetaEventType = 0x00
TypeText MetaEventType = 0x01
TypeCopyright MetaEventType = 0x02
TypeTrackName MetaEventType = 0x03
TypeInstrumentName MetaEventType = 0x04
TypeLyric MetaEventType = 0x05
TypeMarker MetaEventType = 0x06
TypeCuePoint MetaEventType = 0x07
TypeProgramName MetaEventType = 0x08
TypeDeviceName MetaEventType = 0x09
TypeMIDIChannelPrefix MetaEventType = 0x20
TypeMIDIPort MetaEventType = 0x21
TypeTempo MetaEventType = 0x51
TypeSMPTEOffset MetaEventType = 0x54
TypeTimeSignature MetaEventType = 0x58
TypeKeySignature MetaEventType = 0x59
TypeEndOfTrack MetaEventType = 0x2f
TypeSequencerSpecificEvent MetaEventType = 0x7f
TypeSequenceNumber uint64 = 0x00
TypeText uint64 = 0x01
TypeCopyright uint64 = 0x02
TypeTrackName uint64 = 0x03
TypeInstrumentName uint64 = 0x04
TypeLyric uint64 = 0x05
TypeMarker uint64 = 0x06
TypeCuePoint uint64 = 0x07
TypeProgramName uint64 = 0x08
TypeDeviceName uint64 = 0x09
TypeMIDIChannelPrefix uint64 = 0x20
TypeMIDIPort uint64 = 0x21
TypeTempo uint64 = 0x51
TypeSMPTEOffset uint64 = 0x54
TypeTimeSignature uint64 = 0x58
TypeKeySignature uint64 = 0x59
TypeEndOfTrack uint64 = 0x2f
TypeSequencerSpecificEvent uint64 = 0x7f
)
var metaevents = scalar.UintMapSymStr{
0xff00: "sequence_number",
0xff01: "text",
0xff02: "copyright",
0xff03: "track_name",
0xff04: "instrument_name",
0xff05: "lyric",
0xff06: "marker",
0xff07: "cue_point",
0xff08: "program_name",
0xff09: "device_name",
0xff20: "midi_channel_prefix",
0xff21: "midi_port",
0xff51: "tempo",
0xff54: "smpte_offset",
0xff58: "time_signature",
0xff59: "key_signature",
0xff2f: "end_of_track",
0xff7f: "sequencer_specific_event",
TypeSequenceNumber: "sequence_number",
TypeText: "text",
TypeCopyright: "copyright",
TypeTrackName: "track_name",
TypeInstrumentName: "instrument_name",
TypeLyric: "lyric",
TypeMarker: "marker",
TypeCuePoint: "cue_point",
TypeProgramName: "program_name",
TypeDeviceName: "device_name",
TypeMIDIChannelPrefix: "midi_channel_prefix",
TypeMIDIPort: "midi_port",
TypeTempo: "tempo",
TypeSMPTEOffset: "smpte_offset",
TypeTimeSignature: "time_signature",
TypeKeySignature: "key_signature",
TypeEndOfTrack: "end_of_track",
TypeSequencerSpecificEvent: "sequencer_specific_event",
}
var framerates = scalar.UintMapSymUint{
@ -72,12 +70,13 @@ func decodeMetaEvent(d *decode.D, event uint8, ctx *context) {
metaevent := func(name string, f func(d *decode.D)) {
d.FieldStruct(name, func(d *decode.D) {
d.FieldStruct("time", delta)
d.FieldU16("event", metaevents)
d.FieldU8("status")
d.FieldU8("event", metaevents)
f(d)
})
}
switch MetaEventType(event) {
switch uint64(event) {
case TypeSequenceNumber:
metaevent("sequence_number", decodeSequenceNumber)
@ -142,7 +141,7 @@ func decodeSequenceNumber(d *decode.D) {
seqno := uint64(0)
if data, err := vlf(d); err != nil {
d.Errorf("%v", err)
d.Fatalf("%v", err)
} else {
if len(data) > 0 {
seqno += uint64(data[0])
@ -199,7 +198,7 @@ func decodeMIDIChannelPrefix(d *decode.D) {
channel := uint64(0)
if data, err := vlf(d); err != nil {
d.Errorf("%v", err)
d.Fatalf("%v", err)
} else {
for _, b := range data {
channel <<= 8
@ -216,7 +215,7 @@ func decodeMIDIPort(d *decode.D) {
port := uint64(0)
if data, err := vlf(d); err != nil {
d.Errorf("%v", err)
d.Fatalf("%v", err)
} else {
for _, b := range data {
port <<= 8
@ -233,7 +232,7 @@ func decodeTempo(d *decode.D) {
tempo := uint64(0)
if data, err := vlf(d); err != nil {
d.Errorf("%v", err)
d.Fatalf("%v", err)
} else {
for _, b := range data {
tempo <<= 8
@ -252,7 +251,7 @@ func decodeSMPTEOffset(d *decode.D) {
d.FieldStrFn("bytes", func(d *decode.D) string {
if data, err = vlf(d); err != nil {
d.Errorf("%v", err)
d.Fatalf("%v", err)
} else {
return fmt.Sprintf("%v", data)
}
@ -288,38 +287,29 @@ func decodeSMPTEOffset(d *decode.D) {
func decodeTimeSignature(d *decode.D) {
d.FieldStruct("signature", func(d *decode.D) {
var data []uint8
var err error
length := d.FieldUintFn("length", vlq)
d.FieldStrFn("bytes", func(d *decode.D) string {
if data, err = vlf(d); err != nil {
d.Errorf("%v", err)
} else {
return fmt.Sprintf("%v", data)
}
return "[]"
})
if len(data) > 0 {
d.FieldValueUint("numerator", uint64(data[0]))
if length > 0 {
d.FieldU8("numerator")
}
if len(data) > 1 {
denominator := uint64(1)
for i := uint8(0); i < data[1]; i++ {
denominator <<= 1
}
d.FieldValueUint("denominator", denominator)
if length > 1 {
d.FieldUintFn("denominator", func(d *decode.D) uint64 {
denominator := uint64(1)
v := d.U8()
for i := uint64(0); i < v; i++ {
denominator <<= 1
}
return denominator
})
}
if len(data) > 2 {
d.FieldValueUint("ticks_per_click", uint64(data[2]))
if length > 2 {
d.FieldU8("ticks_per_click")
}
if len(data) > 3 {
d.FieldValueUint("thirty_seconds_per_quarter", uint64(data[3]))
if length > 3 {
d.FieldU8("thirty_seconds_per_quarter")
}
})
}
@ -329,7 +319,7 @@ func decodeKeySignature(d *decode.D) {
key := uint64(0)
if data, err := vlf(d); err != nil {
d.Errorf("%v", err)
d.Fatalf("%v", err)
} else {
if len(data) > 0 {
key <<= 8
@ -352,7 +342,7 @@ func decodeEndOfTrack(d *decode.D) {
length := 0
if data, err := vlf(d); err != nil {
d.Errorf("%v", err)
d.Fatalf("%v", err)
} else {
length = len(data)
}
@ -363,30 +353,27 @@ func decodeEndOfTrack(d *decode.D) {
func decodeSequencerSpecificEvent(d *decode.D) {
d.FieldStruct("info", func(d *decode.D) {
var data []uint8
var err error
if length := d.FieldUintFn("length", vlq); length > 0 {
b := d.PeekUintBits(8)
d.FieldStrFn("bytes", func(d *decode.D) string {
if data, err = vlf(d); err != nil {
d.Errorf("%v", err)
} else {
return fmt.Sprintf("%v", data)
}
if length > 2 && b == 0 {
d.FieldStrFn("manufacturer", func(d *decode.D) string {
manufacturer := d.BytesLen(3)
return "[]"
})
return fmt.Sprintf("%02X%02X", manufacturer[1], manufacturer[2])
}, manufacturers)
if len(data) > 2 && data[0] == 0x00 {
d.FieldValueStr("manufacturer", fmt.Sprintf("%02X%02X", data[1], data[2]), manufacturers)
if length > 3 {
d.FieldRawLen("data", 8*(int64(length)-3))
}
} else if length > 0 {
d.FieldStrFn("manufacturer", func(d *decode.D) string {
return fmt.Sprintf("%02X", d.U8())
}, manufacturers)
if len(data) > 3 {
d.FieldValueStr("data", fmt.Sprintf("%v", data[3:]))
}
} else if len(data) > 0 {
d.FieldValueStr("manufacturer", fmt.Sprintf("%02x", data[0]), manufacturers)
if len(data) > 1 {
d.FieldValueStr("data", fmt.Sprintf("%v", data[1:]))
if length > 1 {
d.FieldRawLen("data", 8*(int64(length)-1))
}
}
}
})

View File

@ -195,7 +195,7 @@ func vlf(d *decode.D) ([]uint8, error) {
// Variable length string with a big endian varint length
func vlstring(d *decode.D) string {
if data, err := vlf(d); err != nil {
d.Errorf("%v", err)
d.Fatalf("%v", err)
} else {
return string(data)
}

View File

@ -7,7 +7,7 @@
1. Extract the track names from a MIDI file
```
fq -d midi -d midi '.. | select(.event=="track name")? | "\(.name)"' twinkle.mid
fq -d midi -d midi '.. | select(.event=="track_name")? | "\(.name)"' twinkle.mid
```
2. Extract the tempo changes from a MIDI file
@ -17,12 +17,12 @@ fq -d midi '.. | select(.event=="tempo")?.tempo' twinkle.mid
3. Extract the key changes from a MIDI file
```
fq -d midi '.. | select(.event=="key signature")?.key' key-signatures.mid
fq -d midi '.. | select(.event=="key_signature")?.key' key-signatures.mid
```
4. Extract NoteOn and NoteOff events:
```
fq -d midi 'grep_by(.event=="note on" or .event=="note off") | "\(.event) \(.time.tick) \(.note)"' twinkle.mid
fq -d midi 'grep_by(.event=="note_on" or .event=="note_off") | "\(.event) \(.time.tick) \(.note)"' twinkle.mid
```
### Authors

View File

@ -71,7 +71,7 @@ func decodeSysExMessage(d *decode.D, ctx *context) {
d.FieldStrFn("bytes", func(d *decode.D) string {
if bytes, err = vlf(d); err != nil {
d.Errorf("%v", err)
d.Fatalf("%v", err)
} else {
return fmt.Sprintf("%v", bytes)
}
@ -113,7 +113,7 @@ func decodeSysExContinuation(d *decode.D, ctx *context) {
d.FieldStrFn("bytes", func(d *decode.D) string {
if data, err = vlf(d); err != nil {
d.Errorf("%v", err)
d.Fatalf("%v", err)
} else {
return fmt.Sprintf("%v", data)
}
@ -142,7 +142,7 @@ func decodeSysExEscape(d *decode.D, ctx *context) {
d.FieldStrFn("bytes", func(d *decode.D) string {
if data, err = vlf(d); err != nil {
d.Errorf("%v", err)
d.Fatalf("%v", err)
} else {
return fmt.Sprintf("%v", data)
}

View File

@ -15,7 +15,8 @@ run: build
debug: build
# go run . -d midi dv format/midi/workdir/15ba2fe0cd4bf33a.mid
# go run . -d midi dv format/midi/testdata/unknown-chunks.mid
go test ./format -run TestFormats/all/all.fqtest
# go test ./format -run TestFormats/all/all.fqtest
go run . -d midi dv format/midi/workdir/sequencer-specific-event.mid
test: build
go test ./format -run TestFormats/midi

View File

@ -30,7 +30,6 @@ Test file with all supported MIDI key signatures.
Test file with all supported MIDI notes.
8. _twinkle.mid_
Sample MIDI file for the example queries in the help.

View File

@ -17,92 +17,103 @@ $ fq -d midi dv format-0.mid
| | | time{}: 0x16-0x17 (1)
0x010| 00 | . | delta: 0 0x16-0x17 (1)
| | | tick: 0
0x010| ff 00 | .. | event: "sequence_number" (65280) 0x17-0x19 (2)
0x010| ff | . | status: 255 0x17-0x18 (1)
0x010| 00 | . | event: "sequence_number" (0) 0x18-0x19 (1)
0x010| 02 00 17 | ... | sequence_number: 23 0x19-0x1c (3)
| | | [1]{}: text 0x1c-0x2d (17)
| | | time{}: 0x1c-0x1d (1)
0x010| 00 | . | delta: 0 0x1c-0x1d (1)
| | | tick: 0
0x010| ff 01 | .. | event: "text" (65281) 0x1d-0x1f (2)
0x010| ff | . | status: 255 0x1d-0x1e (1)
0x010| 01 | . | event: "text" (1) 0x1e-0x1f (1)
0x010| 0d| .| text: "This and That" 0x1f-0x2d (14)
0x020|54 68 69 73 20 61 6e 64 20 54 68 61 74 |This and That |
| | | [2]{}: copyright 0x2d-0x35 (8)
| | | time{}: 0x2d-0x2e (1)
0x020| 00 | . | delta: 0 0x2d-0x2e (1)
| | | tick: 0
0x020| ff 02| ..| event: "copyright" (65282) 0x2e-0x30 (2)
0x020| ff | . | status: 255 0x2e-0x2f (1)
0x020| 02| .| event: "copyright" (2) 0x2f-0x30 (1)
0x030|04 54 68 65 6d |.Them | copyright: "Them" 0x30-0x35 (5)
| | | [3]{}: track_name 0x35-0x41 (12)
| | | time{}: 0x35-0x36 (1)
0x030| 00 | . | delta: 0 0x35-0x36 (1)
| | | tick: 0
0x030| ff 03 | .. | event: "track_name" (65283) 0x36-0x38 (2)
0x030| ff | . | status: 255 0x36-0x37 (1)
0x030| 03 | . | event: "track_name" (3) 0x37-0x38 (1)
0x030| 08 46 6f 72 6d 61 74 20| .Format | name: "Format 0" 0x38-0x41 (9)
0x040|30 |0 |
| | | [4]{}: instrument_name 0x41-0x4f (14)
| | | time{}: 0x41-0x42 (1)
0x040| 00 | . | delta: 0 0x41-0x42 (1)
| | | tick: 0
0x040| ff 04 | .. | event: "instrument_name" (65284) 0x42-0x44 (2)
0x040| ff | . | status: 255 0x42-0x43 (1)
0x040| 04 | . | event: "instrument_name" (4) 0x43-0x44 (1)
0x040| 0a 44 69 64 67 65 72 69 64 6f 6f | .Didgeridoo | instrument: "Didgeridoo" 0x44-0x4f (11)
| | | [5]{}: lyric 0x4f-0x5b (12)
| | | time{}: 0x4f-0x50 (1)
0x040| 00| .| delta: 0 0x4f-0x50 (1)
| | | tick: 0
0x050|ff 05 |.. | event: "lyric" (65285) 0x50-0x52 (2)
0x050|ff |. | status: 255 0x50-0x51 (1)
0x050| 05 | . | event: "lyric" (5) 0x51-0x52 (1)
0x050| 08 4c 61 2d 6c 61 2d 6c 61 | .La-la-la | lyric: "La-la-la" 0x52-0x5b (9)
| | | [6]{}: marker 0x5b-0x6e (19)
| | | time{}: 0x5b-0x5c (1)
0x050| 00 | . | delta: 0 0x5b-0x5c (1)
| | | tick: 0
0x050| ff 06 | .. | event: "marker" (65286) 0x5c-0x5e (2)
0x050| ff | . | status: 255 0x5c-0x5d (1)
0x050| 06 | . | event: "marker" (6) 0x5d-0x5e (1)
0x050| 0f 48| .H| marker: "Here Be Dragons" 0x5e-0x6e (16)
0x060|65 72 65 20 42 65 20 44 72 61 67 6f 6e 73 |ere Be Dragons |
| | | [7]{}: cue_point 0x6e-0x7e (16)
| | | time{}: 0x6e-0x6f (1)
0x060| 00 | . | delta: 0 0x6e-0x6f (1)
| | | tick: 0
0x060| ff| .| event: "cue_point" (65287) 0x6f-0x71 (2)
0x070|07 |. |
0x060| ff| .| status: 255 0x6f-0x70 (1)
0x070|07 |. | event: "cue_point" (7) 0x70-0x71 (1)
0x070| 0c 4d 6f 72 65 20 63 6f 77 62 65 6c 6c | .More cowbell | cue: "More cowbell" 0x71-0x7e (13)
| | | [8]{}: program_name 0x7e-0x88 (10)
| | | time{}: 0x7e-0x7f (1)
0x070| 00 | . | delta: 0 0x7e-0x7f (1)
| | | tick: 0
0x070| ff| .| event: "program_name" (65288) 0x7f-0x81 (2)
0x080|08 |. |
0x070| ff| .| status: 255 0x7f-0x80 (1)
0x080|08 |. | event: "program_name" (8) 0x80-0x81 (1)
0x080| 06 45 73 63 61 70 65 | .Escape | program: "Escape" 0x81-0x88 (7)
| | | [9]{}: device_name 0x88-0x94 (12)
| | | time{}: 0x88-0x89 (1)
0x080| 00 | . | delta: 0 0x88-0x89 (1)
| | | tick: 0
0x080| ff 09 | .. | event: "device_name" (65289) 0x89-0x8b (2)
0x080| ff | . | status: 255 0x89-0x8a (1)
0x080| 09 | . | event: "device_name" (9) 0x8a-0x8b (1)
0x080| 08 54 68 65 54| .TheT| device: "TheThing" 0x8b-0x94 (9)
0x090|68 69 6e 67 |hing |
| | | [10]{}: midi_channel_prefix 0x94-0x99 (5)
| | | time{}: 0x94-0x95 (1)
0x090| 00 | . | delta: 0 0x94-0x95 (1)
| | | tick: 0
0x090| ff 20 | . | event: "midi_channel_prefix" (65312) 0x95-0x97 (2)
0x090| ff | . | status: 255 0x95-0x96 (1)
0x090| 20 | | event: "midi_channel_prefix" (32) 0x96-0x97 (1)
0x090| 01 0d | .. | channel: 13 0x97-0x99 (2)
| | | [11]{}: midi_port 0x99-0x9e (5)
| | | time{}: 0x99-0x9a (1)
0x090| 00 | . | delta: 0 0x99-0x9a (1)
| | | tick: 0
0x090| ff 21 | .! | event: "midi_port" (65313) 0x9a-0x9c (2)
0x090| ff | . | status: 255 0x9a-0x9b (1)
0x090| 21 | ! | event: "midi_port" (33) 0x9b-0x9c (1)
0x090| 01 70 | .p | port: 112 0x9c-0x9e (2)
| | | [12]{}: tempo 0x9e-0xa5 (7)
| | | time{}: 0x9e-0x9f (1)
0x090| 00 | . | delta: 0 0x9e-0x9f (1)
| | | tick: 0
0x090| ff| .| event: "tempo" (65361) 0x9f-0xa1 (2)
0x0a0|51 |Q |
0x090| ff| .| status: 255 0x9f-0xa0 (1)
0x0a0|51 |Q | event: "tempo" (81) 0xa0-0xa1 (1)
0x0a0| 03 07 a1 20 | ... | tempo: 500000 0xa1-0xa5 (4)
| | | [13]{}: smpte_offset 0xa5-0xae (9)
| | | time{}: 0xa5-0xa6 (1)
0x0a0| 00 | . | delta: 0 0xa5-0xa6 (1)
| | | tick: 0
0x0a0| ff 54 | .T | event: "smpte_offset" (65364) 0xa6-0xa8 (2)
0x0a0| ff | . | status: 255 0xa6-0xa7 (1)
0x0a0| 54 | T | event: "smpte_offset" (84) 0xa7-0xa8 (1)
| | | offset{}: 0xa8-0xae (6)
0x0a0| 05 4d 2d 3b 07 27 | .M-;.' | bytes: "[77 45 59 7 39]" 0xa8-0xae (6)
| | | framerate: 25 (1) 0xae-0xae (0)
@ -115,30 +126,31 @@ $ fq -d midi dv format-0.mid
| | | time{}: 0xae-0xaf (1)
0x0a0| 00 | . | delta: 0 0xae-0xaf (1)
| | | tick: 0
0x0a0| ff| .| event: "time_signature" (65368) 0xaf-0xb1 (2)
0x0b0|58 |X |
0x0a0| ff| .| status: 255 0xaf-0xb0 (1)
0x0b0|58 |X | event: "time_signature" (88) 0xb0-0xb1 (1)
| | | signature{}: 0xb1-0xb6 (5)
0x0b0| 04 04 02 18 08 | ..... | bytes: "[4 2 24 8]" 0xb1-0xb6 (5)
| | | numerator: 4
| | | denominator: 4
| | | ticks_per_click: 24
| | | thirty_seconds_per_quarter: 8
0x0b0| 04 | . | length: 4 0xb1-0xb2 (1)
0x0b0| 04 | . | numerator: 4 0xb2-0xb3 (1)
0x0b0| 02 | . | denominator: 4 0xb3-0xb4 (1)
0x0b0| 18 | . | ticks_per_click: 24 0xb4-0xb5 (1)
0x0b0| 08 | . | thirty_seconds_per_quarter: 8 0xb5-0xb6 (1)
| | | [15]{}: key_signature 0xb6-0xbc (6)
| | | time{}: 0xb6-0xb7 (1)
0x0b0| 00 | . | delta: 0 0xb6-0xb7 (1)
| | | tick: 0
0x0b0| ff 59 | .Y | event: "key_signature" (65369) 0xb7-0xb9 (2)
0x0b0| ff | . | status: 255 0xb7-0xb8 (1)
0x0b0| 59 | Y | event: "key_signature" (89) 0xb8-0xb9 (1)
0x0b0| 02 00 01 | ... | key: "A minor" (1) 0xb9-0xbc (3)
| | | [16]{}: sequencer_specific_event 0xbc-0xc6 (10)
| | | time{}: 0xbc-0xbd (1)
0x0b0| 00 | . | delta: 0 0xbc-0xbd (1)
| | | tick: 0
0x0b0| ff 7f | .. | event: "sequencer_specific_event" (65407) 0xbd-0xbf (2)
0x0b0| ff | . | status: 255 0xbd-0xbe (1)
0x0b0| 7f | . | event: "sequencer_specific_event" (127) 0xbe-0xbf (1)
| | | info{}: 0xbf-0xc6 (7)
0x0b0| 06| .| bytes: "[0 0 59 58 76 94]" 0xbf-0xc6 (7)
0x0c0|00 00 3b 3a 4c 5e |..;:L^ |
| | | manufacturer: "Mark Of The Unicorn (MOTU)" ("003B")
| | | data: "[58 76 94]"
0x0b0| 06| .| length: 6 0xbf-0xc0 (1)
0x0c0|00 00 3b |..; | manufacturer: "Mark Of The Unicorn (MOTU)" ("003B") 0xc0-0xc3 (3)
0x0c0| 3a 4c 5e | :L^ | data: raw bits 0xc3-0xc6 (3)
| | | [17]{}: note_off 0xc6-0xcb (5)
| | | time{}: 0xc6-0xc8 (2)
0x0c0| 83 60 | .` | delta: 480 0xc6-0xc8 (2)
@ -265,5 +277,6 @@ $ fq -d midi dv format-0.mid
| | | time{}: 0x114-0x115 (1)
0x110| 00 | . | delta: 0 0x114-0x115 (1)
| | | tick: 1020
0x110| ff 2f | ./ | event: "end_of_track" (65327) 0x115-0x117 (2)
0x110| ff | . | status: 255 0x115-0x116 (1)
0x110| 2f | / | event: "end_of_track" (47) 0x116-0x117 (1)
0x110| 00| | .| | length: 0 0x117-0x118 (1)

View File

@ -17,32 +17,35 @@ $ fq -d midi dv format-1.mid
| | | time{}: 0x16-0x17 (1)
0x010| 00 | . | delta: 0 0x16-0x17 (1)
| | | tick: 0
0x010| ff 03 | .. | event: "track_name" (65283) 0x17-0x19 (2)
0x010| ff | . | status: 255 0x17-0x18 (1)
0x010| 03 | . | event: "track_name" (3) 0x18-0x19 (1)
0x010| 08 46 6f 72 6d 61 74| .Format| name: "Format 1" 0x19-0x22 (9)
0x020|20 31 | 1 |
| | | [1]{}: tempo 0x22-0x29 (7)
| | | time{}: 0x22-0x23 (1)
0x020| 00 | . | delta: 0 0x22-0x23 (1)
| | | tick: 0
0x020| ff 51 | .Q | event: "tempo" (65361) 0x23-0x25 (2)
0x020| ff | . | status: 255 0x23-0x24 (1)
0x020| 51 | Q | event: "tempo" (81) 0x24-0x25 (1)
0x020| 03 07 a1 20 | ... | tempo: 500000 0x25-0x29 (4)
| | | [2]{}: time_signature 0x29-0x31 (8)
| | | time{}: 0x29-0x2a (1)
0x020| 00 | . | delta: 0 0x29-0x2a (1)
| | | tick: 0
0x020| ff 58 | .X | event: "time_signature" (65368) 0x2a-0x2c (2)
0x020| ff | . | status: 255 0x2a-0x2b (1)
0x020| 58 | X | event: "time_signature" (88) 0x2b-0x2c (1)
| | | signature{}: 0x2c-0x31 (5)
0x020| 04 04 02 18| ....| bytes: "[4 2 24 8]" 0x2c-0x31 (5)
0x030|08 |. |
| | | numerator: 4
| | | denominator: 4
| | | ticks_per_click: 24
| | | thirty_seconds_per_quarter: 8
0x020| 04 | . | length: 4 0x2c-0x2d (1)
0x020| 04 | . | numerator: 4 0x2d-0x2e (1)
0x020| 02 | . | denominator: 4 0x2e-0x2f (1)
0x020| 18| .| ticks_per_click: 24 0x2f-0x30 (1)
0x030|08 |. | thirty_seconds_per_quarter: 8 0x30-0x31 (1)
| | | [3]{}: end_of_track 0x31-0x35 (4)
| | | time{}: 0x31-0x32 (1)
0x030| 00 | . | delta: 0 0x31-0x32 (1)
| | | tick: 0
0x030| ff 2f | ./ | event: "end_of_track" (65327) 0x32-0x34 (2)
0x030| ff | . | status: 255 0x32-0x33 (1)
0x030| 2f | / | event: "end_of_track" (47) 0x33-0x34 (1)
0x030| 00 | . | length: 0 0x34-0x35 (1)
| | | [1]{}: track 0x35-0x137 (258)
0x030| 4d 54 72 6b | MTrk | tag: "MTrk" 0x35-0x39 (4)
@ -52,85 +55,98 @@ $ fq -d midi dv format-1.mid
| | | time{}: 0x3d-0x3e (1)
0x030| 00 | . | delta: 0 0x3d-0x3e (1)
| | | tick: 0
0x030| ff 00| ..| event: "sequence_number" (65280) 0x3e-0x40 (2)
0x030| ff | . | status: 255 0x3e-0x3f (1)
0x030| 00| .| event: "sequence_number" (0) 0x3f-0x40 (1)
0x040|02 00 17 |... | sequence_number: 23 0x40-0x43 (3)
| | | [1]{}: text 0x43-0x54 (17)
| | | time{}: 0x43-0x44 (1)
0x040| 00 | . | delta: 0 0x43-0x44 (1)
| | | tick: 0
0x040| ff 01 | .. | event: "text" (65281) 0x44-0x46 (2)
0x040| ff | . | status: 255 0x44-0x45 (1)
0x040| 01 | . | event: "text" (1) 0x45-0x46 (1)
0x040| 0d 54 68 69 73 20 61 6e 64 20| .This and | text: "This and That" 0x46-0x54 (14)
0x050|54 68 61 74 |That |
| | | [2]{}: copyright 0x54-0x5c (8)
| | | time{}: 0x54-0x55 (1)
0x050| 00 | . | delta: 0 0x54-0x55 (1)
| | | tick: 0
0x050| ff 02 | .. | event: "copyright" (65282) 0x55-0x57 (2)
0x050| ff | . | status: 255 0x55-0x56 (1)
0x050| 02 | . | event: "copyright" (2) 0x56-0x57 (1)
0x050| 04 54 68 65 6d | .Them | copyright: "Them" 0x57-0x5c (5)
| | | [3]{}: track_name 0x5c-0x6f (19)
| | | time{}: 0x5c-0x5d (1)
0x050| 00 | . | delta: 0 0x5c-0x5d (1)
| | | tick: 0
0x050| ff 03 | .. | event: "track_name" (65283) 0x5d-0x5f (2)
0x050| ff | . | status: 255 0x5d-0x5e (1)
0x050| 03 | . | event: "track_name" (3) 0x5e-0x5f (1)
0x050| 0f| .| name: "Acoustic Guitar" 0x5f-0x6f (16)
0x060|41 63 6f 75 73 74 69 63 20 47 75 69 74 61 72 |Acoustic Guitar |
| | | [4]{}: instrument_name 0x6f-0x7d (14)
| | | time{}: 0x6f-0x70 (1)
0x060| 00| .| delta: 0 0x6f-0x70 (1)
| | | tick: 0
0x070|ff 04 |.. | event: "instrument_name" (65284) 0x70-0x72 (2)
0x070|ff |. | status: 255 0x70-0x71 (1)
0x070| 04 | . | event: "instrument_name" (4) 0x71-0x72 (1)
0x070| 0a 44 69 64 67 65 72 69 64 6f 6f | .Didgeridoo | instrument: "Didgeridoo" 0x72-0x7d (11)
| | | [5]{}: lyric 0x7d-0x89 (12)
| | | time{}: 0x7d-0x7e (1)
0x070| 00 | . | delta: 0 0x7d-0x7e (1)
| | | tick: 0
0x070| ff 05| ..| event: "lyric" (65285) 0x7e-0x80 (2)
0x070| ff | . | status: 255 0x7e-0x7f (1)
0x070| 05| .| event: "lyric" (5) 0x7f-0x80 (1)
0x080|08 4c 61 2d 6c 61 2d 6c 61 |.La-la-la | lyric: "La-la-la" 0x80-0x89 (9)
| | | [6]{}: marker 0x89-0x9c (19)
| | | time{}: 0x89-0x8a (1)
0x080| 00 | . | delta: 0 0x89-0x8a (1)
| | | tick: 0
0x080| ff 06 | .. | event: "marker" (65286) 0x8a-0x8c (2)
0x080| ff | . | status: 255 0x8a-0x8b (1)
0x080| 06 | . | event: "marker" (6) 0x8b-0x8c (1)
0x080| 0f 48 65 72| .Her| marker: "Here Be Dragons" 0x8c-0x9c (16)
0x090|65 20 42 65 20 44 72 61 67 6f 6e 73 |e Be Dragons |
| | | [7]{}: cue_point 0x9c-0xac (16)
| | | time{}: 0x9c-0x9d (1)
0x090| 00 | . | delta: 0 0x9c-0x9d (1)
| | | tick: 0
0x090| ff 07 | .. | event: "cue_point" (65287) 0x9d-0x9f (2)
0x090| ff | . | status: 255 0x9d-0x9e (1)
0x090| 07 | . | event: "cue_point" (7) 0x9e-0x9f (1)
0x090| 0c| .| cue: "More cowbell" 0x9f-0xac (13)
0x0a0|4d 6f 72 65 20 63 6f 77 62 65 6c 6c |More cowbell |
| | | [8]{}: program_name 0xac-0xb6 (10)
| | | time{}: 0xac-0xad (1)
0x0a0| 00 | . | delta: 0 0xac-0xad (1)
| | | tick: 0
0x0a0| ff 08 | .. | event: "program_name" (65288) 0xad-0xaf (2)
0x0a0| ff | . | status: 255 0xad-0xae (1)
0x0a0| 08 | . | event: "program_name" (8) 0xae-0xaf (1)
0x0a0| 06| .| program: "Escape" 0xaf-0xb6 (7)
0x0b0|45 73 63 61 70 65 |Escape |
| | | [9]{}: device_name 0xb6-0xc2 (12)
| | | time{}: 0xb6-0xb7 (1)
0x0b0| 00 | . | delta: 0 0xb6-0xb7 (1)
| | | tick: 0
0x0b0| ff 09 | .. | event: "device_name" (65289) 0xb7-0xb9 (2)
0x0b0| ff | . | status: 255 0xb7-0xb8 (1)
0x0b0| 09 | . | event: "device_name" (9) 0xb8-0xb9 (1)
0x0b0| 08 54 68 65 54 68 69| .TheThi| device: "TheThing" 0xb9-0xc2 (9)
0x0c0|6e 67 |ng |
| | | [10]{}: midi_channel_prefix 0xc2-0xc7 (5)
| | | time{}: 0xc2-0xc3 (1)
0x0c0| 00 | . | delta: 0 0xc2-0xc3 (1)
| | | tick: 0
0x0c0| ff 20 | . | event: "midi_channel_prefix" (65312) 0xc3-0xc5 (2)
0x0c0| ff | . | status: 255 0xc3-0xc4 (1)
0x0c0| 20 | | event: "midi_channel_prefix" (32) 0xc4-0xc5 (1)
0x0c0| 01 0d | .. | channel: 13 0xc5-0xc7 (2)
| | | [11]{}: midi_port 0xc7-0xcc (5)
| | | time{}: 0xc7-0xc8 (1)
0x0c0| 00 | . | delta: 0 0xc7-0xc8 (1)
| | | tick: 0
0x0c0| ff 21 | .! | event: "midi_port" (65313) 0xc8-0xca (2)
0x0c0| ff | . | status: 255 0xc8-0xc9 (1)
0x0c0| 21 | ! | event: "midi_port" (33) 0xc9-0xca (1)
0x0c0| 01 70 | .p | port: 112 0xca-0xcc (2)
| | | [12]{}: smpte_offset 0xcc-0xd5 (9)
| | | time{}: 0xcc-0xcd (1)
0x0c0| 00 | . | delta: 0 0xcc-0xcd (1)
| | | tick: 0
0x0c0| ff 54 | .T | event: "smpte_offset" (65364) 0xcd-0xcf (2)
0x0c0| ff | . | status: 255 0xcd-0xce (1)
0x0c0| 54 | T | event: "smpte_offset" (84) 0xce-0xcf (1)
| | | offset{}: 0xcf-0xd5 (6)
0x0c0| 05| .| bytes: "[77 45 59 7 39]" 0xcf-0xd5 (6)
0x0d0|4d 2d 3b 07 27 |M-;.' |
@ -144,18 +160,20 @@ $ fq -d midi dv format-1.mid
| | | time{}: 0xd5-0xd6 (1)
0x0d0| 00 | . | delta: 0 0xd5-0xd6 (1)
| | | tick: 0
0x0d0| ff 59 | .Y | event: "key_signature" (65369) 0xd6-0xd8 (2)
0x0d0| ff | . | status: 255 0xd6-0xd7 (1)
0x0d0| 59 | Y | event: "key_signature" (89) 0xd7-0xd8 (1)
0x0d0| 02 00 01 | ... | key: "A minor" (1) 0xd8-0xdb (3)
| | | [14]{}: sequencer_specific_event 0xdb-0xe5 (10)
| | | time{}: 0xdb-0xdc (1)
0x0d0| 00 | . | delta: 0 0xdb-0xdc (1)
| | | tick: 0
0x0d0| ff 7f | .. | event: "sequencer_specific_event" (65407) 0xdc-0xde (2)
0x0d0| ff | . | status: 255 0xdc-0xdd (1)
0x0d0| 7f | . | event: "sequencer_specific_event" (127) 0xdd-0xde (1)
| | | info{}: 0xde-0xe5 (7)
0x0d0| 06 00| ..| bytes: "[0 0 59 58 76 94]" 0xde-0xe5 (7)
0x0e0|00 3b 3a 4c 5e |.;:L^ |
| | | manufacturer: "Mark Of The Unicorn (MOTU)" ("003B")
| | | data: "[58 76 94]"
0x0d0| 06 | . | length: 6 0xde-0xdf (1)
0x0d0| 00| .| manufacturer: "Mark Of The Unicorn (MOTU)" ("003B") 0xdf-0xe2 (3)
0x0e0|00 3b |.; |
0x0e0| 3a 4c 5e | :L^ | data: raw bits 0xe2-0xe5 (3)
| | | [15]{}: note_off 0xe5-0xea (5)
| | | time{}: 0xe5-0xe7 (2)
0x0e0| 83 60 | .` | delta: 480 0xe5-0xe7 (2)
@ -282,5 +300,6 @@ $ fq -d midi dv format-1.mid
| | | time{}: 0x133-0x134 (1)
0x130| 00 | . | delta: 0 0x133-0x134 (1)
| | | tick: 1020
0x130| ff 2f | ./ | event: "end_of_track" (65327) 0x134-0x136 (2)
0x130| ff | . | status: 255 0x134-0x135 (1)
0x130| 2f | / | event: "end_of_track" (47) 0x135-0x136 (1)
0x130| 00| | .| | length: 0 0x136-0x137 (1)

View File

@ -17,89 +17,103 @@ $ fq -d midi dv format-2.mid
| | | time{}: 0x16-0x17 (1)
0x010| 00 | . | delta: 0 0x16-0x17 (1)
| | | tick: 0
0x010| ff 00 | .. | event: "sequence_number" (65280) 0x17-0x19 (2)
0x010| ff | . | status: 255 0x17-0x18 (1)
0x010| 00 | . | event: "sequence_number" (0) 0x18-0x19 (1)
0x010| 02 00 17 | ... | sequence_number: 23 0x19-0x1c (3)
| | | [1]{}: text 0x1c-0x2d (17)
| | | time{}: 0x1c-0x1d (1)
0x010| 00 | . | delta: 0 0x1c-0x1d (1)
| | | tick: 0
0x010| ff 01 | .. | event: "text" (65281) 0x1d-0x1f (2)
0x010| ff | . | status: 255 0x1d-0x1e (1)
0x010| 01 | . | event: "text" (1) 0x1e-0x1f (1)
0x010| 0d| .| text: "This and That" 0x1f-0x2d (14)
0x020|54 68 69 73 20 61 6e 64 20 54 68 61 74 |This and That |
| | | [2]{}: copyright 0x2d-0x35 (8)
| | | time{}: 0x2d-0x2e (1)
0x020| 00 | . | delta: 0 0x2d-0x2e (1)
| | | tick: 0
0x020| ff 02| ..| event: "copyright" (65282) 0x2e-0x30 (2)
0x020| ff | . | status: 255 0x2e-0x2f (1)
0x020| 02| .| event: "copyright" (2) 0x2f-0x30 (1)
0x030|04 54 68 65 6d |.Them | copyright: "Them" 0x30-0x35 (5)
| | | [3]{}: track_name 0x35-0x43 (14)
| | | time{}: 0x35-0x36 (1)
0x030| 00 | . | delta: 0 0x35-0x36 (1)
| | | tick: 0
0x030| ff 03 | .. | event: "track_name" (65283) 0x36-0x38 (2)
0x030| ff | . | status: 255 0x36-0x37 (1)
0x030| 03 | . | event: "track_name" (3) 0x37-0x38 (1)
0x030| 0a 4c 65 66 74 20 54 72| .Left Tr| name: "Left Track" 0x38-0x43 (11)
0x040|61 63 6b |ack |
| | | [4]{}: instrument_name 0x43-0x51 (14)
| | | time{}: 0x43-0x44 (1)
0x040| 00 | . | delta: 0 0x43-0x44 (1)
| | | tick: 0
0x040| ff 04 | .. | event: "instrument_name" (65284) 0x44-0x46 (2)
0x040| ff | . | status: 255 0x44-0x45 (1)
0x040| 04 | . | event: "instrument_name" (4) 0x45-0x46 (1)
0x040| 0a 44 69 64 67 65 72 69 64 6f| .Didgerido| instrument: "Didgeridoo" 0x46-0x51 (11)
0x050|6f |o |
| | | [5]{}: lyric 0x51-0x5d (12)
| | | time{}: 0x51-0x52 (1)
0x050| 00 | . | delta: 0 0x51-0x52 (1)
| | | tick: 0
0x050| ff 05 | .. | event: "lyric" (65285) 0x52-0x54 (2)
0x050| ff | . | status: 255 0x52-0x53 (1)
0x050| 05 | . | event: "lyric" (5) 0x53-0x54 (1)
0x050| 08 4c 61 2d 6c 61 2d 6c 61 | .La-la-la | lyric: "La-la-la" 0x54-0x5d (9)
| | | [6]{}: marker 0x5d-0x70 (19)
| | | time{}: 0x5d-0x5e (1)
0x050| 00 | . | delta: 0 0x5d-0x5e (1)
| | | tick: 0
0x050| ff 06| ..| event: "marker" (65286) 0x5e-0x60 (2)
0x050| ff | . | status: 255 0x5e-0x5f (1)
0x050| 06| .| event: "marker" (6) 0x5f-0x60 (1)
0x060|0f 48 65 72 65 20 42 65 20 44 72 61 67 6f 6e 73|.Here Be Dragons| marker: "Here Be Dragons" 0x60-0x70 (16)
| | | [7]{}: cue_point 0x70-0x80 (16)
| | | time{}: 0x70-0x71 (1)
0x070|00 |. | delta: 0 0x70-0x71 (1)
| | | tick: 0
0x070| ff 07 | .. | event: "cue_point" (65287) 0x71-0x73 (2)
0x070| ff | . | status: 255 0x71-0x72 (1)
0x070| 07 | . | event: "cue_point" (7) 0x72-0x73 (1)
0x070| 0c 4d 6f 72 65 20 63 6f 77 62 65 6c 6c| .More cowbell| cue: "More cowbell" 0x73-0x80 (13)
| | | [8]{}: program_name 0x80-0x8a (10)
| | | time{}: 0x80-0x81 (1)
0x080|00 |. | delta: 0 0x80-0x81 (1)
| | | tick: 0
0x080| ff 08 | .. | event: "program_name" (65288) 0x81-0x83 (2)
0x080| ff | . | status: 255 0x81-0x82 (1)
0x080| 08 | . | event: "program_name" (8) 0x82-0x83 (1)
0x080| 06 45 73 63 61 70 65 | .Escape | program: "Escape" 0x83-0x8a (7)
| | | [9]{}: device_name 0x8a-0x96 (12)
| | | time{}: 0x8a-0x8b (1)
0x080| 00 | . | delta: 0 0x8a-0x8b (1)
| | | tick: 0
0x080| ff 09 | .. | event: "device_name" (65289) 0x8b-0x8d (2)
0x080| ff | . | status: 255 0x8b-0x8c (1)
0x080| 09 | . | event: "device_name" (9) 0x8c-0x8d (1)
0x080| 08 54 68| .Th| device: "TheThing" 0x8d-0x96 (9)
0x090|65 54 68 69 6e 67 |eThing |
| | | [10]{}: midi_channel_prefix 0x96-0x9b (5)
| | | time{}: 0x96-0x97 (1)
0x090| 00 | . | delta: 0 0x96-0x97 (1)
| | | tick: 0
0x090| ff 20 | . | event: "midi_channel_prefix" (65312) 0x97-0x99 (2)
0x090| ff | . | status: 255 0x97-0x98 (1)
0x090| 20 | | event: "midi_channel_prefix" (32) 0x98-0x99 (1)
0x090| 01 0d | .. | channel: 13 0x99-0x9b (2)
| | | [11]{}: midi_port 0x9b-0xa0 (5)
| | | time{}: 0x9b-0x9c (1)
0x090| 00 | . | delta: 0 0x9b-0x9c (1)
| | | tick: 0
0x090| ff 21 | .! | event: "midi_port" (65313) 0x9c-0x9e (2)
0x090| ff | . | status: 255 0x9c-0x9d (1)
0x090| 21 | ! | event: "midi_port" (33) 0x9d-0x9e (1)
0x090| 01 70| .p| port: 112 0x9e-0xa0 (2)
| | | [12]{}: tempo 0xa0-0xa7 (7)
| | | time{}: 0xa0-0xa1 (1)
0x0a0|00 |. | delta: 0 0xa0-0xa1 (1)
| | | tick: 0
0x0a0| ff 51 | .Q | event: "tempo" (65361) 0xa1-0xa3 (2)
0x0a0| ff | . | status: 255 0xa1-0xa2 (1)
0x0a0| 51 | Q | event: "tempo" (81) 0xa2-0xa3 (1)
0x0a0| 03 07 a1 20 | ... | tempo: 500000 0xa3-0xa7 (4)
| | | [13]{}: smpte_offset 0xa7-0xb0 (9)
| | | time{}: 0xa7-0xa8 (1)
0x0a0| 00 | . | delta: 0 0xa7-0xa8 (1)
| | | tick: 0
0x0a0| ff 54 | .T | event: "smpte_offset" (65364) 0xa8-0xaa (2)
0x0a0| ff | . | status: 255 0xa8-0xa9 (1)
0x0a0| 54 | T | event: "smpte_offset" (84) 0xa9-0xaa (1)
| | | offset{}: 0xaa-0xb0 (6)
0x0a0| 05 4d 2d 3b 07 27| .M-;.'| bytes: "[77 45 59 7 39]" 0xaa-0xb0 (6)
| | | framerate: 25 (1) 0xb0-0xb0 (0)
@ -112,29 +126,31 @@ $ fq -d midi dv format-2.mid
| | | time{}: 0xb0-0xb1 (1)
0x0b0|00 |. | delta: 0 0xb0-0xb1 (1)
| | | tick: 0
0x0b0| ff 58 | .X | event: "time_signature" (65368) 0xb1-0xb3 (2)
0x0b0| ff | . | status: 255 0xb1-0xb2 (1)
0x0b0| 58 | X | event: "time_signature" (88) 0xb2-0xb3 (1)
| | | signature{}: 0xb3-0xb8 (5)
0x0b0| 04 04 02 18 08 | ..... | bytes: "[4 2 24 8]" 0xb3-0xb8 (5)
| | | numerator: 4
| | | denominator: 4
| | | ticks_per_click: 24
| | | thirty_seconds_per_quarter: 8
0x0b0| 04 | . | length: 4 0xb3-0xb4 (1)
0x0b0| 04 | . | numerator: 4 0xb4-0xb5 (1)
0x0b0| 02 | . | denominator: 4 0xb5-0xb6 (1)
0x0b0| 18 | . | ticks_per_click: 24 0xb6-0xb7 (1)
0x0b0| 08 | . | thirty_seconds_per_quarter: 8 0xb7-0xb8 (1)
| | | [15]{}: key_signature 0xb8-0xbe (6)
| | | time{}: 0xb8-0xb9 (1)
0x0b0| 00 | . | delta: 0 0xb8-0xb9 (1)
| | | tick: 0
0x0b0| ff 59 | .Y | event: "key_signature" (65369) 0xb9-0xbb (2)
0x0b0| ff | . | status: 255 0xb9-0xba (1)
0x0b0| 59 | Y | event: "key_signature" (89) 0xba-0xbb (1)
0x0b0| 02 00 01 | ... | key: "A minor" (1) 0xbb-0xbe (3)
| | | [16]{}: sequencer_specific_event 0xbe-0xc8 (10)
| | | time{}: 0xbe-0xbf (1)
0x0b0| 00 | . | delta: 0 0xbe-0xbf (1)
| | | tick: 0
0x0b0| ff| .| event: "sequencer_specific_event" (65407) 0xbf-0xc1 (2)
0x0c0|7f |. |
0x0b0| ff| .| status: 255 0xbf-0xc0 (1)
0x0c0|7f |. | event: "sequencer_specific_event" (127) 0xc0-0xc1 (1)
| | | info{}: 0xc1-0xc8 (7)
0x0c0| 06 00 00 3b 3a 4c 5e | ...;:L^ | bytes: "[0 0 59 58 76 94]" 0xc1-0xc8 (7)
| | | manufacturer: "Mark Of The Unicorn (MOTU)" ("003B")
| | | data: "[58 76 94]"
0x0c0| 06 | . | length: 6 0xc1-0xc2 (1)
0x0c0| 00 00 3b | ..; | manufacturer: "Mark Of The Unicorn (MOTU)" ("003B") 0xc2-0xc5 (3)
0x0c0| 3a 4c 5e | :L^ | data: raw bits 0xc5-0xc8 (3)
| | | [17]{}: note_off 0xc8-0xcd (5)
| | | time{}: 0xc8-0xca (2)
0x0c0| 83 60 | .` | delta: 480 0xc8-0xca (2)
@ -263,7 +279,8 @@ $ fq -d midi dv format-2.mid
| | | time{}: 0x116-0x117 (1)
0x110| 00 | . | delta: 0 0x116-0x117 (1)
| | | tick: 1020
0x110| ff 2f | ./ | event: "end_of_track" (65327) 0x117-0x119 (2)
0x110| ff | . | status: 255 0x117-0x118 (1)
0x110| 2f | / | event: "end_of_track" (47) 0x118-0x119 (1)
0x110| 00 | . | length: 0 0x119-0x11a (1)
| | | [1]{}: track 0x11a-0x227 (269)
0x110| 4d 54 72 6b | MTrk | tag: "MTrk" 0x11a-0x11e (4)
@ -398,33 +415,37 @@ $ fq -d midi dv format-2.mid
| | | time{}: 0x170-0x171 (1)
0x170|00 |. | delta: 0 0x170-0x171 (1)
| | | tick: 1020
0x170| ff 7f | .. | event: "sequencer_specific_event" (65407) 0x171-0x173 (2)
0x170| ff | . | status: 255 0x171-0x172 (1)
0x170| 7f | . | event: "sequencer_specific_event" (127) 0x172-0x173 (1)
| | | info{}: 0x173-0x17a (7)
0x170| 06 00 00 3b 3a 4c 5e | ...;:L^ | bytes: "[0 0 59 58 76 94]" 0x173-0x17a (7)
| | | manufacturer: "Mark Of The Unicorn (MOTU)" ("003B")
| | | data: "[58 76 94]"
0x170| 06 | . | length: 6 0x173-0x174 (1)
0x170| 00 00 3b | ..; | manufacturer: "Mark Of The Unicorn (MOTU)" ("003B") 0x174-0x177 (3)
0x170| 3a 4c 5e | :L^ | data: raw bits 0x177-0x17a (3)
| | | [17]{}: key_signature 0x17a-0x180 (6)
| | | time{}: 0x17a-0x17b (1)
0x170| 00 | . | delta: 0 0x17a-0x17b (1)
| | | tick: 1020
0x170| ff 59 | .Y | event: "key_signature" (65369) 0x17b-0x17d (2)
0x170| ff | . | status: 255 0x17b-0x17c (1)
0x170| 59 | Y | event: "key_signature" (89) 0x17c-0x17d (1)
0x170| 02 00 01| ...| key: "A minor" (1) 0x17d-0x180 (3)
| | | [18]{}: time_signature 0x180-0x188 (8)
| | | time{}: 0x180-0x181 (1)
0x180|00 |. | delta: 0 0x180-0x181 (1)
| | | tick: 1020
0x180| ff 58 | .X | event: "time_signature" (65368) 0x181-0x183 (2)
0x180| ff | . | status: 255 0x181-0x182 (1)
0x180| 58 | X | event: "time_signature" (88) 0x182-0x183 (1)
| | | signature{}: 0x183-0x188 (5)
0x180| 04 04 02 18 08 | ..... | bytes: "[4 2 24 8]" 0x183-0x188 (5)
| | | numerator: 4
| | | denominator: 4
| | | ticks_per_click: 24
| | | thirty_seconds_per_quarter: 8
0x180| 04 | . | length: 4 0x183-0x184 (1)
0x180| 04 | . | numerator: 4 0x184-0x185 (1)
0x180| 02 | . | denominator: 4 0x185-0x186 (1)
0x180| 18 | . | ticks_per_click: 24 0x186-0x187 (1)
0x180| 08 | . | thirty_seconds_per_quarter: 8 0x187-0x188 (1)
| | | [19]{}: smpte_offset 0x188-0x191 (9)
| | | time{}: 0x188-0x189 (1)
0x180| 00 | . | delta: 0 0x188-0x189 (1)
| | | tick: 1020
0x180| ff 54 | .T | event: "smpte_offset" (65364) 0x189-0x18b (2)
0x180| ff | . | status: 255 0x189-0x18a (1)
0x180| 54 | T | event: "smpte_offset" (84) 0x18a-0x18b (1)
| | | offset{}: 0x18b-0x191 (6)
0x180| 05 4d 2d 3b 07| .M-;.| bytes: "[77 45 59 7 39]" 0x18b-0x191 (6)
0x190|27 |' |
@ -438,90 +459,103 @@ $ fq -d midi dv format-2.mid
| | | time{}: 0x191-0x192 (1)
0x190| 00 | . | delta: 0 0x191-0x192 (1)
| | | tick: 1020
0x190| ff 51 | .Q | event: "tempo" (65361) 0x192-0x194 (2)
0x190| ff | . | status: 255 0x192-0x193 (1)
0x190| 51 | Q | event: "tempo" (81) 0x193-0x194 (1)
0x190| 03 07 a1 20 | ... | tempo: 500000 0x194-0x198 (4)
| | | [21]{}: midi_port 0x198-0x19d (5)
| | | time{}: 0x198-0x199 (1)
0x190| 00 | . | delta: 0 0x198-0x199 (1)
| | | tick: 1020
0x190| ff 21 | .! | event: "midi_port" (65313) 0x199-0x19b (2)
0x190| ff | . | status: 255 0x199-0x19a (1)
0x190| 21 | ! | event: "midi_port" (33) 0x19a-0x19b (1)
0x190| 01 70 | .p | port: 112 0x19b-0x19d (2)
| | | [22]{}: midi_channel_prefix 0x19d-0x1a2 (5)
| | | time{}: 0x19d-0x19e (1)
0x190| 00 | . | delta: 0 0x19d-0x19e (1)
| | | tick: 1020
0x190| ff 20| . | event: "midi_channel_prefix" (65312) 0x19e-0x1a0 (2)
0x190| ff | . | status: 255 0x19e-0x19f (1)
0x190| 20| | event: "midi_channel_prefix" (32) 0x19f-0x1a0 (1)
0x1a0|01 0d |.. | channel: 13 0x1a0-0x1a2 (2)
| | | [23]{}: device_name 0x1a2-0x1ae (12)
| | | time{}: 0x1a2-0x1a3 (1)
0x1a0| 00 | . | delta: 0 0x1a2-0x1a3 (1)
| | | tick: 1020
0x1a0| ff 09 | .. | event: "device_name" (65289) 0x1a3-0x1a5 (2)
0x1a0| ff | . | status: 255 0x1a3-0x1a4 (1)
0x1a0| 09 | . | event: "device_name" (9) 0x1a4-0x1a5 (1)
0x1a0| 08 54 68 65 54 68 69 6e 67 | .TheThing | device: "TheThing" 0x1a5-0x1ae (9)
| | | [24]{}: program_name 0x1ae-0x1b8 (10)
| | | time{}: 0x1ae-0x1af (1)
0x1a0| 00 | . | delta: 0 0x1ae-0x1af (1)
| | | tick: 1020
0x1a0| ff| .| event: "program_name" (65288) 0x1af-0x1b1 (2)
0x1b0|08 |. |
0x1a0| ff| .| status: 255 0x1af-0x1b0 (1)
0x1b0|08 |. | event: "program_name" (8) 0x1b0-0x1b1 (1)
0x1b0| 06 45 73 63 61 70 65 | .Escape | program: "Escape" 0x1b1-0x1b8 (7)
| | | [25]{}: cue_point 0x1b8-0x1c8 (16)
| | | time{}: 0x1b8-0x1b9 (1)
0x1b0| 00 | . | delta: 0 0x1b8-0x1b9 (1)
| | | tick: 1020
0x1b0| ff 07 | .. | event: "cue_point" (65287) 0x1b9-0x1bb (2)
0x1b0| ff | . | status: 255 0x1b9-0x1ba (1)
0x1b0| 07 | . | event: "cue_point" (7) 0x1ba-0x1bb (1)
0x1b0| 0c 4d 6f 72 65| .More| cue: "More cowbell" 0x1bb-0x1c8 (13)
0x1c0|20 63 6f 77 62 65 6c 6c | cowbell |
| | | [26]{}: marker 0x1c8-0x1db (19)
| | | time{}: 0x1c8-0x1c9 (1)
0x1c0| 00 | . | delta: 0 0x1c8-0x1c9 (1)
| | | tick: 1020
0x1c0| ff 06 | .. | event: "marker" (65286) 0x1c9-0x1cb (2)
0x1c0| ff | . | status: 255 0x1c9-0x1ca (1)
0x1c0| 06 | . | event: "marker" (6) 0x1ca-0x1cb (1)
0x1c0| 0f 48 65 72 65| .Here| marker: "Here Be Dragons" 0x1cb-0x1db (16)
0x1d0|20 42 65 20 44 72 61 67 6f 6e 73 | Be Dragons |
| | | [27]{}: lyric 0x1db-0x1e7 (12)
| | | time{}: 0x1db-0x1dc (1)
0x1d0| 00 | . | delta: 0 0x1db-0x1dc (1)
| | | tick: 1020
0x1d0| ff 05 | .. | event: "lyric" (65285) 0x1dc-0x1de (2)
0x1d0| ff | . | status: 255 0x1dc-0x1dd (1)
0x1d0| 05 | . | event: "lyric" (5) 0x1dd-0x1de (1)
0x1d0| 08 4c| .L| lyric: "La-la-la" 0x1de-0x1e7 (9)
0x1e0|61 2d 6c 61 2d 6c 61 |a-la-la |
| | | [28]{}: instrument_name 0x1e7-0x1f5 (14)
| | | time{}: 0x1e7-0x1e8 (1)
0x1e0| 00 | . | delta: 0 0x1e7-0x1e8 (1)
| | | tick: 1020
0x1e0| ff 04 | .. | event: "instrument_name" (65284) 0x1e8-0x1ea (2)
0x1e0| ff | . | status: 255 0x1e8-0x1e9 (1)
0x1e0| 04 | . | event: "instrument_name" (4) 0x1e9-0x1ea (1)
0x1e0| 0a 44 69 64 67 65| .Didge| instrument: "Didgeridoo" 0x1ea-0x1f5 (11)
0x1f0|72 69 64 6f 6f |ridoo |
| | | [29]{}: track_name 0x1f5-0x204 (15)
| | | time{}: 0x1f5-0x1f6 (1)
0x1f0| 00 | . | delta: 0 0x1f5-0x1f6 (1)
| | | tick: 1020
0x1f0| ff 03 | .. | event: "track_name" (65283) 0x1f6-0x1f8 (2)
0x1f0| ff | . | status: 255 0x1f6-0x1f7 (1)
0x1f0| 03 | . | event: "track_name" (3) 0x1f7-0x1f8 (1)
0x1f0| 0b 52 69 67 68 74 20 54| .Right T| name: "Right Track" 0x1f8-0x204 (12)
0x200|72 61 63 6b |rack |
| | | [30]{}: copyright 0x204-0x20c (8)
| | | time{}: 0x204-0x205 (1)
0x200| 00 | . | delta: 0 0x204-0x205 (1)
| | | tick: 1020
0x200| ff 02 | .. | event: "copyright" (65282) 0x205-0x207 (2)
0x200| ff | . | status: 255 0x205-0x206 (1)
0x200| 02 | . | event: "copyright" (2) 0x206-0x207 (1)
0x200| 04 54 68 65 6d | .Them | copyright: "Them" 0x207-0x20c (5)
| | | [31]{}: text 0x20c-0x21d (17)
| | | time{}: 0x20c-0x20d (1)
0x200| 00 | . | delta: 0 0x20c-0x20d (1)
| | | tick: 1020
0x200| ff 01 | .. | event: "text" (65281) 0x20d-0x20f (2)
0x200| ff | . | status: 255 0x20d-0x20e (1)
0x200| 01 | . | event: "text" (1) 0x20e-0x20f (1)
0x200| 0d| .| text: "This and That" 0x20f-0x21d (14)
0x210|54 68 69 73 20 61 6e 64 20 54 68 61 74 |This and That |
| | | [32]{}: sequence_number 0x21d-0x223 (6)
| | | time{}: 0x21d-0x21e (1)
0x210| 00 | . | delta: 0 0x21d-0x21e (1)
| | | tick: 1020
0x210| ff 00| ..| event: "sequence_number" (65280) 0x21e-0x220 (2)
0x210| ff | . | status: 255 0x21e-0x21f (1)
0x210| 00| .| event: "sequence_number" (0) 0x21f-0x220 (1)
0x220|02 00 17 |... | sequence_number: 23 0x220-0x223 (3)
| | | [33]{}: end_of_track 0x223-0x227 (4)
| | | time{}: 0x223-0x224 (1)
0x220| 00 | . | delta: 0 0x223-0x224 (1)
| | | tick: 1020
0x220| ff 2f | ./ | event: "end_of_track" (65327) 0x224-0x226 (2)
0x220| ff | . | status: 255 0x224-0x225 (1)
0x220| 2f | / | event: "end_of_track" (47) 0x225-0x226 (1)
0x220| 00| | .| | length: 0 0x226-0x227 (1)

View File

@ -18,7 +18,7 @@ Sample queries
==============
* Extract the track names from a MIDI file
fq -d midi -d midi '.. | select(.event=="track name")? | "\(.name)"' twinkle.mid
fq -d midi -d midi '.. | select(.event=="track_name")? | "\(.name)"' twinkle.mid
* Extract the tempo changes from a MIDI file
@ -26,11 +26,11 @@ Sample queries
* Extract the key changes from a MIDI file
fq -d midi '.. | select(.event=="key signature")?.key' key-signatures.mid
fq -d midi '.. | select(.event=="key_signature")?.key' key-signatures.mid
* Extract NoteOn and NoteOff events:
fq -d midi 'grep_by(.event=="note on" or .event=="note off") | "\(.event) \(.time.tick) \(.note)"' twinkle.mid
fq -d midi 'grep_by(.event=="note_on" or .event=="note_off") | "\(.event) \(.time.tick) \(.note)"' twinkle.mid
Authors
=======

View File

@ -1,3 +1,3 @@
$ /fq -d midi '.. | select(.event=="key_signature")?.key' test.mid
$ fq -d midi '.. | select(.event=="key_signature")?.key' test.mid
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
0xd0| 02 00 01 | ... |.tracks[1].events[12].key: "A minor" (1)

View File

@ -1,4 +1,4 @@
$ ./fq -d midi d key-signatures.mid
$ fq -d midi d key-signatures.mid
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: key-signatures.mid (midi)
| | | header{}:
| | | header[0:5]:
@ -17,212 +17,244 @@ $ ./fq -d midi d key-signatures.mid
| | | time{}:
0x010| 00 | . | delta: 0
| | | tick: 0
0x010| ff 03 | .. | event: "track_name" (65283)
0x010| ff | . | status: 255
0x010| 03 | . | event: "track_name" (3)
0x010| 0e 4b 65 79 20 53 69| .Key Si| name: "Key Signatures"
0x020|67 6e 61 74 75 72 65 73 |gnatures |
| | | [1]{}: key_signature
| | | time{}:
0x020| 00 | . | delta: 0
| | | tick: 0
0x020| ff 59 | .Y | event: "key_signature" (65369)
0x020| ff | . | status: 255
0x020| 59 | Y | event: "key_signature" (89)
0x020| 02 00 00 | ... | key: "C major" (0)
| | | [2]{}: key_signature
| | | time{}:
0x020| 8f 00| ..| delta: 1920
| | | tick: 0
0x030|ff 59 |.Y | event: "key_signature" (65369)
0x030|ff |. | status: 255
0x030| 59 | Y | event: "key_signature" (89)
0x030| 02 01 00 | ... | key: "G major" (256)
| | | [3]{}: key_signature
| | | time{}:
0x030| 8f 00 | .. | delta: 1920
| | | tick: 1920
0x030| ff 59 | .Y | event: "key_signature" (65369)
0x030| ff | . | status: 255
0x030| 59 | Y | event: "key_signature" (89)
0x030| 02 02 00 | ... | key: "D major" (512)
| | | [4]{}: key_signature
| | | time{}:
0x030| 8f 00 | .. | delta: 1920
| | | tick: 3840
0x030| ff 59| .Y| event: "key_signature" (65369)
0x030| ff | . | status: 255
0x030| 59| Y| event: "key_signature" (89)
0x040|02 03 00 |... | key: "A major" (768)
| | | [5]{}: key_signature
| | | time{}:
0x040| 8f 00 | .. | delta: 1920
| | | tick: 5760
0x040| ff 59 | .Y | event: "key_signature" (65369)
0x040| ff | . | status: 255
0x040| 59 | Y | event: "key_signature" (89)
0x040| 02 04 00 | ... | key: "E major" (1024)
| | | [6]{}: key_signature
| | | time{}:
0x040| 8f 00 | .. | delta: 1920
| | | tick: 7680
0x040| ff 59 | .Y | event: "key_signature" (65369)
0x040| ff | . | status: 255
0x040| 59 | Y | event: "key_signature" (89)
0x040| 02 05| ..| key: "B major" (1280)
0x050|00 |. |
| | | [7]{}: key_signature
| | | time{}:
0x050| 8f 00 | .. | delta: 1920
| | | tick: 9600
0x050| ff 59 | .Y | event: "key_signature" (65369)
0x050| ff | . | status: 255
0x050| 59 | Y | event: "key_signature" (89)
0x050| 02 06 00 | ... | key: "F♯ major" (1536)
| | | [8]{}: key_signature
| | | time{}:
0x050| 8f 00 | .. | delta: 1920
| | | tick: 11520
0x050| ff 59 | .Y | event: "key_signature" (65369)
0x050| ff | . | status: 255
0x050| 59 | Y | event: "key_signature" (89)
0x050| 02 07 00 | ... | key: "C♯ major" (1792)
| | | [9]{}: key_signature
| | | time{}:
0x050| 8f| .| delta: 1920
0x060|00 |. |
| | | tick: 13440
0x060| ff 59 | .Y | event: "key_signature" (65369)
0x060| ff | . | status: 255
0x060| 59 | Y | event: "key_signature" (89)
0x060| 02 00 00 | ... | key: "C major" (0)
| | | [10]{}: key_signature
| | | time{}:
0x060| 8f 00 | .. | delta: 1920
| | | tick: 15360
0x060| ff 59 | .Y | event: "key_signature" (65369)
0x060| ff | . | status: 255
0x060| 59 | Y | event: "key_signature" (89)
0x060| 02 ff 00 | ... | key: "F major" (65280)
| | | [11]{}: key_signature
| | | time{}:
0x060| 8f 00 | .. | delta: 1920
| | | tick: 17280
0x060| ff| .| event: "key_signature" (65369)
0x070|59 |Y |
0x060| ff| .| status: 255
0x070|59 |Y | event: "key_signature" (89)
0x070| 02 fe 00 | ... | key: "B♭ major" (65024)
| | | [12]{}: key_signature
| | | time{}:
0x070| 8f 00 | .. | delta: 1920
| | | tick: 19200
0x070| ff 59 | .Y | event: "key_signature" (65369)
0x070| ff | . | status: 255
0x070| 59 | Y | event: "key_signature" (89)
0x070| 02 fd 00 | ... | key: "E♭ major" (64768)
| | | [13]{}: key_signature
| | | time{}:
0x070| 8f 00 | .. | delta: 1920
| | | tick: 21120
0x070| ff 59 | .Y | event: "key_signature" (65369)
0x070| ff | . | status: 255
0x070| 59 | Y | event: "key_signature" (89)
0x070| 02| .| key: "A♭ major" (64512)
0x080|fc 00 |.. |
| | | [14]{}: key_signature
| | | time{}:
0x080| 8f 00 | .. | delta: 1920
| | | tick: 23040
0x080| ff 59 | .Y | event: "key_signature" (65369)
0x080| ff | . | status: 255
0x080| 59 | Y | event: "key_signature" (89)
0x080| 02 fb 00 | ... | key: "D♭ major" (64256)
| | | [15]{}: key_signature
| | | time{}:
0x080| 8f 00 | .. | delta: 1920
| | | tick: 24960
0x080| ff 59 | .Y | event: "key_signature" (65369)
0x080| ff | . | status: 255
0x080| 59 | Y | event: "key_signature" (89)
0x080| 02 fa 00| ...| key: "G♭ major" (64000)
| | | [16]{}: key_signature
| | | time{}:
0x090|8f 00 |.. | delta: 1920
| | | tick: 26880
0x090| ff 59 | .Y | event: "key_signature" (65369)
0x090| ff | . | status: 255
0x090| 59 | Y | event: "key_signature" (89)
0x090| 02 f9 00 | ... | key: "C♭ major" (63744)
| | | [17]{}: key_signature
| | | time{}:
0x090| 8f 00 | .. | delta: 1920
| | | tick: 28800
0x090| ff 59 | .Y | event: "key_signature" (65369)
0x090| ff | . | status: 255
0x090| 59 | Y | event: "key_signature" (89)
0x090| 02 00 01 | ... | key: "A minor" (1)
| | | [18]{}: key_signature
| | | time{}:
0x090| 8f 00| ..| delta: 1920
| | | tick: 30720
0x0a0|ff 59 |.Y | event: "key_signature" (65369)
0x0a0|ff |. | status: 255
0x0a0| 59 | Y | event: "key_signature" (89)
0x0a0| 02 01 01 | ... | key: "E minor" (257)
| | | [19]{}: key_signature
| | | time{}:
0x0a0| 8f 00 | .. | delta: 1920
| | | tick: 32640
0x0a0| ff 59 | .Y | event: "key_signature" (65369)
0x0a0| ff | . | status: 255
0x0a0| 59 | Y | event: "key_signature" (89)
0x0a0| 02 02 01 | ... | key: "B minor" (513)
| | | [20]{}: key_signature
| | | time{}:
0x0a0| 8f 00 | .. | delta: 1920
| | | tick: 34560
0x0a0| ff 59| .Y| event: "key_signature" (65369)
0x0a0| ff | . | status: 255
0x0a0| 59| Y| event: "key_signature" (89)
0x0b0|02 03 01 |... | key: "F♯ minor" (769)
| | | [21]{}: key_signature
| | | time{}:
0x0b0| 8f 00 | .. | delta: 1920
| | | tick: 36480
0x0b0| ff 59 | .Y | event: "key_signature" (65369)
0x0b0| ff | . | status: 255
0x0b0| 59 | Y | event: "key_signature" (89)
0x0b0| 02 04 01 | ... | key: "C♯ minor" (1025)
| | | [22]{}: key_signature
| | | time{}:
0x0b0| 8f 00 | .. | delta: 1920
| | | tick: 38400
0x0b0| ff 59 | .Y | event: "key_signature" (65369)
0x0b0| ff | . | status: 255
0x0b0| 59 | Y | event: "key_signature" (89)
0x0b0| 02 05| ..| key: "G♯ minor" (1281)
0x0c0|01 |. |
| | | [23]{}: key_signature
| | | time{}:
0x0c0| 8f 00 | .. | delta: 1920
| | | tick: 40320
0x0c0| ff 59 | .Y | event: "key_signature" (65369)
0x0c0| ff | . | status: 255
0x0c0| 59 | Y | event: "key_signature" (89)
0x0c0| 02 06 01 | ... | key: "D♯ minor" (1537)
| | | [24]{}: key_signature
| | | time{}:
0x0c0| 8f 00 | .. | delta: 1920
| | | tick: 42240
0x0c0| ff 59 | .Y | event: "key_signature" (65369)
0x0c0| ff | . | status: 255
0x0c0| 59 | Y | event: "key_signature" (89)
0x0c0| 02 07 01 | ... | key: "A♯ minor" (1793)
| | | [25]{}: key_signature
| | | time{}:
0x0c0| 8f| .| delta: 1920
0x0d0|00 |. |
| | | tick: 44160
0x0d0| ff 59 | .Y | event: "key_signature" (65369)
0x0d0| ff | . | status: 255
0x0d0| 59 | Y | event: "key_signature" (89)
0x0d0| 02 00 01 | ... | key: "A minor" (1)
| | | [26]{}: key_signature
| | | time{}:
0x0d0| 8f 00 | .. | delta: 1920
| | | tick: 46080
0x0d0| ff 59 | .Y | event: "key_signature" (65369)
0x0d0| ff | . | status: 255
0x0d0| 59 | Y | event: "key_signature" (89)
0x0d0| 02 ff 01 | ... | key: "D minor" (65281)
| | | [27]{}: key_signature
| | | time{}:
0x0d0| 9e 00 | .. | delta: 3840
| | | tick: 48000
0x0d0| ff| .| event: "key_signature" (65369)
0x0e0|59 |Y |
0x0d0| ff| .| status: 255
0x0e0|59 |Y | event: "key_signature" (89)
0x0e0| 02 fe 01 | ... | key: "G minor" (65025)
| | | [28]{}: key_signature
| | | time{}:
0x0e0| 8f 00 | .. | delta: 1920
| | | tick: 51840
0x0e0| ff 59 | .Y | event: "key_signature" (65369)
0x0e0| ff | . | status: 255
0x0e0| 59 | Y | event: "key_signature" (89)
0x0e0| 02 fd 01 | ... | key: "C minor" (64769)
| | | [29]{}: key_signature
| | | time{}:
0x0e0| 8f 00 | .. | delta: 1920
| | | tick: 53760
0x0e0| ff 59 | .Y | event: "key_signature" (65369)
0x0e0| ff | . | status: 255
0x0e0| 59 | Y | event: "key_signature" (89)
0x0e0| 02| .| key: "F minor" (64513)
0x0f0|fc 01 |.. |
| | | [30]{}: key_signature
| | | time{}:
0x0f0| 8f 00 | .. | delta: 1920
| | | tick: 55680
0x0f0| ff 59 | .Y | event: "key_signature" (65369)
0x0f0| ff | . | status: 255
0x0f0| 59 | Y | event: "key_signature" (89)
0x0f0| 02 fb 01 | ... | key: "B♭ minor" (64257)
| | | [31]{}: key_signature
| | | time{}:
0x0f0| 8f 00 | .. | delta: 1920
| | | tick: 57600
0x0f0| ff 59 | .Y | event: "key_signature" (65369)
0x0f0| ff | . | status: 255
0x0f0| 59 | Y | event: "key_signature" (89)
0x0f0| 02 fa 01| ...| key: "E♭ minor" (64001)
| | | [32]{}: key_signature
| | | time{}:
0x100|8f 00 |.. | delta: 1920
| | | tick: 59520
0x100| ff 59 | .Y | event: "key_signature" (65369)
0x100| ff | . | status: 255
0x100| 59 | Y | event: "key_signature" (89)
0x100| 02 f9 01 | ... | key: "A♭ minor" (63745)
| | | [33]{}: end_of_track
| | | time{}:
0x100| 00 | . | delta: 0
| | | tick: 61440
0x100| ff 2f | ./ | event: "end_of_track" (65327)
0x100| ff | . | status: 255
0x100| 2f | / | event: "end_of_track" (47)
0x100| 00| | .| | length: 0

View File

@ -1 +1,5 @@
$ fq -d midi 'grep_by(.event=="NoteOn" or .event=="NoteOff") | [.time.tick, .note] | join(" ")' test.mid
$ fq -d midi 'grep_by(.event=="note_on" or .event=="note_off") | [.time.tick, .note] | join(" ")' test.mid
"0 C3"
"0 C♯3/D♭3"
"0 C3"
"240 C3"

View File

@ -1 +1,3 @@
$ fq -d midi '.. | select(.event=="Tempo")?.tempo' test.mid
$ fq -d midi '.. | select(.event=="tempo")?.tempo' test.mid
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
0x20| 03 07 a1 20 | ... |.tracks[0].events[1].tempo: 500000

View File

@ -17,32 +17,35 @@ $ fq -d midi dv test.mid
| | | time{}: 0x16-0x17 (1)
0x010| 00 | . | delta: 0 0x16-0x17 (1)
| | | tick: 0
0x010| ff 03 | .. | event: "track_name" (65283) 0x17-0x19 (2)
0x010| ff | . | status: 255 0x17-0x18 (1)
0x010| 03 | . | event: "track_name" (3) 0x18-0x19 (1)
0x010| 0b 52 65 66 65 72 65| .Refere| name: "Reference-1" 0x19-0x25 (12)
0x020|6e 63 65 2d 31 |nce-1 |
| | | [1]{}: tempo 0x25-0x2c (7)
| | | time{}: 0x25-0x26 (1)
0x020| 00 | . | delta: 0 0x25-0x26 (1)
| | | tick: 0
0x020| ff 51 | .Q | event: "tempo" (65361) 0x26-0x28 (2)
0x020| ff | . | status: 255 0x26-0x27 (1)
0x020| 51 | Q | event: "tempo" (81) 0x27-0x28 (1)
0x020| 03 07 a1 20 | ... | tempo: 500000 0x28-0x2c (4)
| | | [2]{}: time_signature 0x2c-0x34 (8)
| | | time{}: 0x2c-0x2d (1)
0x020| 00 | . | delta: 0 0x2c-0x2d (1)
| | | tick: 0
0x020| ff 58 | .X | event: "time_signature" (65368) 0x2d-0x2f (2)
0x020| ff | . | status: 255 0x2d-0x2e (1)
0x020| 58 | X | event: "time_signature" (88) 0x2e-0x2f (1)
| | | signature{}: 0x2f-0x34 (5)
0x020| 04| .| bytes: "[4 2 24 8]" 0x2f-0x34 (5)
0x030|04 02 18 08 |.... |
| | | numerator: 4
| | | denominator: 4
| | | ticks_per_click: 24
| | | thirty_seconds_per_quarter: 8
0x020| 04| .| length: 4 0x2f-0x30 (1)
0x030|04 |. | numerator: 4 0x30-0x31 (1)
0x030| 02 | . | denominator: 4 0x31-0x32 (1)
0x030| 18 | . | ticks_per_click: 24 0x32-0x33 (1)
0x030| 08 | . | thirty_seconds_per_quarter: 8 0x33-0x34 (1)
| | | [3]{}: smpte_offset 0x34-0x3d (9)
| | | time{}: 0x34-0x35 (1)
0x030| 00 | . | delta: 0 0x34-0x35 (1)
| | | tick: 0
0x030| ff 54 | .T | event: "smpte_offset" (65364) 0x35-0x37 (2)
0x030| ff | . | status: 255 0x35-0x36 (1)
0x030| 54 | T | event: "smpte_offset" (84) 0x36-0x37 (1)
| | | offset{}: 0x37-0x3d (6)
0x030| 05 4d 2d 3b 07 27 | .M-;.' | bytes: "[77 45 59 7 39]" 0x37-0x3d (6)
| | | framerate: 25 (1) 0x3d-0x3d (0)
@ -55,7 +58,8 @@ $ fq -d midi dv test.mid
| | | time{}: 0x3d-0x3e (1)
0x030| 00 | . | delta: 0 0x3d-0x3e (1)
| | | tick: 0
0x030| ff 2f| ./| event: "end_of_track" (65327) 0x3e-0x40 (2)
0x030| ff | . | status: 255 0x3e-0x3f (1)
0x030| 2f| /| event: "end_of_track" (47) 0x3f-0x40 (1)
0x040|00 |. | length: 0 0x40-0x41 (1)
| | | [1]{}: track 0x41-0x13a (249)
0x040| 4d 54 72 6b | MTrk | tag: "MTrk" 0x41-0x45 (4)
@ -65,97 +69,109 @@ $ fq -d midi dv test.mid
| | | time{}: 0x49-0x4a (1)
0x040| 00 | . | delta: 0 0x49-0x4a (1)
| | | tick: 0
0x040| ff 00 | .. | event: "sequence_number" (65280) 0x4a-0x4c (2)
0x040| ff | . | status: 255 0x4a-0x4b (1)
0x040| 00 | . | event: "sequence_number" (0) 0x4b-0x4c (1)
0x040| 02 00 17 | ... | sequence_number: 23 0x4c-0x4f (3)
| | | [1]{}: text 0x4f-0x60 (17)
| | | time{}: 0x4f-0x50 (1)
0x040| 00| .| delta: 0 0x4f-0x50 (1)
| | | tick: 0
0x050|ff 01 |.. | event: "text" (65281) 0x50-0x52 (2)
0x050|ff |. | status: 255 0x50-0x51 (1)
0x050| 01 | . | event: "text" (1) 0x51-0x52 (1)
0x050| 0d 54 68 69 73 20 61 6e 64 20 54 68 61 74| .This and That| text: "This and That" 0x52-0x60 (14)
| | | [2]{}: copyright 0x60-0x68 (8)
| | | time{}: 0x60-0x61 (1)
0x060|00 |. | delta: 0 0x60-0x61 (1)
| | | tick: 0
0x060| ff 02 | .. | event: "copyright" (65282) 0x61-0x63 (2)
0x060| ff | . | status: 255 0x61-0x62 (1)
0x060| 02 | . | event: "copyright" (2) 0x62-0x63 (1)
0x060| 04 54 68 65 6d | .Them | copyright: "Them" 0x63-0x68 (5)
| | | [3]{}: track_name 0x68-0x7b (19)
| | | time{}: 0x68-0x69 (1)
0x060| 00 | . | delta: 0 0x68-0x69 (1)
| | | tick: 0
0x060| ff 03 | .. | event: "track_name" (65283) 0x69-0x6b (2)
0x060| ff | . | status: 255 0x69-0x6a (1)
0x060| 03 | . | event: "track_name" (3) 0x6a-0x6b (1)
0x060| 0f 41 63 6f 75| .Acou| name: "Acoustic Guitar" 0x6b-0x7b (16)
0x070|73 74 69 63 20 47 75 69 74 61 72 |stic Guitar |
| | | [4]{}: instrument_name 0x7b-0x89 (14)
| | | time{}: 0x7b-0x7c (1)
0x070| 00 | . | delta: 0 0x7b-0x7c (1)
| | | tick: 0
0x070| ff 04 | .. | event: "instrument_name" (65284) 0x7c-0x7e (2)
0x070| ff | . | status: 255 0x7c-0x7d (1)
0x070| 04 | . | event: "instrument_name" (4) 0x7d-0x7e (1)
0x070| 0a 44| .D| instrument: "Didgeridoo" 0x7e-0x89 (11)
0x080|69 64 67 65 72 69 64 6f 6f |idgeridoo |
| | | [5]{}: lyric 0x89-0x95 (12)
| | | time{}: 0x89-0x8a (1)
0x080| 00 | . | delta: 0 0x89-0x8a (1)
| | | tick: 0
0x080| ff 05 | .. | event: "lyric" (65285) 0x8a-0x8c (2)
0x080| ff | . | status: 255 0x8a-0x8b (1)
0x080| 05 | . | event: "lyric" (5) 0x8b-0x8c (1)
0x080| 08 4c 61 2d| .La-| lyric: "La-la-la" 0x8c-0x95 (9)
0x090|6c 61 2d 6c 61 |la-la |
| | | [6]{}: marker 0x95-0xa8 (19)
| | | time{}: 0x95-0x96 (1)
0x090| 00 | . | delta: 0 0x95-0x96 (1)
| | | tick: 0
0x090| ff 06 | .. | event: "marker" (65286) 0x96-0x98 (2)
0x090| ff | . | status: 255 0x96-0x97 (1)
0x090| 06 | . | event: "marker" (6) 0x97-0x98 (1)
0x090| 0f 48 65 72 65 20 42 65| .Here Be| marker: "Here Be Dragons" 0x98-0xa8 (16)
0x0a0|20 44 72 61 67 6f 6e 73 | Dragons |
| | | [7]{}: cue_point 0xa8-0xb8 (16)
| | | time{}: 0xa8-0xa9 (1)
0x0a0| 00 | . | delta: 0 0xa8-0xa9 (1)
| | | tick: 0
0x0a0| ff 07 | .. | event: "cue_point" (65287) 0xa9-0xab (2)
0x0a0| ff | . | status: 255 0xa9-0xaa (1)
0x0a0| 07 | . | event: "cue_point" (7) 0xaa-0xab (1)
0x0a0| 0c 4d 6f 72 65| .More| cue: "More cowbell" 0xab-0xb8 (13)
0x0b0|20 63 6f 77 62 65 6c 6c | cowbell |
| | | [8]{}: program_name 0xb8-0xc2 (10)
| | | time{}: 0xb8-0xb9 (1)
0x0b0| 00 | . | delta: 0 0xb8-0xb9 (1)
| | | tick: 0
0x0b0| ff 08 | .. | event: "program_name" (65288) 0xb9-0xbb (2)
0x0b0| ff | . | status: 255 0xb9-0xba (1)
0x0b0| 08 | . | event: "program_name" (8) 0xba-0xbb (1)
0x0b0| 06 45 73 63 61| .Esca| program: "Escape" 0xbb-0xc2 (7)
0x0c0|70 65 |pe |
| | | [9]{}: device_name 0xc2-0xce (12)
| | | time{}: 0xc2-0xc3 (1)
0x0c0| 00 | . | delta: 0 0xc2-0xc3 (1)
| | | tick: 0
0x0c0| ff 09 | .. | event: "device_name" (65289) 0xc3-0xc5 (2)
0x0c0| ff | . | status: 255 0xc3-0xc4 (1)
0x0c0| 09 | . | event: "device_name" (9) 0xc4-0xc5 (1)
0x0c0| 08 54 68 65 54 68 69 6e 67 | .TheThing | device: "TheThing" 0xc5-0xce (9)
| | | [10]{}: midi_channel_prefix 0xce-0xd3 (5)
| | | time{}: 0xce-0xcf (1)
0x0c0| 00 | . | delta: 0 0xce-0xcf (1)
| | | tick: 0
0x0c0| ff| .| event: "midi_channel_prefix" (65312) 0xcf-0xd1 (2)
0x0d0|20 | |
0x0c0| ff| .| status: 255 0xcf-0xd0 (1)
0x0d0|20 | | event: "midi_channel_prefix" (32) 0xd0-0xd1 (1)
0x0d0| 01 0d | .. | channel: 13 0xd1-0xd3 (2)
| | | [11]{}: midi_port 0xd3-0xd8 (5)
| | | time{}: 0xd3-0xd4 (1)
0x0d0| 00 | . | delta: 0 0xd3-0xd4 (1)
| | | tick: 0
0x0d0| ff 21 | .! | event: "midi_port" (65313) 0xd4-0xd6 (2)
0x0d0| ff | . | status: 255 0xd4-0xd5 (1)
0x0d0| 21 | ! | event: "midi_port" (33) 0xd5-0xd6 (1)
0x0d0| 01 70 | .p | port: 112 0xd6-0xd8 (2)
| | | [12]{}: key_signature 0xd8-0xde (6)
| | | time{}: 0xd8-0xd9 (1)
0x0d0| 00 | . | delta: 0 0xd8-0xd9 (1)
| | | tick: 0
0x0d0| ff 59 | .Y | event: "key_signature" (65369) 0xd9-0xdb (2)
0x0d0| ff | . | status: 255 0xd9-0xda (1)
0x0d0| 59 | Y | event: "key_signature" (89) 0xda-0xdb (1)
0x0d0| 02 00 01 | ... | key: "A minor" (1) 0xdb-0xde (3)
| | | [13]{}: sequencer_specific_event 0xde-0xe8 (10)
| | | time{}: 0xde-0xdf (1)
0x0d0| 00 | . | delta: 0 0xde-0xdf (1)
| | | tick: 0
0x0d0| ff| .| event: "sequencer_specific_event" (65407) 0xdf-0xe1 (2)
0x0e0|7f |. |
0x0d0| ff| .| status: 255 0xdf-0xe0 (1)
0x0e0|7f |. | event: "sequencer_specific_event" (127) 0xe0-0xe1 (1)
| | | info{}: 0xe1-0xe8 (7)
0x0e0| 06 00 00 3b 3a 4c 5e | ...;:L^ | bytes: "[0 0 59 58 76 94]" 0xe1-0xe8 (7)
| | | manufacturer: "Mark Of The Unicorn (MOTU)" ("003B")
| | | data: "[58 76 94]"
0x0e0| 06 | . | length: 6 0xe1-0xe2 (1)
0x0e0| 00 00 3b | ..; | manufacturer: "Mark Of The Unicorn (MOTU)" ("003B") 0xe2-0xe5 (3)
0x0e0| 3a 4c 5e | :L^ | data: raw bits 0xe5-0xe8 (3)
| | | [14]{}: controller 0xe8-0xec (4)
| | | time{}: 0xe8-0xe9 (1)
0x0e0| 00 | . | delta: 0 0xe8-0xe9 (1)
@ -284,5 +300,6 @@ $ fq -d midi dv test.mid
| | | time{}: 0x136-0x137 (1)
0x130| 00 | . | delta: 0 0x136-0x137 (1)
| | | tick: 1020
0x130| ff 2f | ./ | event: "end_of_track" (65327) 0x137-0x139 (2)
0x130| ff | . | status: 255 0x137-0x138 (1)
0x130| 2f | / | event: "end_of_track" (47) 0x138-0x139 (1)
0x130| 00| | .| | length: 0 0x139-0x13a (1)

View File

@ -1 +1,7 @@
$ fq -d midi '.. | select(.event=="TrackName")?.name' test.mid
$ fq -d midi '.. | select(.event=="track_name")?.name' test.mid
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
0x10| 0b 52 65 66 65 72 65| .Refere|.tracks[0].events[0].name: "Reference-1"
0x20|6e 63 65 2d 31 |nce-1 |
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
0x60| 0f 41 63 6f 75| .Acou|.tracks[1].events[3].name: "Acoustic Guitar"
0x70|73 74 69 63 20 47 75 69 74 61 72 |stic Guitar |