< Home

Project "Raindrop Chimes"


The "Raindrop Chimes" project aims at developing algorithms for computer generated music from primitive inputs. If successful, the project finds algorithms with outputs that are pleasant to the human ear in a similar way as graphical representations of fractal algorithms please the human eye.

Two-dimensional random series weighted by prime number relations

This algorithm takes two independent, random whole number series, weighs each element of the series by some prime number relation, and applies the outcome to audible frequencies.

A Song consists of many "ding" sounds that are each repeated a number of times. Multiple "ding" sounds play at the same time, giving the impression of chords. The number of repetitions of a "ding", as well as, the frequency relations within chords, are generated from two independent random series of whole numbers. The "ding" repetition count is obtained from an initial random series of whole numbers in the range { 0, 1, ..., 10 }. The frequency relations originate from an initial random series in the range { 0, 1, ..., 24 }.

For repetitions, the 11 members from the initial random number series are mapped one-on-one to the first 11 prime numbers { 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 }.

Whenever the number of repetitions of a given "ding" has been reached, it is time to play a new sound. The frequency of the new "ding" sound is computed from the frequency of one of the other "ding" sounds that are currently playing, by calculating one of its 25 nearest overtone relations. In this context, "25 nearest" means overtone relations that are ideal octaves, fifths, fourths, or thirds. Since overtone relations between frequencies are whole number fractions, this calculation effectively relates the new "ding" frequency to the previous one through fractions from small prime numbers { 2, 3, 5 }.

When putting this together, a Song is structured through a series of one-to-many relations (here denoted with "-<"):

  Song -< Ding -< Slot -< Bin

The first "ding" in a Song will be repeated a total number of times, each repetition being part of a Ding element of the Song. In order to generate chords, each Ding is divided into a total of 11 equally spaced Slots. Each Slot is then filled by a "ding" sound of different frequency. At any given time a total of 11 different frequencies may therefore be playing, resulting in a chord from 11 frequencies.

All of the frequencies in a chord are obtained from perfect overtone relations to another frequency currently playing. Since perfect overtone relations are not well-tempered, the result over time typically also includes sharp dissonances. Chords are essentially scale free and cannot be played - say - on a piano. There is no algorithmic correction to these dissonances. Instead, a "ding" will eventually stop playing once its number of repetitions has been reached. It will then be replaced by a "ding" with new frequency that is in a well-sounding, perfect overtone relation to another frequency playing at that time.

The smallest unit in a Song is a Bin, which is the audio wave amplitude quantum to be sent to the digital-analog converter of the sound card. The chosen wave form for each frequency is a sine wave, which is quantized over a series of bins through a preset sampling frequency (here 44.1 kHz).

The role of prime numbers

Prime numbers play two roles in the algorithm: They relate consecutive frequencies to one another through overtone relations, and they provide a weighting scheme to the otherwise randomly obtained durations. The frequency relations appear "harmonious" to the human ear, even though chords are truly scale free and could not be played on a piano. The distribution of notes over time then appears to generate some dynamic struture over time, as opposed to a random linear time distribution of notes that randomly "drop in".

While the overtone relations are probably more agreeable as a source of beauty from prime number relations, the structure of notes played over time is more speculative and possibly subjective. Is it really the prime number weighted distribution of timed events that generates the impression of a dynamic balance between calm and intense periods? I would like to point out that prime numbers are related to unexpected appearance of structure from the Ulam spiral. Just as structure there is readily recognizable by the human eye, a weighted duration scheme from randomly selected prime numbers might form such an equivalent in the realm of accoustic perception.


The previous section describes the algorithm at its core. From trials of this algorithm in raw form, the human ear seems unprepared and aestetically repelled when the sounds start playing right away as described above. Also, using unmodulated sine waves bluntly reminds one of sounds from a car door left open. Overall, preexisting accoustical experience appears to have a strong impact on human perception of timed audible events.

A "ding" sound is repeated a number of times. With each "ding" repetition, the total volume slowly decreases such that the last "ding" is played at about half the volume of the first one. This composition element aims at properly conveying the subjective notion of one note that is repeated for a certain number of times, as opposed to being a mechanical repetition of the same note over and over.

The following composition elements then are added to give the human listener a certain introductory time period before the algorithm actually plays fully as described above. This composition aims at a cognitive guide of sorts that connects preexisting human experience to the algorithmic output. It seems that this gives the human ear a chance to adjust to the unfamiliar chords. During the middle section of a Song, the full algorithm is then active (for a bit more than half of the total song time). It is surrounded by a modified lead-in and lead-out version of the algorithm described in the following paragraphs.

At the beginning and end of a song, Slots are randomly picked for not being played at all, to leave the center section of a song for following the algorithm exactly as described above. Based on the effective density of played Slots per Ding, the repetition number is also linearily adjusted lower. The combined effects create the impression of a calm introduction and lead-out, and aims at improving subjective cognitive acceptance of the complex mid section of a Song, more than half of its duration, which plays all notes from the algorithm without alteration.

For shaping the plain sine wave into something more aesthetically pleasing, a slight vibrato ( < 0.05% of base frequency ) was added to each wave. Then, a list of echos was added that generate the effect of reverb in a large room. The combined accoustic effects seem to better prepare the human ear for the realm generated from the algorithm.

Code and Samples

This section references some prototype C source code for some samples. It should be understood as a feasibility demonstration, rather than well designed software. The code snippets vary slightly, but essentially produce sound from the core algorithm describe above.

The samples here are the source code that generate the (unmastered, raw WAVE file) music at http://raindropchimes.com. For reading the current page until here, I'd be glad to give you a way to dowload the music for free: Follow the "download them again" link on the remote page, and enter transaction ID "primes" and e-mail address "rock". After clicking "Submit Query" you should be able to download the music. If you want legalese, I've granted the natural person reading this page a nonexclusive license to the content for personal use.

Are there bugs in the software? You bet. For example, I left out "19" as a prime number ... It would be nice to turn these concept code snippets into software that is properly designed. One day maybe. If your srand() implementation produces the identical random number series as mine, then the below snippets will recreate exactly four out of the five songs at raindropchimes.com, leaving out the one song for which I have forgotten the seed and therefore cannot recreate it anymore.

The code snippets are:

This page was last updated 2 October 2011 -- jens@prisage.com

< Home