Skip to content

Commit

Permalink
moved charge migration sound gen into BalloonNode.js, see #479
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Feb 23, 2021
1 parent 2acccf5 commit 50ad486
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
18 changes: 0 additions & 18 deletions js/balloons-and-static-electricity/view/BASEView.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@ import Vector2 from '../../../../dot/js/Vector2.js';
import ScreenView from '../../../../joist/js/ScreenView.js';
import Node from '../../../../scenery/js/nodes/Node.js';
import Rectangle from '../../../../scenery/js/nodes/Rectangle.js';
import PitchedPopGenerator from '../../../../tambo/js/sound-generators/PitchedPopGenerator.js';
import soundManager from '../../../../tambo/js/soundManager.js';
import balloonGreen from '../../../images/balloon-green_png.js';
import balloonYellow from '../../../images/balloon-yellow_png.js';
import greenBalloonDriftVelocityLoop from '../../../sounds/carrier-002_wav.js';
import balloonsAndStaticElectricity from '../../balloonsAndStaticElectricity.js';
import BASEA11yStrings from '../BASEA11yStrings.js';
import BASEConstants from '../BASEConstants.js';
import BASEQueryParameters from '../BASEQueryParameters.js';
import BalloonNode from './BalloonNode.js';
import BASESummaryNode from './BASESummaryNode.js';
Expand Down Expand Up @@ -146,21 +143,6 @@ class BASEView extends ScreenView {
}
} );

// sound generation
const popSoundGenerator = new PitchedPopGenerator( {
// enableControlProperties: [ resetNotInProgressProperty ],
initialOutputLevel: 0.3
} );
soundManager.addSoundGenerator( popSoundGenerator );
model.balloons.forEach( balloon => {
balloon.chargeProperty.lazyLink( charge => {
const chargeAbsoluteValue = Math.abs( charge );
if ( chargeAbsoluteValue > 0 ) {
popSoundGenerator.playPop( chargeAbsoluteValue / BASEConstants.MAX_BALLOON_CHARGE );
}
} );
} );

// set the accessible order: sweater, balloons wall
this.pdomPlayAreaNode.pdomOrder = [ sweaterNode, yellowBalloonLayerNode, greenBalloonLayerNode, this.wallNode ];

Expand Down
19 changes: 17 additions & 2 deletions js/balloons-and-static-electricity/view/BalloonNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import Image from '../../../../scenery/js/nodes/Image.js';
import Line from '../../../../scenery/js/nodes/Line.js';
import Node from '../../../../scenery/js/nodes/Node.js';
import Rectangle from '../../../../scenery/js/nodes/Rectangle.js';
import PitchedPopGenerator from '../../../../tambo/js/sound-generators/PitchedPopGenerator.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';
Expand All @@ -34,6 +35,7 @@ import releaseBalloonSound from '../../../sounds/balloon-release-004_mp3.js';
import balloonHitsWallSound from '../../../sounds/wall-contact_mp3.js';
import balloonsAndStaticElectricity from '../../balloonsAndStaticElectricity.js';
import BASEA11yStrings from '../BASEA11yStrings.js';
import BASEConstants from '../BASEConstants.js';
import BASEQueryParameters from '../BASEQueryParameters.js';
import BalloonDirectionEnum from '../model/BalloonDirectionEnum.js';
import PlayAreaMap from '../model/PlayAreaMap.js';
Expand Down Expand Up @@ -214,6 +216,19 @@ class BalloonNode extends Node {
}
} );

// sound generation for charges moving on to this balloon
const popSoundGenerator = new PitchedPopGenerator( {
// enableControlProperties: [ model.showChargesProperty ],
initialOutputLevel: 0.3
} );
soundManager.addSoundGenerator( popSoundGenerator );
model.chargeProperty.lazyLink( charge => {
const chargeAbsoluteValue = Math.abs( charge );
if ( chargeAbsoluteValue > 0 ) {
popSoundGenerator.playPop( chargeAbsoluteValue / BASEConstants.MAX_BALLOON_CHARGE );
}
} );

// sound generation for drift velocity
soundManager.addSoundGenerator(
new BalloonVelocitySoundGenerator(
Expand All @@ -237,7 +252,7 @@ class BalloonNode extends Node {
model.velocityProperty.lazyLink( ( currentVelocity, previousVelocity ) => {
const currentSpeed = currentVelocity.magnitude;
const previousSpeed = previousVelocity.magnitude;
if ( currentSpeed === 0 && previousSpeed > 0 && model.onSweaterProperty.value ){
if ( currentSpeed === 0 && previousSpeed > 0 && model.onSweaterProperty.value ) {
balloonHitsSweaterSoundClip.play();
}
} );
Expand All @@ -253,7 +268,7 @@ class BalloonNode extends Node {
} );
soundManager.addSoundGenerator( balloonHitsWallSoundClip );
model.touchingWallProperty.link( touchingWall => {
if ( touchingWall ) {
if ( touchingWall ) {
balloonHitsWallSoundClip.play();
}
} );
Expand Down

0 comments on commit 50ad486

Please sign in to comment.