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.
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.
Now it's time to actually make some sound.
Last updated
Was this helpful?