1
1
mirror of https://github.com/wader/fq.git synced 2024-11-22 15:45:45 +03:00
This commit is contained in:
twystd 2024-11-06 15:21:04 -08:00
parent a43d43c7f8
commit a5f3dad800
4 changed files with 27 additions and 28 deletions

View File

@ -1,13 +0,0 @@
/*
Package midi implements an fq plugin to decode [standard MIDI files].
The MIDI decoder is a member of the 'probe' group and fq should automatically invoke the
decoder when opening a MIDI file. The decoder can be explicitly specified with the '-d midi'
command line option.
The decoder currently only supports MIDI 1.0 files and does only basic validation on the
MIDI file structure.
[standard MIDI files]: https://midi.org/standard-midi-files.
*/
package midi

View File

@ -94,7 +94,7 @@ func decodeMetaEvent(d *decode.D, event uint8, ctx *context) {
}
// decodeSequenceNumber parses a Sequence Number MIDI meta event to a struct comprising:
// - sequence_number
// - sequence_number
func decodeSequenceNumber(d *decode.D) {
d.FieldUintFn("length", vlq, d.UintRequire(2))
d.FieldU16("sequence_number")

View File

@ -1,3 +1,15 @@
/*
Package midi implements an fq plugin to decode [standard MIDI files].
The MIDI decoder is a member of the 'probe' group and fq should automatically invoke the
decoder when opening a MIDI file. The decoder can be explicitly specified with the '-d midi'
command line option.
The decoder currently only supports MIDI 1.0 files and does only basic validation on the
MIDI file structure.
[standard MIDI files]: https://midi.org/standard-midi-files.
*/
package midi
// https://www.midi.org/specifications/item/the-midi-1-0-specification
@ -61,11 +73,11 @@ func decodeMIDI(d *decode.D) any {
}
// decodeMThd decodes an MThd MIDI header chunk into a struct with the fields:
// - tag "MThd"
// - length Header chunk size
// - format MIDI format (0,1 or 2)
// - tracks Number of tracks
// - division Time division
// - tag "MThd"
// - length Header chunk size
// - format MIDI format (0,1 or 2)
// - tracks Number of tracks
// - division Time division
func decodeMThd(d *decode.D) {
if !bytes.Equal(d.PeekBytes(4), []byte("MThd")) {
d.Errorf("missing MThd tag")
@ -90,9 +102,9 @@ func decodeMThd(d *decode.D) {
}
// decodeMTrk decodes an MTrk MIDI track chunk into a struct with the header fields:
// - tag "MTrk"
// - length Track chunk size
// - events List of track events
// - tag "MTrk"
// - length Track chunk size
// - events List of track events
func decodeMTrk(d *decode.D) {
if !bytes.Equal(d.PeekBytes(4), []byte("MTrk")) {
d.Errorf("missing MTrk tag")
@ -117,9 +129,9 @@ func decodeMTrk(d *decode.D) {
}
// decodeEvent decodes a single MIDI event as either:
// - Meta event
// - MIDI channel event
// - SysEx system event
// - Meta event
// - MIDI channel event
// - SysEx system event
func decodeEvent(d *decode.D, ctx *context) {
_, status, event := peekEvent(d)