Skip to content
Joe Turner edited this page Jun 14, 2011 · 3 revisions

Start Making Noise

If you haven't already grabbed a copy of Audiolet, follow the installation instructions before getting started with this tutorial.

Getting Started

The first step you need to take to get started with Audiolet is to create a new project. If you navigate to the examples directory you will find a folder called template, which contains all of the code (HTML and JavaScript) you need to get quickly up and running. Create a copy of the folder in the examples directory and call it startmakingnoise.

Now, in your favourite text editor open up startmakingnoise/js/audiolet_app.js. You can see that this already contains a class called AudioletApp with an Audiolet object initialized. The Audiolet object contains the audio output which we connect nodes to in order to generate sound. So to make our first bit of noise using Audiolet we will create a sine oscillator, and connect it up to the output.

    ...
    var AudioletApp = function() {
        this.audiolet = new Audiolet();
        this.sine = new Sine(this.audiolet, 440);

        this.sine.connect(this.audiolet.output);
    };
    ...

If you navigate your browser to startmakingnoise/index.htm you should hear a clear sine tone at 440hz.

Making it more interesting

Okay, so a sine tone is great, but it's not very interesting, so let's expand on what you know a little and add in some frequency modulation. For this example we will modulate the sine tone with a 880hz saw wave, so go ahead and create that below where you make the sine wave. It should look like:

    ...
    this.sine = new Sine(this.audiolet, 440);
    this.modulator = new Saw(this.audiolet, 880);

    this.sine.connect(this.audiolet.output);
    ...

The saw oscillator, like the sine oscillator, gives values which range between -1 and 1. Clearly this range of values won't work as a modulator, so we need to scale and shift the saw wave using a MulAdd node. MulAdds simply multiply and add values to any incoming data. We will modulate our frequency in a range 200hz either side of its original value of 440hz, so we need a MulAdd which multiplies by 200, and adds 440.

    ...
    this.modulator = new Saw(this.audiolet, 880);
    this.modulatorMulAdd = new MulAdd(this.audiolet, 200, 440);

    this.sine.connect(this.audiolet.output);
    ...

Finally we can connect up the modulator to the frequency input of the sine oscillator.

    ...
    this.modulatorMulAdd = new MulAdd(this.audiolet, 200, 440);

    this.modulator.connect(this.modulatorMulAdd);
    this.modulatorMulAdd.connect(this.sine);
    this.sine.connect(this.audiolet.output);
    ...

If you again point your browser at startmakingnoise/index.htm you should hear the richer frequency modulated sine tone.