Racket MIDI reader
(require midi-readwrite) | package: midi-readwrite |
procedure
(midi-file-parse path) → MIDIFile?
path : path-string?
procedure
(midi-port-parse port) → MIDIFile?
port : port?
struct
(struct MIDIFile (format division tracks) #:extra-constructor-name make-MIDIFile) format : MIDIFormat division : MIDIDivision tracks : (listof MIDITrack)
(define-type MIDIFormat (U 'multi 'single 'sequential)) |
(define-type MIDIDivision (U TicksPerQuarter SMPTE)) |
(define-struct: TicksPerQuarter ([ticks : Clocks]) #:transparent) |
(define-struct: SMPTE ([a : Natural] [b : Natural]) #:transparent) |
|
;; hidden invariant: the events in the track must have increasing times |
(define-type MIDITrack (Listof MIDIEvent)) |
|
;; Clocks absolute, relative to start of track. |
(define-type MIDIEvent (List Clocks MIDIMessage)) |
(define-type Clocks Natural) |
(define-type MIDIMessage (U MetaMessage ChannelMessage SysexMessage)) |
(define-struct: MetaMessage ([content : Any]) #:transparent) |
(define-struct: SysexMessage ([content : Any]) #:transparent) |
(define-struct: ChannelMessage ([kind : MIDIKind] |
[channel : Byte] |
[operands : (List Byte (U Byte False))]) |
#:transparent) |
(define-type MIDIKind Symbol) |
|
procedure
(MIDIFile->notelist file #:careful? careful?) → (listof note?) file : MIDIFile? careful? : #f
struct
(struct note (pitch time duration) #:extra-constructor-name make-note) pitch : midi-note-num? time : tick? duration : tick?