Audio Graph

Audio Graph Basics

As mentioned in the Introduction section, Sattern operates around the Audio Graph concept. Audio Graphs are a way to house multiple "audio units" or nodes and interconnect them to each other.

Let's begin by adding some code to our "main.js" file that creates a new Sampler object and adds it to Sattern's main audio graph object.

// main.js
// Arpeggiator
//
// Created by Jacob Sologub on 23 Jul 2020.
// Copyright © 2020 Jacob Sologub. All rights reserved.

const sampler = new sattern.Sampler();
sattern.graph.add (sampler);

The code on line #7 creates a new sampler object and the code on line #8 adds the newly created sampler object to Sattern's main graph object. You can copy the above code snippet and replace the contents of your "main.js" file. Press Command + R or Command + S to save and re-load the current file.

The defaultsattern.Graph.add()method connects the specified node (sampler) object's default output channel(s) to the graph object's default output channel(s). You can specify what channel(s) are connected explicitly if you want to for example only connect the sampler object's left output channel to the graph object's right output channel etc. Please refer to the JavaScript API Documentation for more details.

Samplers need some sort of audio file(s) to make sound, so let's add some sounds to our sampler object.

// main.js
// Arpeggiator
//
// Created by Jacob Sologub on 23 Jul 2020.
// Copyright © 2020 Jacob Sologub. All rights reserved.

const sampler = new sattern.Sampler();
sattern.graph.add (sampler);

const sound = new sattern.Sound ("./mcg_mp_064.wav", { 
    lowKey: 0, highKey: 127, rootKey: 64 
});
sampler.add (sound);

The newly added lines #10-12 create a sound object for the specified .wav file and sets the lowKey, highKey and rootKey properties that will be used to "map" the specified sound one it is added to the sampler object. Line #13 adds the newly created sound object to our sampler object. Again, copy the above code snippet and replace the contents of your "main.js" file. Press Command + R or Command + S to save and re-load the current file.

The sample being used in this example is taken from Linux Sampler Project's Maestro Concert Grand v2 library and can be downloaded below. Place this file inside the project's root folder.

Command + S saves the current file being edited, and Command + R reloads the entire Sattern JavaScript context.

Now it's time to actually make some sound.

Last updated