Skip to content

Commit

Permalink
added (back) sound for photon absorption, see phetsims/molecules-and-…
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet authored and jessegreenberg committed Apr 21, 2021
1 parent 85ff132 commit 92c6829
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions js/moleculesandlight/view/MoleculesAndLightScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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, {
Expand Down Expand Up @@ -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 );
Expand All @@ -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 );
}
Expand Down

0 comments on commit 92c6829

Please sign in to comment.