03Waveform scope
Reads the time-domain waveform instead of frequencies and writes it straight into the points of an SVG polyline. It is one line without a canvas, so color, width and glow all stay in CSS.
Best forLive waveform on a recording screen, input display in a voice-memo app
polylinegetByteTimeDomainDatastroke-dasharray

<svg width="0" height="0" style="position:absolute" aria-hidden="true">
<defs>
<symbol id="ico-waveform" viewBox="0 0 256 256" fill="currentColor"><path d="M208 96v64H48V96Z" opacity=".2"/><path d="M56 96v64a8 8 0 0 1-16 0V96a8 8 0 0 1 16 0m32-72a8 8 0 0 0-8 8v192a8 8 0 0 0 16 0V32a8 8 0 0 0-8-8m40 32a8 8 0 0 0-8 8v128a8 8 0 0 0 16 0V64a8 8 0 0 0-8-8m40 32a8 8 0 0 0-8 8v64a8 8 0 0 0 16 0V96a8 8 0 0 0-8-8m40-16a8 8 0 0 0-8 8v96a8 8 0 0 0 16 0V72a8 8 0 0 0-8-8"/></symbol>
<symbol id="ico-play" viewBox="0 0 256 256" fill="currentColor"><path d="M228.23 134.69L84.15 222.81A8 8 0 0 1 72 216.12V39.88a8 8 0 0 1 12.15-6.69l144.08 88.12a7.82 7.82 0 0 1 0 13.38" opacity=".2"/><path d="M232.4 114.49L88.32 26.35a16 16 0 0 0-16.2-.3A15.86 15.86 0 0 0 64 39.87v176.26A15.94 15.94 0 0 0 80 232a16.07 16.07 0 0 0 8.36-2.35l144.04-88.14a15.88 15.88 0 0 0 0-27.02M80 215.94V40l143.83 88Z"/></symbol>
<symbol id="ico-pause" viewBox="0 0 256 256" fill="currentColor"><path d="M208 48v160a8 8 0 0 1-8 8h-40a8 8 0 0 1-8-8V48a8 8 0 0 1 8-8h40a8 8 0 0 1 8 8M96 40H56a8 8 0 0 0-8 8v160a8 8 0 0 0 8 8h40a8 8 0 0 0 8-8V48a8 8 0 0 0-8-8" opacity=".2"/><path d="M200 32h-40a16 16 0 0 0-16 16v160a16 16 0 0 0 16 16h40a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16m0 176h-40V48h40zM96 32H56a16 16 0 0 0-16 16v160a16 16 0 0 0 16 16h40a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16m0 176H56V48h40z"/></symbol>
</defs>
</svg>
<main class="stage">
<div class="ws is-demo" id="ws">
<p class="ws__hint"><svg class="ws__ico" aria-hidden="true"><use href="#ico-waveform"/></svg><span>Press play and it moves with real sound</span></p>
<div class="ws__scope">
<svg class="ws__svg" viewBox="0 0 360 96" preserveAspectRatio="none" aria-hidden="true">
<!-- 바닥 파형: 미리 계산해 둔 정적 시퀀스. 실제 재생을 시작하면 JS 가 points 를 진짜 파형으로 매 프레임 바꾼다. -->
<polyline class="ws__base" id="baseLine" points=""/>
<!-- 흐르는 하이라이트: 같은 파형 위를 짧은 대시가 지나간다 — 미리보기 루프의 몸통. -->
<polyline class="ws__flow" id="flowLine" points=""/>
</svg>
</div>
<div class="ws__foot">
<button class="ws__play" id="play" type="button" aria-pressed="false">
<svg class="ws__ico ws__ico--play" aria-hidden="true"><use href="#ico-play"/></svg>
<svg class="ws__ico ws__ico--pause" aria-hidden="true"><use href="#ico-pause"/></svg>
<span id="playLabel">Play</span>
</button>
<p class="ws__level">
<span class="ws__levelLabel">Wave now</span>
<b class="ws__levelBox">
<span class="ws__levelText" id="levelText" aria-live="polite">Calm</span>
<span class="ws__loop" aria-hidden="true"><i>Calm</i><i>Swaying</i><i>Big wave</i></span>
</b>
</p>
</div>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// 파형 오실로스코프 — 캔버스 없이 SVG polyline 하나. 색·두께·그림자는 전부 CSS 가 가진다.
// 미리보기(.is-demo)는 정적 파형 위를 stroke-dasharray 대시가 흐르는 루프 — points 는 CSS 로 움직일 수 없어서
// "같은 파형을 따라 흐르는 하이라이트"로 2초 루프를 만든다. 재생을 누르면 JS 가 points 를 진짜 파형으로 바꾼다.
$duration: $dur-quick;
$easing: $ease-out;
$color: $subject-mint;
@include stage($stage-ink);
.ws { display: flex; flex-direction: column; align-items: center; gap: $sp-3; width: 100%; max-width: 400px; }
.ws__hint {
display: flex; align-items: center; gap: $sp-1; margin: 0;
font-weight: 700; font-size: clamp(11px, 3vw, 12px); color: $subject-cream;
}
.ws__ico { width: 16px; height: 16px; color: $color; }
.ws__scope {
box-sizing: border-box; width: 100%; padding: $sp-2 $sp-2 0;
border-radius: $r-card; background: #211d26;
border: 1px solid rgba($subject-cream, .12);
}
.ws__svg { display: block; width: 100%; height: 104px; }
.ws__base {
fill: none; stroke: rgba($subject-cream, .28); stroke-width: 2;
stroke-linejoin: round; stroke-linecap: round;
}
.ws__flow {
fill: none; stroke: $color; stroke-width: 3;
stroke-linejoin: round; stroke-linecap: round;
filter: drop-shadow(0 0 6px rgba(76, 212, 166, .45));
}
.ws__foot { display: flex; align-items: center; justify-content: center; gap: $sp-4; width: 100%; }
.ws__play {
display: inline-flex; align-items: center; gap: $sp-1;
border: 0; border-radius: $r-pill; padding: $sp-2 $sp-4;
background: $stage-yellow; color: $subject-ink; cursor: pointer;
font-family: inherit; font-weight: 800; font-size: clamp(11px, 3vw, 12px); line-height: 1;
}
.ws__ico--pause { display: none; }
.ws__play[aria-pressed="true"] .ws__ico--play { display: none; }
.ws__play[aria-pressed="true"] .ws__ico--pause { display: inline-block; }
.ws__play .ws__ico { color: $subject-ink; }
.ws__level { margin: 0; display: flex; align-items: center; gap: $sp-2; }
.ws__levelLabel { font-weight: 700; font-size: clamp(10px, 2.6vw, 11px); color: rgba($subject-cream, .82); }
.ws__levelBox {
position: relative; display: grid; place-items: center;
min-width: 48px; height: 20px; border-radius: $r-xs; padding: 0 $sp-1;
background: rgba($subject-cream, .16); color: $subject-cream;
font-weight: 800; font-size: clamp(11px, 3vw, 12px); line-height: 1;
}
.ws__loop { position: absolute; inset: 0; display: grid; place-items: center; visibility: hidden; }
.ws__loop i { grid-area: 1 / 1; font-style: normal; visibility: hidden; }
// ── 격자 미리보기 루프 ─────────────────────────────────────────────
// 56px 대시가 파형 위를 왼쪽에서 오른쪽으로 흐른다. dashoffset 의 총 이동량 = 대시 주기(56+124=180)라
// 루프가 정확히 닫힌다. 하이라이트가 한 바퀴 도는 동안 상태 글자도 세 단계로 바뀐다(steps 컷).
.ws.is-demo .ws__flow {
stroke-dasharray: 56 124;
animation-name: wsFlow; animation-duration: $dur-loop; animation-timing-function: linear;
animation-iteration-count: infinite;
}
@keyframes wsFlow {
from { stroke-dashoffset: 180; }
to { stroke-dashoffset: 0; }
}
.ws.is-demo .ws__levelText { color: transparent; }
.ws.is-demo .ws__loop { visibility: visible; }
.ws.is-demo .ws__loop i {
animation-name: wsStateName; animation-duration: $dur-loop; animation-timing-function: steps(1, end);
animation-iteration-count: infinite;
}
.ws.is-demo .ws__loop i:nth-child(1) { animation-delay: 0ms; }
.ws.is-demo .ws__loop i:nth-child(2) { animation-delay: 666ms; }
.ws.is-demo .ws__loop i:nth-child(3) { animation-delay: 1332ms; }
@keyframes wsStateName {
0%, 33% { visibility: visible; }
34%, 100% { visibility: hidden; }
}
@media (max-width: 340px) {
.ws { gap: $sp-2; }
.ws__scope { padding: $sp-1 $sp-1 0; }
.ws__svg { height: 76px; }
.ws__foot { gap: $sp-2; }
.ws__play { padding: $sp-1 $sp-3; }
}
// reduce 에서는 흐르는 대시를 멈춘다 — 정적 파형이 그대로 남아 화면이 비지 않는다
@media (prefers-reduced-motion: reduce) {
.ws.is-demo .ws__flow {
animation: none !important;
stroke-dasharray: none;
}
.ws.is-demo .ws__loop i { animation: none !important; }
.ws.is-demo .ws__levelText { color: $subject-cream !important; }
.ws.is-demo .ws__loop { visibility: hidden !important; }
.ws__flow { transition: none !important; }
}html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #17141a;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
padding: clamp(8px, 4vw, 24px);
}
.ws {
display: flex;
flex-direction: column;
align-items: center;
gap: 12px;
width: 100%;
max-width: 400px;
}
.ws__hint {
display: flex;
align-items: center;
gap: 4px;
margin: 0;
font-weight: 700;
font-size: clamp(11px, 3vw, 12px);
color: #fff7e6;
}
.ws__ico {
width: 16px;
height: 16px;
color: #4cd4a6;
}
.ws__scope {
box-sizing: border-box;
width: 100%;
padding: 8px 8px 0;
border-radius: 16px;
background: #211d26;
border: 1px solid rgba(255, 247, 230, 0.12);
}
.ws__svg {
display: block;
width: 100%;
height: 104px;
}
.ws__base {
fill: none;
stroke: rgba(255, 247, 230, 0.28);
stroke-width: 2;
stroke-linejoin: round;
stroke-linecap: round;
}
.ws__flow {
fill: none;
stroke: #4cd4a6;
stroke-width: 3;
stroke-linejoin: round;
stroke-linecap: round;
filter: drop-shadow(0 0 6px rgba(76, 212, 166, 0.45));
}
.ws__foot {
display: flex;
align-items: center;
justify-content: center;
gap: 16px;
width: 100%;
}
.ws__play {
display: inline-flex;
align-items: center;
gap: 4px;
border: 0;
border-radius: 999px;
padding: 8px 16px;
background: #ffd23f;
color: #17141a;
cursor: pointer;
font-family: inherit;
font-weight: 800;
font-size: clamp(11px, 3vw, 12px);
line-height: 1;
}
.ws__ico--pause {
display: none;
}
.ws__play[aria-pressed=true] .ws__ico--play {
display: none;
}
.ws__play[aria-pressed=true] .ws__ico--pause {
display: inline-block;
}
.ws__play .ws__ico {
color: #17141a;
}
.ws__level {
margin: 0;
display: flex;
align-items: center;
gap: 8px;
}
.ws__levelLabel {
font-weight: 700;
font-size: clamp(10px, 2.6vw, 11px);
color: rgba(255, 247, 230, 0.82);
}
.ws__levelBox {
position: relative;
display: grid;
place-items: center;
min-width: 48px;
height: 20px;
border-radius: 4px;
padding: 0 4px;
background: rgba(255, 247, 230, 0.16);
color: #fff7e6;
font-weight: 800;
font-size: clamp(11px, 3vw, 12px);
line-height: 1;
}
.ws__loop {
position: absolute;
inset: 0;
display: grid;
place-items: center;
visibility: hidden;
}
.ws__loop i {
grid-area: 1/1;
font-style: normal;
visibility: hidden;
}
.ws.is-demo .ws__flow {
stroke-dasharray: 56 124;
animation-name: wsFlow;
animation-duration: 2s;
animation-timing-function: linear;
animation-iteration-count: infinite;
}
@keyframes wsFlow {
from {
stroke-dashoffset: 180;
}
to {
stroke-dashoffset: 0;
}
}
.ws.is-demo .ws__levelText {
color: transparent;
}
.ws.is-demo .ws__loop {
visibility: visible;
}
.ws.is-demo .ws__loop i {
animation-name: wsStateName;
animation-duration: 2s;
animation-timing-function: steps(1, end);
animation-iteration-count: infinite;
}
.ws.is-demo .ws__loop i:nth-child(1) {
animation-delay: 0ms;
}
.ws.is-demo .ws__loop i:nth-child(2) {
animation-delay: 666ms;
}
.ws.is-demo .ws__loop i:nth-child(3) {
animation-delay: 1332ms;
}
@keyframes wsStateName {
0%, 33% {
visibility: visible;
}
34%, 100% {
visibility: hidden;
}
}
@media (max-width: 340px) {
.ws {
gap: 8px;
}
.ws__scope {
padding: 4px 4px 0;
}
.ws__svg {
height: 76px;
}
.ws__foot {
gap: 8px;
}
.ws__play {
padding: 4px 12px;
}
}
@media (prefers-reduced-motion: reduce) {
.ws.is-demo .ws__flow {
animation: none !important;
stroke-dasharray: none;
}
.ws.is-demo .ws__loop i {
animation: none !important;
}
.ws.is-demo .ws__levelText {
color: #fff7e6 !important;
}
.ws.is-demo .ws__loop {
visibility: hidden !important;
}
.ws__flow {
transition: none !important;
}
}var root = document.getElementById('ws');
var baseLine = document.getElementById('baseLine');
var flowLine = document.getElementById('flowLine');
var playBtn = document.getElementById('play');
var playLabel = document.getElementById('playLabel');
var levelText = document.getElementById('levelText');
var W = 360, H = 96, MID = H / 2, N = 60;
// 바닥 파형 — 사인 두 개를 더한 정적 시퀀스. 난수가 아니라 식이라 같은 그림이 항상 재현된다.
var pts = [];
for (var i = 0; i < N; i++) {
var x = (i / (N - 1)) * W;
var y = MID - Math.sin(i / N * Math.PI * 6) * 18 - Math.sin(i / N * Math.PI * 2) * 8;
pts.push(x.toFixed(1) + ',' + y.toFixed(1));
}
baseLine.setAttribute('points', pts.join(' '));
flowLine.setAttribute('points', pts.join(' '));
var ctx = null, analyser = null, wave = null, timer = 0, playing = false;
var STATE_NAMES = ['Calm', 'Swaying', 'Big wave'];
function buildAudio() {
ctx = new (window.AudioContext || window.webkitAudioContext)();
analyser = ctx.createAnalyser();
analyser.fftSize = 2048;
analyser.smoothingTimeConstant = 0;
wave = new Uint8Array(analyser.fftSize);
var out = ctx.createGain();
out.gain.value = 0.06;
out.connect(analyser);
analyser.connect(ctx.destination);
// 외부 음원 파일 없이 코드 진행을 직접 합성한다 — 네 박자마다 화음이 바뀐다.
[196, 246.94, 293.66, 392].forEach(function (hz, n) {
var osc = ctx.createOscillator();
var amp = ctx.createGain();
osc.type = n === 3 ? 'triangle' : 'sawtooth';
osc.frequency.value = hz;
amp.gain.value = 0;
for (var beat = 0; beat < 64; beat++) {
var at = ctx.currentTime + beat * 0.5;
amp.gain.setValueAtTime(beat % 4 === n % 4 ? 0.9 : 0.25, at);
amp.gain.exponentialRampToValueAtTime(0.02, at + 0.45);
}
osc.connect(amp); amp.connect(out); osc.start();
});
}
function draw() {
// 시간 도메인 — 주파수가 아니라 "지금 이 순간의 진폭" 을 그대로 읽는다.
analyser.getByteTimeDomainData(wave);
var step = Math.floor(wave.length / N);
var line = [];
var peak = 0;
for (var i = 0; i < N; i++) {
var v = (wave[i * step] - 128) / 128;
peak = Math.max(peak, Math.abs(v));
line.push(((i / (N - 1)) * W).toFixed(1) + ',' + (MID - v * (H / 2 - 6)).toFixed(1));
}
var p = line.join(' ');
baseLine.setAttribute('points', p);
flowLine.setAttribute('points', p);
var st = peak < 0.18 ? 0 : peak < 0.5 ? 1 : 2;
if (levelText.textContent !== STATE_NAMES[st]) { levelText.textContent = STATE_NAMES[st]; }
timer = requestAnimationFrame(draw);
}
playBtn.addEventListener('click', function () {
root.classList.remove('is-demo');
if (!ctx) { buildAudio(); }
playing = !playing;
playBtn.setAttribute('aria-pressed', playing ? 'true' : 'false');
playLabel.textContent = playing ? 'Stop' : 'Play';
// 자동재생 정책: AudioContext 는 사용자 제스처 뒤 resume() 해야 소리가 난다.
if (playing) { ctx.resume(); timer = requestAnimationFrame(draw); }
else { ctx.suspend(); cancelAnimationFrame(timer); }
});// WaveformScope — vanilla 판(run/291/demo/03-audio-viz-waveform-scope/index.html) 의 React 포트.
// 시간 도메인 파형을 SVG polyline 의 points 에 그대로 쓴다. 캔버스 없이 선 하나.
import { useEffect, useRef, useState } from "react";
import type { CSSProperties } from "react";
import styles from "./WaveformScope.module.scss";
export type WaveformScopeProps = {
/** 격자 미리보기용 2초 자동 루프. 재생을 누르면 꺼진다 */
demo?: boolean;
duration?: number;
easing?: string;
color?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string; "--color"?: string };
/** ambient 타입에 useRef<T> 의 null 합집합이 없어 로컬로 좁힌다 */
type Box<T> = { current: T };
const W = 360;
const H = 96;
const MID = H / 2;
const N = 60;
const STATE_NAMES = ["고요", "출렁", "큰물결"];
/** 바닥 파형 — 사인 두 개를 더한 정적 시퀀스. 난수가 아니라 식이라 같은 그림이 항상 재현된다. */
const BASE_PTS: string[] = [];
for (let i = 0; i < N; i++) {
const x = (i / (N - 1)) * W;
const y = MID - Math.sin((i / N) * Math.PI * 6) * 18 - Math.sin((i / N) * Math.PI * 2) * 8;
BASE_PTS.push(x.toFixed(1) + "," + y.toFixed(1));
}
const BASE_LINE = BASE_PTS.join(" ");
export default function WaveformScope({
demo = true,
duration = 220,
easing = "ease-out",
color = "#4cd4a6",
}: WaveformScopeProps) {
const [live, setLive] = useState(demo);
const [playing, setPlaying] = useState(false);
const [line, setLine] = useState(BASE_LINE);
const [state, setState] = useState(STATE_NAMES[0]);
const ctxBox = useRef(null) as Box<AudioContext | null>;
const nodeBox = useRef(null) as Box<AnalyserNode | null>;
const frameBox = useRef(0) as Box<number>;
const vars: Vars = { "--duration": `${duration}ms`, "--easing": easing, "--color": color };
useEffect(() => {
return () => {
cancelAnimationFrame(frameBox.current);
if (ctxBox.current) {
ctxBox.current.close();
}
};
}, []);
function buildAudio() {
const ctx = new AudioContext();
const analyser = ctx.createAnalyser();
analyser.fftSize = 2048;
analyser.smoothingTimeConstant = 0;
const out = ctx.createGain();
out.gain.value = 0.06;
out.connect(analyser);
analyser.connect(ctx.destination);
// 외부 음원 파일 없이 코드 진행을 직접 합성한다 — 네 박자마다 화음이 바뀐다.
[196, 246.94, 293.66, 392].forEach((hz, n) => {
const osc = ctx.createOscillator();
const amp = ctx.createGain();
osc.type = n === 3 ? "triangle" : "sawtooth";
osc.frequency.value = hz;
amp.gain.value = 0;
for (let beat = 0; beat < 64; beat++) {
const at = ctx.currentTime + beat * 0.5;
amp.gain.setValueAtTime(beat % 4 === n % 4 ? 0.9 : 0.25, at);
amp.gain.exponentialRampToValueAtTime(0.02, at + 0.45);
}
osc.connect(amp);
amp.connect(out);
osc.start();
});
ctxBox.current = ctx;
nodeBox.current = analyser;
}
function draw() {
const analyser = nodeBox.current;
if (!analyser) {
return;
}
// 시간 도메인 — 주파수가 아니라 "지금 이 순간의 진폭" 을 그대로 읽는다.
const wave = new Uint8Array(analyser.fftSize);
analyser.getByteTimeDomainData(wave);
const step = Math.floor(wave.length / N);
const next: string[] = [];
let peak = 0;
for (let i = 0; i < N; i++) {
const v = (wave[i * step] - 128) / 128;
peak = Math.max(peak, Math.abs(v));
next.push(((i / (N - 1)) * W).toFixed(1) + "," + (MID - v * (H / 2 - 6)).toFixed(1));
}
setLine(next.join(" "));
setState(STATE_NAMES[peak < 0.18 ? 0 : peak < 0.5 ? 1 : 2]);
frameBox.current = requestAnimationFrame(draw);
}
function toggle() {
setLive(false);
if (!ctxBox.current) {
buildAudio();
}
const ctx = ctxBox.current;
if (!ctx) {
return;
}
const next = !playing;
setPlaying(next);
// 자동재생 정책: AudioContext 는 사용자 제스처 뒤 resume() 해야 소리가 난다.
if (next) {
ctx.resume();
frameBox.current = requestAnimationFrame(draw);
} else {
ctx.suspend();
cancelAnimationFrame(frameBox.current);
}
}
const cls = [styles.root, live ? styles.isDemo : ""].filter(Boolean).join(" ");
return (
<main className={styles.stage} style={vars}>
<svg width="0" height="0" style={{ position: "absolute" }} aria-hidden="true">
<defs>
<symbol id="ico-waveform" viewBox="0 0 256 256" fill="currentColor">
<path d="M208 96v64H48V96Z" opacity=".2" />
<path d="M56 96v64a8 8 0 0 1-16 0V96a8 8 0 0 1 16 0m32-72a8 8 0 0 0-8 8v192a8 8 0 0 0 16 0V32a8 8 0 0 0-8-8m40 32a8 8 0 0 0-8 8v128a8 8 0 0 0 16 0V64a8 8 0 0 0-8-8m40 32a8 8 0 0 0-8 8v64a8 8 0 0 0 16 0V96a8 8 0 0 0-8-8m40-16a8 8 0 0 0-8 8v96a8 8 0 0 0 16 0V72a8 8 0 0 0-8-8" />
</symbol>
<symbol id="ico-play" viewBox="0 0 256 256" fill="currentColor">
<path d="M228.23 134.69L84.15 222.81A8 8 0 0 1 72 216.12V39.88a8 8 0 0 1 12.15-6.69l144.08 88.12a7.82 7.82 0 0 1 0 13.38" opacity=".2" />
<path d="M232.4 114.49L88.32 26.35a16 16 0 0 0-16.2-.3A15.86 15.86 0 0 0 64 39.87v176.26A15.94 15.94 0 0 0 80 232a16.07 16.07 0 0 0 8.36-2.35l144.04-88.14a15.88 15.88 0 0 0 0-27.02M80 215.94V40l143.83 88Z" />
</symbol>
<symbol id="ico-pause" viewBox="0 0 256 256" fill="currentColor">
<path d="M208 48v160a8 8 0 0 1-8 8h-40a8 8 0 0 1-8-8V48a8 8 0 0 1 8-8h40a8 8 0 0 1 8 8M96 40H56a8 8 0 0 0-8 8v160a8 8 0 0 0 8 8h40a8 8 0 0 0 8-8V48a8 8 0 0 0-8-8" opacity=".2" />
<path d="M200 32h-40a16 16 0 0 0-16 16v160a16 16 0 0 0 16 16h40a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16m0 176h-40V48h40zM96 32H56a16 16 0 0 0-16 16v160a16 16 0 0 0 16 16h40a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16m0 176H56V48h40z" />
</symbol>
</defs>
</svg>
<div className={cls}>
<p className={styles.hint}>
<svg className={styles.ico} aria-hidden="true">
<use href="#ico-waveform" />
</svg>
<span>재생을 누르면 실제 소리로 움직입니다</span>
</p>
<div className={styles.scope}>
<svg className={styles.svg} viewBox="0 0 360 96" preserveAspectRatio="none" aria-hidden="true">
<polyline className={styles.base} points={line} />
<polyline className={styles.flow} points={line} />
</svg>
</div>
<div className={styles.foot}>
<button className={styles.play} type="button" aria-pressed={playing} onClick={toggle}>
<svg className={[styles.ico, playing ? styles.icoHidden : ""].join(" ")} aria-hidden="true">
<use href="#ico-play" />
</svg>
<svg className={[styles.ico, playing ? "" : styles.icoHidden].join(" ")} aria-hidden="true">
<use href="#ico-pause" />
</svg>
<span>{playing ? "정지" : "재생"}</span>
</button>
<p className={styles.level}>
<span className={styles.levelLabel}>지금 파형</span>
<b className={styles.levelBox}>
<span className={styles.levelText} aria-live="polite">
{state}
</span>
<span className={styles.loop} aria-hidden="true">
<i>고요</i>
<i>출렁</i>
<i>큰물결</i>
</span>
</b>
</p>
</div>
</div>
</main>
);
}03 Waveform scope — Measured area 2.893% · moving frames 23/23Original by GODRICH · SCSS and React ship in the zip · Audio Visualizer JavaScript: 9 Parts, No Library
The post this demo lives in
Audio Visualizer JavaScript: 9 Parts, No LibraryAn audio visualizer JavaScript project needs one thing from the browser: Web Audio's AnalyserNode, which turns live soun See all demos in this post


