Skip to content

Commit

Permalink
Converting dot Utils usage, see phetsims/dot#4
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanolson committed Feb 14, 2025
1 parent b12160b commit b3b1ef8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions js/sound-generators/ValueChangeSoundPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Disposable, { DisposableOptions } from '../../../axon/js/Disposable.js';
import TinyProperty from '../../../axon/js/TinyProperty.js';
import TReadOnlyProperty from '../../../axon/js/TReadOnlyProperty.js';
import Range from '../../../dot/js/Range.js';
import Utils from '../../../dot/js/Utils.js';
import { roundToInterval } from '../../../dot/js/util/roundToInterval.js';
import optionize from '../../../phet-core/js/optionize.js';
import generalBoundaryBoop_mp3 from '../../sounds/generalBoundaryBoop_mp3.js';
import generalSoftClick_mp3 from '../../sounds/generalSoftClick_mp3.js';
Expand Down Expand Up @@ -51,7 +51,7 @@ const DEFAULT_MIDDLE_MOVING_DOWN_SOUND_PLAYER = new SoundClipPlayer( generalSoft

// Define a default constraint function. See the docs for the associated option for more info. The interval value used
// here was empirically determined.
const DEFAULT_VALUE_CONSTRAINT = ( value: number ) => Utils.roundToInterval( value, 0.000000001 );
const DEFAULT_VALUE_CONSTRAINT = ( value: number ) => roundToInterval( value, 0.000000001 );

// A "no-op" function for mapping pitch values. Always returns one, which signifies no change to the playback rate.
const NO_PLAYBACK_RATE_CHANGE = () => 1;
Expand Down Expand Up @@ -339,11 +339,11 @@ class ValueChangeSoundPlayer extends Disposable {
const roundingInterval = 1E-7;

const segment = Math.floor(
Utils.roundToInterval( ( value - this.valueRangeProperty.value.min ) / this.interThresholdDistance,
roundToInterval( ( value - this.valueRangeProperty.value.min ) / this.interThresholdDistance,
roundingInterval )
);

const lowerThreshold = Utils.roundToInterval(
const lowerThreshold = roundToInterval(
segment * this.interThresholdDistance + this.valueRangeProperty.value.min,
roundingInterval
);
Expand All @@ -353,7 +353,7 @@ class ValueChangeSoundPlayer extends Disposable {
// The provided value wasn't exactly at a threshold. Since the preceding calculation provided the lower
// threshold, add the upper one now.
const upperThreshold = Math.min(
Utils.roundToInterval( lowerThreshold + this.interThresholdDistance, roundingInterval ),
roundToInterval( lowerThreshold + this.interThresholdDistance, roundingInterval ),
this.valueRangeProperty.value.max
);

Expand Down
4 changes: 2 additions & 2 deletions js/soundManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import BooleanProperty from '../../axon/js/BooleanProperty.js';
import createObservableArray, { ObservableArray } from '../../axon/js/createObservableArray.js';
import Multilink from '../../axon/js/Multilink.js';
import TReadOnlyProperty, { PropertyLinkListener } from '../../axon/js/TReadOnlyProperty.js';
import Utils from '../../dot/js/Utils.js';
import { toFixed } from '../../dot/js/util/toFixed.js';
import arrayRemove from '../../phet-core/js/arrayRemove.js';
import optionize from '../../phet-core/js/optionize.js';
import DisplayGlobals from '../../scenery/js/display/DisplayGlobals.js';
Expand Down Expand Up @@ -653,7 +653,7 @@ class SoundManager extends PhetioObject {
function logGain(): void {
const now = Date.now();
const timeInMilliseconds = now - startTime;
console.log( `Time (ms): ${Utils.toFixed( timeInMilliseconds, 2 )}, Gain Value: ${gainNode.gain.value}` );
console.log( `Time (ms): ${toFixed( timeInMilliseconds, 2 )}, Gain Value: ${gainNode.gain.value}` );
if ( now - startTime < ( duration * 1000 ) ) {
window.requestAnimationFrame( logGain );
}
Expand Down

0 comments on commit b3b1ef8

Please sign in to comment.