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
twant committed Oct 28, 2019
2 parents bd508e9 + 4c39b8d commit 84df927
Show file tree
Hide file tree
Showing 4 changed files with 371 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ For a description of this simulation, associated resources, and a link to the pu
</a>

### Documentation
The <a href="http://bit.ly/phet-html5-development-overview" target="_blank">PhET Development Overview</a> is the most complete guide to PhET Simulation
The <a href="https://github.com/phetsims/phet-info/blob/master/doc/phet-development-overview.md" target="_blank">PhET Development Overview</a> is the most complete guide to PhET Simulation
Development. This guide includes how to obtain simulation code and its dependencies, notes about architecture & design, how to test and build
the sims, as well as other important information.

Expand Down
22 changes: 15 additions & 7 deletions js/molarity/view/ConcentrationSoundGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ define( require => {
// constants
const NUM_SOLUTE_BINS = 13; // empirically determined to produce sounds as frequently as needed but not TOO frequently
const NUM_VOLUME_BINS = 10; // empirically determined to produce sounds as frequently as needed but not TOO frequently
const ZERO_CONCENTRATION_PITCH_RATE = 2; // about 2 octaves above the nominal pitch, empirically determined
const ZERO_CONCENTRATION_PLAYBACK_RATE = 2; // about 2 octaves above the nominal pitch, empirically determined

class ConcentrationSoundGenerator extends SoundGenerator {

Expand All @@ -36,11 +36,20 @@ define( require => {
constructor( solution, soluteAmountSlider, solutionVolumeSlider, resetInProgressProperty, options ) {
super( options );

// create and hook up the sound clips
// sound clip that is played when the concentration is above zero (pitch is varied as a function of concentration)
const nonZeroConcentrationSoundClip = new SoundClip( marimbaSound, { rateChangesAffectPlayingSounds: false } );
nonZeroConcentrationSoundClip.connect( this.masterGainNode );
const zeroConcentrationSoundClip = new SoundClip( noSoluteSound, { initialOutputLevel: 0.6 } );
zeroConcentrationSoundClip.connect( this.masterGainNode );

// sound clip that is played when the solute amount transitions to zero
const transitionToZeroConcentrationSoundClip = new SoundClip( marimbaSound, {
initialOutputLevel: 1.5, // higher than nominal, seems to work to make it more pronounced
initialPlaybackRate: ZERO_CONCENTRATION_PLAYBACK_RATE
} );
transitionToZeroConcentrationSoundClip.connect( this.masterGainNode );

// sound clip that is played when the solution level is changed when the concentration is zero
const atZeroConcentrationSoundClip = new SoundClip( noSoluteSound, { initialOutputLevel: 0.6 } );
atZeroConcentrationSoundClip.connect( this.masterGainNode );

// keep track of the concentration value each time sound is played
let concentrationAtLastSoundProduction = solution.concentrationProperty.value;
Expand All @@ -56,13 +65,12 @@ define( require => {
else if ( concentrationAtLastSoundProduction > 0 ) {

// the concentration value has transitioned to zero, so play the sound at a pitch meant to convey emptiness
nonZeroConcentrationSoundClip.setPlaybackRate( ZERO_CONCENTRATION_PITCH_RATE );
nonZeroConcentrationSoundClip.play();
transitionToZeroConcentrationSoundClip.play();
}
else {

// the user is changing the volume of the solution with no solute in it, play the sound for this specific case
zeroConcentrationSoundClip.play();
atZeroConcentrationSoundClip.play();
}
concentrationAtLastSoundProduction = concentration;
};
Expand Down
Loading

0 comments on commit 84df927

Please sign in to comment.