(rate)
| 435 | } |
| 436 | |
| 437 | function applySpeed(rate) { |
| 438 | const clamped = Math.max(0.25, Math.min(2, rate)); |
| 439 | setPlaybackSpeed(clamped); |
| 440 | if (speedEl) { |
| 441 | speedEl.value = String(clamped); |
| 442 | // range is 0-2; 1.0 sits at exactly 50% |
| 443 | const pct = (clamped / 2) * 100; |
| 444 | speedEl.style.setProperty("--speed-pct", `${pct.toFixed(1)}%`); |
| 445 | } |
| 446 | if (speedLabelEl) speedLabelEl.textContent = `${clamped % 1 === 0 ? clamped.toFixed(1) : clamped}x`; |
| 447 | audioEngine?.setPlaybackRate?.(clamped); |
| 448 | if (multitrack) { |
| 449 | for (const a of (multitrack.audios ?? [])) { |
| 450 | try { a.playbackRate = clamped; } catch { /* noop */ } |
| 451 | } |
| 452 | } |
| 453 | } |
| 454 | |
| 455 | export function resetSpeed() { |
| 456 | applySpeed(1.0); |
no test coverage detected