music_common Module

Contains music theory elements: scales, circle of fifths, chords, etc.

This file will be kept identical in the ForMIDI and ForSynth projects. It could be put in a separate fpm repository and used as a dependency, but for the time being, synchronizing it by hand is sufficient.



Used by

  • module~~music_common~~UsedByGraph module~music_common music_common module~music music module~music->module~music_common program~arpeggios arpeggios program~arpeggios->module~music_common program~arpeggios->module~music program~blues blues program~blues->module~music_common program~blues->module~music program~chords_and_melody chords_and_melody program~chords_and_melody->module~music_common program~chords_and_melody->module~music program~demo_effects demo_effects program~demo_effects->module~music_common program~demo_effects->module~music program~all_signals all_signals program~all_signals->module~music program~drone_music drone_music program~drone_music->module~music program~misc_sounds misc_sounds program~misc_sounds->module~music

Variables

Type Visibility Attributes Name Initial
character(len=2), public, parameter, dimension(1:12) :: CHROMATIC_SCALE = ['C ', 'C#', 'D ', 'D#', 'E ', 'F ', 'F#', 'G ', 'G#', 'A ', 'A#', 'B ']

We define some scales, excluding the octave of the first note. Always use the trim() function to remove trailing spaces. https://en.wikipedia.org/wiki/Scale_(music)

character(len=2), public, dimension(1:12) :: CIRCLE_OF_FIFTHS_MAJOR = ['C ', 'G ', 'D ', 'A ', 'E ', 'B ', 'Gb', 'Db', 'Ab', 'Eb', 'Bb', 'F ']

Always use the trim() function to remove trailing spaces.

character(len=2), public, dimension(1:12) :: CIRCLE_OF_FIFTHS_MINOR = ['A ', 'E ', 'B ', 'F#', 'C#', 'G#', 'Eb', 'Bb', 'F ', 'C ', 'G ', 'D ']
integer, public, parameter :: CLUSTER_CHORD(1:12) = [(j, j=0, 11)]
integer, public, parameter :: DOMINANT_7TH_CHORD(1:4) = [0, 4, 7, 10]
character(len=2), public, parameter, dimension(1:7) :: HARMONIC_MINOR_SCALE = ['A ', 'B ', 'C ', 'D ', 'E ', 'F ', 'G#']

https://en.wikipedia.org/wiki/Minor_scale#Harmonic_minor_scale

character(len=2), public, parameter, dimension(1:6) :: HEXATONIC_BLUES_SCALE = ['C ', 'Eb', 'F ', 'Gb', 'G ', 'Bb']

https://en.wikipedia.org/wiki/Hexatonic_scale#Blues_scale

integer, public, parameter :: MAJOR_CHORD(1:3) = [0, 4, 7]

Some frequent chords. These arrays can be passed to the write_chord() subroutine. https://en.wikipedia.org/wiki/Chord_(music)

character(len=1), public, parameter, dimension(1:5) :: MAJOR_PENTATONIC_SCALE = ['C', 'D', 'E', 'G', 'A']

https://en.wikipedia.org/wiki/Pentatonic_scale#Major_pentatonic_scale

character(len=1), public, parameter, dimension(1:7) :: MAJOR_SCALE = ['C', 'D', 'E', 'F', 'G', 'A', 'B']

https://en.wikipedia.org/wiki/Major_scale

integer, public, parameter :: MINOR_CHORD(1:3) = [0, 3, 7]
integer, public, parameter :: POWER_CHORD(1:3) = [0, 7, 12]
integer, public, parameter :: SUS2_CHORD(1:3) = [0, 2, 7]
integer, public, parameter :: SUS4_CHORD(1:3) = [0, 5, 7]
character(len=2), public, parameter, dimension(1:6) :: WHOLE_TONE_SCALE = ['C ', 'D ', 'E ', 'F#', 'G#', 'A#']
integer, private :: j