audio-oscillator
Generate periodic oscillation data.
Usage
const oscillate = const output = // render sine sound stream; { await }
API
let array = oscillate.<waveform>(length=1024|dst, frequency=440|options?)
Generate periodic-function waveform
samples into a dst
float array / array of arrays / AudioBuffer. If length
is provided, a new mono array
is created. The phase of consequently generated chunks is aligned, if the same array is passed multiple times.
let oscillate = let samples = 1024 oscillate // output array has additional properties of the data// samples.phase, samples.frequency, samples.detune, samples.sampleRate // next data phase is aligned with the previous dataoscillate
options
Property | Default | Meaning |
---|---|---|
frequency , f |
440 |
Frequency of oscillations, in Hz. |
detune |
0 |
Detune of oscillations -100...+100 , in cents. |
phase , t |
0 |
Normalized initial phase of waveform, 0..1 . |
sampleRate , rate |
44100 |
Sample rate of output data. |
waveform
Available waveforms with their additional options:
Type | Waveshape | Parameters |
---|---|---|
'sin' |
||
'cos' |
||
'saw' |
inverse=false |
|
'tri' |
ratio=0.5 |
|
'rect' |
ratio=0.5 |
|
'series' |
real=[0, 1] , imag=[0, 0] , normalize=true |
|
'clausen' |
limit=10 |
|
'step' |
samples=10 |
Related
- periodic-function − a collection of periodic functions.
License
© 2017 Dmitry Yv. MIT License