a diatonic experiment

We can play a game here: to generate diatonic melodies generated more or less randomly. Maybe not entirely random, but with some little restrictions.

By diatonic I mean taking only the notes from a ionian major scale in this case. Or, if you like, the white keys on a keyboard.

Here you can find a C++ code to generate silly, sometimes funny, melodies. The result is not what I would call "musical", but sometimes you find interesting ideas. Also interesting is that I find rhythmic ideas quite musical already. But I suppose that melodies rely too much on harmonic progressions, which here as completely lacking.

As you can see in the code, I limit the span to two octaves, so you will see how sometimes the algorithm insists bouncing on these two walls.

diatonic.cpp

Notice as well how I export the score to LilyPond, so that you can listen to Csound playing it while checking the sheet-score in a pdf file.

I have also added a noise instrument to serve as a metronome, marking at 2nd and 4th beats of each measure, to help following the score.

To facilitate the process I leave here a little script with the commands that you may want to chain: compile, execute Csound, convert wav to ogg, delete the wav, compile the LilyPond and open the pdf. I don't include the playing of the ogg file as a comand, though.

diatonic.sh

Check here two examples:

diatonic.pdf

[audio] diatonic.ogg


diatonic2.pdf

[audio] diatonic2.ogg


You can also check the Csound file of the first example:

diatonic.csd, the Csound file

I think these examples are quite good rhythmic exercises for sight reading.