style: auto-fix linting issues
This commit is contained in:
parent
30865d2632
commit
a6f94a8385
6 changed files with 2782 additions and 1989 deletions
1567
index.html
1567
index.html
File diff suppressed because one or more lines are too long
|
|
@ -18,9 +18,9 @@ export class Visualizer {
|
||||||
this.animationId = null;
|
this.animationId = null;
|
||||||
|
|
||||||
this.presets = {
|
this.presets = {
|
||||||
'lcd': new LCDPreset(),
|
lcd: new LCDPreset(),
|
||||||
'particles': new ParticlesPreset(),
|
particles: new ParticlesPreset(),
|
||||||
'unknown-pleasures': new UnknownPleasuresPreset()
|
'unknown-pleasures': new UnknownPleasuresPreset(),
|
||||||
};
|
};
|
||||||
|
|
||||||
this.activePresetKey = visualizerSettings.getPreset();
|
this.activePresetKey = visualizerSettings.getPreset();
|
||||||
|
|
@ -39,7 +39,7 @@ export class Visualizer {
|
||||||
upbeatSmoother: 0,
|
upbeatSmoother: 0,
|
||||||
sensitivity: 0.5,
|
sensitivity: 0.5,
|
||||||
primaryColor: '#ffffff',
|
primaryColor: '#ffffff',
|
||||||
mode: ''
|
mode: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---- CACHED STATE ----
|
// ---- CACHED STATE ----
|
||||||
|
|
@ -145,12 +145,7 @@ export class Visualizer {
|
||||||
this.analyser.getByteFrequencyData(this.dataArray);
|
this.analyser.getByteFrequencyData(this.dataArray);
|
||||||
|
|
||||||
// Bass (first bins only — cheap)
|
// Bass (first bins only — cheap)
|
||||||
let bass =
|
let bass = (this.dataArray[0] + this.dataArray[1] + this.dataArray[2] + this.dataArray[3]) * 0.000980392; // 1 / (4 * 255)
|
||||||
(this.dataArray[0] +
|
|
||||||
this.dataArray[1] +
|
|
||||||
this.dataArray[2] +
|
|
||||||
this.dataArray[3]) *
|
|
||||||
0.000980392; // 1 / (4 * 255)
|
|
||||||
|
|
||||||
const intensity = bass * bass;
|
const intensity = bass * bass;
|
||||||
const stats = this.stats;
|
const stats = this.stats;
|
||||||
|
|
@ -164,8 +159,7 @@ export class Visualizer {
|
||||||
if (stats.energyAverage > 0.4) {
|
if (stats.energyAverage > 0.4) {
|
||||||
sensitivity = 0.7;
|
sensitivity = 0.7;
|
||||||
} else if (stats.energyAverage > 0.2) {
|
} else if (stats.energyAverage > 0.2) {
|
||||||
sensitivity =
|
sensitivity = 0.1 + ((stats.energyAverage - 0.2) / 0.2) * 0.6;
|
||||||
0.1 + ((stats.energyAverage - 0.2) / 0.2) * 0.6;
|
|
||||||
} else {
|
} else {
|
||||||
sensitivity = 0.1;
|
sensitivity = 0.1;
|
||||||
}
|
}
|
||||||
|
|
@ -173,15 +167,10 @@ export class Visualizer {
|
||||||
|
|
||||||
// ===== KICK DETECTION =====
|
// ===== KICK DETECTION =====
|
||||||
const now = performance.now();
|
const now = performance.now();
|
||||||
let threshold = stats.energyAverage < 0.3
|
let threshold = stats.energyAverage < 0.3 ? 0.5 + (0.3 - stats.energyAverage) * 2 : 0.5;
|
||||||
? 0.5 + (0.3 - stats.energyAverage) * 2
|
|
||||||
: 0.5;
|
|
||||||
|
|
||||||
if (intensity > threshold) {
|
if (intensity > threshold) {
|
||||||
if (
|
if (intensity > stats.lastIntensity + 0.05 && now - stats.lastBeatTime > 50) {
|
||||||
intensity > stats.lastIntensity + 0.05 &&
|
|
||||||
now - stats.lastBeatTime > 50
|
|
||||||
) {
|
|
||||||
stats.kick = 1.0;
|
stats.kick = 1.0;
|
||||||
stats.lastBeatTime = now;
|
stats.lastBeatTime = now;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -205,10 +194,7 @@ export class Visualizer {
|
||||||
stats.sensitivity = sensitivity;
|
stats.sensitivity = sensitivity;
|
||||||
|
|
||||||
// ===== COLORS (CACHED) =====
|
// ===== COLORS (CACHED) =====
|
||||||
const color =
|
const color = getComputedStyle(document.documentElement).getPropertyValue('--primary').trim() || '#ffffff';
|
||||||
getComputedStyle(document.documentElement)
|
|
||||||
.getPropertyValue('--primary')
|
|
||||||
.trim() || '#ffffff';
|
|
||||||
|
|
||||||
if (color !== this._lastPrimaryColor) {
|
if (color !== this._lastPrimaryColor) {
|
||||||
stats.primaryColor = color;
|
stats.primaryColor = color;
|
||||||
|
|
@ -218,13 +204,7 @@ export class Visualizer {
|
||||||
stats.mode = visualizerSettings.getMode();
|
stats.mode = visualizerSettings.getMode();
|
||||||
|
|
||||||
// ===== DRAW =====
|
// ===== DRAW =====
|
||||||
this.activePreset.draw(
|
this.activePreset.draw(this.ctx, this.canvas, this.analyser, this.dataArray, stats);
|
||||||
this.ctx,
|
|
||||||
this.canvas,
|
|
||||||
this.analyser,
|
|
||||||
this.dataArray,
|
|
||||||
stats
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
setPreset(key) {
|
setPreset(key) {
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ export class LCDPreset {
|
||||||
// --- Apply Global Skew Transform ---
|
// --- Apply Global Skew Transform ---
|
||||||
ctx.save();
|
ctx.save();
|
||||||
ctx.translate(centerX, centerY);
|
ctx.translate(centerX, centerY);
|
||||||
ctx.transform(1, -0.08, 0.20, 1, 0, 0);
|
ctx.transform(1, -0.08, 0.2, 1, 0, 0);
|
||||||
ctx.translate(-centerX, -centerY);
|
ctx.translate(-centerX, -centerY);
|
||||||
|
|
||||||
// Shake on kick
|
// Shake on kick
|
||||||
|
|
@ -225,7 +225,7 @@ export class LCDPreset {
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Draw Bars ---
|
// --- Draw Bars ---
|
||||||
const baseBarW = totalW / this.gridCols * 0.7; // Base width
|
const baseBarW = (totalW / this.gridCols) * 0.7; // Base width
|
||||||
|
|
||||||
for (let c = 0; c < this.gridCols; c++) {
|
for (let c = 0; c < this.gridCols; c++) {
|
||||||
const p = c / (this.gridCols - 1);
|
const p = c / (this.gridCols - 1);
|
||||||
|
|
@ -294,7 +294,8 @@ export class LCDPreset {
|
||||||
const startBin = Math.floor(minBin * Math.pow(maxBin / minBin, p));
|
const startBin = Math.floor(minBin * Math.pow(maxBin / minBin, p));
|
||||||
const endBin = Math.max(startBin + 1, Math.floor(minBin * Math.pow(maxBin / minBin, p + 1 / center)));
|
const endBin = Math.max(startBin + 1, Math.floor(minBin * Math.pow(maxBin / minBin, p + 1 / center)));
|
||||||
|
|
||||||
let sum = 0, count = 0;
|
let sum = 0,
|
||||||
|
count = 0;
|
||||||
for (let k = startBin; k < endBin && k < totalBins; k++) {
|
for (let k = startBin; k < endBin && k < totalBins; k++) {
|
||||||
sum += dataArray[k];
|
sum += dataArray[k];
|
||||||
count++;
|
count++;
|
||||||
|
|
@ -322,14 +323,14 @@ export class LCDPreset {
|
||||||
|
|
||||||
// Auto-gain with more headroom
|
// Auto-gain with more headroom
|
||||||
this.maxVol = Math.max(this.maxVol * this.volDecay, peakVal, 40);
|
this.maxVol = Math.max(this.maxVol * this.volDecay, peakVal, 40);
|
||||||
const normFactor = (200 / this.maxVol);
|
const normFactor = 200 / this.maxVol;
|
||||||
|
|
||||||
// Normalize and apply contrast curve
|
// Normalize and apply contrast curve
|
||||||
for (let c = 0; c < this.gridCols; c++) {
|
for (let c = 0; c < this.gridCols; c++) {
|
||||||
let v = (this.prevData[c] * normFactor) / 255;
|
let v = (this.prevData[c] * normFactor) / 255;
|
||||||
|
|
||||||
// Noise gate: important to scale the bars
|
// Noise gate: important to scale the bars
|
||||||
const gate = 0.50
|
const gate = 0.5;
|
||||||
if (v < gate) v = 0;
|
if (v < gate) v = 0;
|
||||||
else v = (v - gate) / (1 - gate);
|
else v = (v - gate) / (1 - gate);
|
||||||
|
|
||||||
|
|
@ -365,7 +366,7 @@ export class LCDPreset {
|
||||||
const r = parseInt(hex.slice(1, 3), 16);
|
const r = parseInt(hex.slice(1, 3), 16);
|
||||||
const g = parseInt(hex.slice(3, 5), 16);
|
const g = parseInt(hex.slice(3, 5), 16);
|
||||||
const b = parseInt(hex.slice(5, 7), 16);
|
const b = parseInt(hex.slice(5, 7), 16);
|
||||||
const clamp = v => Math.min(255, Math.max(0, Math.round(v * factor)));
|
const clamp = (v) => Math.min(255, Math.max(0, Math.round(v * factor)));
|
||||||
return `rgb(${clamp(r)},${clamp(g)},${clamp(b)})`;
|
return `rgb(${clamp(r)},${clamp(g)},${clamp(b)})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,9 @@ export class UnknownPleasuresPreset {
|
||||||
}
|
}
|
||||||
|
|
||||||
resize() {}
|
resize() {}
|
||||||
destroy() { this.history.length = 0; }
|
destroy() {
|
||||||
|
this.history.length = 0;
|
||||||
|
}
|
||||||
|
|
||||||
_precompute() {
|
_precompute() {
|
||||||
const pts = this.dataPoints;
|
const pts = this.dataPoints;
|
||||||
|
|
@ -71,7 +73,7 @@ export class UnknownPleasuresPreset {
|
||||||
}
|
}
|
||||||
|
|
||||||
const pts = this.dataPoints;
|
const pts = this.dataPoints;
|
||||||
const len = (dataArray.length) | 0;
|
const len = dataArray.length | 0;
|
||||||
|
|
||||||
const line = this.history[this.writeIndex];
|
const line = this.history[this.writeIndex];
|
||||||
if (line) {
|
if (line) {
|
||||||
|
|
@ -129,10 +131,7 @@ export class UnknownPleasuresPreset {
|
||||||
ctx.moveTo(margin, y);
|
ctx.moveTo(margin, y);
|
||||||
|
|
||||||
for (let j = 0; j < pts; j++) {
|
for (let j = 0; j < pts; j++) {
|
||||||
ctx.lineTo(
|
ctx.lineTo(margin + this.xLookup[j] * lw, y - data[j] * amp);
|
||||||
margin + this.xLookup[j] * lw,
|
|
||||||
y - data[j] * amp
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -719,7 +719,6 @@ input[type='search']::-webkit-search-cancel-button {
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes pulse {
|
@keyframes pulse {
|
||||||
|
|
||||||
0%,
|
0%,
|
||||||
100% {
|
100% {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
|
|
@ -1038,7 +1037,6 @@ input[type='search']::-webkit-search-cancel-button {
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 1100px) {
|
@media (max-width: 1100px) {
|
||||||
|
|
||||||
#home-recommended-songs,
|
#home-recommended-songs,
|
||||||
#artist-detail-tracks,
|
#artist-detail-tracks,
|
||||||
#playlist-detail-recommended {
|
#playlist-detail-recommended {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue