/ HALion Developer Resource / HALion Script / Reference /
MIDI Sequence Table
On this page:
Description
MIDI Files are managed through a special predefined table: the MIDI sequence table. This table allows you to change values and add or remove notes like with normal Lua tables, but the structure of that table must remain as defined below.
Available in: Controller.
MIDI Sequence Fields
Field | Description | Value Type |
---|---|---|
.format | The MIDI file format. It can be determined via names or indices.
| enum or number |
.smpteformat | The SMPTE format.
| number |
.division | Specifies the ticks used for the SMPTE format. The default is 480 ticks. | number |
.tempo | The original tempo in beats per minute. The default is 120 BPM. | number |
.signature | The time signature of the MIDI file as a table. Numerator and denominator are separate fields of that table (see Signature Table below). | table |
.songname | The name of the song. | string |
.tracks | The tracks of the MIDI file as an array with the index starting at 1. Name, channel and event are separate fields of that table (see Tracks Table below). | table |
Signature Table
Field | Description | Value Type |
---|---|---|
.numerator | The numerator of the time signature. The default is 4. | number |
.denominator | The denominator of the time signature. The default is 4. | number |
Tracks Table
Field | Description | Value Type |
---|---|---|
.name | The name of the track. | string |
.channel | The MIDI channel of the track. The default is 1. | number |
.events | The events of the track as an array with the index starting at 1. The events are stored as Event objects. | table |
Example
To explore the following script:
- Download C Major Scale.mid.
- Create an empty program and add a script module.
- Paste the script into the text editor of the script module and adjust the file path of readMidiFile to the location of the file on your system.
- Execute the script.
-- Read information from a MIDI file.
midiseq = readMidiFile("c:/temp/C Major Scale.mid") --[[ please set the file path to the location
of the file on your system before you run
the script ]]
-- Information from the header chunk.
print("Standard MIDI File Format:", midiseq.format)
print("SMPTE:", midiseq.smpteformat)
print("Division:", midiseq.division)
-- Information from the track chunk.
print("Tempo:", midiseq.tempo)
print("Signature:", midiseq.signature.numerator, "/", midiseq.signature.denominator)
print("Song Name:", midiseq.songname)
print("Number of Tracks:", #midiseq.tracks)
print("Name of 1st Track:", midiseq.tracks[1].name)
print("Channel of 1st Track:", midiseq.tracks[1].channel)
print("Number of Events in 1st Track", #midiseq.tracks[1].events, "\n")
See also: readMidiFile, writeMidiFile, insertEvent, sortEvents, MIDI File Format Types