From 3523bc99cd94018890f94f2c585e5d4a2a4526f9 Mon Sep 17 00:00:00 2001 From: zepumph Date: Mon, 27 Jul 2020 13:12:51 -0800 Subject: [PATCH] simplify moving in proportion threshold into a single value, https://github.com/phetsims/ratio-and-proportion/issues/9 --- js/common/RatioAndProportionConstants.js | 3 ++- js/common/RatioAndProportionQueryParameters.js | 5 +++-- js/common/view/sound/MovingInProportionSoundGenerator.js | 6 ++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/js/common/RatioAndProportionConstants.js b/js/common/RatioAndProportionConstants.js index 615e99f8..f70ec30d 100644 --- a/js/common/RatioAndProportionConstants.js +++ b/js/common/RatioAndProportionConstants.js @@ -7,6 +7,7 @@ */ import ratioAndProportion from '../ratioAndProportion.js'; +import RatioAndProportionQueryParameters from './RatioAndProportionQueryParameters.js'; const RatioAndProportionConstants = { @@ -18,7 +19,7 @@ const RatioAndProportionConstants = { // distance (in fitness) from max fitness that still indicates a successful proportion when both hands moving in the // same direction. See RatioAndProportionModel.movingInDirection() - MOVING_IN_PROPORTION_FITNESS_THRESHOLD: .3, + MOVING_IN_PROPORTION_FITNESS_THRESHOLD: RatioAndProportionQueryParameters.movingInProportionThreshold, // The value to multiple the keyboard step size by to get the shift + keydown step size SHIFT_KEY_MULTIPLIER: 1 / 5 diff --git a/js/common/RatioAndProportionQueryParameters.js b/js/common/RatioAndProportionQueryParameters.js index 2865ba30..6b9b850c 100644 --- a/js/common/RatioAndProportionQueryParameters.js +++ b/js/common/RatioAndProportionQueryParameters.js @@ -33,11 +33,12 @@ const RatioAndProportionQueryParameters = QueryStringMachine.getAll( { }, /** - * The fitness must be at least this big to allow the "moving in proportion" sound (choir "ahhh"). + * The distance (in fitness) from max fitness that still indicates a successful proportion when both hands moving in the + * same direction. See RatioAndProportionModel.movingInDirection() */ movingInProportionThreshold: { type: 'number', - defaultValue: .7 + defaultValue: .3 }, // For staccato sounds when frequnecy is changing (faster notes at higher fitness): what is the quickest interval diff --git a/js/common/view/sound/MovingInProportionSoundGenerator.js b/js/common/view/sound/MovingInProportionSoundGenerator.js index 5d958f0f..c77aae7b 100644 --- a/js/common/view/sound/MovingInProportionSoundGenerator.js +++ b/js/common/view/sound/MovingInProportionSoundGenerator.js @@ -14,10 +14,8 @@ import movingInProportionOption3 from '../../../../sounds/moving-in-proportion/m import movingInProportionOption4 from '../../../../sounds/moving-in-proportion/moving-in-proportion-loop-option-4_wav.js'; import ratioAndProportion from '../../../ratioAndProportion.js'; import designingProperties from '../../designingProperties.js'; -import RatioAndProportionQueryParameters from '../../RatioAndProportionQueryParameters.js'; // constants -const FITNESS_THRESHOLD = RatioAndProportionQueryParameters.movingInProportionThreshold; const CHOIR_TRANQUILITY_BLEND = 'how wonderful this world is, ahhh.'; const MOVING_IN_PROPORTION_SOUNDS = [ @@ -71,9 +69,9 @@ class MovingInProportionSoundGenerator extends SoundGenerator { Property.multilink( [ model.leftVelocityProperty, model.rightVelocityProperty, ratioFitnessProperty ], ( leftVelocity, rightVelocity, fitness ) => { if ( this.movingInProportionSoundClip ) { - if ( model.movingInDirection() && + if ( model.movingInDirection() && // only when moving !model.valuesTooSmallForSuccess() && // no moving in proportion success if too small - fitness > FITNESS_THRESHOLD ) { // must be fit enough to play the moving in proportion success + model.inProportion() ) { // must be fit enough to play the moving in proportion success this.movingInProportionSoundClip.setOutputLevel( 1, .1 ); !this.movingInProportionSoundClip.isPlaying && this.movingInProportionSoundClip.play(); }