From 7a1fbcd152fcc63351191341220465bba2d17885 Mon Sep 17 00:00:00 2001 From: Jonathan Olson Date: Sat, 5 Mar 2022 10:09:28 -0700 Subject: [PATCH] TypeScript conversion for SoundGenerator/ValueChangeSoundGenerator (added ISoundPlayer). See https://github.com/phetsims/scenery-phet/issues/726 --- js/common/view/ConcentrationControlPanel.ts | 3 ++- js/common/view/TemperatureSoundGenerator.ts | 5 +++-- js/common/view/TemperatureSoundGeneratorFiltered.ts | 4 +++- js/common/view/TemperatureSoundGeneratorSpeed.ts | 3 ++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/js/common/view/ConcentrationControlPanel.ts b/js/common/view/ConcentrationControlPanel.ts index 8c1bac3f..7d9a28b6 100644 --- a/js/common/view/ConcentrationControlPanel.ts +++ b/js/common/view/ConcentrationControlPanel.ts @@ -22,7 +22,7 @@ import RectangularRadioButtonGroup from '../../../../sun/js/buttons/RectangularR import Panel from '../../../../sun/js/Panel.js'; import VSlider from '../../../../sun/js/VSlider.js'; import SoundClip from '../../../../tambo/js/sound-generators/SoundClip.js'; -import SoundGenerator from '../../../../tambo/js/sound-generators/SoundGenerator.js'; +import SoundGenerator, { SoundGeneratorOptions } from '../../../../tambo/js/sound-generators/SoundGenerator.js'; import soundManager from '../../../../tambo/js/soundManager.js'; import Tandem from '../../../../tandem/js/Tandem.js'; import sliderMovement_mp3 from '../../../sounds/sliderMovement_mp3.js'; @@ -547,6 +547,7 @@ class ConcentrationSliderSoundGenerator extends SoundGenerator { this.baseSoundClip = new SoundClip( sliderMovement_mp3, { rateChangesAffectPlayingSounds: false } ); + // @ts-ignore TODO: typing for AudioParam this.baseSoundClip.connect( dynamicsCompressorNode ); // The number of bins was chosen to match the design of the slider. diff --git a/js/common/view/TemperatureSoundGenerator.ts b/js/common/view/TemperatureSoundGenerator.ts index ba40eb50..b1a01403 100644 --- a/js/common/view/TemperatureSoundGenerator.ts +++ b/js/common/view/TemperatureSoundGenerator.ts @@ -9,7 +9,7 @@ import Property from '../../../../axon/js/Property.js'; import SoundClip from '../../../../tambo/js/sound-generators/SoundClip.js'; -import SoundGenerator from '../../../../tambo/js/sound-generators/SoundGenerator.js'; +import SoundGenerator, { SoundGeneratorOptions } from '../../../../tambo/js/sound-generators/SoundGenerator.js'; import greenhouseTemperatureHighV2_mp3 from '../../../sounds/greenhouseTemperatureHighV2_mp3.js'; import greenhouseTemperatureHighV3_mp3 from '../../../sounds/greenhouseTemperatureHighV3_mp3.js'; import greenhouseTemperatureHigh_mp3 from '../../../sounds/greenhouseTemperatureHigh_mp3.js'; @@ -88,6 +88,7 @@ class TemperatureSoundGenerator extends SoundGenerator { // the temperature sound loops in order from lowest temperature to highest this.temperatureSoundClipLoops = orderedTemperatureSoundSets.map( sound => { const soundClip = new SoundClip( sound, { loop: true } ); + // @ts-ignore TODO: typing for AudioParam soundClip.connect( this.masterGainNode ); return soundClip; } ); @@ -124,7 +125,7 @@ class TemperatureSoundGenerator extends SoundGenerator { // Get a value that summarizes the state of all the enable-control properties. const okayToPlay = this.enableControlProperties.reduce( - ( valueSoFar: boolean, enabled: boolean ) => valueSoFar || enabled + ( valueSoFar, enabled ) => valueSoFar || enabled.value, true ); // Set the volume levels for any loops that are non-zero. diff --git a/js/common/view/TemperatureSoundGeneratorFiltered.ts b/js/common/view/TemperatureSoundGeneratorFiltered.ts index d8560214..61af08e9 100644 --- a/js/common/view/TemperatureSoundGeneratorFiltered.ts +++ b/js/common/view/TemperatureSoundGeneratorFiltered.ts @@ -10,7 +10,7 @@ import LinearFunction from '../../../../dot/js/LinearFunction.js'; import Range from '../../../../dot/js/Range.js'; import SoundClip from '../../../../tambo/js/sound-generators/SoundClip.js'; -import SoundGenerator from '../../../../tambo/js/sound-generators/SoundGenerator.js'; +import SoundGenerator, { SoundGeneratorOptions } from '../../../../tambo/js/sound-generators/SoundGenerator.js'; import greenhouseEffectTemperatureBaseAmbience4Octaves_mp3 from '../../../sounds/greenhouseEffectTemperatureBaseAmbience4Octaves_mp3.js'; import greenhouseEffect from '../../greenhouseEffect.js'; import GreenhouseEffectOptionsDialogContent from './GreenhouseEffectOptionsDialogContent.js'; @@ -54,7 +54,9 @@ class TemperatureSoundGeneratorFiltered extends SoundGenerator { bandPassFilter.Q.value = FILTER_Q; // Send the loop into both filters. + // @ts-ignore TODO: typing for AudioParam baseSoundLoop.connect( lowPassFilter ); + // @ts-ignore TODO: typing for AudioParam baseSoundLoop.connect( bandPassFilter ); // Put the appropriate filter in the signal chain depending on which sound generation is selected for temperature. diff --git a/js/common/view/TemperatureSoundGeneratorSpeed.ts b/js/common/view/TemperatureSoundGeneratorSpeed.ts index 4f10b3ec..b7196e7f 100644 --- a/js/common/view/TemperatureSoundGeneratorSpeed.ts +++ b/js/common/view/TemperatureSoundGeneratorSpeed.ts @@ -10,7 +10,7 @@ import LinearFunction from '../../../../dot/js/LinearFunction.js'; import Range from '../../../../dot/js/Range.js'; import SoundClip from '../../../../tambo/js/sound-generators/SoundClip.js'; -import SoundGenerator from '../../../../tambo/js/sound-generators/SoundGenerator.js'; +import SoundGenerator, { SoundGeneratorOptions } from '../../../../tambo/js/sound-generators/SoundGenerator.js'; import greenhouseTemperatureRisingWithBaseNoteLow_mp3 from '../../../sounds/greenhouseTemperatureRisingWithBaseNoteLow_mp3.js'; import greenhouseEffect from '../../greenhouseEffect.js'; import Property from '../../../../axon/js/Property.js'; @@ -31,6 +31,7 @@ class TemperatureSoundGeneratorSpeed extends SoundGenerator { const baseSoundLoop = new SoundClip( greenhouseTemperatureRisingWithBaseNoteLow_mp3, { loop: true } ); + // @ts-ignore TODO: typing for AudioParam baseSoundLoop.connect( this.masterGainNode ); // This loop should be producing sound whenever the sun is shining.