Skip to content

Commit

Permalink
TypeScript conversion for SoundGenerator/ValueChangeSoundGenerator (a…
Browse files Browse the repository at this point in the history
…dded ISoundPlayer). See phetsims/scenery-phet#726
  • Loading branch information
jonathanolson committed Mar 5, 2022
1 parent e1243bd commit 7a1fbcd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion js/common/view/ConcentrationControlPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions js/common/view/TemperatureSoundGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
} );
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion js/common/view/TemperatureSoundGeneratorFiltered.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion js/common/view/TemperatureSoundGeneratorSpeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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.
Expand Down

0 comments on commit 7a1fbcd

Please sign in to comment.