Skip to content

OscillatorSoundGenerator

Under Construction

This documentation is auto-generated, and is a work in progress. Please see the source code at https://github.com/phetsims/tambo/blob/main/js/sound-generators/OscillatorSoundGenerator.ts for the most up-to-date information.

Overview

OscillatorSoundGenerator is a Web Audio oscillator node wrapped in a sound generator so that it can be easily be used in PhET sims.

@author John Blanco (PhET Interactive Simulations)

Class OscillatorSoundGenerator

import { OscillatorSoundGenerator } from 'scenerystack/tambo';

Constructor

new OscillatorSoundGenerator( providedOptions? : OscillatorSoundGeneratorOptions )

Instance Methods

play()

Starts the oscillator. The name 'play' is used because this is commonly used in the tambo library for sound generators. If the oscillator is already playing, this has no effect.

stop()

Stops the oscillator. If the oscillator isn't playing, this has no effect.

setWaveformType( waveformType : OscillatorType )

Sets the waveform type.

Type OscillatorSoundGeneratorOptions

import type { OscillatorSoundGeneratorOptions } from 'scenerystack/tambo';
  • initialFrequency?: number
    initial frequency in Hz, can be changed later
  • initialWaveformType?: OscillatorType
    initial waveform type, can be changed later
  • & SoundGeneratorOptions

Source Code

See the source for OscillatorSoundGenerator.ts in the tambo repository.