examples / processing / libraries / random-synthesizer

Random Synthesizer

example processing library

This code uses the Minim library, which makes it possible to play sounds from Processing.

Looking at Minim’s documentation, I found the AudioPlayer#playNote() function, which allows playing of a note at a specific frequency.

Now that we have that function, we can feed it random values to create a random song.

import ddf.minim.Minim;
import ddf.minim.AudioOutput;

AudioOutput out;

void setup() {
  size(300, 100);

  Minim minim = new Minim(this);
  out = minim.getLineOut();


void draw() {

  float note = random(1000);


  stroke(random(256), random(256), random(256));
  line(width*note/1000, 0, width*note/1000, height);

The result is a random “song” that sounds like this:

Oh and then just for fun, I’m drawing a randomly colored line with an X value based on the frequency of the note.


Tweak Ideas