-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
drag sounds for the angle controls, see #105
- Loading branch information
1 parent
57e7695
commit 151018b
Showing
6 changed files
with
107 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2024, University of Colorado Boulder | ||
|
||
/** | ||
* Query parameters for this simulation. | ||
* | ||
* @author Jesse Greenberg (PhET Interactive Simulations) | ||
*/ | ||
|
||
import trigTour from '../trigTour.js'; | ||
|
||
const TrigTourQueryParameters = QueryStringMachine.getAll( { | ||
|
||
// Reduces the number of rotations in the unit circle so that it is easier to find the limit.s | ||
maxRotations: { | ||
type: 'number', | ||
|
||
// Value must be an integer becase it is used in a multiple of PI. It must be an even | ||
// number because the drag handlers in this sim assume that in their calculations. | ||
isValidValue: ( value: number ) => value < 60 && Number.isInteger( value ) && value % 2 === 0, | ||
defaultValue: 50 // High number makes it difficult and whimsical to find the limit. | ||
} | ||
} ); | ||
|
||
trigTour.register( 'TrigTourQueryParameters', TrigTourQueryParameters ); | ||
export default TrigTourQueryParameters; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2024, University of Colorado Boulder | ||
|
||
/** | ||
* AngleSoundGenerator is a sound generator specifically designed to produce sounds for the | ||
* controls that change the angle in trig-tour. | ||
* | ||
* @author Jesse Greenberg (PhET Interactive Simulations) | ||
*/ | ||
|
||
import Range from '../../../../dot/js/Range.js'; | ||
import Utils from '../../../../dot/js/Utils.js'; | ||
import ValueChangeSoundPlayer from '../../../../tambo/js/sound-generators/ValueChangeSoundPlayer.js'; | ||
import trigTour from '../../trigTour.js'; | ||
import TrigTourModel from '../model/TrigTourModel.js'; | ||
|
||
class AngleSoundGenerator extends ValueChangeSoundPlayer { | ||
public constructor() { | ||
|
||
const range = new Range( -TrigTourModel.MAX_ANGLE_LIMIT, TrigTourModel.MAX_ANGLE_LIMIT ); | ||
super( range, { | ||
|
||
// Limit precision so that comparison against the range limits works consistently. | ||
constrainValue: ( value: number ) => Utils.toFixedNumber( value, 1 ), | ||
|
||
// Arbitrary, but creates a consistent sound as the user interacts with the angle. | ||
numberOfMiddleThresholds: 700 | ||
} ); | ||
} | ||
} | ||
|
||
trigTour.register( 'AngleSoundGenerator', AngleSoundGenerator ); | ||
|
||
export default AngleSoundGenerator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters