Arguably, the core of the API. It holds every aspect of a MIDI note "process". I call it process because it requires two signals: one to start and another to end the note. There's also the delta-time, which is not an intuitive concept. So, the NoteEvent class wraps it all and is, therefore, a bridge between an easily readable note concept and the MIDI format NoteOn+NoteOff event(s).
-- Creates a simple C noteNoteEvent.new({pitch='C4'})-- AlternativelyNoteEvent.new({pitch=60})-- Creates an E5 chord (with default length of a quarter note)NoteEvent.new({pitch={'E3','B3'}})-- Creates an A minor chord arpeggio event(s sequence) (with each note lasting an eighth note)NoteEvent.new({pitch={'A3','C4','E4','C5','E5'},duration='8',sequential=true})
A ProgramChangeEvent makes it possible to change the "program" of a channel, which is, for the first 15 channels and most of MIDI devices, changing the instrument sound. This event is mostly the same as the raw MIDI data. That's due to the fact that this is one of the shortest events, being just 2 bytes long.
An abstraction to represent a MIDI track. It comprises the events (Note, Meta and ProgramChange) and handles it's own setup data, as its header (MTrk) and its meta-event ending. Because MIDI meta events are always tied to tracks, LuaMidi ♫ doesn't expect the user to directly create MetaEvents (which is an API class) objects, but to use Track's methods instead. These methods manage to create these objects and configure them.
-- Creates a new TrackTrack.new()-- Creates a new Track with a "name" meta event (set as "Track1")localtrk=Track.new("Track1")-- Adds a NoteEvent to the Tracktrk:add_events(NoteEvent.new({pitch='C4'}))-- Adds a ProgramChangeEvent and adds a MetaEvent to describe which instrument it is supposed to betrk:add_events(ProgramChangeEvent.new(25)):set_instrument_name("Nylon Guitar")