Reference > WaveGuide
Wave
Spectrum
WaveGuide(size) is a class that creates a wave guide object. A wave guide is implemented in synthesine as a circular buffer. This is a type of array where we can shift the point at which we start reading from, and where the end is followed by the start. Wave guides such as these are used in simulating musical instruments.
size (optional)This sets the size of the array, and can be any positive integer.
WaveGuide is an extension of Wave, which is itself an extension of javascript’s built-in Float32Array, so it inherits all the Float32Array methods.
Usage
new WaveGuide(size);creates an empty wave guide.new WaveGuide().fill(0.1)creates a wave guide filled with the value 0.1new WaveGuide(100).map((e,i) => i/100)creates a wave guide filled with 100 equally spaced values from 0 to 1
Wave Guide Manipulation Functions
.delay(n)shifts the current position of the wave guide bynsamples, and returns the wave guide. To shift the wave guide by a full audio cycle, use n = 128 (i.e.numSamples).set(array)sets the next 128 values of the wave guide to the entries ofarray. The wave guide is rewritten in a circular fashion, starting from the current position..get()returns the next 128 values of the wave guide, starting from the current position.
Wave Manipulation Functions
.addadds two waves together.subsubtracts one wave from another.multmultiples two waves or multiplies a wave with a number.divdivides two waves or divides a wave with a number.modulatemodulates one wave with another wave.mapapplies any function onto the wave entries
You can find the code for WaveGuide in the synthesine library.