Files
midi-sequencer/node-server/public/index.html
mikael-lovqvists-claude-agent 9b45905d80 Add multi-track playback with mute/solo support
Replaces the single-root-pattern sequencer with a Track[] array that
allows multiple patterns to loop independently. Adds ADD_TRACK (0x0A),
REMOVE_TRACK (0x0B), PLAY_TRACKS (0x0C), and SET_TRACK_MUTE (0x0D)
protocol records. The C backend gains per-track pending_subs and a
tracks_mutex. The Node server gains track-state APIs (/api/tracks/:id/
active, mute, solo) and the frontend shows per-pattern track/mute/solo
buttons in the sidebar list.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 04:16:06 +00:00

360 lines
9.6 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MIDI Sequencer</title>
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--bg: #1a1a2e;
--surface: #16213e;
--surface2: #0f3460;
--accent: #e94560;
--accent2: #533483;
--text: #eaeaea;
--text-dim: #888;
--step-off: #1e2a42;
--step-on: #e94560;
--step-pend: #7a2233;
--step-active: #f0a500;
--border: #2a3a5e;
--radius: 6px;
}
body {
background: var(--bg);
color: var(--text);
font-family: 'Courier New', monospace;
font-size: 14px;
min-height: 100vh;
display: flex;
flex-direction: column;
}
header {
background: var(--surface);
border-bottom: 1px solid var(--border);
padding: 12px 20px;
display: flex;
align-items: center;
gap: 16px;
}
header h1 { font-size: 18px; letter-spacing: 2px; color: var(--accent); }
.status-dot {
width: 8px; height: 8px; border-radius: 50%;
background: #444;
transition: background 0.3s;
}
.status-dot.connected { background: #2ecc71; }
.status-dot.playing { background: var(--accent); animation: pulse 0.5s infinite alternate; }
@keyframes pulse { from { opacity: 1; } to { opacity: 0.4; } }
main { flex: 1; display: flex; gap: 0; }
/* Sidebar */
.sidebar {
width: 240px;
background: var(--surface);
border-right: 1px solid var(--border);
display: flex;
flex-direction: column;
padding: 12px;
gap: 12px;
}
.sidebar h2 { font-size: 11px; letter-spacing: 2px; color: var(--text-dim); text-transform: uppercase; }
.pattern-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.pattern-item {
padding: 8px 10px;
border-radius: var(--radius);
cursor: pointer;
border: 1px solid transparent;
display: flex;
align-items: center;
gap: 8px;
}
.pattern-item:hover { background: var(--surface2); }
.pattern-item.selected { border-color: var(--accent); background: var(--surface2); }
.pattern-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pattern-item .steps { font-size: 11px; color: var(--text-dim); }
.track-btn {
width: 16px; height: 16px;
padding: 0;
font-size: 8px;
background: transparent;
border: none;
cursor: pointer;
color: var(--text-dim);
flex-shrink: 0;
line-height: 1;
}
.track-btn:hover { color: var(--text); }
.track-btn.on { color: #2ecc71; }
.track-ctl { display: flex; gap: 3px; margin-left: auto; }
.mute-btn, .solo-btn {
width: 18px; height: 18px;
padding: 0;
font-size: 10px;
font-weight: bold;
background: var(--surface2);
border: 1px solid var(--border);
border-radius: 3px;
cursor: pointer;
color: var(--text-dim);
flex-shrink: 0;
font-family: inherit;
}
.mute-btn:hover, .solo-btn:hover { border-color: var(--accent2); color: var(--text); }
.mute-btn.on { background: #7a3030; border-color: #c04040; color: #f08080; }
.solo-btn.on { background: #7a6000; border-color: #c0a000; color: #f0d060; }
.mute-btn.dim, .solo-btn.dim { opacity: 0.3; cursor: default; }
/* Transport */
.transport {
display: flex; gap: 8px; flex-wrap: wrap;
}
/* Content area */
.content {
flex: 1;
padding: 20px;
display: flex;
flex-direction: column;
gap: 16px;
overflow-y: auto;
}
.panel {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 16px;
}
.panel-header {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 14px;
}
.panel-header h2 { font-size: 12px; letter-spacing: 2px; color: var(--text-dim); text-transform: uppercase; }
/* Buttons */
button {
background: var(--surface2);
color: var(--text);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 6px 14px;
cursor: pointer;
font-family: inherit;
font-size: 13px;
transition: background 0.15s;
}
button:hover { background: var(--accent2); border-color: var(--accent2); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #c73452; }
button.danger { background: #7a1a2e; border-color: #9b2a3e; }
button.danger:hover { background: #9b2a3e; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
/* Inputs */
input, select {
background: var(--bg);
color: var(--text);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 5px 10px;
font-family: inherit;
font-size: 13px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
input[type="number"] { width: 80px; }
label { font-size: 12px; color: var(--text-dim); }
.field-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* Step grid */
.step-grid-scroll {
max-height: 400px;
overflow-y: auto;
overflow-x: auto;
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 4px;
background: var(--bg);
}
.step-grid {
display: flex;
flex-direction: column;
gap: 2px;
width: fit-content;
min-width: 100%;
}
.note-row {
display: flex;
align-items: center;
gap: 4px;
}
/* Percussion mode — wider labels */
.step-grid--perc .note-label {
width: 110px;
font-size: 10px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
/* Percussion family row tints */
.perc-bass { background: rgba(220, 60, 60, 0.06); }
.perc-snare { background: rgba(220, 140, 40, 0.06); }
.perc-tom { background: rgba(60, 180, 80, 0.06); }
.perc-hihat { background: rgba(220, 200, 40, 0.06); }
.perc-cymbal { background: rgba(60, 140, 220, 0.06); }
.perc-latin { background: rgba(160, 60, 220, 0.06); }
/* Percussion on-button colors per family */
.perc-bass .step-btn.on { background: #c43c3c; border-color: #d04d4d; }
.perc-snare .step-btn.on { background: #c48020; border-color: #d09030; }
.perc-tom .step-btn.on { background: #2a9040; border-color: #3aa050; }
.perc-hihat .step-btn.on { background: #b09a10; border-color: #c0aa20; }
.perc-cymbal .step-btn.on { background: #2866b0; border-color: #3876c0; }
.perc-latin .step-btn.on { background: #7030a0; border-color: #8040b0; }
/* Playhead indicator row */
.playhead-row { margin-bottom: 2px; }
.step-indicator {
width: 28px;
height: 4px;
border-radius: 2px;
background: var(--border);
flex-shrink: 0;
transition: background 0.04s;
}
.step-indicator.current { background: var(--step-active); }
.note-label {
width: 36px;
text-align: right;
font-size: 11px;
color: var(--text-dim);
flex-shrink: 0;
cursor: pointer;
transition: color 0.1s;
overflow: hidden;
}
.note-label:hover { color: var(--text); }
.note-label-input {
background: var(--bg);
color: var(--text);
border: 1px solid var(--accent);
border-radius: 3px;
padding: 1px 4px;
font-family: inherit;
font-size: 10px;
width: 100%;
box-sizing: border-box;
}
.row-play-btn {
width: 18px;
height: 18px;
padding: 0;
font-size: 8px;
background: transparent;
border: 1px solid var(--border);
border-radius: 3px;
cursor: pointer;
color: var(--text-dim);
flex-shrink: 0;
line-height: 1;
display: flex;
align-items: center;
justify-content: center;
}
.row-play-btn:hover { background: var(--surface2); color: var(--text); border-color: var(--accent2); }
.row-play-spacer { width: 18px; flex-shrink: 0; }
.step-btn {
width: 28px;
height: 28px;
border-radius: 3px;
background: var(--step-off);
border: 1px solid var(--border);
cursor: pointer;
padding: 0;
position: relative;
transition: background 0.05s;
flex-shrink: 0;
}
.step-btn.on { background: var(--step-on); border-color: var(--accent); }
.step-btn.pending { background: var(--step-pend); border-color: #7a2233; }
/* Velocity bar inside step button */
.step-btn .vel-bar {
position: absolute;
bottom: 0; left: 0; right: 0;
height: 3px;
background: rgba(255,255,255,0.4);
border-radius: 0 0 3px 3px;
}
.empty-state { color: var(--text-dim); text-align: center; padding: 40px; }
.sub-ref-list { display: flex; flex-direction: column; gap: 4px; }
.sub-ref-item {
display: flex; align-items: center; gap: 8px;
background: var(--surface2); border-radius: var(--radius); padding: 6px 10px;
font-size: 12px;
}
.sub-ref-item .label { flex: 1; }
</style>
</head>
<body>
<header>
<h1>MIDI SEQUENCER</h1>
<div class="status-dot" id="backend-dot" title="Backend connection"></div>
<div class="status-dot" id="play-dot" title="Playing"></div>
<span id="status-label" style="font-size:12px;color:var(--text-dim)">disconnected</span>
<div style="flex:1"></div>
<label>BPM</label>
<input type="number" id="bpm-input" value="120" min="1" max="300" step="0.1" style="width:70px">
<button id="set-tempo-btn">Set Tempo</button>
</header>
<main>
<aside class="sidebar">
<h2>Patterns</h2>
<div class="transport">
<button id="play-btn" class="primary">▶ Play</button>
<button id="stop-btn">■ Stop</button>
</div>
<div class="pattern-list" id="pattern-list"></div>
<div style="display:flex;gap:6px;">
<button id="new-pattern-btn" style="flex:1">+ Melodic</button>
<button id="new-perc-btn" style="flex:1">🥁 Drums</button>
</div>
</aside>
<div class="content" id="content">
<div class="empty-state">Select or create a pattern to get started.</div>
</div>
</main>
<script type="module" src="app.mjs"></script>
</body>
</html>