Skip to content

Commit

Permalink
remove TODO and lastStaccatoSoundValue, #127
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Sep 29, 2020
1 parent 7a33099 commit e2d647f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 39 deletions.
1 change: 0 additions & 1 deletion js/common/model/RAPRatioTuple.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

/**
* Data type that holds both terms of the ratio
* // TODO: use Poolable? https://github.com/phetsims/ratio-and-proportion/issues/181
* @author Michael Kauzmann (PhET Interactive Simulations)
*/

Expand Down
28 changes: 13 additions & 15 deletions js/common/view/sound/MovingInProportionSoundGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,20 @@ class MovingInProportionSoundGenerator extends SoundGenerator {
// @private {SoundClip|MultiSoundClip|null} - null when no sound
this.movingInProportionSoundClip = null;

this.movingInProportionSoundClip = new MultiSoundClip( [
{
sound: choirAhhSound,
options: {
loop: true,
trimSilence: true
}
}, {
sound: movingInProportionOption4,
options: {
loop: true,
initialOutputLevel: .6,
trimSilence: true
}
this.movingInProportionSoundClip = new MultiSoundClip( [ {
sound: choirAhhSound,
options: {
loop: true,
trimSilence: true
}
] );
}, {
sound: movingInProportionOption4,
options: {
loop: true,
initialOutputLevel: .6,
trimSilence: true
}
} ] );
this.movingInProportionSoundClip.connect( this.soundSourceDestination );

Property.multilink( [
Expand Down
24 changes: 1 addition & 23 deletions js/common/view/sound/StaccatoFrequencySoundGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ class StaccatoFrequencySoundGenerator extends SoundGenerator {

// @private - in ms, keep track of the amount of time that has passed since the last staccato sound played
this.timeSinceLastPlay = 0;

// @private {number} - keep track of the last value to prevent the same sound from being played twice in a row.
// TODO: do we need this, or would it be ok to repeat these sounds sometimes?
this.lastStaccatoSoundValue = -1;
}

/**
Expand All @@ -112,29 +108,11 @@ class StaccatoFrequencySoundGenerator extends SoundGenerator {
const isInRatio = this.isInProportion();
if ( this.timeSinceLastPlay > this.timeLinearFunction( newFitness ) && !isInRatio && newFitness > 0 ) {
const sounds = this.staccatoSoundClips[ Math.floor( newFitness * this.staccatoSoundClips.length ) ];
sounds[ this.getStaccatoSoundValueToPlay() ].play();
sounds[ Math.floor( phet.joist.random.nextDouble() * sounds.length ) ].play();
this.timeSinceLastPlay = 0;
}
}

/**
* Get the value of the MultiClip map for the staccato sound to play, see "staccatoSoundMap"
* @returns {number}
* @private
*/
getStaccatoSoundValueToPlay() {

let soundValue = this.lastStaccatoSoundValue;
while ( soundValue === this.lastStaccatoSoundValue ) {

// "3 + 1" is a hard coded number based on staccatoSoundMap
soundValue = Math.floor( phet.joist.random.nextDouble() * 3 );
}

this.lastStaccatoSoundValue = soundValue;
return soundValue;
}

/**
* stop any in-progress sound generation
* @public
Expand Down

0 comments on commit e2d647f

Please sign in to comment.