Skip to content

Commit

Permalink
add tick mark bumps to enhanced sound, #158
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Sep 2, 2020
1 parent e5a23fd commit e728c57
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
17 changes: 10 additions & 7 deletions js/common/view/RatioHalf.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import ArrowNode from '../../../../scenery-phet/js/ArrowNode.js';
import DragListener from '../../../../scenery/js/listeners/DragListener.js';
import Rectangle from '../../../../scenery/js/nodes/Rectangle.js';
import SoundClip from '../../../../tambo/js/sound-generators/SoundClip.js';
import SoundLevelEnum from '../../../../tambo/js/SoundLevelEnum.js';
import soundManager from '../../../../tambo/js/soundManager.js';
import sliderBoundaryClickSound from '../../../../tambo/sounds/general-boundary-boop_mp3.js';
import sliderClickSound from '../../../../tambo/sounds/general-soft-click_mp3.js';
Expand Down Expand Up @@ -129,7 +130,6 @@ class RatioHalf extends Rectangle {
} );
this.addChild( this.ratioHandNode );

// Sound for the wave slider clicks
const addSoundOptions = { categoryName: 'user-interface' };
const soundClipOptions = {
initialOutputLevel: 0.15,
Expand All @@ -141,14 +141,17 @@ class RatioHalf extends Rectangle {
soundManager.addSoundGenerator( commonReleaseSoundClip, addSoundOptions );

const tickMarksDisplayedProperty = new DerivedProperty( [ tickMarkViewProperty ], tickMarkView => tickMarkView !== TickMarkView.NONE );

const tickMarkBumpSoundClip = new SoundClip( sliderClickSound, merge( soundClipOptions, {
const tickMarkBumpSoundClip = new SoundClip( sliderClickSound, merge( {}, soundClipOptions, {
enableControlProperties: soundClipOptions.enableControlProperties.concat( [ tickMarksDisplayedProperty, playTickMarkBumpSoundProperty ] )
} ) );
soundManager.addSoundGenerator( tickMarkBumpSoundClip, addSoundOptions );

const sliderBoundaryClickSoundClip = new SoundClip( sliderBoundaryClickSound, soundClipOptions );
soundManager.addSoundGenerator( sliderBoundaryClickSoundClip, addSoundOptions );
const enhancedAddSoundOptions = merge( {
sonificationLevel: SoundLevelEnum.ENHANCED
}, addSoundOptions );
soundManager.addSoundGenerator( tickMarkBumpSoundClip, enhancedAddSoundOptions );

const boundaryClickSoundClip = new SoundClip( sliderBoundaryClickSound, soundClipOptions );
soundManager.addSoundGenerator( boundaryClickSoundClip, enhancedAddSoundOptions );

// Keep track of the previous value on slider drag for playing sounds
let lastValue = valueProperty.value;
Expand Down Expand Up @@ -231,7 +234,7 @@ class RatioHalf extends Rectangle {
for ( let i = 0; i < tickMarkRangeProperty.value; i++ ) {
const tickValue = ( i / valueRange.getLength() ) / tickMarkRangeProperty.value;
if ( lastValue !== value && ( value === valueRange.min || value === valueRange.max ) ) {
sliderBoundaryClickSoundClip.play();
boundaryClickSoundClip.play();
break;
}
else if ( lastValue < tickValue && value >= tickValue || lastValue > tickValue && value <= tickValue ) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"runnable": true,
"readmeCreatedManually": true,
"supportsSound": true,
"supportsEnhancedSound": true,
"supportsZoom": true,
"supportsInteractiveDescriptions": true,
"supportedBrands": [
Expand Down
1 change: 1 addition & 0 deletions ratio-and-proportion_en.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"runnable": true,
"readmeCreatedManually": true,
"supportsSound": true,
"supportsEnhancedSound": true,
"supportsZoom": true,
"supportsInteractiveDescriptions": true,
"supportedBrands": [
Expand Down

0 comments on commit e728c57

Please sign in to comment.