The proto-cl-harmony is toy program to add harmony to a given melody by very simple rules.
Download sources under a directory managed by quicklisp.
$ https://github.com/eshamster/ps-experiment.git
$ https://github.com/eshamster/proto-cl-harmony.git
Then, load and start server as the following on REPL.
CL-USER> (ql:register-local-projects)
...
CL-USER> (ql:quickload :proto-cl-harmony)
...
CL-USER> (proto-cl-harmony:start :port 5000)
...
Then, you can access to it by http://localhost:5000/
.
This project adopts tiny subset of MML (Music Macro Language) to write melody.
The detail definition is the following.
<MML> := <block>...
<block> := <note>|<octave>|<rest>
<note> := <tone>[<tone-changer>...][<note len>]
<tone> := "A"|"B"|"C"|"D"|"E"|"F"|"G"
<tone-changer> := "#"|"+"|"-"
<octave> := <set octave>|<inc octave>
<set octave> := "O"integer
<inc octave> := "<"|">"
<rest> := "R"[<note len>]
<note len> := [integer["."...]] ;; Ex. 4 means quater note
Weight for each harmony is calculated in each measure. The weight is added by the following factors.
- If a tone in a measure is included in the harmony.
- If the tone is the first one of the measure, more weight is added.
- If the tone is the base one of the harmony, more weight is added.
- If the harmony is not substitute one.
Harmonies are selected by the following steps from first measure to last one.
- Randomly select a harmony according to their weight for each measure.
- If the sequence of harmonies includes prohibited progression, return to step 1.
- Repeat above steps N times (the default N is 3).
- Select the sequence that has highest some of weight.
The followings should be manually specified.
- Scale
- Beat
The supported harmonies satisfy the following conditions.
- It is a triad.
- It includes only tones in a specified scale.
Other limitations:
- Only one harmony is selected to one measure.
- eshamster (hamgoostar@gmail.com)
Copyright (c) 2019 eshamster (hamgoostar@gmail.com)
Licensed under the LLGPL License.