Skip to content

SoundDesigner

The soundDesigner is a tool for manually designing the tonal qualities of digital instruments. It can only be used inside the tracks code block. Here is what an empty tracks code block looks like:

1
2
3
tracks {

};

The way that the soundDesigner works, is that it allows you to create one or more soundLayers, which are components that are capable of creating sound when Modulo1 runs your code.

There are three stages in the design of an instrument 1. Create an instance of the soundDesigner tool 2. Manually configure the automation of your soundDesigner 3. Use the soundDesigner to create one or more soundLayers 4. Manually configure the automation of your soundLayers

Info

If you would prefer the instrument to be configured automatically, then be sure to try out the autoDesigner tool.


Creating A SoundDesigner

1
2
3
4
5
6
var inst1 = soundDesigner({ 
    name : "Dirty Bass", 
    type : "bass", 
    filter : "LP", 
    octave : 1 
});

We start with the var keyword, which lets Modulo1 know that we're creating a new variable, and we follow this with a valid variable name (we've chosen inst1 in this example) that we will use in our code to identify this soundDesigner. Be aware that the variable name of inst1 has a different purpose to the instrument name of "Dirty Bass". The variable name is only used in our code, and the instrument name will be used later, when Modulo1 runs our code and creates the digital instrument.

We put an = symbol after inst1, followed by the name of our tool: the soundDesigner.

Finally, we include an object as the input parameter, specifying a few options. name and type are compulsory. filter and octave are optional. If you do not set them, they will be set to default values.

  • The name must have at least one character that is not a space or a line-break
  • The type can be any of the following: "bass", "lead", "pad", or "synth"
  • The filter can be any of the following: "LP", "HP", "BP", "PK"
  • The octave must be a number between 1 and 8

Configuring A SoundDesigner's Automation

A soundDesigner has several aspects that can be automated to change throughout the brief period of time between the beginning and end of a musical note. These changes give the instrument an increased level of complexity and that in turn may lead to results that sound amazing, terrible, or somewhere inbetween. That is a subjective choice which we will leave to you.

These are the aspects than can be automated:

  • interval affects the pitch of every soundLayer's sound, relative to the note that the composition is attempting to play
  • filterCutoff controls a filter which will affect every soundLayer simultaneously

This is how to automate the interval of the soundDesigner:

1
2
inst1.automate({ aspect: "interval", time: 0 ticks, value: 0 });
inst1.automate({ aspect: "interval", time: 100 ticks, value: -1 });

Duplicating A SoundDesigner

There might be a circumstance where you want to create a song that has two basslines that play interchangeably. Instead of starting from scratch for the second bassline, you could duplicate the original bassline and then make changes to its layers. Here is how to duplicate it:

1
2
3
var inst2 = inst1.copyAll({
    name : "Dirty Bass 2"
});

Creating A SoundLayer

1
var layer1 = inst1.createLayer({ type : "square", filter : "LP" });

Once again, we start with the var keyword, which lets Modulo1 know that we're creating a new variable, and we follow this with a valid variable name (we've chosen layer1 in this example) that we will use in our code to identify this soundLayer.

After the = symbol, we type the name of the soundDesigner we created earlier: inst1. We are going to run its built-in function createLayer(), and for this we can choose to include an object as the input parameter, specifying a couple of options.

  • The type can be any of the following: "square", "sine", "sawL", "sawR", "tri"
  • The filter can be any of the following: "LP", "HP", "BP", "PK"

These options however, are not mandatory. If you do not set them, they will be set to default values. You could alternatively create a layer like this:

1
var layer1 = inst1.createLayer();

Duplicating A SoundLayer

1
var layer2 = layer1.copyAll();

Configuring A SoundLayer's Automation

A soundLayer has several aspects that can be automated to change throughout the brief period of time between the beginning and end of a musical note.

These are the aspects than can be automated:

  • amp controls the volume of the layer's sound
  • pan affects the direction the layer's sound appears to be coming from
  • interval affects the pitch of the layer's sound, relative to the note that the composition is attempting to play
  • filterCutoff controls the filter which is attached to the layer
  • distortion controls the amount of distortion applied to the layer
  • delay allows you to introduce a slight delay in the layer. If you have two identical layers and one of them is delayed, it can lead to interesting sound effects

This is how to automate the distortion of a soundLayer:

1
2
3
4
5
layer1.automate({ 
    aspect: "distortion",
    value: 0.7
    time: 0 ticks,
});

Putting it all together

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
tracks {
    var inst1 = soundDesigner({ 
        name: "Dirty Bass", 
        type: "bass", 
        filter : "LP", 
        octave : 1 
    });

    inst1.automate({ aspect: "filterCutoff", time: 0 ticks, value: 0.05 });
    inst1.automate({ aspect: "filterCutoff", time: 80 ticks, value: 0.4 });
    inst1.automate({ aspect: "filterCutoff", time: 100 ticks, value: 1.0 });

    var layer1 = inst1.createLayer({ type : "square" });

    layer1.automate({ aspect: "distortion", time: 0 ticks, value: 0.7 });
    layer1.automate({ aspect: "interval", time: 0 ticks, value: 0.55 });
    layer1.automate({ aspect: "interval", time: 100 ticks, value: 0.5 });
    layer1.automate({ aspect: "amp", time: 0 ticks, value: 1.0 });
};

Properties

A property is a special feature of a variable that can be used to get and/or set some aspect of that variable.

totalLayers

The totalLayers property can be used to find out how many soundLayers exist within a particular soundDesigner

1
var result = inst1.totalLayers;

type

The type property can be used to find out the data-type of a particular soundDesigner. The result will always be "soundDesigner"

1
var result = inst1.type;

Functions

createLayer( object options )

The createLayer function allows you to create a new soundLayer.

1
var layer1 = inst1.createLayer({ type : "sine" });

getLayerX( number x )

The getLayerX function allows you to retrieve one of the soundLayers from within the soundDesigner, by specifying its numerical index. The first soundLayer will have an index of 0, the second soundLayer will have an index of 1, and so on.

1
var layerCopy = inst1.getLayer(0);