-
Notifications
You must be signed in to change notification settings - Fork 243
MIDI file decoder #1004
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
MIDI file decoder #1004
Changes from all commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
ad0a06d
midi: initial import
twystd f11dfaf
midi: decoded TrackName meta event
twystd 1bdeeb6
midi: decoded tempo metaevent
twystd cee51ec
midi: reworked to include delta in event
twystd 8b236a1
midi: decoded TimeSignature meta event
twystd 9dfcb96
midi: experimenting with struct metaevent data
twystd a1385ca
midi: Decoded EndOfTrack and ProgramChange events
twystd 3276641
midi: Decoded KeySignature, NoteOn and Controller events
twystd d7ec38a
midi: basic test set
twystd cbd4a8a
midi: Decoded NoteOff event
twystd 4fe27f5
midi: decoded remaining text metaevents
twystd 2a16748
Merge updated branch 'master' into 'midi' branch
twystd 109719f
midi: Decoded MIDIChannelPrefix, MIDIPort and SequencerSpecific metae…
twystd 0226fc6
midi: Decoded PolyphonicPressure, ChannelPressure and PitchBend MIDI …
twystd b2e71a3
midi: accomodated MIDI event running status
twystd b433998
midi: decoded SysEx events
twystd 5c89d7d
midi: moved MIDI running status and Casio flag to context struct
twystd 34fca40
midi: mapped manufacturer IDs to strings
twystd 0ef3304
midi: mapped note numbers to note names
twystd 9099a3e
midi: decoded chunk tags as FieldUTF8
twystd 4bb3292
midi: fixed key signature map
twystd 0915f75
midi: added 'data' field to EndOfTrack event
twystd a41e123
midi: cleaned up SysExContinuation and SysExEscape logic
twystd c5637f0
midi: partly fixed gaps in SysExMessage
twystd f1b888b
midi: fixed gap in SequencerSpecificEvent
twystd fdde568
midi: (partly) fixed SMPTEOffsetEvent gap
twystd befdf1f
midi: reworked SysEx events as struct with length field
twystd ce02d6e
midi: added length field to TimeSignature struct
twystd a337ff0
midi: reworked sysex and metaevent 'struct' events to decode as byte …
twystd 3809ddb
midi: combined metaevent status + event bytes
twystd 3ed9889
midi: mapped SMPTE framerates
twystd 54a0cf1
midi: mapped SysEx event types
twystd 59b1faa
midi: decorated 'delta' field with running tick
twystd 473394b
midi: added event type to events to simplify query by event
twystd 91fa547
midi: added example queries to the test data
twystd 0e0a669
midi: added tests for format 0, format 1 and format 2 MIDI files
twystd 57adef4
midi: added sample queries to midi.md
twystd 80b9343
midi: added new test and MIDI files
twystd e99d9f6
midi: asserted bytes left for MIDI events
twystd 4fac4c6
midi: discarded unknown chunks
twystd 0b4be89
midi: cleaned up unknown chunk logic
twystd 2f2070e
midi: fixed lint warnings
twystd 3105b7d
Added to probe group
twystd 2a65036
midi: fixed fuzzing errors
twystd 2970fb1
midi: lowercased event names
twystd 36b776e
Merge branch 'master' into midi
twystd 8995496
midi: cleaned up event decoding logic
twystd 763d142
midi: moved 'dev only' Makefile to workdir and removed it from .gitig…
twystd 7fd9ad2
midi: removed debug leftovers (cf. https://github.com/wader/fq/pull/1…
twystd dad4a91
midi: replace d.BytesLen(1) with d.U8()
twystd ea3e089
midi: reworked decoding to expect an MThd header as the first chunk (…
twystd c8d9397
midi: snake-cased event types and event names (cf. https://github.com…
twystd 2350afe
midi: updated help text to use snake-case event names (cf. https://gi…
twystd b5f2bda
midi: added localised Makefile (cf. https://github.com/wader/fq/pull/…
twystd 462ae15
midi: removed superfluous AssertLeastBytesLeft (cf. https://github.co…
twystd f424936
midi: fixed lint warning (cf. https://github.com/wader/fq/pull/1004#d…
twystd 7950dd6
midi: added midi to the TestFormats all.fqtest list (cf. https://gith…
twystd e940f47
midi: reworked metaevent decoding for PR comments
twystd 578b7e7
midi: restructured event decoding to decode length and struct fields …
twystd a7d0cde
midi: cleaned up and simplied event decoding logic
twystd a3a0a06
midi: simplifed and cleaned up MIDI 'fq' tests:
twystd 17bac77
midi: removed superfluous uint64 cast (cf. https://github.com/wader/f…
twystd 9f057b6
midi: fixes for PR comments
twystd 87c80f5
midi: fixes for PR comments
twystd 9c7f7f9
midi: fixes for PR comments:
twystd 3966d5b
midi: tightened up status/event decoding logic (cf. https://github.co…
twystd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,6 +82,7 @@ | |
| |`macho_fat` |Fat Mach-O macOS executable (multi-architecture) |<sub>`macho`</sub>| | ||
| |[`markdown`](#markdown) |Markdown |<sub></sub>| | ||
| |[`matroska`](#matroska) |Matroska 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 MIDI file |<sub></sub>| | ||
| |[`moc3`](#moc3) |MOC3 file |<sub></sub>| | ||
| |[`mp3`](#mp3) |MP3 file |<sub>`id3v2` `id3v1` `id3v11` `apev2` `mp3_frame`</sub>| | ||
| |`mp3_frame` |MPEG audio layer 3 frame |<sub>`mp3_frame_tags`</sub>| | ||
|
|
@@ -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. | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| .DS_Store | ||
| workdir |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.