Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
ad0a06d
midi: initial import
twystd Aug 11, 2024
f11dfaf
midi: decoded TrackName meta event
twystd Aug 11, 2024
1bdeeb6
midi: decoded tempo metaevent
twystd Aug 12, 2024
cee51ec
midi: reworked to include delta in event
twystd Aug 13, 2024
8b236a1
midi: decoded TimeSignature meta event
twystd Aug 13, 2024
9dfcb96
midi: experimenting with struct metaevent data
twystd Aug 13, 2024
a1385ca
midi: Decoded EndOfTrack and ProgramChange events
twystd Aug 14, 2024
3276641
midi: Decoded KeySignature, NoteOn and Controller events
twystd Aug 15, 2024
d7ec38a
midi: basic test set
twystd Aug 15, 2024
cbd4a8a
midi: Decoded NoteOff event
twystd Aug 15, 2024
4fe27f5
midi: decoded remaining text metaevents
twystd Aug 16, 2024
2a16748
Merge updated branch 'master' into 'midi' branch
twystd Aug 16, 2024
109719f
midi: Decoded MIDIChannelPrefix, MIDIPort and SequencerSpecific metae…
twystd Aug 17, 2024
0226fc6
midi: Decoded PolyphonicPressure, ChannelPressure and PitchBend MIDI …
twystd Aug 17, 2024
b2e71a3
midi: accomodated MIDI event running status
twystd Aug 17, 2024
b433998
midi: decoded SysEx events
twystd Aug 17, 2024
5c89d7d
midi: moved MIDI running status and Casio flag to context struct
twystd Aug 18, 2024
34fca40
midi: mapped manufacturer IDs to strings
twystd Aug 18, 2024
0ef3304
midi: mapped note numbers to note names
twystd Aug 18, 2024
9099a3e
midi: decoded chunk tags as FieldUTF8
twystd Aug 18, 2024
4bb3292
midi: fixed key signature map
twystd Aug 18, 2024
0915f75
midi: added 'data' field to EndOfTrack event
twystd Aug 18, 2024
a41e123
midi: cleaned up SysExContinuation and SysExEscape logic
twystd Aug 18, 2024
c5637f0
midi: partly fixed gaps in SysExMessage
twystd Aug 19, 2024
f1b888b
midi: fixed gap in SequencerSpecificEvent
twystd Aug 19, 2024
fdde568
midi: (partly) fixed SMPTEOffsetEvent gap
twystd Aug 19, 2024
befdf1f
midi: reworked SysEx events as struct with length field
twystd Aug 19, 2024
ce02d6e
midi: added length field to TimeSignature struct
twystd Aug 19, 2024
a337ff0
midi: reworked sysex and metaevent 'struct' events to decode as byte …
twystd Aug 20, 2024
3809ddb
midi: combined metaevent status + event bytes
twystd Aug 20, 2024
3ed9889
midi: mapped SMPTE framerates
twystd Aug 22, 2024
54a0cf1
midi: mapped SysEx event types
twystd Aug 22, 2024
59b1faa
midi: decorated 'delta' field with running tick
twystd Aug 22, 2024
473394b
midi: added event type to events to simplify query by event
twystd Aug 23, 2024
91fa547
midi: added example queries to the test data
twystd Aug 23, 2024
0e0a669
midi: added tests for format 0, format 1 and format 2 MIDI files
twystd Aug 23, 2024
57adef4
midi: added sample queries to midi.md
twystd Aug 24, 2024
80b9343
midi: added new test and MIDI files
twystd Aug 24, 2024
e99d9f6
midi: asserted bytes left for MIDI events
twystd Aug 24, 2024
4fac4c6
midi: discarded unknown chunks
twystd Aug 25, 2024
0b4be89
midi: cleaned up unknown chunk logic
twystd Aug 25, 2024
2f2070e
midi: fixed lint warnings
twystd Aug 26, 2024
3105b7d
Added to probe group
twystd Aug 26, 2024
2a65036
midi: fixed fuzzing errors
twystd Aug 26, 2024
2970fb1
midi: lowercased event names
twystd Aug 26, 2024
36b776e
Merge branch 'master' into midi
twystd Aug 26, 2024
8995496
midi: cleaned up event decoding logic
twystd Aug 26, 2024
763d142
midi: moved 'dev only' Makefile to workdir and removed it from .gitig…
twystd Aug 27, 2024
7fd9ad2
midi: removed debug leftovers (cf. https://github.com/wader/fq/pull/1…
twystd Aug 27, 2024
dad4a91
midi: replace d.BytesLen(1) with d.U8()
twystd Aug 27, 2024
ea3e089
midi: reworked decoding to expect an MThd header as the first chunk (…
twystd Aug 27, 2024
c8d9397
midi: snake-cased event types and event names (cf. https://github.com…
twystd Aug 27, 2024
2350afe
midi: updated help text to use snake-case event names (cf. https://gi…
twystd Aug 28, 2024
b5f2bda
midi: added localised Makefile (cf. https://github.com/wader/fq/pull/…
twystd Aug 28, 2024
462ae15
midi: removed superfluous AssertLeastBytesLeft (cf. https://github.co…
twystd Aug 28, 2024
f424936
midi: fixed lint warning (cf. https://github.com/wader/fq/pull/1004#d…
twystd Aug 28, 2024
7950dd6
midi: added midi to the TestFormats all.fqtest list (cf. https://gith…
twystd Aug 28, 2024
e940f47
midi: reworked metaevent decoding for PR comments
twystd Aug 30, 2024
578b7e7
midi: restructured event decoding to decode length and struct fields …
twystd Aug 30, 2024
a7d0cde
midi: cleaned up and simplied event decoding logic
twystd Aug 31, 2024
a3a0a06
midi: simplifed and cleaned up MIDI 'fq' tests:
twystd Sep 1, 2024
17bac77
midi: removed superfluous uint64 cast (cf. https://github.com/wader/f…
twystd Sep 3, 2024
9f057b6
midi: fixes for PR comments
twystd Sep 4, 2024
87c80f5
midi: fixes for PR comments
twystd Sep 5, 2024
9c7f7f9
midi: fixes for PR comments:
twystd Sep 6, 2024
3966d5b
midi: tightened up status/event decoding logic (cf. https://github.co…
twystd Sep 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ jsonl,
macho_fat,
[markdown](doc/formats.md#markdown),
[matroska](doc/formats.md#matroska),
[midi](doc/formats.md#midi),
[moc3](doc/formats.md#moc3),
[mp3](doc/formats.md#mp3),
mp3_frame,
Expand Down
38 changes: 38 additions & 0 deletions doc/formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
|`macho_fat` |Fat&nbsp;Mach-O&nbsp;macOS&nbsp;executable&nbsp;(multi-architecture) |<sub>`macho`</sub>|
|[`markdown`](#markdown) |Markdown |<sub></sub>|
|[`matroska`](#matroska) |Matroska&nbsp;file |<sub>`aac_frame` `av1_ccr` `av1_frame` `avc_au` `avc_dcr` `flac_frame` `flac_metadatablocks` `hevc_au` `hevc_dcr` `image` `mp3_frame` `mpeg_asc` `mpeg_pes_packet` `mpeg_spu` `opus_packet` `vorbis_packet` `vp8_frame` `vp9_cfm` `vp9_frame`</sub>|
|[`midi`](#midi) |Standard&nbsp;MIDI&nbsp;file |<sub></sub>|
|[`moc3`](#moc3) |MOC3&nbsp;file |<sub></sub>|
|[`mp3`](#mp3) |MP3&nbsp;file |<sub>`id3v2` `id3v1` `id3v11` `apev2` `mp3_frame`</sub>|
|`mp3_frame` |MPEG&nbsp;audio&nbsp;layer&nbsp;3&nbsp;frame |<sub>`mp3_frame_tags`</sub>|
Expand Down Expand Up @@ -867,6 +868,43 @@ $ fq 'grep_by(.id == "Tracks") | matroska_path' file.mkv
- https://www.matroska.org/technical/codec_specs.html
- https://wiki.xiph.org/MatroskaOpus

## midi
Standard MIDI file.

### Notes

1. Only supports the MIDI 1.0 specification.
2. Does only basic validation on the MIDI data.

### Sample queries

1. Extract the track names from a MIDI file
```
fq -d midi -d midi '.. | select(.event=="Track Name")? | "\(.name)"' twinkle.mid
```

2. Extract the tempo changes from a MIDI file
```
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
```

4. Extract NoteOn and NoteOff events:
```
fq -d midi 'grep_by(.event=="Note On" or .event=="Note Off") | "\(.event) \(.time.tick) \(.note)"' twinkle.mid
```

### Authors
- [email protected]

### References

1. [The Complete MIDI 1.0 Detailed Specification](https://www.midi.org/specifications/item/the-midi-1-0-specification)

## moc3
MOC3 file.

Expand Down
2 changes: 2 additions & 0 deletions format/all/all.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ $ fq -n _registry.groups.probe
"macho",
"macho_fat",
"matroska",
"midi",
"moc3",
"mp4",
"nes",
Expand Down Expand Up @@ -126,6 +127,7 @@ macho Mach-O macOS executable
macho_fat Fat Mach-O macOS executable (multi-architecture)
markdown Markdown
matroska Matroska file
midi Standard MIDI file
moc3 MOC3 file
mp3 MP3 file
mp3_frame MPEG audio layer 3 frame
Expand Down
1 change: 1 addition & 0 deletions format/all/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
_ "github.com/wader/fq/format/markdown"
_ "github.com/wader/fq/format/math"
_ "github.com/wader/fq/format/matroska"
_ "github.com/wader/fq/format/midi"
_ "github.com/wader/fq/format/moc3"
_ "github.com/wader/fq/format/mp3"
_ "github.com/wader/fq/format/mp4"
Expand Down
1 change: 1 addition & 0 deletions format/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ var (
MachO_Fat = &decode.Group{Name: "macho_fat"}
Markdown = &decode.Group{Name: "markdown"}
Matroska = &decode.Group{Name: "matroska"}
MIDI = &decode.Group{Name: "midi"}
MOC3 = &decode.Group{Name: "moc3"}
MP3 = &decode.Group{Name: "mp3"}
MP3_Frame = &decode.Group{Name: "mp3_frame"}
Expand Down
2 changes: 2 additions & 0 deletions format/midi/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
workdir
Loading