music Module

Offers music parameters and functions specific to MIDI files.


Uses

  • module~~music~~UsesGraph module~music music iso_fortran_env iso_fortran_env module~music->iso_fortran_env module~music_common music_common module~music->module~music_common module~utilities utilities module~music->module~utilities module~utilities->iso_fortran_env

Used by

  • module~~music~~UsedByGraph module~music music program~blues blues program~blues->module~music program~canon canon program~canon->module~music program~circle_of_fifths circle_of_fifths program~circle_of_fifths->module~music program~la_folia la_folia program~la_folia->module~music program~motifs motifs program~motifs->module~music program~third_kind third_kind program~third_kind->module~music

Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: eighth_note = quarter_note/2
integer, public, parameter :: f_level = 80
integer, public, parameter :: ff_level = 96
integer, public, parameter :: fff_level = 112
integer, public, parameter :: ffff_level = 127

Common note levels expressed as MIDI velocities https://arxiv.org/pdf/1705.05322

integer, public, parameter :: half_note = 2*quarter_note
integer, public, parameter :: mf_level = 64
integer, public, parameter :: mp_level = 53
integer, public, parameter :: p_level = 42
integer, public, parameter :: pp_level = 31
integer, public, parameter :: ppp_level = 20
integer, public, parameter :: pppp_level = 8
integer, public, parameter :: quarter_note = 96

The timing resolution of a MIDI file is defined by the number of MIDI ticks in a quarter note: the value 96 is commonly used because it can be divided by 2 and 3. We also define the most useful other values. https://en.wikipedia.org/wiki/Note_value

integer, public, parameter :: sixteenth_note = quarter_note/4
integer, public, parameter :: thirty_second_note = quarter_note/8
integer, public, parameter :: whole_note = 4*quarter_note

Functions

public function MIDI_Note(note)

Returns the MIDI note number, from 12 (C0) to 127 (G9). The note name is composed of two or three characters, for example "A4", "A#4", "Ab4", where the final character is the octave.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: note

Return Value integer

public function dotted(value)

Returns the value of a dotted note.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: value

Return Value integer

public function note_name(MIDI_note) result(name)

Receives a MIDI note (for example 69), and returns the name of the note (for example A4). It works also with the octave -1, although most of its notes are too low for hearing.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: MIDI_note

Return Value character(len=4)