Skip to content

Commit

Permalink
replace enableControlProperties with enabledProperty, mute sounds dur…
Browse files Browse the repository at this point in the history
…ing reset by default, & other sound lib API improvements, see phetsims/tambo#189
  • Loading branch information
jbphet committed Jul 12, 2024
1 parent a214785 commit 9f7a7f2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 2 additions & 4 deletions js/discrete/view/DiscreteScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,8 @@ export default class DiscreteScreenView extends ScreenView {
//------------------------------------------------------------------------------------------------------------------

// Sound for the Fourier series
const fourierSoundGenerator = new FourierSoundGenerator( model.fourierSeries );
soundManager.addSoundGenerator( fourierSoundGenerator, {
associatedViewNode: this
} );
const fourierSoundGenerator = new FourierSoundGenerator( model.fourierSeries, this );
soundManager.addSoundGenerator( fourierSoundGenerator );

//------------------------------------------------------------------------------------------------------------------
// Amplitudes chart
Expand Down
8 changes: 5 additions & 3 deletions js/discrete/view/FourierSoundGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,21 @@ import soundManager from '../../../../tambo/js/soundManager.js';
import FMWConstants from '../../common/FMWConstants.js';
import FourierSeries from '../../common/model/FourierSeries.js';
import fourierMakingWaves from '../../fourierMakingWaves.js';
import { Node } from '../../../../scenery/js/imports.js';

// Output level range of each harmonic. These have a reduced range because harmonics are summed.
// See https://github.com/phetsims/fourier-making-waves/issues/45
const HARMONIC_OUTPUT_LEVEL_RANGE = new Range( -1 / FMWConstants.MAX_HARMONICS, 1 / FMWConstants.MAX_HARMONICS );

export default class FourierSoundGenerator extends SoundGenerator {

public constructor( fourierSeries: FourierSeries ) {
public constructor( fourierSeries: FourierSeries, associatedViewNode: Node ) {

super( {

// SoundGeneratorOptions
initialOutputLevel: fourierSeries.soundOutputLevelProperty.value
initialOutputLevel: fourierSeries.soundOutputLevelProperty.value,
associatedViewNode: associatedViewNode
} );

// Maps amplitude to an output level that is appropriate for SoundGenerator.
Expand Down Expand Up @@ -74,7 +76,7 @@ export default class FourierSoundGenerator extends SoundGenerator {
this.setOutputLevel( outputLevel, timeConstant );
} );

// Turn sound on/off. We could have controlled this via options.enableControlProperties,
// Turn sound on/off. We could have controlled this via options.enabledProperty,
// but stopping OscillatorSoundGenerators may use fewer resources.
fourierSeries.soundEnabledProperty.link( enabled => {
if ( enabled ) {
Expand Down

0 comments on commit 9f7a7f2

Please sign in to comment.