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.
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.
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.