phetsims / wave-interference

"Wave Interference" is an educational simulation in HTML5, by PhET Interactive Simulations.
MIT License
18 stars 5 forks source link

Issues with sound ducking #521

Open pixelzoom opened 3 years ago

pixelzoom commented 3 years ago

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:

    // 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.

samreid commented 3 years ago

Unassigning until we return our attention to this sim.