diff --git a/js/moleculesandlight/view/MoleculesAndLightScreenView.js b/js/moleculesandlight/view/MoleculesAndLightScreenView.js index 4a3af160..cd611e79 100644 --- a/js/moleculesandlight/view/MoleculesAndLightScreenView.js +++ b/js/moleculesandlight/view/MoleculesAndLightScreenView.js @@ -50,18 +50,19 @@ define( require => { // sounds const breakApartSoundInfo = require( 'sound!MOLECULES_AND_LIGHT/break-apart.mp3' ); + const infraredPhotonFromMoleculeSoundInfo = require( 'sound!MOLECULES_AND_LIGHT/photon-release-ir.mp3' ); + const infraredPhotonInitialEmissionSoundInfo = require( 'sound!MOLECULES_AND_LIGHT/photon-emit-ir.mp3' ); + const microwavePhotonFromMoleculeSoundInfo = require( 'sound!MOLECULES_AND_LIGHT/photon-release-microwave.mp3' ); const moleculeEnergizedSoundInfo = require( 'sound!MOLECULES_AND_LIGHT/glow-loop-higher.mp3' ); + const microwavePhotonInitialEmissionSoundInfo = require( 'sound!MOLECULES_AND_LIGHT/photon-emit-microwave.mp3' ); + const photonAbsorbedSoundInfo = require( 'sound!MOLECULES_AND_LIGHT/absorb-loop.mp3' ); const rotationClockwiseSoundInfo = require( 'sound!MOLECULES_AND_LIGHT/rotate-clockwise.mp3' ); const rotationCounterclockwiseSoundInfo = require( 'sound!MOLECULES_AND_LIGHT/rotate-counterclockwise.mp3' ); + const ultravioletPhotonFromMoleculeSoundInfo = require( 'sound!MOLECULES_AND_LIGHT/photon-release-uv.mp3' ); + const ultravioletPhotonInitialEmissionSoundInfo = require( 'sound!MOLECULES_AND_LIGHT/photon-emit-uv.mp3' ); const vibrationSoundInfo = require( 'sound!MOLECULES_AND_LIGHT/vibration.mp3' ); - const microwavePhotonFromMoleculeSoundInfo = require( 'sound!MOLECULES_AND_LIGHT/photon-release-microwave.mp3' ); - const infraredPhotonFromMoleculeSoundInfo = require( 'sound!MOLECULES_AND_LIGHT/photon-release-ir.mp3' ); const visiblePhotonFromMoleculeSoundInfo = require( 'sound!MOLECULES_AND_LIGHT/photon-release-visible.mp3' ); - const ultravioletPhotonFromMoleculeSoundInfo = require( 'sound!MOLECULES_AND_LIGHT/photon-release-uv.mp3' ); - const microwavePhotonInitialEmissionSoundInfo = require( 'sound!MOLECULES_AND_LIGHT/photon-emit-microwave.mp3' ); - const infraredPhotonInitialEmissionSoundInfo = require( 'sound!MOLECULES_AND_LIGHT/photon-emit-ir.mp3' ); const visiblePhotonInitialEmissionSoundInfo = require( 'sound!MOLECULES_AND_LIGHT/photon-emit-visible.mp3' ); - const ultravioletPhotonInitialEmissionSoundInfo = require( 'sound!MOLECULES_AND_LIGHT/photon-emit-uv.mp3' ); // constants // Model-view transform for intermediate coordinates. @@ -232,6 +233,13 @@ define( require => { // sound generation //----------------------------------------------------------------------------------------------------------------- + // photon absorbed sound + const photonAbsorbedSound = new SoundClip( photonAbsorbedSoundInfo, { initialOutputLevel: 0.025 } ); + soundManager.addSoundGenerator( photonAbsorbedSound ); + const photonAbsorbedSoundPlayer = () => { + photonAbsorbedSound.play(); + }; + // TODO - @Ashton-Morris - please adjust level if needed, see https://github.com/phetsims/molecules-and-light/issues/233 // sound to play when molecule becomes "energized", which is depicted as glowing in the view const moleculeEnergizedLoop = new SoundClip( moleculeEnergizedSoundInfo, { @@ -312,6 +320,7 @@ define( require => { // function that adds all of the listeners involved in creating sound const addSoundPlayersToMolecule = molecule => { + molecule.photonAbsorbedEmitter.addListener( photonAbsorbedSoundPlayer ); molecule.highElectronicEnergyStateProperty.link( updateMoleculeEnergizedSound ); molecule.brokeApartEmitter.addListener( breakApartSoundPlayer ); molecule.rotatingProperty.link( updateRotationSound ); @@ -324,6 +333,9 @@ define( require => { // remove listeners when the molecules go away photonAbsorptionModel.activeMolecules.addItemRemovedListener( function( removedMolecule ) { + if ( removedMolecule.photonAbsorbedEmitter.hasListener( photonAbsorbedSoundPlayer ) ) { + removedMolecule.photonAbsorbedEmitter.removeListener( photonAbsorbedSoundPlayer ); + } if ( removedMolecule.highElectronicEnergyStateProperty.hasListener( updateMoleculeEnergizedSound ) ) { removedMolecule.highElectronicEnergyStateProperty.unlink( updateMoleculeEnergizedSound ); }