diff --git a/src/mappings/dimensions.js b/src/mappings/dimensions.js index 422bd56..20a4c9e 100644 --- a/src/mappings/dimensions.js +++ b/src/mappings/dimensions.js @@ -13,7 +13,7 @@ import { mapBinNumerical, mapRangedAvgNumerical } from "./numeric.js"; * @param {string} conf.unit The unit the upper and lower bounds are measured in. * @param {number} conf.lowerBin The lower boundary of bins to be mapped (or the single bin to be mapped if the upper bin is undefined). * @param {VisUpdateRouter} conf.visUpdateRouter The visualizer update manager to be mapped to. - * @param {interpolator} conf.interpolator The interpolation function to be used to transition from one value to the next. + * @param {module:support/easings~interpolator} conf.interpolator The interpolation function to be used to transition from one value to the next. * @param {number} [conf.upperBin] The upper bin or undefined, which results in mapping to a single bin. * @param {boolean} [conf.reversed=false] If true, then high amplitudes are mapped to lower values and vice versa. * @returns {{bin: number, listener: VisUpdateRouter.visualizerBinUpdateListener}|{lower: number, upper: number, listener: VisUpdateRouter.visualizerRangedUpdateListener}} The listener that was added (ranged if an upper bound was provided, binned otherwise). @@ -51,7 +51,7 @@ export function mapWidth({ element, growLower, growUpper, unit, lowerBin, visUpd * @param {string} conf.unit The unit the upper and lower bounds are measured in. * @param {number} conf.lowerBin The lower boundary of bins to be mapped (or the single bin to be mapped if the upper bin is undefined). * @param {VisUpdateRouter} conf.visUpdateRouter The visualizer update manager to be mapped to. - * @param {interpolator} conf.interpolator The interpolation function to be used to transition from one value to the next. + * @param {module:support/easings~interpolator} conf.interpolator The interpolation function to be used to transition from one value to the next. * @param {number} [conf.upperBin] The upper bin or undefined, which results in mapping to a single bin. * @param {boolean} [conf.reversed=false] If true, then high amplitudes are mapped to lower values and vice versa. * @returns {{bin: number, listener: VisUpdateRouter.visualizerBinUpdateListener}|{lower: number, upper: number, listener: VisUpdateRouter.visualizerRangedUpdateListener}} The listener that was added (ranged if an upper bound was provided, binned otherwise). diff --git a/src/mappings/numeric.js b/src/mappings/numeric.js index 467a752..56496af 100644 --- a/src/mappings/numeric.js +++ b/src/mappings/numeric.js @@ -23,9 +23,9 @@ import VisUpdateRouter from "../visualization/VisUpdateRouter.js"; * @param {number} conf.maxVal The maximum value of the numerical value. * @param {number} conf.lowerBin The lower bin of the range of bins this value is to be mapped to. * @param {number} conf.upperBin The upper bin of the range of bins this value si to be mapped to. - * @param {numericalGetter} conf.getter The getter callback to be used to get the current number. - * @param {numericalSetter} conf.setter The setter callback to be used to set the new number. - * @param {interpolator} conf.interpolator The interpolation function to use. + * @param {module:mappings/numeric~numericalGetter} conf.getter The getter callback to be used to get the current number. + * @param {module:mappings/numeric~numericalSetter} conf.setter The setter callback to be used to set the new number. + * @param {module:support/easings~interpolator} conf.interpolator The interpolation function to use. * @param {VisUpdateRouter} conf.visUpdateRouter the visualizer update manager this mapping corresponds with. * @param {boolean} [conf.reversed = false] If true, then high amplitudes will be mapped to low values and vice versa. * @returns {{lower: number, upper: number, listener: VisUpdateRouter.visualizerRangedUpdateListener}} An object containing the lower and upper bounds for the range of a listener, which is also in the object. @@ -64,9 +64,9 @@ export function mapRangedAvgNumerical({ minVal, maxVal, lowerBin = undefined, up * @param {number} conf.minVal The minimum value the mapping can produce. * @param {number} conf.maxVal The maximum value the mapping can produce. * @param {number} conf.bin The bin to map this number to. - * @param {numericalGetter} conf.getter The callback to be used to get the current number. - * @param {numericalSetter} conf.setter The callback to be used to set the new number. - * @param {interpolator} conf.interpolator The interpolation function to use. + * @param {module:mappings/numeric~numericalGetter} conf.getter The callback to be used to get the current number. + * @param {module:mappings/numeric~numericalSetter} conf.setter The callback to be used to set the new number. + * @param {module:support/easings~interpolator} conf.interpolator The interpolation function to use. * @param {VisUpdateRouter} conf.visUpdateRouter The update manager to map to. * @param {boolean} [conf.reversed] If true, then high amplitudes will be mapped to lower values and vice versa. * @returns {{bin: number, listener: VisUpdateRouter.visualizerBinUpdateListener}} The bin listener that was added. diff --git a/src/mappings/text.js b/src/mappings/text.js index 43284c1..ce83ab6 100644 --- a/src/mappings/text.js +++ b/src/mappings/text.js @@ -12,7 +12,7 @@ import { mapBinNumerical, mapRangedAvgNumerical } from "./numeric.js"; * @param {number} rgbaMapConfiguration.color Where r for red, g, for green, b for blue, and a for alpha. * @param {number} rgbaMapConfiguration.lowerBin The lower bound of the bins to be mapped. * @param {VisUpdateRouter} rgbaMapConfiguration.visUpdateRouter The visualizer update manager associated with the audio playback you would like the mapping with. - * @param {interpolator} rgbaMapConfiguration.interpolator The interpolation function to use. + * @param {Function} rgbaMapConfiguration.interpolator The interpolation function to use. * @param {number} [rgbaMapConfiguration.upperBin=undefined] The upper bound of the bins to be mapped. If left undefined, then only the bin defined by the min value is used. * @param {boolean} [rgbaMapConfiguration.reversed=true] If true, then the quieter, the greater the red value. * @returns {{bin: number, listener: visualizerBinUpdateListener}|{lower: number, upper: number, listener: visualizerRangedUpdateListener}} The ranged listener that was added. @@ -58,7 +58,7 @@ export function mapRgba({ element, color, lowerBin, visUpdateRouter, interpolato * @param {string} fontSizeMapConfiguration.unit The unit the upper and lower bounds are measured in. * @param {number} fontSizeMapConfiguration.lowerBin The lower boundary of bins to be mapped (or the single bin to be mapped if the upper bin is undefined). * @param {VisUpdateRouter} fontSizeMapConfiguration.visUpdateRouter the visualizer update manager to be mapped to. - * @param {interpolator} fontSizeMapConfiguration.interpolator The interpolation function to be used to transition from one value to the next. + * @param {module:support/easings~interpolator} fontSizeMapConfiguration.interpolator The interpolation function to be used to transition from one value to the next. * @param {number} [fontSizeMapConfiguration.upperBin=undefined] The upper bin, or undefined, which results in mapping to a single bin. * @param {boolean} [fontSizeMapConfiguration.reversed=false] If true, then high amplitudes are mapped to lower values and vice versa. * @returns {{bin: number, listener: VisUpdateRouter.visualizerBinUpdateListener}|{lower: number, upper: number, listener: VisUpdateRouter.visualizerRangedUpdateListener}} The listener that was added (ranged if an upper bound was provided, binned otherwise). diff --git a/src/player/Music.js b/src/player/Music.js index 61f99b0..7df087a 100644 --- a/src/player/Music.js +++ b/src/player/Music.js @@ -2,10 +2,6 @@ import Visualizer from "../visualization/Visualizer.js"; -/** - * @callback AudioEventCallback - * @param {HTMLAudioElement} audio - */ /** * A music with metadata that can be used as part of a {@link MusicPlaylist}. @@ -19,6 +15,11 @@ export default class Music { #visualizer; #ready = false; + /** + * @callback Music~audioEventCallback + * @param {HTMLAudioElement} audio + */ + /** * Constructs a music for a {@link MusicPlaylist}. * @@ -35,7 +36,7 @@ export default class Music { /** * - * @param {AudioEventCallback} [onReady] called when the music is ready, including right away if the music is already ready. + * @param {Music~audioEventCallback} [onReady] called when the music is ready, including right away if the music is already ready. * @returns {HTMLAudioElement} The audio element that represents this music. */ fetchAudio(onReady) { @@ -90,7 +91,7 @@ export default class Music { /** * Begins audio playback as soon as possible. * - * This function uses the {@link PlaylistMusic#getAudio} function and specifically, the {@link AudioEventCallback}. + * This function uses the {@link PlaylistMusic#getAudio} function and specifically, the {@link Music~audioEventCallback}. */ play() { this.fetchAudio((audio) => { diff --git a/src/player/MusicPlayer.js b/src/player/MusicPlayer.js index 9312863..5182dd5 100644 --- a/src/player/MusicPlayer.js +++ b/src/player/MusicPlayer.js @@ -3,11 +3,6 @@ import MusicPlaylist from "./MusicPlaylist.js"; -/** - * @callback changeListener - * @param {*} old the previous value. - * @param {*} current the the current (new) value. - */ /** * A player that keeps track of global properties for playback as well as traversing a playlist. Additionally keeps track of music audio data and attempts to reduce memory usage when possible. @@ -21,6 +16,12 @@ export default class MusicPlayer { #volumeChangeListeners = []; #allAudioEventListeners = {}; + /** + * @callback MusicPlayer~changeListener + * @param {*} old the previous value. + * @param {*} current the the current (new) value. + */ + /** * * @param {MusicPlaylist} playlist the playlist of musics that this player is in charge of. @@ -224,7 +225,7 @@ export default class MusicPlayer { /** * - * @param {changeListener} listener the playlist change listener to add to the callback list. + * @param {MusicPlayer~changeListener} listener the playlist change listener to add to the callback list. * @returns {boolean} true if and only if the given listener was successfully registered. */ addPlaylistChangeListener(listener) { @@ -236,7 +237,7 @@ export default class MusicPlayer { /** * - * @param {changeListener} listener the playlist change listener to remove. + * @param {MusicPlayer~changeListener} listener the playlist change listener to remove. * @returns {boolean} true if and only if a listener was successfully removed from the callback list. */ removePlaylistChangeListener(listener) { @@ -249,7 +250,7 @@ export default class MusicPlayer { /** * - * @param {changeListener} listener the listener that is called when the player's volume is changed. + * @param {MusicPlayer~changeListener} listener the listener that is called when the player's volume is changed. * @returns {boolean} true if and only if the listener was successfully added. */ addVolumeChangeListener(listener) { @@ -260,7 +261,7 @@ export default class MusicPlayer { /** * - * @param {changeListener} listener the volume change listener to remove. + * @param {MusicPlayer~changeListener} listener the volume change listener to remove. * @returns {boolean} true if and only if a listener was successfully removed from the callback list. */ removeVolumeChangeListener(listener) { diff --git a/src/player/MusicPlaylist.js b/src/player/MusicPlaylist.js index 3e9c6d5..ca0050b 100644 --- a/src/player/MusicPlaylist.js +++ b/src/player/MusicPlaylist.js @@ -2,18 +2,6 @@ import Music from "./Music.js"; -/** - * @callback positionChangeListener - * @param {number} old the previous position. - * @param {number} current the the current (new) position. - */ - -/** - * @callback lengthChangeListener - * @param {number} changed The index of the music that has changed. - * @param {boolean} added True if and only if the change was caused by adding music. - * @param {Music} music The music that was added or removed. - */ /** * A playlist that holds a multitude of musics in the form of {@link Music}. @@ -25,6 +13,20 @@ export default class MusicPlaylist { #positionChangeListeners = []; #lengthChangeListeners = []; + + /** + * @callback MusicPlaylist~positionChangeListener + * @param {number} old the previous position. + * @param {number} current the the current (new) position. + */ + + /** + * @callback MusicPlaylist~lengthChangeListener + * @param {number} changed The index of the music that has changed. + * @param {boolean} added True if and only if the change was caused by adding music. + * @param {Music} music The music that was added or removed. + */ + /** * Instantiates a playlist for musics. * @@ -155,7 +157,7 @@ export default class MusicPlaylist { /** * - * @param {positionChangeListener} listener the listener to receive the updates. + * @param {MusicPlaylist~positionChangeListener} listener the listener to receive the updates. * @returns {boolean} true if and only if successfully added the listener. */ addPositionChangeListener(listener) { @@ -166,7 +168,7 @@ export default class MusicPlaylist { /** * - * @param {positionChangeListener} listener the music change listener to remove. + * @param {MusicPlaylist~positionChangeListener} listener the music change listener to remove. * @returns {boolean} true if and only if the music change listener given was successfully removed. */ removePositionChangeListener(listener) { @@ -180,7 +182,7 @@ export default class MusicPlaylist { /** * Adds a listener for whether music was added or removed to the playlist. * - * @param {lengthChangeListener} listener The listener to be added. + * @param {MusicPlaylist~lengthChangeListener} listener The listener to be added. * @returns {boolean} True if and only if the listener was successfully added. */ addLengthChangeListener(listener) { @@ -192,7 +194,7 @@ export default class MusicPlaylist { /** * Removes a listener for whether music is added or removed to the playlist. * - * @param {lengthChangeListener} listener The listener to be removed. + * @param {MusicPlaylist~lengthChangeListener} listener The listener to be removed. * @returns {boolean} True if and only if the provided listener was successfully removed. */ removeLengthChangeListener(listener) { diff --git a/src/support/easings.js b/src/support/easings.js index 772ac75..549cb54 100644 --- a/src/support/easings.js +++ b/src/support/easings.js @@ -13,7 +13,7 @@ /** * * @param {number} rate the number of frequency values to shift by per second. - * @returns {interpolator} the interpolation function with the given rate. + * @returns {module:support/easings~interpolator} the interpolation function with the given rate. */ export function createEaseLinear(rate) { return (current, dest, frameDelta) => { diff --git a/src/visualization/VisUpdateRouter.js b/src/visualization/VisUpdateRouter.js index 9551e3e..8bb91e3 100644 --- a/src/visualization/VisUpdateRouter.js +++ b/src/visualization/VisUpdateRouter.js @@ -2,18 +2,6 @@ import Visualizer from "./Visualizer.js"; -/** - * @callback visualizerBinUpdateListener - * @param {number} timeDelta elapsed time since last update. - * @param {number} amplitude The amplitude of the associated bin. - * @param {number} ampDelta change in amplitude of the frequency bin. - */ - -/** - * @callback visualizerRangedUpdateListener - * @param {number} timeDelta elapsed time since last update. - * @param {number} bins the bins of the range. - */ /** @@ -28,6 +16,18 @@ export default class VisUpdateRouter { #lastBins; #visualizer; + /** + * @callback VisUpdateRouter~visualizerBinUpdateListener + * @param {number} timeDelta elapsed time since last update. + * @param {number} amplitude The amplitude of the associated bin. + * @param {number} ampDelta change in amplitude of the frequency bin. + */ + + /** + * @callback VisUpdateRouter~visualizerRangedUpdateListener + * @param {number} timeDelta elapsed time since last update. + * @param {number} bins the bins of the range. + */ /** * @@ -73,7 +73,7 @@ export default class VisUpdateRouter { * * @param {object} freqBinListener the listener for a specific frequency bin. * @param {number} freqBinListener.freqBin the frequency bin this update listener should listen to. - * @param {visualizerBinUpdateListener} freqBinListener.listener the listener itself that will be called upon the bin updating. + * @param {VisUpdateRouter~visualizerBinUpdateListener} freqBinListener.listener the listener itself that will be called upon the bin updating. * @returns {boolean} true if and only if the updater was added successfully. */ AddVisualizerBinUpdateListener({ freqBin, listener }) { @@ -88,7 +88,7 @@ export default class VisUpdateRouter { * @param {object} rangedUpdateListener The ranged update listener to add. * @param {number} rangedUpdateListener.lower The lower bound of the bins to listen to (inclusive). * @param {number} rangedUpdateListener.upper The upper bound of the bins to listen to (inclusive). - * @param {visualizerRangedUpdateListener} rangedUpdateListener.listener The listener to register to the range. + * @param {VisUpdateRouter~visualizerRangedUpdateListener} rangedUpdateListener.listener The listener to register to the range. * @returns {boolean} True if and only if the ranged listener was added successfully. */ addVisualizerRangedUpdateListener({ lower, upper, listener }) { @@ -108,7 +108,7 @@ export default class VisUpdateRouter { * * @param {object} binFreqListener The bin frequency listener to remove. * @param {number} binFreqListener.freqBin the frequency bin the update listener to be removed from is in. - * @param {visualizerBinUpdateListener} binFreqListener.listener the listener that is to be removed. + * @param {VisUpdateRouter~visualizerBinUpdateListener} binFreqListener.listener the listener that is to be removed. * @returns {boolean} true if and only if the listener was successfully removed. */ removeVisualizerBinUpdateListener({ freqBin, listener }) { @@ -124,7 +124,7 @@ export default class VisUpdateRouter { * @param {object} rangedListener The ranged listener to remove. * @param {number} rangedListener.lower The lower bound of bins to remove the listener from (inclusive). * @param {number} rangedListener.upper The upper bound of bin to remove the listener from (inclusive.) - * @param {visualizerRangedUpdateListener} rangedListener.listener The update listener to remove from the bins. + * @param {VisUpdateRouter~visualizerRangedUpdateListener} rangedListener.listener The update listener to remove from the bins. * @returns {boolean} True if and only if the given listener was removed. */ removeVisualizerRangedUpdateListener({ lower, upper, listener }) { @@ -145,7 +145,7 @@ export default class VisUpdateRouter { * @param {object[]} listeners.ranged The array of ranged listeners. * @param {number} listeners.ranged[].lower The lower bound of the listener. * @param {number} listeners.ranged[].upper The upper bound of the listener. - * @param {visualizerRangedUpdateListener} listeners.ranged[].listener The listener for the previously mentioned ranges. + * @param {VisUpdateRouter~visualizerRangedUpdateListener} listeners.ranged[].listener The listener for the previously mentioned ranges. * @returns {boolean} true if and only if successfully loaded the new listeners. */ loadListeners(listeners) { diff --git a/src/visualization/Visualizer.js b/src/visualization/Visualizer.js index 67da000..6d41a19 100644 --- a/src/visualization/Visualizer.js +++ b/src/visualization/Visualizer.js @@ -1,8 +1,3 @@ -/** - * @callback visualizerUpdateListener - * @param {number} delta elapsed time since last update. - * @param {Uint8Array} bins the bins with varying frequency values. - */ /** * Provides a simplified access point to the frequency bins in the form of a visualization update listener. @@ -18,6 +13,12 @@ export default class Visualizer { #lastUpdate; #fftSize; + /** + * @callback Visualizer~visualizerUpdateListener + * @param {number} delta elapsed time since last update. + * @param {Uint8Array} bins the bins with varying frequency values. + */ + /** * * @param {MediaSource|HTMLMediaElement} stream a media source to analyze. @@ -81,7 +82,7 @@ export default class Visualizer { /** * - * @param {visualizerUpdateListener} listener the visualizer update listener to be registered. + * @param {Visualizer~visualizerUpdateListener} listener the visualizer update listener to be registered. * @returns {boolean} true if and only if the listener was successfully added. */ addUpdateListener(listener) { @@ -93,7 +94,7 @@ export default class Visualizer { /** * - * @param {visualizerUpdateListener} listener the visualizer update listener to remove. + * @param {Visualizer~visualizerUpdateListener} listener the visualizer update listener to remove. * @returns {boolean} true if and only if the removal of the listener was a success. */ removeUpdateListener(listener) {