From 368de9d54d0c5d9b7ca3023385ae5c3496eb6542 Mon Sep 17 00:00:00 2001 From: jbphet Date: Thu, 24 Mar 2022 12:42:27 -0600 Subject: [PATCH] TS conversion step, see https://github.com/phetsims/tambo/issues/160 --- .../testing/model/AmplitudeModulatorDemo.ts | 19 +++++++++---------- js/sound-generators/SoundGenerator.ts | 6 +++--- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/js/demo/testing/model/AmplitudeModulatorDemo.ts b/js/demo/testing/model/AmplitudeModulatorDemo.ts index 04d51e74..4af073b7 100644 --- a/js/demo/testing/model/AmplitudeModulatorDemo.ts +++ b/js/demo/testing/model/AmplitudeModulatorDemo.ts @@ -1,31 +1,30 @@ // Copyright 2020-2022, University of Colorado Boulder -// @ts-nocheck - import saturatedSineLoop220Hz_mp3 from '../../../../sounds/saturatedSineLoop220Hz_mp3.js'; import windsLoopC3Oscilloscope_mp3 from '../../../../sounds/demo-and-test/windsLoopC3Oscilloscope_mp3.js'; import windsLoopMiddleCOscilloscope_mp3 from '../../../../sounds/demo-and-test/windsLoopMiddleCOscilloscope_mp3.js'; import AmplitudeModulator from '../../../AmplitudeModulator.js'; import SoundClip from '../../../sound-generators/SoundClip.js'; -import SoundGenerator from '../../../sound-generators/SoundGenerator.js'; +import SoundGenerator, { SoundGeneratorOptions } from '../../../sound-generators/SoundGenerator.js'; import tambo from '../../../tambo.js'; +import NumberProperty from '../../../../../axon/js/NumberProperty.js'; /** * Demo and test harness for the AmplitudeModulator class. This creates several sound loops and routes them through * an amplitude modulator instance. It also provides the properties that can be manipulated in the view to change the * attributes of the modulation. */ + + class AmplitudeModulatorDemo extends SoundGenerator { - /** - * @param {NumberProperty} sourceSoundIndexProperty - index of the selected sound, 0 indicates none - * @param {Object} [options] - */ - constructor( sourceSoundIndexProperty, options ) { + public readonly amplitudeModulator: AmplitudeModulator; + + constructor( sourceSoundIndexProperty: NumberProperty, options: SoundGeneratorOptions ) { super( options ); - // @public {AmplitudeModulator} + // Create the amplitude modulator. this.amplitudeModulator = new AmplitudeModulator(); this.amplitudeModulator.connect( this.soundSourceDestination ); @@ -59,7 +58,7 @@ class AmplitudeModulatorDemo extends SoundGenerator { * @public */ reset() { - this.amplitudeModulator.enabledProperty.reset(); + this.amplitudeModulator.enabledProperty.set( true ); this.amplitudeModulator.frequencyProperty.reset(); this.amplitudeModulator.depthProperty.reset(); this.amplitudeModulator.waveformProperty.reset(); diff --git a/js/sound-generators/SoundGenerator.ts b/js/sound-generators/SoundGenerator.ts index 7f6cae0e..0155821c 100644 --- a/js/sound-generators/SoundGenerator.ts +++ b/js/sound-generators/SoundGenerator.ts @@ -209,12 +209,12 @@ abstract class SoundGenerator { /** * Connect the sound generator to an audio parameter. */ - connect( audioParam: AudioParam ) { - this.masterGainNode.connect( audioParam ); + connect( audioParam: AudioParam | AudioNode ) { + this.masterGainNode.connect( audioParam as AudioParam ); // Track this sound generator's connections. This is necessary because Web Audio doesn't support checking which // nodes are connected to which, and we need this information when disconnecting. - this.connectionList.push( audioParam ); + this.connectionList.push( audioParam as AudioParam ); } /**