Sources
Sources are audio-producing nodes that generate or play back sound. Unlike instruments, they don't respond to note triggers.
Oscillator
Generates a periodic waveform. Supports sine, square, sawtooth, and triangle types.
1let osc = Oscillator.make()2let osc2 = Oscillator.makeWithOptions({3 frequency: 440.0,4 "type": "sawtooth",5 detune: 0.0,6 phase: 0.0,7 volume: -12.0,8})9let osc3 = Oscillator.makeWithFreq(440.0, "sine")1011osc->Oscillator.asAudioNode->AudioNode.toDestination1213// Start/stop14osc->Oscillator.start()15osc->Oscillator.stop()16osc->Oscillator.restart()1718// Properties19osc->Oscillator.frequency // Param.t20osc->Oscillator.detune // Param.t21osc->Oscillator.volume // Param.t22osc->Oscillator.getType() // oscillatorType23osc->Oscillator.setType("square")24osc->Oscillator.phase // degrees25osc->Oscillator.partialCount // int26osc->Oscillator.partials // array<float>2728// Frequency sync29osc->Oscillator.syncFrequency()30osc->Oscillator.unsyncFrequency()Player
Plays an audio file. Supports loading from URL and various playback controls.
1let player = Player.make("path/to/audio.mp3")2let player2 = Player.makeWithOptions({3 url: "path/to/audio.mp3",4 loop: true,5 playbackRate: 1.0,6 autostart: false,7})89player->Player.asAudioNode->AudioNode.toDestination1011// Playback12player->Player.start()13player->Player.stop()14player->Player.restart()15player->Player.seek("0:2:0")1617// Properties18player->Player.loop // bool19player->Player.setLoop(true)20player->Player.playbackRate // Param.t21player->Player.reverse // bool22player->Player.setReverse(true)23player->Player.loaded // bool24player->Player.buffer // ToneAudioBuffer.tNoise
Generates noise. Supports white, pink, and brown noise types.
1let noise = Noise.make()2let noise2 = Noise.makeWithType("pink")3let noise3 = Noise.makeWithOptions({4 "type": "brown",5 volume: -20.0,6 playbackRate: 1.0,7})89noise->Noise.asAudioNode->AudioNode.toDestination10noise->Noise.start()11noise->Noise.stop()1213noise->Noise.getType() // "white" | "pink" | "brown"14noise->Noise.setType("pink")