// Turn down the water drops, speaker or light sound when the wave meter is being used.
this.duckingProperty = new DerivedProperty( [ series1PlayingProperty, series2PlayingProperty ], ( a, b ) => {
if ( a || b ) {
return 0.3;
}
else {
return 1;
}
} );
And then that Property is observed elsewhere, to set the output of sound clips.
Problems:
(1) Insufficient documentation for duckingProperty. It's actually {number} and it's an output level.
(2) You're assuming (and hardcoding) a default output level of 1. That's incredibly brittle. Ditto for the ducked output level; it should be a function of the normal output level.
(3) This could be done without a Property, and with less coupling, by creating a sound category for the 3 clips that you want to duck. Then use soundManager.setOutputLevelForCategory to change their output level.
Noted in https://github.com/phetsims/fourier-making-waves/issues/55, where I was asked to use WaveMeterNode.js as an example of how to duck sounds.
In WaveMeterNode.js:
And then that Property is observed elsewhere, to set the output of sound clips.
Problems:
(1) Insufficient documentation for
duckingProperty
. It's actually{number}
and it's an output level.(2) You're assuming (and hardcoding) a default output level of 1. That's incredibly brittle. Ditto for the ducked output level; it should be a function of the normal output level.
(3) This could be done without a Property, and with less coupling, by creating a sound category for the 3 clips that you want to duck. Then use
soundManager.setOutputLevelForCategory
to change their output level.