Skip to content

Commit

Permalink
simplify moving in proportion threshold into a single value, #9
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Jul 27, 2020
1 parent 47b16fa commit 3523bc9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
3 changes: 2 additions & 1 deletion js/common/RatioAndProportionConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import ratioAndProportion from '../ratioAndProportion.js';
import RatioAndProportionQueryParameters from './RatioAndProportionQueryParameters.js';

const RatioAndProportionConstants = {

Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions js/common/RatioAndProportionQueryParameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions js/common/view/sound/MovingInProportionSoundGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 3523bc9

Please sign in to comment.