Skip to content


Repository files navigation

(of a journal article describing the first DarwinTunes experiment)

This directory contains the DarwinTunes song-generation source code.

Moderate Linux and Perl knowledge is assumed.  The author takes no
responsibility for hearing loss.  Please take care of your ears!

Author: Bob MacCallum,

Please note that the DarwinTunes code has only been tested in Linux.
It seems to run fine on a mid-range 2010 netbook.

In order to run DarwinTunes on your own machine you'll need to
install the following:

1. Perl modules: PDL and PDL::Audio::Scales

2. PerlGP ( - set the PERLGP_SCRATCH
   environment variable to "." without the quotes.

To get started generating music, edit to set the tempo
(if you are familiar with PerlGP's grammar description syntax you can
set other things too).

From within this directory:

1. Type "screen nice -loop" and ctrl-a d to detach the
   screen (or just run it in a spare window without the 'screen').

2. Run this script: ./
   You should hear music (you might need to install pulseaudio, esound
   or tweak the script to suit your system).

   You can replace the esdcat command with
   sox -q -t raw -r 44100 -b 16 -c 2 -e signed-integer - -t alsa

3. Rate the loops with any integer you like, followed by <enter> (then
   you get to hear the next loop).  If you follow the number with a
   period, the loop (and its Perl source) will be saved.

4. Repeat 3 indefinitely...

5. To stop the program:
   ctrl-c to stop
   screen -r
   then ctrl-c twice to kill the loop generation in the background

6. To restart the program, just run again.

7. To completely wipe the project in this directory, stop all programs
   and type

If you have Perl/PerlGP knowledge, you can add WAV sample files (keep
them short-ish) in a hierarchical directory structure within 'samples'
(keep directory names short and use letters and no numbers or
punctuation).  You can then edit the file to allow use of
the loadwav function.  If you name kick, snare and hi-hat samples
appropriately you can uncomment various bits of code (,, search for 'house') early on in evolution to encourage
some basic house beats.

Have fun!


Source code for evolutionary music engine to accompany forthcoming journal article






No releases published


No packages published