From b3b1ef85440e43c691f3a5e652717372ea1b8897 Mon Sep 17 00:00:00 2001 From: Jonathan Olson Date: Thu, 13 Feb 2025 22:19:41 -0700 Subject: [PATCH] Converting dot Utils usage, see https://github.com/phetsims/dot/issues/4 --- js/sound-generators/ValueChangeSoundPlayer.ts | 10 +++++----- js/soundManager.ts | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/js/sound-generators/ValueChangeSoundPlayer.ts b/js/sound-generators/ValueChangeSoundPlayer.ts index a0b4c64..b9763dd 100644 --- a/js/sound-generators/ValueChangeSoundPlayer.ts +++ b/js/sound-generators/ValueChangeSoundPlayer.ts @@ -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'; @@ -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; @@ -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 ); @@ -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 ); diff --git a/js/soundManager.ts b/js/soundManager.ts index 1932817..b9f362f 100644 --- a/js/soundManager.ts +++ b/js/soundManager.ts @@ -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'; @@ -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 ); }