API reference
Every public class, method, and event in @codexo/exojs. Generated from source.
classOscillatorSound
Procedural tone generator — generates audio without an AudioBuffer asset. Useful for prototyping, game-jam SFX, retro-style sound effects, music apps that need synthesizer-style tones. Each `play()` creates a new OscillatorNode (oscillators are one-shot in Web Audio). Pool semantics match `Sound`: multiple concurrent voices up to `poolSize`, FIFO eviction by default. const tone = new OscillatorSound({ frequency: 440, type: 'sine' }); tone.play(); // plays A4 sine wave tone.frequency = 880; tone.play(); // plays A5 (in addition to A4 if pool > 1) For musical applications, use `setNote(midi)`: tone.setNote(69); // MIDI 69 = A4 tone.setNote(60); // C4 (middle C) With an envelope for smooth attack/release: const synth = new OscillatorSound({ frequency: 440, envelope: new Envelope({ attackMs: 50, decayMs: 100, sustainLevel: 0.7, releaseMs: 300 }), }); synth.play(); // ... later synth.pause(); // triggers release phase, stops after releaseMs
import { OscillatorSound } from '@codexo/exojs' Procedural tone generator — generates audio without an AudioBuffer asset. Useful for prototyping, game-jam SFX, retro-style sound effects, music apps that need synthesizer-style tones.
Each `play()` creates a new OscillatorNode (oscillators are one-shot in Web Audio). Pool semantics match `Sound`: multiple concurrent voices up to `poolSize`, FIFO eviction by default.
const tone = new OscillatorSound({ frequency: 440, type: 'sine' }); tone.play(); // plays A4 sine wave tone.frequency = 880; tone.play(); // plays A5 (in addition to A4 if pool > 1)
For musical applications, use `setNote(midi)`:
tone.setNote(69); // MIDI 69 = A4 tone.setNote(60); // C4 (middle C)
With an envelope for smooth attack/release:
const synth = new OscillatorSound({ frequency: 440, envelope: new Envelope({ attackMs: 50, decayMs: 100, sustainLevel: 0.7, releaseMs: 300 }), }); synth.play(); // ... later synth.pause(); // triggers release phase, stops after releaseMs
new(options: OscillatorSoundOptions): OscillatorSound _connectToBus(): void _defaultBus(): AudioBus _disconnectFromBus(): void _getAudioSetup(): object | null applyOptions(options: Partial<PlaybackOptions>): this destroy(): void fadeIn(durationMs: number): this fadeOut(durationMs: number, options: object): this getTime(): number pause(): this play(options: OscillatorPlayOptions): this setLoop(loop: boolean): this setMuted(muted: boolean): this setNote(midiNote: number): this setPlaybackRate(value: number): this setTime(_currentTime: number): this setVolume(value: number): this stop(options?: Partial<PlaybackOptions>): this toggle(options?: Partial<PlaybackOptions>): this midiToFrequency(midiNote: number): number detune: number envelope: Envelope | null frequency: number poolSize: number poolStrategy: SoundPoolStrategy priority: number type: OscillatorType analyserTarget: GainNode | null bus: AudioBus currentTime: number duration: number loop: boolean muted: boolean paused: boolean playbackRate: number playing: boolean progress: number volume: number onStart: Signal<[]> onStop: Signal<[]>