Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Feb 17, 2021
2 parents 9373fb5 + 3dab92e commit 364d974
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 193 deletions.
22 changes: 9 additions & 13 deletions js/balloons-and-static-electricity/view/BalloonNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,8 @@ import Rectangle from '../../../../scenery/js/nodes/Rectangle.js';
import SoundClip from '../../../../tambo/js/sound-generators/SoundClip.js';
import soundManager from '../../../../tambo/js/soundManager.js';
import Utterance from '../../../../utterance-queue/js/Utterance.js';
import grabBalloonSound from '../../../sounds/balloon-grab-002_mp3.js';
// import grabBalloonSound from '../../../sounds/balloon-grab-003_mp3.js';
// import grabBalloonSound from '../../../sounds/balloon-grab-004_mp3.js';
// import grabBalloonSound from '../../../sounds/balloon-grab-005_mp3.js';
import releaseBalloonSound from '../../../sounds/balloon-release-002_mp3.js';
// import releaseBalloonSound from '../../../sounds/balloon-release-003_mp3.js';
// import releaseBalloonSound from '../../../sounds/balloon-release-004_mp3.js';
// import releaseBalloonSound from '../../../sounds/balloon-release-005_mp3.js';
import grabBalloonSound from '../../../sounds/balloon-grab-004_mp3.js';
import releaseBalloonSound from '../../../sounds/balloon-release-004_mp3.js';
import balloonsAndStaticElectricity from '../../balloonsAndStaticElectricity.js';
import BASEA11yStrings from '../BASEA11yStrings.js';
import BASEQueryParameters from '../BASEQueryParameters.js';
Expand All @@ -53,7 +47,7 @@ const X_POSITIONS = PlayAreaMap.X_POSITIONS;

// constants
const grabBalloonKeyboardHelpString = BASEA11yStrings.grabBalloonKeyboardHelp.value;
const GRAB_RELEASE_SOUND_LEVEL = 0.2; // empirically determined
const GRAB_RELEASE_SOUND_LEVEL = 0.1; // empirically determined

class BalloonNode extends Node {

Expand Down Expand Up @@ -209,14 +203,16 @@ class BalloonNode extends Node {
addedChargesNode.visible = true;
}
else {
const visiblity = ( value === 'all' );
originalChargesNode.visible = visiblity;
addedChargesNode.visible = visiblity;
const visibility = ( value === 'all' );
originalChargesNode.visible = visibility;
addedChargesNode.visible = visibility;
}
} );

// sound generation for drift velocity
soundManager.addSoundGenerator( new BalloonVelocitySoundGenerator( model.velocityProperty ) );
soundManager.addSoundGenerator(
new BalloonVelocitySoundGenerator( model.velocityProperty, model.onSweaterProperty, model.touchingWallProperty )
);

// sound generation for when the balloon is being rubbed on the sweater
soundManager.addSoundGenerator(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* @author John Blanco
*/

import Property from '../../../../axon/js/Property.js';
import LinearFunction from '../../../../dot/js/LinearFunction.js';
import merge from '../../../../phet-core/js/merge.js';
import SoundClip from '../../../../tambo/js/sound-generators/SoundClip.js';
Expand All @@ -24,9 +25,11 @@ class BalloonVelocitySoundGenerator extends SoundClip {
/**
* {Property.<number>} balloonVelocityProperty - velocity of the balloon when drifting (i.e. when it is not being
* dragged by a user).
* {Property.<boolean>} onSweaterProperty - whether the balloon is on the sweater
* {Property.<boolean>} touchingWallProperty - whether the balloon is touching the wall
* {Object} [options]
*/
constructor( balloonVelocityProperty, options ) {
constructor( balloonVelocityProperty, onSweaterProperty, touchingWallProperty, options ) {

options = merge(
{
Expand All @@ -50,10 +53,13 @@ class BalloonVelocitySoundGenerator extends SoundClip {

super( driftVelocityLoop, options );

// Monitor the balloon velocity and modify the output sound as changes occur.
balloonVelocityProperty.lazyLink( velocity => {
const speed = velocity.magnitude;
if ( speed > 0 ) {
// Monitor the balloon velocity and modify the output sound as changes occur. If the balloon is on the sweater or
// the wall, no sound should be produced.
const outputUpdaterMultilink = Property.multilink(
[ balloonVelocityProperty, onSweaterProperty, touchingWallProperty ],
( balloonVelocity, onSweater, touchingWall ) => {
const speed = balloonVelocity.magnitude;
if ( speed > 0 && !( onSweater || touchingWall ) ) {
if ( !this.isPlaying ) {

// Before starting playback, set the playback rate immediately, otherwise there can be a bit of the "chirp"
Expand All @@ -73,11 +79,24 @@ class BalloonVelocitySoundGenerator extends SoundClip {
// Set the output level based on the velocity.
this.setOutputLevel( mapSpeedToOutputLevel( speed, 0.1 ) * options.maxOutputLevel );
}
else if ( speed === 0 && this.isPlaying ) {
else if ( ( speed === 0 || onSweater || touchingWall ) && this.isPlaying ) {
this.stop();
this.setOutputLevel( 0 );
}
} );

this.disposeBalloonVelocitySoundGenerator = () => {
outputUpdaterMultilink.dispose();
};
}

/**
* release memory references
* @public
*/
dispose(){
this.disposeBalloonVelocitySoundGenerator();
super.dispose();
}
}

Expand Down
Binary file removed sounds/balloon-grab-002.mp3
Binary file not shown.
21 changes: 0 additions & 21 deletions sounds/balloon-grab-002_mp3.js

This file was deleted.

Binary file removed sounds/balloon-grab-003.mp3
Binary file not shown.
21 changes: 0 additions & 21 deletions sounds/balloon-grab-003_mp3.js

This file was deleted.

Binary file removed sounds/balloon-grab-005.mp3
Binary file not shown.
21 changes: 0 additions & 21 deletions sounds/balloon-grab-005_mp3.js

This file was deleted.

Binary file removed sounds/balloon-release-002.mp3
Binary file not shown.
21 changes: 0 additions & 21 deletions sounds/balloon-release-002_mp3.js

This file was deleted.

Binary file removed sounds/balloon-release-003.mp3
Binary file not shown.
21 changes: 0 additions & 21 deletions sounds/balloon-release-003_mp3.js

This file was deleted.

Binary file removed sounds/balloon-release-005.mp3
Binary file not shown.
21 changes: 0 additions & 21 deletions sounds/balloon-release-005_mp3.js

This file was deleted.

Loading

0 comments on commit 364d974

Please sign in to comment.