ForMIDI, a small Fortran MIDI sequencer for composing music 🎵

ForMIDI v0.1 “Formidable” has been released under GNU GPLv3 license:

It is a translation of a C project used for teaching. You can build it using fpm or the build.sh script.

It includes several demos with comments:

  • demo1: five notes that could be useful to communicate with an E.T. intelligence…
  • demo2: a simple canon based on the first measures of Pachelbel’s Canon. Listen to the ogg file.
  • demo3: a stochastic blues, including a percussion track.

Some difficulties concerning the C->Fortran translation were discussed here:

Coding the basics of the MIDI protocole was not very complicated, except concerning the fact that some 32 bits data are encoded using the Variable-Length Quantity code to use only the minimum number of bytes. It’s because MIDI (Musical Instrument Digital Interface) was launched in 1983 and its speed is only 31250 baud!

6 Likes

Two interesting articles about an early experiment: “Push Button Bertha” (1956). In the second link, there is some newspapers articles published in 1956-57:

Probably not yet in Fortran, our baby was just being born…

:musical_keyboard: ForMIDI v0.2 “Forever Young” has been released with these new features:

  • src/music.f90: a module containing some music theory elements (scales, circle of fifths, chords), and the subroutine write_chord() and the function get_note_name().
  • src/MIDI_control_changes.f90: a module with all the MIDI Control Changes parameters.
  • src/GM_instruments.f90: contains the list of 128 General MIDI instruments and 47 percussive instruments (channel 9).
  • src/demos.f90: a new demo4 plays a random walk on the circle of fifths. You can listen to it here :musical_note:. It’s a pleasant music, although just a random walk: the probabilities are 1/3 to move one chord clockwise on the circle of fifths, 1/3 to move one chord counterclockwise, 1/3 to switch between the major and minor circles. The Pythagoreans already knew the fifth was very important in music, with its simple 2/3 string length ratio!

The music theory elements are stored in arrays, for example chords can be defined like this and passed to the write_chord() subroutine:

integer, parameter :: MAJOR_CHORD(1:3) = [ 0, 4, 7 ]
integer, parameter :: MINOR_CHORD(1:3) = [ 0, 3, 7 ]
integer, parameter :: DOMINANT_7TH_CHORD(1:4) = [ 0, 4, 7, 10 ]

A scale can be defined like this:

character(2), dimension(1:6),  parameter :: WHOLE_TONE_SCALE = &
                                          & ['C ','D ','E ','F#','G#','A#']

(if you want to sound like Debussy :ocean:).

2 Likes