Music — Animated Equalizer Bars
A self-contained music audio-visualizer built with pure CSS keyframes and vanilla JS. Four equalizer styles — classic bars, dot matrix, mirrored center-out, and a circular radial burst — bounce in staggered sync to simulate a live signal. A morphing play/pause button starts and settles the animation, while sliders retune the band count and tempo and a swatch row recolors every bar from a themed accent palette.
MCP
Kod
:root {
--bg: #0b0b0f;
--bg-2: #13131a;
--surface: #1a1a22;
--surface-2: #22222c;
--text: #f4f4f7;
--muted: #a0a0ad;
--line: rgba(255, 255, 255, 0.10);
--line-2: rgba(255, 255, 255, 0.18);
--accent: #1db954;
--accent-2: #8b5cf6;
--accent-3: #ff3d71;
--r-sm: 8px;
--r-md: 14px;
--r-lg: 20px;
--r-full: 999px;
--shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
--eq-speed: 1s;
--eq-bands: 24;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
margin: 0;
background:
radial-gradient(1100px 600px at 80% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%),
radial-gradient(900px 520px at -10% 10%, color-mix(in srgb, var(--accent-2) 14%, transparent), transparent 55%),
var(--bg);
color: var(--text);
font-family: "Inter", system-ui, sans-serif;
line-height: 1.5;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
min-height: 100vh;
}
.app {
max-width: 1120px;
margin: 0 auto;
padding: 22px 22px 64px;
display: flex;
flex-direction: column;
gap: 22px;
}
h1, h2 { font-family: "Space Grotesk", "Inter", sans-serif; }
/* ---------- Topbar ---------- */
.topbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
padding: 12px 16px;
background: color-mix(in srgb, var(--surface) 70%, transparent);
border: 1px solid var(--line);
border-radius: var(--r-lg);
backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
display: flex;
align-items: flex-end;
gap: 3px;
height: 26px;
width: 30px;
}
.brand-mark i {
width: 5px;
border-radius: 3px;
background: linear-gradient(var(--accent), var(--accent-2));
animation: brandBounce 1.1s ease-in-out infinite;
}
.brand-mark i:nth-child(1) { height: 40%; animation-delay: 0s; }
.brand-mark i:nth-child(2) { height: 90%; animation-delay: .15s; }
.brand-mark i:nth-child(3) { height: 60%; animation-delay: .3s; }
.brand-mark i:nth-child(4) { height: 100%; animation-delay: .45s; }
@keyframes brandBounce { 0%, 100% { transform: scaleY(.4); } 50% { transform: scaleY(1); } }
.brand-txt { display: flex; flex-direction: column; line-height: 1.1; }
.brand-txt strong { font-family: "Space Grotesk", sans-serif; font-size: 1.05rem; letter-spacing: .3px; }
.brand-txt small { color: var(--muted); font-size: .72rem; }
.now { display: flex; align-items: center; gap: 12px; min-width: 0; }
.now .cover {
width: 40px; height: 40px; border-radius: var(--r-sm);
background:
conic-gradient(from 120deg, var(--accent), var(--accent-2), var(--accent-3), var(--accent));
box-shadow: inset 0 0 0 1px var(--line-2);
flex: none;
}
.now-meta { display: flex; flex-direction: column; min-width: 0; }
.now-track { font-weight: 700; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-artist { color: var(--muted); font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-time {
font-variant-numeric: tabular-nums;
font-size: .78rem; color: var(--muted);
padding: 3px 9px; border-radius: var(--r-full);
border: 1px solid var(--line); background: var(--bg-2);
}
/* ---------- Hero ---------- */
.hero {
display: grid;
grid-template-columns: 220px 1fr;
gap: 24px;
padding: 22px;
background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 88%, transparent), var(--bg-2));
border: 1px solid var(--line);
border-radius: var(--r-lg);
box-shadow: var(--shadow);
}
.hero-art {
border-radius: var(--r-md);
aspect-ratio: 1;
position: relative;
overflow: hidden;
background:
radial-gradient(120% 120% at 20% 15%, color-mix(in srgb, var(--accent) 70%, #fff 0%), transparent 55%),
radial-gradient(120% 120% at 85% 90%, var(--accent-2), transparent 60%),
linear-gradient(135deg, var(--accent-3), var(--accent-2));
box-shadow: inset 0 0 0 1px var(--line-2), 0 14px 40px color-mix(in srgb, var(--accent) 28%, transparent);
}
.hero-art::before {
content: "";
position: absolute; inset: 18% 0 auto 0; height: 64%;
background:
repeating-linear-gradient(90deg, rgba(255,255,255,.22) 0 3px, transparent 3px 11px);
-webkit-mask: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
mask: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
animation: heroPan 6s linear infinite;
}
@keyframes heroPan { to { background-position: 80px 0; } }
.hero-art::after {
content: "";
position: absolute; inset: 0;
background: radial-gradient(60% 60% at 50% 120%, rgba(0,0,0,.5), transparent 70%);
}
.hero-body { display: flex; flex-direction: column; gap: 12px; }
.kicker {
align-self: flex-start;
font-size: .68rem; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase;
color: var(--accent);
padding: 4px 10px; border-radius: var(--r-full);
background: color-mix(in srgb, var(--accent) 14%, transparent);
border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.hero-body h1 { margin: 0; font-size: clamp(1.6rem, 4vw, 2.4rem); letter-spacing: -.5px; }
.hero-body p { margin: 0; color: var(--muted); max-width: 56ch; }
/* ---------- Player ---------- */
.player {
display: flex; align-items: center; gap: 16px;
margin-top: 6px;
padding: 12px 14px;
background: var(--surface);
border: 1px solid var(--line);
border-radius: var(--r-md);
}
.play {
position: relative;
width: 52px; height: 52px; flex: none;
border-radius: var(--r-full);
border: none;
cursor: pointer;
background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--accent-2)));
box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 40%, transparent);
transition: transform .15s ease, box-shadow .2s ease;
}
.play:hover { transform: scale(1.06); }
.play:active { transform: scale(.96); }
.play:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.play .ico { position: absolute; inset: 0; margin: auto; transition: opacity .18s ease, transform .18s ease; }
.ico-play {
width: 0; height: 0;
border-style: solid;
border-width: 9px 0 9px 15px;
border-color: transparent transparent transparent #07120c;
transform: translateX(2px);
}
.ico-pause {
width: 14px; height: 16px;
border-left: 5px solid #07120c;
border-right: 5px solid #07120c;
opacity: 0; transform: scale(.6);
}
.play[aria-pressed="true"] .ico-play { opacity: 0; transform: scale(.6); }
.play[aria-pressed="true"] .ico-pause { opacity: 1; transform: scale(1); }
.scrub { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.scrub-track {
position: relative;
height: 8px; border-radius: var(--r-full);
background: var(--surface-2);
cursor: pointer;
}
.scrub-track:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.scrub-fill {
position: absolute; inset: 0 auto 0 0; width: 0%;
border-radius: var(--r-full);
background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.scrub-knob {
position: absolute; top: 50%; left: 0%;
width: 14px; height: 14px; border-radius: 50%;
background: var(--text);
transform: translate(-50%, -50%);
box-shadow: 0 2px 8px rgba(0,0,0,.5);
transition: transform .1s ease;
}
.scrub-track:hover .scrub-knob { transform: translate(-50%, -50%) scale(1.15); }
.scrub-times {
display: flex; justify-content: space-between;
font-size: .72rem; color: var(--muted);
font-variant-numeric: tabular-nums;
}
.like {
width: 42px; height: 42px; flex: none;
border-radius: var(--r-full);
border: 1px solid var(--line);
background: var(--bg-2);
color: var(--muted);
cursor: pointer;
display: grid; place-items: center;
transition: color .2s ease, transform .15s ease, border-color .2s ease;
}
.like svg { width: 20px; height: 20px; fill: currentColor; }
.like:hover { color: var(--accent-3); border-color: color-mix(in srgb, var(--accent-3) 40%, transparent); }
.like:focus-visible { outline: 2px solid var(--accent-3); outline-offset: 2px; }
.like[aria-pressed="true"] { color: var(--accent-3); animation: pop .35s ease; }
@keyframes pop { 40% { transform: scale(1.25); } }
.ticker {
display: flex; align-items: center; gap: 8px;
font-size: .8rem; color: var(--muted);
}
.ticker .dot {
width: 8px; height: 8px; border-radius: 50%;
background: var(--muted);
}
.ticker .dot.on {
background: var(--accent);
box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent);
animation: pulse 1.4s ease-out infinite;
}
@keyframes pulse {
0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
100% { box-shadow: 0 0 0 10px transparent; }
}
.ticker .sep { opacity: .4; }
.ticker #plays { color: var(--text); font-weight: 600; }
/* ---------- Controls ---------- */
.controls {
display: grid;
grid-template-columns: 1fr 1fr auto;
gap: 18px;
padding: 18px 20px;
background: color-mix(in srgb, var(--surface) 70%, transparent);
border: 1px solid var(--line);
border-radius: var(--r-lg);
}
.ctl { display: flex; flex-direction: column; gap: 8px; }
.ctl label {
font-size: .8rem; font-weight: 600; color: var(--muted);
display: flex; align-items: center; gap: 6px;
}
.ctl label b { color: var(--text); font-variant-numeric: tabular-nums; }
input[type="range"] {
-webkit-appearance: none; appearance: none;
width: 100%; height: 6px;
border-radius: var(--r-full);
background: var(--surface-2);
outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none; appearance: none;
width: 18px; height: 18px; border-radius: 50%;
background: var(--accent);
border: 3px solid var(--bg);
box-shadow: 0 0 0 1px var(--line-2);
cursor: pointer;
transition: transform .12s ease;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
width: 18px; height: 18px; border-radius: 50%;
background: var(--accent);
border: 3px solid var(--bg);
cursor: pointer;
}
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.swatches .swatch-row { display: flex; gap: 8px; }
.sw {
width: 28px; height: 28px; border-radius: 50%;
border: 2px solid var(--line-2);
background: var(--sw);
cursor: pointer;
padding: 0;
transition: transform .15s ease, box-shadow .2s ease;
}
.sw:hover { transform: scale(1.12); }
.sw[aria-checked="true"] {
box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--sw);
transform: scale(1.1);
}
.sw:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
/* ---------- Visualizer grid ---------- */
.grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 18px;
}
.viz {
background: linear-gradient(180deg, var(--surface), var(--bg-2));
border: 1px solid var(--line);
border-radius: var(--r-lg);
padding: 16px 16px 18px;
display: flex; flex-direction: column; gap: 14px;
overflow: hidden;
}
.viz-head { display: flex; align-items: center; justify-content: space-between; }
.viz-head h2 { margin: 0; font-size: 1.05rem; letter-spacing: -.2px; }
.tag {
font-size: .66rem; font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
color: var(--muted);
padding: 3px 9px; border-radius: var(--r-full);
border: 1px solid var(--line); background: var(--bg-2);
}
.stage { height: 150px; }
/* paused: bars flat */
.paused .bar,
.paused .dot-col i,
.paused .ray { animation-play-state: paused !important; }
.paused .bar { transform: scaleY(.08); }
.paused .dot-col i { opacity: .14; }
.paused .ray { transform: rotate(var(--rot)) scaleY(.18); }
/* classic & mirrored bars */
.stage-bars, .stage-mirror {
display: flex; align-items: flex-end; justify-content: center;
gap: 4px;
}
.stage-mirror { align-items: center; }
.bar {
flex: 1 1 0; min-width: 3px; max-width: 18px;
border-radius: var(--r-sm) var(--r-sm) 2px 2px;
background: linear-gradient(var(--accent), color-mix(in srgb, var(--accent) 45%, var(--accent-2)));
transform-origin: bottom;
height: 100%;
animation: eq var(--eq-speed) ease-in-out infinite alternate;
animation-delay: var(--d);
box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 30%, transparent);
}
.stage-mirror .bar {
border-radius: var(--r-full);
transform-origin: center;
background: linear-gradient(180deg,
color-mix(in srgb, var(--accent) 50%, var(--accent-2)),
var(--accent),
color-mix(in srgb, var(--accent) 50%, var(--accent-2)));
animation-name: eqMirror;
}
@keyframes eq {
0% { transform: scaleY(.18); }
100% { transform: scaleY(var(--h, 1)); }
}
@keyframes eqMirror {
0% { transform: scaleY(.2); }
100% { transform: scaleY(var(--h, 1)); }
}
/* dot matrix */
.stage-dots {
display: flex; align-items: flex-end; justify-content: center;
gap: 5px;
}
.dot-col { display: flex; flex-direction: column-reverse; gap: 4px; }
.dot-col i {
width: 9px; height: 9px; border-radius: 50%;
background: var(--accent);
opacity: .14;
animation: dotGlow var(--eq-speed) steps(1, end) infinite alternate;
animation-delay: var(--d);
}
@keyframes dotGlow {
0%, 100% { opacity: .14; box-shadow: none; }
50% { opacity: 1; box-shadow: 0 0 10px var(--accent); }
}
/* radial */
.stage-radial { display: grid; place-items: center; }
.radial-hub {
position: relative;
width: 150px; height: 150px;
display: grid; place-items: center;
}
.radial-core {
width: 52px; height: 52px; border-radius: 50%;
background:
radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--accent) 80%, #fff), var(--accent) 60%, var(--accent-2));
box-shadow: 0 0 24px color-mix(in srgb, var(--accent) 45%, transparent), inset 0 0 0 1px var(--line-2);
z-index: 2;
}
.ray {
position: absolute; top: 50%; left: 50%;
width: 5px; height: 50px;
margin: -25px 0 0 -2.5px;
border-radius: var(--r-full);
background: linear-gradient(var(--accent), transparent);
transform-origin: center;
transform: rotate(var(--rot)) scaleY(.4);
animation: ray var(--eq-speed) ease-in-out infinite alternate;
animation-delay: var(--d);
}
@keyframes ray {
0% { transform: rotate(var(--rot)) translateY(-26px) scaleY(.3); }
100% { transform: rotate(var(--rot)) translateY(-26px) scaleY(var(--h, 1.4)); }
}
/* ---------- Queue ---------- */
.queue {
background: color-mix(in srgb, var(--surface) 70%, transparent);
border: 1px solid var(--line);
border-radius: var(--r-lg);
padding: 18px 20px;
}
.queue-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.queue-head h2 { margin: 0; font-size: 1.1rem; }
.queue-sub { color: var(--muted); font-size: .82rem; }
.tracks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.track {
display: grid;
grid-template-columns: 28px 40px 1fr auto auto;
align-items: center;
gap: 12px;
padding: 10px 10px;
border-radius: var(--r-md);
cursor: pointer;
transition: background .18s ease;
}
.track:hover { background: var(--surface); }
.track.active { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.track .num { color: var(--muted); font-size: .82rem; text-align: center; font-variant-numeric: tabular-nums; }
.track.active .num { color: var(--accent); font-weight: 700; }
.track .mini {
width: 40px; height: 40px; border-radius: var(--r-sm);
box-shadow: inset 0 0 0 1px var(--line-2);
}
.track .info { min-width: 0; }
.track .t-title { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track .t-artist { color: var(--muted); font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track .t-plays { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.track .t-dur { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.track .miniwave {
display: none;
align-items: flex-end; gap: 2px; height: 16px;
}
.track.active .miniwave { display: flex; }
.track.active .num { display: none; }
.miniwave i {
width: 3px; border-radius: 2px; background: var(--accent);
animation: eq .8s ease-in-out infinite alternate;
}
.miniwave i:nth-child(1) { height: 40%; animation-delay: 0s; }
.miniwave i:nth-child(2) { height: 90%; animation-delay: .2s; }
.miniwave i:nth-child(3) { height: 60%; animation-delay: .35s; }
.paused .miniwave i { animation-play-state: paused; }
/* ---------- Toast ---------- */
.toast {
position: fixed;
left: 50%; bottom: 24px;
transform: translate(-50%, 140%);
background: var(--surface-2);
color: var(--text);
border: 1px solid var(--line-2);
padding: 11px 18px;
border-radius: var(--r-full);
font-size: .85rem; font-weight: 500;
box-shadow: var(--shadow);
opacity: 0;
transition: transform .35s cubic-bezier(.2,.9,.3,1), opacity .3s ease;
z-index: 60;
pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
/* ---------- Responsive ---------- */
@media (max-width: 820px) {
.grid { grid-template-columns: 1fr; }
.controls { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
.app { padding: 14px 14px 48px; gap: 16px; }
.topbar { flex-wrap: wrap; gap: 12px; }
.now { order: 3; width: 100%; }
.hero { grid-template-columns: 1fr; padding: 16px; }
.hero-art { width: 140px; aspect-ratio: 1; }
.player { flex-wrap: wrap; }
.scrub { order: 3; flex-basis: 100%; }
.stage { height: 120px; }
.track { grid-template-columns: 24px 36px 1fr auto; gap: 10px; }
.track .t-plays { display: none; }
}
@media (prefers-reduced-motion: reduce) {
.bar, .dot-col i, .ray, .brand-mark i, .miniwave i, .hero-art::before { animation: none !important; }
}(function () {
"use strict";
/* ---------- State ---------- */
var state = {
playing: false,
bands: 24,
speed: 1.0, // multiplier
accent: "#1db954",
accent2: "#8b5cf6",
position: 0, // 0..1
duration: 222, // 3:42 in seconds
liked: false,
queueIndex: 0
};
/* ---------- Helpers ---------- */
function $(sel) { return document.querySelector(sel); }
function clamp(v, a, b) { return Math.max(a, Math.min(b, v)); }
function fmt(sec) {
sec = Math.max(0, Math.floor(sec));
var m = Math.floor(sec / 60);
var s = sec % 60;
return m + ":" + (s < 10 ? "0" : "") + s;
}
var toastEl = $("#toast");
var toastTimer;
function toast(msg) {
toastEl.textContent = msg;
toastEl.classList.add("show");
clearTimeout(toastTimer);
toastTimer = setTimeout(function () { toastEl.classList.remove("show"); }, 1900);
}
/* base duration in seconds for one eq cycle at 1x */
function baseDur() { return 1.0 / state.speed; }
/* ---------- Build visualizers ---------- */
var barsStage = $("#vizBars");
var dotsStage = $("#vizDots");
var mirrorStage = $("#vizMirror");
var radialStage = $("#vizRadial");
function rnd(min, max) { return min + Math.random() * (max - min); }
function buildBars() {
var n = state.bands;
var html = "";
for (var i = 0; i < n; i++) {
var h = rnd(0.35, 1).toFixed(2);
var d = (-rnd(0, 0.9)).toFixed(2);
html += '<span class="bar" style="--h:' + h + ';--d:' + d + 's"></span>';
}
barsStage.innerHTML = html;
}
function buildMirror() {
var n = state.bands;
var html = "";
for (var i = 0; i < n; i++) {
// mirrored feel: tall in center, short at edges
var center = 1 - Math.abs((i / (n - 1)) - 0.5) * 1.6;
var h = clamp(center * rnd(0.6, 1.05), 0.2, 1).toFixed(2);
var d = (-rnd(0, 0.8)).toFixed(2);
html += '<span class="bar" style="--h:' + h + ';--d:' + d + 's"></span>';
}
mirrorStage.innerHTML = html;
}
function buildDots() {
var cols = Math.max(6, Math.round(state.bands / 2));
var rows = 7;
var html = "";
for (var c = 0; c < cols; c++) {
var colDelay = -rnd(0, 0.9);
html += '<span class="dot-col">';
for (var r = 0; r < rows; r++) {
var d = (colDelay - r * 0.06).toFixed(2);
html += '<i style="--d:' + d + 's"></i>';
}
html += "</span>";
}
dotsStage.innerHTML = html;
}
function buildRadial() {
var n = Math.max(10, Math.round(state.bands * 0.9));
var html = "";
for (var i = 0; i < n; i++) {
var rot = (360 / n) * i;
var h = rnd(0.7, 1.7).toFixed(2);
var d = (-rnd(0, 0.9)).toFixed(2);
html += '<span class="ray" style="--rot:' + rot + 'deg;--h:' + h + ';--d:' + d + 's"></span>';
}
radialStage.insertAdjacentHTML("beforeend", html);
}
function rebuildAll() {
buildBars();
buildMirror();
buildDots();
// radial: keep core, rebuild rays
radialStage.querySelectorAll(".ray").forEach(function (el) { el.remove(); });
buildRadial();
}
/* ---------- Apply speed / accent via CSS vars ---------- */
var root = document.documentElement;
function applySpeed() {
root.style.setProperty("--eq-speed", baseDur().toFixed(3) + "s");
$("#speedVal").innerHTML = state.speed.toFixed(1) + "×";
}
function applyAccent() {
root.style.setProperty("--accent", state.accent);
}
/* ---------- Play / pause ---------- */
var playBtn = $("#playBtn");
var liveDot = $("#liveDot");
var statusTxt = $("#statusTxt");
function setPlaying(on) {
state.playing = on;
playBtn.setAttribute("aria-pressed", on ? "true" : "false");
playBtn.setAttribute("aria-label", on ? "Pause visualizer" : "Play visualizer");
document.body.classList.toggle("paused", !on);
liveDot.classList.toggle("on", on);
statusTxt.textContent = on ? "Playing" : "Paused";
if (on) startTick(); else stopTick();
}
playBtn.addEventListener("click", function () {
setPlaying(!state.playing);
toast(state.playing ? "Playback started" : "Paused");
});
/* ---------- Simulated playback clock ---------- */
var tickTimer = null;
var lastTs = 0;
function startTick() {
lastTs = performance.now();
if (tickTimer) return;
tickTimer = setInterval(tick, 250);
}
function stopTick() {
if (tickTimer) { clearInterval(tickTimer); tickTimer = null; }
}
function tick() {
var now = performance.now();
var dt = (now - lastTs) / 1000;
lastTs = now;
state.position += (dt * state.speed) / state.duration;
if (state.position >= 1) {
state.position = 0;
nextTrack(true);
toast("Up next: " + QUEUE[state.queueIndex].title);
}
renderProgress();
}
/* ---------- Progress / scrubber ---------- */
var scrub = $("#scrub");
var scrubFill = $("#scrubFill");
var scrubKnob = $("#scrubKnob");
var elapsedEl = $("#elapsed");
var totalEl = $("#total");
var nowTimeEl = $("#now-time");
function renderProgress() {
var pct = clamp(state.position, 0, 1) * 100;
scrubFill.style.width = pct + "%";
scrubKnob.style.left = pct + "%";
var cur = state.position * state.duration;
elapsedEl.textContent = fmt(cur);
nowTimeEl.textContent = fmt(cur);
totalEl.textContent = fmt(state.duration);
scrub.setAttribute("aria-valuenow", Math.round(pct));
}
function seekFromClientX(clientX) {
var rect = scrub.getBoundingClientRect();
var p = clamp((clientX - rect.left) / rect.width, 0, 1);
state.position = p;
renderProgress();
}
var dragging = false;
scrub.addEventListener("pointerdown", function (e) {
dragging = true;
scrub.setPointerCapture(e.pointerId);
seekFromClientX(e.clientX);
});
scrub.addEventListener("pointermove", function (e) {
if (dragging) seekFromClientX(e.clientX);
});
scrub.addEventListener("pointerup", function () { dragging = false; });
scrub.addEventListener("keydown", function (e) {
var step = 0.02;
if (e.key === "ArrowRight" || e.key === "ArrowUp") { state.position = clamp(state.position + step, 0, 1); }
else if (e.key === "ArrowLeft" || e.key === "ArrowDown") { state.position = clamp(state.position - step, 0, 1); }
else if (e.key === "Home") { state.position = 0; }
else if (e.key === "End") { state.position = 1; }
else return;
e.preventDefault();
renderProgress();
});
/* ---------- Like ---------- */
var likeBtn = $("#likeBtn");
likeBtn.addEventListener("click", function () {
state.liked = !state.liked;
likeBtn.setAttribute("aria-pressed", state.liked ? "true" : "false");
toast(state.liked ? "Added to Liked Songs" : "Removed from Liked Songs");
});
/* ---------- Controls: bands ---------- */
var bandsInput = $("#bands");
var bandsVal = $("#bandsVal");
bandsInput.addEventListener("input", function () {
state.bands = parseInt(bandsInput.value, 10);
bandsVal.textContent = state.bands;
root.style.setProperty("--eq-bands", state.bands);
rebuildAll();
});
/* ---------- Controls: speed ---------- */
var speedInput = $("#speed");
speedInput.addEventListener("input", function () {
state.speed = parseInt(speedInput.value, 10) / 100;
applySpeed();
});
/* ---------- Controls: accent swatches ---------- */
var swatchWrap = $("#swatches");
swatchWrap.addEventListener("click", function (e) {
var btn = e.target.closest(".sw");
if (!btn) return;
state.accent = btn.getAttribute("data-c");
applyAccent();
swatchWrap.querySelectorAll(".sw").forEach(function (s) {
s.setAttribute("aria-checked", s === btn ? "true" : "false");
});
paintCovers();
toast("Accent: " + btn.getAttribute("aria-label"));
});
/* ---------- Queue ---------- */
var QUEUE = [
{ title: "Paper Lanterns", artist: "Neon Tides", dur: 222, plays: "128,402", hue: 152 },
{ title: "Velvet Static", artist: "Glass Harbor", dur: 198, plays: "94,118", hue: 268 },
{ title: "Low Orbit", artist: "Neon Tides", dur: 245, plays: "76,540", hue: 340 },
{ title: "Cassette Sunrise", artist: "Marlowe Drift", dur: 176, plays: "61,205", hue: 190 },
{ title: "Saltwater Code", artist: "The Quiet Wire", dur: 211, plays: "52,889", hue: 44 },
{ title: "Halogen Bloom", artist: "Neon Tides", dur: 233, plays: "47,310", hue: 280 }
];
function coverGradient(hue) {
return "linear-gradient(135deg, hsl(" + hue + " 70% 55%), hsl(" + ((hue + 60) % 360) + " 65% 45%))";
}
var queueEl = $("#queue");
function renderQueue() {
var html = "";
QUEUE.forEach(function (t, i) {
var active = i === state.queueIndex ? " active" : "";
html += '<li class="track' + active + '" data-i="' + i + '" tabindex="0" role="button" aria-label="Play ' + t.title + ' by ' + t.artist + '">'
+ '<span class="num">' + (i + 1) + '</span>'
+ '<span class="miniwave"><i></i><i></i><i></i></span>'
+ '<span class="mini" style="background:' + coverGradient(t.hue) + '"></span>'
+ '<span class="info"><span class="t-title">' + t.title + '</span><span class="t-artist">' + t.artist + '</span></span>'
+ '<span class="t-plays">' + t.plays + ' plays</span>'
+ '<span class="t-dur">' + fmt(t.dur) + '</span>'
+ '</li>';
});
queueEl.innerHTML = html;
}
function loadTrack(i, autoplay) {
state.queueIndex = clamp(i, 0, QUEUE.length - 1);
var t = QUEUE[state.queueIndex];
state.duration = t.dur;
state.position = 0;
$(".now-track").textContent = t.title;
$(".now-artist").textContent = t.artist + " · Midnight Reservoir";
$("#plays").textContent = t.plays;
renderQueue();
renderProgress();
paintCovers();
if (autoplay && !state.playing) setPlaying(true);
}
function nextTrack(autoplay) {
loadTrack((state.queueIndex + 1) % QUEUE.length, autoplay);
}
queueEl.addEventListener("click", function (e) {
var li = e.target.closest(".track");
if (!li) return;
loadTrack(parseInt(li.getAttribute("data-i"), 10), true);
toast("Playing: " + QUEUE[state.queueIndex].title);
});
queueEl.addEventListener("keydown", function (e) {
if (e.key !== "Enter" && e.key !== " ") return;
var li = e.target.closest(".track");
if (!li) return;
e.preventDefault();
loadTrack(parseInt(li.getAttribute("data-i"), 10), true);
});
/* recolor hero art + now cover to match active track + accent */
function paintCovers() {
var t = QUEUE[state.queueIndex];
$("#heroArt").style.background =
"radial-gradient(120% 120% at 20% 15%, " + state.accent + ", transparent 55%),"
+ "radial-gradient(120% 120% at 85% 90%, hsl(" + t.hue + " 65% 45%), transparent 60%),"
+ coverGradient(t.hue);
$(".now .cover").style.background = coverGradient(t.hue);
}
/* ---------- Init ---------- */
function init() {
root.style.setProperty("--eq-bands", state.bands);
applySpeed();
applyAccent();
rebuildAll();
renderQueue();
loadTrack(0, false);
setPlaying(false); // start paused, bars flat
renderProgress();
}
init();
})();<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Animated Equalizer Bars — Neon Tides</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="app">
<header class="topbar">
<div class="brand">
<span class="brand-mark" aria-hidden="true">
<i></i><i></i><i></i><i></i>
</span>
<div class="brand-txt">
<strong>Pulse</strong>
<small>Audio Visualizer Lab</small>
</div>
</div>
<div class="now">
<div class="cover" aria-hidden="true"></div>
<div class="now-meta">
<span class="now-track">Paper Lanterns</span>
<span class="now-artist">Neon Tides · Midnight Reservoir</span>
</div>
<span class="now-time" id="now-time">0:00</span>
</div>
</header>
<section class="hero">
<div class="hero-art" id="heroArt" aria-hidden="true"></div>
<div class="hero-body">
<span class="kicker">Now Playing</span>
<h1>Animated Equalizer Bars</h1>
<p>Four visualizer styles bouncing in sync with a simulated stereo signal. Hit play and the bars come alive; pause and they settle flat. Tune the band count, tempo, and accent color in real time.</p>
<div class="player">
<button class="play" id="playBtn" type="button" aria-pressed="false" aria-label="Play visualizer">
<span class="ico ico-play" aria-hidden="true"></span>
<span class="ico ico-pause" aria-hidden="true"></span>
</button>
<div class="scrub">
<div class="scrub-track"
id="scrub"
role="slider"
tabindex="0"
aria-label="Seek position"
aria-valuemin="0"
aria-valuemax="100"
aria-valuenow="0">
<div class="scrub-fill" id="scrubFill"></div>
<div class="scrub-knob" id="scrubKnob"></div>
</div>
<div class="scrub-times">
<span id="elapsed">0:00</span>
<span id="total">3:42</span>
</div>
</div>
<button class="like" id="likeBtn" type="button" aria-pressed="false" aria-label="Like this track">
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 21s-7.5-4.9-10-9.2C.2 8.6 1.9 5 5.4 5c2 0 3.3 1.1 4.1 2.3l.5.8.5-.8C11.3 6.1 12.6 5 14.6 5 18.1 5 19.8 8.6 22 11.8 19.5 16.1 12 21 12 21z"/></svg>
</button>
</div>
<div class="ticker">
<span class="dot live" id="liveDot"></span>
<span id="statusTxt">Paused</span>
<span class="sep">·</span>
<span id="plays">128,402</span> plays
</div>
</div>
</section>
<section class="controls" aria-label="Visualizer controls">
<div class="ctl">
<label for="bands">Bands <b id="bandsVal">24</b></label>
<input type="range" id="bands" min="6" max="48" step="1" value="24" />
</div>
<div class="ctl">
<label for="speed">Tempo <b id="speedVal">1.0×</b></label>
<input type="range" id="speed" min="40" max="220" step="5" value="100" />
</div>
<div class="ctl swatches">
<label>Accent</label>
<div class="swatch-row" id="swatches" role="radiogroup" aria-label="Accent color">
<button class="sw" data-c="#1db954" style="--sw:#1db954" role="radio" aria-checked="true" aria-label="Green" type="button"></button>
<button class="sw" data-c="#8b5cf6" style="--sw:#8b5cf6" role="radio" aria-checked="false" aria-label="Violet" type="button"></button>
<button class="sw" data-c="#ff3d71" style="--sw:#ff3d71" role="radio" aria-checked="false" aria-label="Rose" type="button"></button>
<button class="sw" data-c="#22d3ee" style="--sw:#22d3ee" role="radio" aria-checked="false" aria-label="Cyan" type="button"></button>
<button class="sw" data-c="#fbbf24" style="--sw:#fbbf24" role="radio" aria-checked="false" aria-label="Amber" type="button"></button>
</div>
</div>
</section>
<section class="grid" aria-label="Equalizer styles">
<article class="viz" data-style="bars">
<div class="viz-head">
<h2>Classic Bars</h2>
<span class="tag">linear</span>
</div>
<div class="stage stage-bars" id="vizBars" aria-hidden="true"></div>
</article>
<article class="viz" data-style="dots">
<div class="viz-head">
<h2>Dot Matrix</h2>
<span class="tag">stacked</span>
</div>
<div class="stage stage-dots" id="vizDots" aria-hidden="true"></div>
</article>
<article class="viz" data-style="mirror">
<div class="viz-head">
<h2>Mirrored</h2>
<span class="tag">center-out</span>
</div>
<div class="stage stage-mirror" id="vizMirror" aria-hidden="true"></div>
</article>
<article class="viz" data-style="radial">
<div class="viz-head">
<h2>Radial</h2>
<span class="tag">circular</span>
</div>
<div class="stage stage-radial">
<div class="radial-hub" id="vizRadial" aria-hidden="true">
<span class="radial-core"></span>
</div>
</div>
</article>
</section>
<section class="queue" aria-label="Up next">
<div class="queue-head">
<h2>Up Next</h2>
<span class="queue-sub">Midnight Reservoir</span>
</div>
<ul class="tracks" id="queue"></ul>
</section>
</div>
<div class="toast" id="toast" role="status" aria-live="polite"></div>
<script src="script.js"></script>
</body>
</html>Animated Equalizer Bars
A compact audio-visualizer playground themed around the fictional album Midnight Reservoir by Neon Tides. It renders four distinct equalizer treatments side by side — Classic Bars, a stacked Dot Matrix, a Mirrored center-out spectrum, and a Radial burst of rays around a glowing core — all driven by staggered CSS keyframes so they feel like they are reacting to a real audio stream. Everything is CSS-drawn: no images, no audio files, no libraries.
The morphing play/pause button (aria-pressed) toggles the whole stage between an animated and a flattened resting state. A draggable, keyboard-operable scrubber (role="slider") advances a simulated playback clock with live 0:00-style timestamps, and reaching the end auto-advances the queue. The control row lets you set the band count (6–48 bars), the tempo (which maps to animation-duration), and the accent color, which recolors every bar plus the CSS cover art via a single custom property. A like toggle, a play-count ticker, and a clickable up-next list round out the now-playing feel, with a small toast() helper confirming each action.
Built dark-first on the standard token palette, responsive down to ~360px, and respectful of prefers-reduced-motion. Drop the three snippet files into any page — no build step required.
Illustrative UI only — fictional artists, albums, tracks, and data. No real audio playback.