Reference > Wave
Wave
Spectrum
Wave(size)
is a class that creates the wave objects that store sounds in synthesine. A wave is an array of 32 bit floating point numbers, along with some prebuilt functions to manipulate waves.
size (optional)
This sets the size of the array. Typically we leave this empty. If unspecified, the length of a wave is set tonumSamples
, which is 128 by default.
Wave
is an extension of javascript’s built-in Float32Array
, so it inherits all the Float32Array methods.
Usage
new Wave()
creates an empty wave.new Wave().fill(0.1)
creates a wave filled with the value 0.1new Wave().map((e,i) => i/128)
creates a wave with 128 equally spaced values from 0 to 1
Wave Manipulation Functions
.add
adds two waves together.sub
subtracts one wave from another.mult
multiples two waves or multiplies a wave with a number.div
divides two waves or divides a wave with a number.modulate
modulates one wave with another wave
You can find the code for Wave
in the synthesine library.