Skip to content

Commit

Permalink
inserted delay between absorption and activity sounds, see #293
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Mar 17, 2020
1 parent 443a86d commit f1341b8
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions js/moleculesandlight/view/MoleculeActionSoundGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import merge from '../../../../phet-core/js/merge.js';

// constants
const USE_SPATIALIZED_SOUNDS = MoleculesAndLightConstants.USE_SPATIALIZED_SOUNDS;
const ABSORPTION_TO_ACTIVITY_SOUND_DELAY = 0.2; // in seconds

class MoleculeActionSoundGenerator extends SoundGenerator {

Expand Down Expand Up @@ -69,7 +70,7 @@ class MoleculeActionSoundGenerator extends SoundGenerator {
moleculeEnergizedLoop.connect( this.masterGainNode );
const updateMoleculeEnergizedSound = moleculeEnergized => {
if ( moleculeEnergized ) {
moleculeEnergizedLoop.play();
moleculeEnergizedLoop.play( ABSORPTION_TO_ACTIVITY_SOUND_DELAY );
}
else {
moleculeEnergizedLoop.stop();
Expand Down Expand Up @@ -122,18 +123,18 @@ class MoleculeActionSoundGenerator extends SoundGenerator {
const molecule = activeMolecules.get( 0 );
if ( molecule.rotationDirectionClockwiseProperty.value ) {
if ( isSlowMotionProperty.value ) {
rotateClockwiseSlowMotionLoop.play();
rotateClockwiseSlowMotionLoop.play( ABSORPTION_TO_ACTIVITY_SOUND_DELAY );
}
else {
rotateClockwiseNormalSpeedLoop.play();
rotateClockwiseNormalSpeedLoop.play( ABSORPTION_TO_ACTIVITY_SOUND_DELAY );
}
}
else {
if ( isSlowMotionProperty.value ) {
rotateCounterclockwiseSlowMotionLoop.play();
rotateCounterclockwiseSlowMotionLoop.play( ABSORPTION_TO_ACTIVITY_SOUND_DELAY );
}
else {
rotateCounterclockwiseNormalSpeedLoop.play();
rotateCounterclockwiseNormalSpeedLoop.play( ABSORPTION_TO_ACTIVITY_SOUND_DELAY );
}
}
}
Expand Down Expand Up @@ -180,10 +181,10 @@ class MoleculeActionSoundGenerator extends SoundGenerator {

// start the vibration sound playing (this will have no effect if the sound is already playing)
if ( isSlowMotionProperty.value ) {
moleculeVibrationSlowMotionLoop.play();
moleculeVibrationSlowMotionLoop.play( ABSORPTION_TO_ACTIVITY_SOUND_DELAY );
}
else {
moleculeVibrationNormalSpeedLoop.play();
moleculeVibrationNormalSpeedLoop.play( ABSORPTION_TO_ACTIVITY_SOUND_DELAY );
}
}
else {
Expand Down

0 comments on commit f1341b8

Please sign in to comment.