Class names refactored.

This commit is contained in:
Harrison Deng 2022-04-18 12:07:09 -05:00
parent 9453ce5f0b
commit 9a0ff26288
7 changed files with 40 additions and 26 deletions

View File

@ -5,7 +5,14 @@
"ckeditor",
"easings",
"linebreak",
"musicplayer"
"musicplayer",
"musicplaylist",
"nextbtn",
"pathetique",
"playbtn",
"prevbtn",
"Rosen",
"syncdir"
],
"javascript.preferences.importModuleSpecifierEnding": "js",
"html.format.wrapLineLength": 0,

View File

@ -1,4 +1,4 @@
import VisualizerUpdateManager from "../visualization/VisualizerUpdateManager.js";
import VisUpdateRouter from "../visualization/VisUpdateRouter.js";
import { mapBinNumerical, mapRangedAvgNumerical } from "./numeric.js";
@ -11,11 +11,11 @@ import { mapBinNumerical, mapRangedAvgNumerical } from "./numeric.js";
* @param {number} conf.growUpper The upper limit of the width.
* @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 {VisualizerUpdateManager} conf.visUpdateManager The visualizer update manager to be mapped to.
* @param {VisUpdateRouter} conf.visUpdateManager 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 {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: VisualizerUpdateManager.visualizerBinUpdateListener}|{lower: number, upper: number, listener: VisualizerUpdateManager.visualizerRangedUpdateListener}} The listener that was added (ranged if an upper bound was provided, binned otherwise).
* @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).
*/
function mapWidth({ element, growLower, growUpper, unit, lowerBin, visUpdateManager, interpolator, upperBin = undefined, reversed = false }) {
const getter = () => element.style.width;
@ -49,11 +49,11 @@ function mapWidth({ element, growLower, growUpper, unit, lowerBin, visUpdateMana
* @param {number} conf.growUpper The upper limit of the height.
* @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 {VisualizerUpdateManager} conf.visUpdateManager The visualizer update manager to be mapped to.
* @param {VisUpdateRouter} conf.visUpdateManager 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 {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: VisualizerUpdateManager.visualizerBinUpdateListener}|{lower: number, upper: number, listener: VisualizerUpdateManager.visualizerRangedUpdateListener}} The listener that was added (ranged if an upper bound was provided, binned otherwise).
* @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).
*/
function mapHeight({ element, growLower, growUpper, unit, lowerBin, visUpdateManager, interpolator, upperBin = undefined, reversed = false }) {
const getter = () => element.style.height;

View File

@ -1,4 +1,4 @@
import VisualizerUpdateManager from "../visualization/VisualizerUpdateManager.js";
import VisUpdateRouter from "../visualization/VisUpdateRouter.js";
/**
*
@ -24,9 +24,9 @@ import VisualizerUpdateManager from "../visualization/VisualizerUpdateManager.js
* @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 {VisualizerUpdateManager} conf.visUpdateManager the visualizer update manager this mapping corresponds with.
* @param {VisUpdateRouter} conf.visUpdateManager 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: VisualizerUpdateManager.visualizerRangedUpdateListener}} An object containing the lower and upper bounds for the range of a listener, which is also in the object.
* @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.
*/
function mapRangedAvgNumerical({ minVal, maxVal, lowerBin = undefined, upperBin, getter, setter, interpolator, visUpdateManager, reversed = false }) {
const rangedListener = {
@ -63,9 +63,9 @@ function mapRangedAvgNumerical({ minVal, maxVal, lowerBin = undefined, upperBin,
* @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 {VisualizerUpdateManager} conf.visUpdateManager The update manager to map to.
* @param {VisUpdateRouter} conf.visUpdateManager 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: VisualizerUpdateManager.visualizerBinUpdateListener}} The bin listener that was added.
* @returns {{bin: number, listener: VisUpdateRouter.visualizerBinUpdateListener}} The bin listener that was added.
*/
function mapBinNumerical({ minVal, maxVal, bin, getter, setter, interpolator, visUpdateManager, reversed = false }) {
const listener = {

View File

@ -1,5 +1,5 @@
import Visualizer from "../visualization/Visualizer.js";
import VisualizerUpdateManager from "../visualization/VisualizerUpdateManager.js";
import VisUpdateRouter from "../visualization/VisUpdateRouter.js";
import MusicPlayer from "./MusicPlayer.js";
import MusicPlaylist from "./MusicPlaylist.js";
@ -11,7 +11,7 @@ import MusicPlaylist from "./MusicPlaylist.js";
*
* @augments MusicPlayer
*/
export default class VisualizedMusicPlayer extends MusicPlayer {
export default class VisMusicPlayer extends MusicPlayer {
#fftSize = 1024;
#visualizerUpdateManager;
@ -24,7 +24,11 @@ export default class VisualizedMusicPlayer extends MusicPlayer {
constructor(playlist, fftSize = 1024) {
super(playlist);
this.#fftSize = fftSize;
this.#visualizerUpdateManager = new VisualizerUpdateManager(this.getCurrentMusicVisualizer());
this.#updateVisUpdateManager();
}
#updateVisUpdateManager() {
this.#visualizerUpdateManager = new VisUpdateRouter(this.getCurrentMusicVisualizer());
}
/**
@ -32,7 +36,7 @@ export default class VisualizedMusicPlayer extends MusicPlayer {
*/
set playlist(playlist) {
super.playlist = playlist;
this.#visualizerUpdateManager = new VisualizerUpdateManager(this.getCurrentMusicVisualizer());
}
/**
@ -42,7 +46,8 @@ export default class VisualizedMusicPlayer extends MusicPlayer {
next() {
const updateListeners = this.#visualizerUpdateManager.getBinnedListeners();
if (!super.next()) return false;
this.#visualizerUpdateManager = new VisualizerUpdateManager(this.getCurrentMusicVisualizer());
this.#updateVisUpdateManager();
this.#visualizerUpdateManager.setBinnedListeners(updateListeners);
return true;
}
@ -56,7 +61,8 @@ export default class VisualizedMusicPlayer extends MusicPlayer {
const updateListeners = this.#visualizerUpdateManager.getBinnedListeners();
if (!super.previous()) return false;
this.#visualizerUpdateManager = new VisualizerUpdateManager(this.getCurrentMusicVisualizer());
this.#updateVisUpdateManager();
this.#visualizerUpdateManager.setBinnedListeners(updateListeners);
return true;
}
@ -69,13 +75,14 @@ export default class VisualizedMusicPlayer extends MusicPlayer {
changeCurrent(index) {
const updateListeners = this.VisualizerUpdateManager.getBinnedListeners();
if (!super.changeCurrent(index)) return false;
this.#visualizerUpdateManager = new VisualizerUpdateManager(this.getCurrentMusicVisualizer());
this.#updateVisUpdateManager();
this.#visualizerUpdateManager.setBinnedListeners = updateListeners();
return true;
}
/**
* @returns {VisualizerUpdateManager} The current visualizer update manager.
* @returns {VisUpdateRouter} The current visualizer update manager.
*/
get currentVisualizerUpdateManager() {
return this.#visualizerUpdateManager();

View File

@ -1,7 +1,7 @@
import MusicPlayer from "./MusicPlayer.js";
import MusicPlaylist from "./MusicPlaylist.js";
import VisualizedMusicPlayer from "./VisualizedMusicPlayer.js";
import VisMusicPlayer from "./VisMusicPlayer.js";
import Music from "./Music.js";
/**@module */
export { MusicPlayer, MusicPlaylist, VisualizedMusicPlayer, Music };
export { MusicPlayer, MusicPlaylist, VisMusicPlayer, Music };

View File

@ -22,7 +22,7 @@ import Visualizer from "./Visualizer.js";
* Specifically, the update manager handles updates directly from the {@link Visualizer} and checks for changes in the individual bins. These changes are then broadcasted to the individual bin listeners.
* In the rare event that a bin has not changed, then it will not receive an update call.
*/
export default class VisualizerUpdateManager {
export default class VisUpdateRouter {
#binnedListeners = [];
#rangedListeners = [];
#lastBins;
@ -82,7 +82,7 @@ export default class VisualizerUpdateManager {
}
/**
* Similar to {@link VisualizerUpdateManager#AddVisualizerBinUpdateListener}, this method adds a listener for to a range of bins.
* Similar to {@link VisUpdateRouter#AddVisualizerBinUpdateListener}, this method adds a listener for to a range of bins.
*
* @param {object} rangedUpdateListener The ranged update listener to add.
* @param {number} rangedUpdateListener.lower The lower bound of the bins to listen to (inclusive).
@ -155,7 +155,7 @@ export default class VisualizerUpdateManager {
/**
*
* @returns {object} All the listeners, both for binned, and ranged listeners. See {@link VisualizerUpdateManager#loadListeners} to see the structure of the returned object.
* @returns {object} All the listeners, both for binned, and ranged listeners. See {@link VisUpdateRouter#loadListeners} to see the structure of the returned object.
*/
retrieveListeners() {
return {

View File

@ -1,5 +1,5 @@
import Visualizer from "./Visualizer.js";
import VisualizerUpdateManager from "./VisualizerUpdateManager.js";
import VisUpdateRouter from "./VisUpdateRouter.js";
/**@module */
export { Visualizer, VisualizerUpdateManager };
export { Visualizer, VisUpdateRouter };