From cacophony to music. Trying to create bearable evolving music in flash 10 (beta).

September 15, 2008. Posted by Andy Hulstkamp under Actionscript 3 Astro (Flash 10 beta) Sound
Keywords: , ,

In this post I was experimenting with waveforms. Playing sounds constantly on the same pitch gets a bit boring after a while, however simply introducing random pitch isn’t too charming either. I started to twiddle a bit with evolving music.

  • goal:
    • create a player that plays a bearable evolving tune
  • constraints:
    • player <5k
    • no samples
    • 3 voices
    • stop experimenting after 3 hours before loosing myself

First, get some decent frequencies. Notes on a western chromatic scale are related, so introducing a frequency table is simple:

//BASE_FREQ = 65 or 110 or 220 or whatever
private function buildNotetable():void {
	for (var i:int = 0; i < noteTable.length; i++) {
		noteTable[i] = int (BASE_FREQ * Math.pow(1.05946, i));
	}
}

Having all the semitones in it doesn’t really help. A lookup table of ‘valid’ notes gives better results. I decided, that mainly thirds, fifths, sevenths etc. (notes that fit well to the keynote) should be played.

Sequence of notes should somehow sound ‘related’, thus I used perlin noise over randomly selecting notes. I used one channel of perlin noise for each voice. This gives an improvement to simply play a sequence of notes randomly but the outcome is still too nervous.

To calm things down I merged voices 2+3 and let voice 2 modulate voice 3, giving a more interesting sound. There’s now a clear lead and a lower line. Still, progression of the lower line was to aggressive. It’s better when the lower line changes at only int*4 bars or so. Additionally, the whole scale is transposed by a few semitones once in a while.

Well then, did it work? Not really, although there is an improvement to random music and there are some transitions that sound promising, it still is cacophony. As expected, introducing perlin noise and constraining the selection of notes is not enough. Some other means need to be established.

If you want to listen to the result or compare random play to the more structured approach here’s a simple example. Turn your volume down first. Bettter A and Better B use different settings for the frequency of the perlin noise. The seed is set to a new value each time you toggle a button.

Random Music Player

I think Better B generates the most bearable tunes. Click here for the doodle tune. Needs the latest Flash-Player 10 (rc of 091508).

Here’s the source. UPDATE: Adobe changed the sound api. Use SampleDataEvent.SAMPLE_DATA instead of Event.SAMPLE_DATA for the listener.

External Sound resources

make some noise
Astro Dynamic Sound



Share/Save/Bookmark

3 Responses to “From cacophony to music. Trying to create bearable evolving music in flash 10 (beta).”

  1. Akaneko » Blog Archive » Seen on the web : Fun synthesis Says:

    [...] http://www.hulstkamp.com/2008/09/15/rmp/40 [...]

  2. Akane Says:

    I really like this one.
    Making sound in flash is cool, but he ! making random things with sounds is really fun.
    Keep the great work up !

  3. Andy Hulstkamp Says:

    Thanks Akane!

    Had a look at your stuff… great!

Leave a Reply