Skip to content

Commit

Permalink
removed @constructor designations, fixed a number of places where opt…
Browse files Browse the repository at this point in the history
…ions weren't really optional, see #161
  • Loading branch information
jbphet committed Apr 22, 2022
1 parent 7f6541a commit e6c96ae
Show file tree
Hide file tree
Showing 17 changed files with 21 additions and 31 deletions.
2 changes: 1 addition & 1 deletion js/PeakDetectorAudioNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export type PeakDetectorAudioNodeOptions = {

class PeakDetectorAudioNode extends AudioWorkletNode {

constructor( providedOptions: PeakDetectorAudioNodeOptions ) {
constructor( providedOptions?: PeakDetectorAudioNodeOptions ) {

const options = optionize<PeakDetectorAudioNodeOptions, PeakDetectorAudioNodeOptions>()( {
logZeroValues: false
Expand Down
4 changes: 0 additions & 4 deletions js/demo/TamboKeyboardHelpContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ import { HBox } from '../../../scenery/js/imports.js';
import tambo from '../tambo.js';

class TamboKeyboardHelpContent extends HBox {

/**
* @constructor
*/
constructor() {
super( { children: [ new BasicActionsKeyboardHelpSection() ], align: 'top', spacing: 30 } );
}
Expand Down
2 changes: 1 addition & 1 deletion js/demo/testing/view/AmplitudeModulatorDemoNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const LABEL_FONT = new PhetFont( 16 );

class AmplitudeModulatorDemoNode extends VBox {

constructor( providedOptions: AmplitudeModulatorDemoNodeOptions ) {
constructor( providedOptions?: AmplitudeModulatorDemoNodeOptions ) {

const soundSourceRadioButtonItems = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ContinuousPropertySoundGeneratorTestNode extends VBox {
// dispose function
private readonly disposeContinuousPropertySoundGeneratorTestNode: () => void;

constructor( stepEmitter: Emitter<[ number ]>, providedOptions: ContinuousPropertySoundGeneratorTestNodeOptions ) {
constructor( stepEmitter: Emitter<[ number ]>, providedOptions?: ContinuousPropertySoundGeneratorTestNodeOptions ) {

// keep track of listeners added to the step emitter so that they can be disposed
const stepListeners: ( ( dt: number ) => void )[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const SOUND_GENERATOR_INFO = new Map<string, SoundGeneratorComboBoxItemInfo>( [

class RemoveAndDisposeSoundGeneratorsTestPanel extends Panel {

constructor( providedOptions: RemoveAndDisposeSoundGeneratorsTestPanelOptions ) {
constructor( providedOptions?: RemoveAndDisposeSoundGeneratorsTestPanelOptions ) {

const options = optionize<RemoveAndDisposeSoundGeneratorsTestPanelOptions, SelfOptions, PanelOptions>()( {
fill: '#f5d3b3',
Expand Down
2 changes: 1 addition & 1 deletion js/demo/testing/view/SoundClipChordTestNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SoundClipChordTestNode extends VBox {

private readonly disposeSoundClipChordTestNode: () => void;

constructor( providedOptions: SoundClipChordTestNodeOptions ) {
constructor( providedOptions?: SoundClipChordTestNodeOptions ) {

// sound clips to be played
const chordSoundClipChord = new SoundClipChord( brightMarimba_mp3 );
Expand Down
3 changes: 0 additions & 3 deletions js/demo/testing/view/TestingScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ class TestingScreenView extends DemosScreenView {

private readonly stepEmitter: Emitter<[ number ]>;

/**
* @constructor
*/
constructor() {

const resetInProgressProperty = new BooleanProperty( false );
Expand Down
3 changes: 0 additions & 3 deletions js/demo/ui-components/model/UIComponentsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ class UIComponentsModel {
// tracks whether a reset is happening
public readonly resetInProgressProperty: BooleanProperty;

/**
* @constructor
*/
constructor() {
this.resetInProgressProperty = new BooleanProperty( false );
}
Expand Down
1 change: 0 additions & 1 deletion js/sound-generators/ContinuousPropertySoundGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class ContinuousPropertySoundGenerator extends SoundClip {
* may require it to be a .wav file, since .mp3 files generally have a bit of silence at the beginning.
* @param range - the range of values that the provided property can take on
* @param [providedOptions]
* @constructor
*/
constructor( property: NumberProperty,
sound: WrappedAudioBuffer,
Expand Down
9 changes: 4 additions & 5 deletions js/sound-generators/DiscreteSoundGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@ class DiscreteSoundGenerator extends SoundClip {
private readonly disposeDiscreteSoundGenerator: () => void;

/**
* valueProperty - the value that is monitored to trigger sounds
* valueRange - the range of values expected and over which sounds will be played
* options - options for this sound generation and its parent class
* @constructor
* @param valueProperty - the value that is monitored to trigger sounds
* @param valueRange - the range of values expected and over which sounds will be played
* @param [providedOptions] - options for this sound generation and its parent class
*/
constructor( valueProperty: NumberProperty, valueRange: Range, providedOptions: DiscreteSoundGeneratorOptions ) {
constructor( valueProperty: NumberProperty, valueRange: Range, providedOptions?: DiscreteSoundGeneratorOptions ) {

const options = optionize<DiscreteSoundGeneratorOptions, SelfOptions, SoundClipOptions>()( {
sound: brightMarimba_mp3,
Expand Down
2 changes: 1 addition & 1 deletion js/sound-generators/MultiClip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class MultiClip<T> extends SoundGenerator {
* associated with the value.
* @param [providedOptions]
*/
constructor( valueToWrappedAudioBufferMap: Map<T, WrappedAudioBuffer>, providedOptions: MultiClipOptions ) {
constructor( valueToWrappedAudioBufferMap: Map<T, WrappedAudioBuffer>, providedOptions?: MultiClipOptions ) {

const options = optionize<MultiClipOptions, SelfOptions, MultiClipOptions>()( {
initialPlaybackRate: 1
Expand Down
4 changes: 1 addition & 3 deletions js/sound-generators/NoiseGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class NoiseGenerator extends SoundGenerator {
// function that handles changes to the audio context
private readonly audioContextStateChangeListener: ( state: string ) => void;

constructor( providedOptions: NoiseGeneratorOptions ) {
constructor( providedOptions?: NoiseGeneratorOptions ) {

const options = optionize<NoiseGeneratorOptions, SelfOptions, SoundGeneratorOptions>()( {
noiseType: 'pink', // valid values are 'white', 'pink', and 'brown'
Expand Down Expand Up @@ -236,8 +236,6 @@ class NoiseGenerator extends SoundGenerator {

this.noiseSourceConnectionPoint = nextOutputToConnect;
this.isPlaying = false;

// @private {number} - time at which a deferred play request occurred.
this.timeOfDeferredStartRequest = Number.NEGATIVE_INFINITY;

// define the listener for audio context state transitions
Expand Down
2 changes: 1 addition & 1 deletion js/sound-generators/OscillatorSoundGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class OscillatorSoundGenerator extends SoundGenerator {
private readonly frequency: number;
private waveformType: OscillatorType;

constructor( providedOptions: OscillatorSoundGeneratorOptions ) {
constructor( providedOptions?: OscillatorSoundGeneratorOptions ) {

const options = optionize<OscillatorSoundGeneratorOptions, SelfOptions, SoundGeneratorOptions>()( {
initialFrequency: 440,
Expand Down
2 changes: 1 addition & 1 deletion js/sound-generators/PitchedPopGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class PitchedPopGenerator extends SoundGenerator {
// next sound source to use to play a sound
private nextSoundSourceIndex: number;

constructor( providedOptions: PitchedPopGeneratorOptions ) {
constructor( providedOptions?: PitchedPopGeneratorOptions ) {

const options = optionize<PitchedPopGeneratorOptions, SelfOptions, SoundGeneratorOptions>()( {
pitchRange: new Range( 220, 660 ),
Expand Down
2 changes: 1 addition & 1 deletion js/sound-generators/PropertyMultiClip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class PropertyMultiClip<T> extends MultiClip<T> {
* between values and sounds.
* @param [providedOptions]
*/
constructor( property: Property<T>, valueToSoundMap: Map<T, WrappedAudioBuffer>, providedOptions: PropertyMultiClipOptions ) {
constructor( property: Property<T>, valueToSoundMap: Map<T, WrappedAudioBuffer>, providedOptions?: PropertyMultiClipOptions ) {

const options = optionize<PropertyMultiClipOptions, SelfOptions, MultiClipOptions>()( {
linkLazily: true
Expand Down
1 change: 0 additions & 1 deletion js/sound-generators/SoundClipPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class SoundClipPlayer {
/**
* @param wrappedAudioBuffer - a Web Audio audio buffer containing decoded audio samples
* @param [providedOptions]
* @constructor
*/
constructor( wrappedAudioBuffer: WrappedAudioBuffer, providedOptions?: SoundClipPlayerOptions ) {

Expand Down
9 changes: 7 additions & 2 deletions js/soundManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class SoundManager extends PhetioObject {
simVisibleProperty: BooleanProperty,
simActiveProperty: BooleanProperty,
simSettingPhetioStateProperty: BooleanProperty,
providedOptions: SoundGeneratorInitializationOptions ) {
providedOptions?: SoundGeneratorInitializationOptions ) {

assert && assert( !this.initialized, 'can\'t initialize the sound manager more than once' );

Expand Down Expand Up @@ -345,7 +345,12 @@ class SoundManager extends PhetioObject {
* Add a sound generator. This connects the sound generator to the audio path, puts it on the list of sound
* generators, and creates and returns a unique ID.
*/
public addSoundGenerator( soundGenerator: SoundGenerator, providedOptions: SoundGeneratorAddOptions = {} ) {
public addSoundGenerator( soundGenerator: SoundGenerator, providedOptions?: SoundGeneratorAddOptions ) {

// We'll need an empty object of no options were provided.
if ( providedOptions === undefined ) {
providedOptions = {};
}

// Check if initialization has been done and, if not, queue the sound generator and its options for addition
// once initialization is complete. Note that when sound is not supported, initialization will never occur.
Expand Down

0 comments on commit e6c96ae

Please sign in to comment.