Skip to content

MultiClip

Overview

MultiClip is a sound generator that plays one-shot sounds from a set of pre-recorded files that are provided upon construction. This is often used as a base class for a sound generator when a finite set of sounds clips need to be played in response to different values of a model parameter.

Individual gain controls are not provided for the different sound clips in this class, there is just a single gain node for the sound generator as a whole. The intent here is that this saves resources by not creating unneeded gain nodes. If such fine-grained control is needed, a similar type could be created using multiple instances of the SoundClip class.

This class only supports clips that are played as one shots, i.e. it does not include support for looping.

@author John Blanco (PhET Interactive Simulations)

Class MultiClip

import { MultiClip } from 'scenerystack/tambo';

Constructor

new MultiClip( valueToWrappedAudioBufferMap : Map<T, WrappedAudioBuffer>, providedOptions? : MultiClipOptions )

Instance Methods

playAssociatedSound( value : T, delay )

play the sound associated with the provided value

setPlaybackRate( playbackRate : number )

Change the speed that the sound playback occurs. Note, this does not affect playing sounds, but will only affect subsequent plays of sounds. @param playbackRate - desired playback speed, 1 = normal speed

stopAll()

Stop playing any sounds that are currently in progress.

Type MultiClipOptions

import type { MultiClipOptions } from 'scenerystack/tambo';

Source Code

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