Skip to content

Commit

Permalink
TS conversion step, see #160
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Mar 24, 2022
1 parent 3578742 commit 368de9d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
19 changes: 9 additions & 10 deletions js/demo/testing/model/AmplitudeModulatorDemo.ts
Original file line number Diff line number Diff line change
@@ -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 );

Expand Down Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions js/sound-generators/SoundGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

/**
Expand Down

0 comments on commit 368de9d

Please sign in to comment.