Skip to content

DiscreteSoundGenerator

Overview

DiscreteSoundGenerator produces sounds based on the value of a number property. It monitors the property value and maps it to one of a finite number of bins, and produces a discrete sound when the bin to which the value is mapped changes.

@author John Blanco (PhET Interactive Simulations)

Class DiscreteSoundGenerator

import { DiscreteSoundGenerator } from 'scenerystack/tambo';

Constructor

new DiscreteSoundGenerator( valueProperty : NumberProperty, valueRange : Range, providedOptions? : DiscreteSoundGeneratorOptions )

Instance Methods

dispose()

Type DiscreteSoundGeneratorOptions

import type { DiscreteSoundGeneratorOptions } from 'scenerystack/tambo';
  • sound?: WrappedAudioBuffer
    the sound that will be played at the discrete values
  • numBins?: 7
    number of discrete bins, crossing between them will produce a sound
  • playbackRateRange?: Range
    the range over which the playback rate is varied, 1 is normal speed, 2 is double speed, et cetera
  • alwaysPlayOnChangesProperty?: null | BooleanProperty
    when true will cause sound to be played on any change of the value property
  • playSoundAtMin?: boolean
    If true, the sound will be played when the value reaches the min.
  • playSoundAtMax?: boolean
    If true, the sound will be played when the value reaches the max.
  • outOfRangeValuesOK?: boolean
    a flag that indicates whether out of range values should be ignored
  • & SoundClipOptions

Source Code

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