The main class you need to create a MIDI file.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
character(len=:), | private, | allocatable | :: | filename | |||
integer(kind=int32), | private | :: | size_pos | ||||
integer, | private | :: | status | ||||
integer, | private | :: | unit |
Many MIDI parameters can be set by Control Change. See the list.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(MIDI_file), | intent(inout) | :: | self | |||
integer, | intent(in) | :: | channel | |||
integer, | intent(in) | :: | type | |||
integer, | intent(in) | :: | ctl_value |
Writes a Note OFF event. MIDI notes are in the range 0..127 The release velocity is in the range 0..127.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(MIDI_file), | intent(inout) | :: | self | |||
integer, | intent(in) | :: | channel | |||
integer, | intent(in) | :: | note | |||
integer, | intent(in), | optional | :: | velocity |
Writes a Note ON event. MIDI notes are in the range 0..127 The attack velocity is in the range 1..127 and will set the volume. A Note ON event with a zero velocity is equivalent to a Note OFF.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(MIDI_file), | intent(inout) | :: | self | |||
integer, | intent(in) | :: | channel | |||
integer, | intent(in) | :: | note | |||
integer, | intent(in) | :: | velocity |
Apply a pitch bend to all notes currently sounding on the channel. No bend is 00 40 (64 in decimal), maximum downward bend is 00 00, maximum upward bend is 7F 7F. The Least Significant Byte (lsb) is optional (default value is 0), as it is useful only for fine adjustment. You can not use it with play_note, play_chord or play_broken_chord: you must manage yourself the Note ON and Note OFF events, and put the bend between.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(MIDI_file), | intent(inout) | :: | self | |||
integer, | intent(in) | :: | channel | |||
integer, | intent(in), | optional | :: | lsb | ||
integer, | intent(in) | :: | msb |
Each channel (0..15) can use one General MIDI instrument (0..127) at a time.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(MIDI_file), | intent(inout) | :: | self | |||
integer, | intent(in) | :: | channel | |||
integer, | intent(in) | :: | instrument |
Each MIDI event must be preceded by a delay called "delta time", expressed in MIDI ticks.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(MIDI_file), | intent(inout) | :: | self | |||
integer, | intent(in) | :: | ticks |
A track must end with 0xFF2F00.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(MIDI_file), | intent(inout) | :: | self |
Instrument Name event: FF 04 len text
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(MIDI_file), | intent(inout) | :: | self | |||
character(len=*), | intent(in) | :: | text |
Create a new MIDI file and its metadata track. Concerning the "divisions" argument, ForMIDI uses the "metrical timing" scheme, defining the number of ticks in a quarter note. The "timecode" scheme is not implemented. SMF format: 0: only one track in the file 1: several tracks played together (generally used) 2: several tracks played sequentially
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(MIDI_file), | intent(inout) | :: | self | |||
character(len=*), | intent(in) | :: | file_name | |||
integer, | intent(in) | :: | format | |||
integer, | intent(in) | :: | tracks | |||
integer, | intent(in) | :: | divisions | |||
integer, | intent(in) | :: | tempo | |||
integer, | intent(in), | optional | :: | time_signature(:) | ||
character(len=*), | intent(in), | optional | :: | copyright | ||
character(len=*), | intent(in), | optional | :: | text_event |
Writes a broken chord using an array containing the intervals (see the music_common module). https://en.wikipedia.org/wiki/Arpeggio You must pass either a scalar value (whole duration) or a values array (containing the values for each note).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(MIDI_file), | intent(inout) | :: | self | |||
integer, | intent(in) | :: | channel | |||
integer, | intent(in) | :: | note | |||
integer, | intent(in), | dimension(:) | :: | chord | ||
integer, | intent(in) | :: | velocity | |||
integer, | intent(in), | optional | :: | value | ||
integer, | intent(in), | optional, | dimension(:) | :: | values |
Writes a chord, waits for its duration, and writes the OFF events
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(MIDI_file), | intent(inout) | :: | self | |||
integer, | intent(in) | :: | channel | |||
integer, | intent(in) | :: | note | |||
integer, | intent(in), | dimension(:) | :: | chord | ||
integer, | intent(in) | :: | velocity | |||
integer, | intent(in) | :: | value |
Write a Note ON event, waits for its duration, and writes a Note OFF.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(MIDI_file), | intent(inout) | :: | self | |||
integer, | intent(in) | :: | channel | |||
integer, | intent(in) | :: | note | |||
integer, | intent(in) | :: | velocity | |||
integer, | intent(in) | :: | value |
Sequence or Track Name event: FF 03 len text
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(MIDI_file), | intent(inout) | :: | self | |||
character(len=*), | intent(in) | :: | text |
Specifies a tempo change by writing the duration of a quarter note expressed in µs. It is coded on 3 bytes: from 1 µs to 256**3 µs ~ 16.7 s. A duration of 500000 µs = 0.5 s is equivalent to a 120 bpm tempo. https://en.wikipedia.org/wiki/Tempo MIDI events must always be preceded by a "delta time", even if null:
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(MIDI_file), | intent(inout) | :: | self | |||
integer, | intent(in) | :: | duration |
The time signature includes the numerator, the denominator, the number of MIDI clocks between metronome ticks, (there are 24 MIDI clocks per quarter note) and the number of 32nd notes in a quarter note. The number of "MIDI clocks" between metronome clicks.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(MIDI_file), | intent(inout) | :: | self | |||
integer, | intent(in) | :: | numerator | |||
integer, | intent(in) | :: | denominator | |||
integer, | intent(in) | :: | metronome | |||
integer, | intent(in), | optional | :: | tsnotes |
Text event: FF 01 len text
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(MIDI_file), | intent(inout) | :: | self | |||
character(len=*), | intent(in) | :: | text |
Writes a track header and stores the position where the size of the track will be written when the track will be closed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(MIDI_file), | intent(inout) | :: | self | |||
character(len=*), | intent(in), | optional | :: | track_name | ||
character(len=*), | intent(in), | optional | :: | text_event |
Copyright Notice event: FF 02 len text
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(MIDI_file), | intent(inout) | :: | self | |||
character(len=*), | intent(in) | :: | text |
Verifies the needed data types.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(MIDI_file), | intent(in) | :: | self |
This subroutine is used my many events. The text must be coded in ASCII (7 bits).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(MIDI_file), | intent(inout) | :: | self | |||
integer, | intent(in) | :: | event | |||
character(len=*), | intent(in) | :: | text |
Must be called when the track is finished. It writes its size at the memorized position in the track header.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(MIDI_file), | intent(inout) | :: | self |
Writes the integer i in the MIDI file using the variable length quantity representation:
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(MIDI_file), | intent(inout) | :: | self | |||
integer(kind=int32), | intent(in) | :: | i |
type MIDI_file character(len=:), private, allocatable :: filename ! Output unit and file status: integer, private :: unit integer, private :: status ! To store where to write the size of a track in the file: integer(int32), private :: size_pos contains procedure, private :: init_formidi procedure, private :: write_variable_length_quantity procedure :: new procedure :: track_header procedure :: set_tempo procedure :: set_time_signature procedure :: end_of_track procedure :: get_name procedure, private :: write_track_size procedure :: Program_Change procedure :: play_note procedure :: play_chord procedure :: play_broken_chord procedure :: close procedure :: Control_Change procedure :: Pitch_Bend procedure :: Note_ON procedure :: Note_OFF procedure :: delta_time procedure, private :: write_string procedure :: text_event procedure, private :: copyright_notice procedure :: sequence_track_name procedure :: instrument_name procedure :: lyric procedure :: marker procedure :: cue_point end type MIDI_file