Repository navigation
Expand file tree
/
Copy pathmulticlip.html
More file actions
183 lines (168 loc) · 7.84 KB
/
Copy pathmulticlip.html
File metadata and controls
183 lines (168 loc) · 7.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dawcore — multiclip interactions</title>
<style>
body {
font-family: system-ui, sans-serif;
background: #0f0f1a;
color: #e0d4c8;
padding: 24px;
}
h1 {
font-size: 1.2rem;
margin-bottom: 16px;
}
daw-editor {
--daw-wave-color: #c49a6c;
--daw-playhead-color: #d08070;
--daw-background: #1a1a2e;
--daw-track-background: #16213e;
--daw-ruler-color: #c49a6c;
--daw-ruler-background: #0f0f1a;
--daw-selection-color: rgba(99, 199, 95, 0.3);
margin-bottom: 12px;
}
daw-transport {
display: flex;
gap: 8px;
margin-bottom: 12px;
}
#log {
margin-top: 12px;
font-family: monospace;
font-size: 0.75rem;
color: #888;
max-height: 160px;
overflow-y: auto;
}
</style>
</head>
<body>
<h1>dawcore — multiclip interactions</h1>
<script type="module">import '@dawcore/components';</script>
<daw-editor id="editor" samples-per-pixel="1024" wave-height="80" timescale file-drop clip-headers interactive-clips track-reordering>
<daw-keyboard-shortcuts playback splitting undo></daw-keyboard-shortcuts>
<!-- Kick: two clips with a gap -->
<daw-track name="Kick">
<daw-clip src="/media/audio/AlbertKader_Ubiquitous/01_Kick.opus"
peaks-src="/media/audio/AlbertKader_Ubiquitous/01_Kick.dat"
start="0" duration="8" offset="0"></daw-clip>
<daw-clip src="/media/audio/AlbertKader_Ubiquitous/01_Kick.opus"
peaks-src="/media/audio/AlbertKader_Ubiquitous/01_Kick.dat"
start="12" duration="8" offset="8"></daw-clip>
</daw-track>
<!-- HiHat: one clip starting mid-timeline -->
<daw-track name="HiHat">
<daw-clip src="/media/audio/AlbertKader_Ubiquitous/02_HiHat1.opus"
peaks-src="/media/audio/AlbertKader_Ubiquitous/02_HiHat1.dat"
start="4" duration="12" offset="4"></daw-clip>
</daw-track>
<!-- Claps: two clips -->
<daw-track name="Claps">
<daw-clip src="/media/audio/AlbertKader_Ubiquitous/04_Claps.opus"
peaks-src="/media/audio/AlbertKader_Ubiquitous/04_Claps.dat"
start="8" duration="4" offset="0"></daw-clip>
<daw-clip src="/media/audio/AlbertKader_Ubiquitous/04_Claps.opus"
peaks-src="/media/audio/AlbertKader_Ubiquitous/04_Claps.dat"
start="16" duration="4" offset="4"></daw-clip>
</daw-track>
<!-- Shakers: two clips with gap -->
<daw-track name="Shakers">
<daw-clip src="/media/audio/AlbertKader_Ubiquitous/07_Shakers.opus"
peaks-src="/media/audio/AlbertKader_Ubiquitous/07_Shakers.dat"
start="0" duration="6" offset="0"></daw-clip>
<daw-clip src="/media/audio/AlbertKader_Ubiquitous/07_Shakers.opus"
peaks-src="/media/audio/AlbertKader_Ubiquitous/07_Shakers.dat"
start="10" duration="6" offset="6"></daw-clip>
</daw-track>
<!-- Bass: one long clip spanning the full timeline -->
<daw-track name="Bass">
<daw-clip src="/media/audio/AlbertKader_Ubiquitous/08_Bass.opus"
peaks-src="/media/audio/AlbertKader_Ubiquitous/08_Bass.dat"
start="0" duration="20" offset="0"></daw-clip>
</daw-track>
<!-- Synth1: two clips with offset -->
<daw-track name="Synth 1">
<daw-clip src="/media/audio/AlbertKader_Ubiquitous/09_Synth1_Unmodulated.opus"
peaks-src="/media/audio/AlbertKader_Ubiquitous/09_Synth1_Unmodulated.dat"
start="4" duration="8" offset="2"></daw-clip>
<daw-clip src="/media/audio/AlbertKader_Ubiquitous/09_Synth1_Unmodulated.opus"
peaks-src="/media/audio/AlbertKader_Ubiquitous/09_Synth1_Unmodulated.dat"
start="14" duration="6" offset="10"></daw-clip>
</daw-track>
<!-- Synth2: three clips -->
<daw-track name="Synth 2">
<daw-clip src="/media/audio/AlbertKader_Ubiquitous/11_Synth2.opus"
peaks-src="/media/audio/AlbertKader_Ubiquitous/11_Synth2.dat"
start="0" duration="4" offset="0"></daw-clip>
<daw-clip src="/media/audio/AlbertKader_Ubiquitous/11_Synth2.opus"
peaks-src="/media/audio/AlbertKader_Ubiquitous/11_Synth2.dat"
start="8" duration="4" offset="4"></daw-clip>
<daw-clip src="/media/audio/AlbertKader_Ubiquitous/11_Synth2.opus"
peaks-src="/media/audio/AlbertKader_Ubiquitous/11_Synth2.dat"
start="16" duration="4" offset="8"></daw-clip>
</daw-track>
</daw-editor>
<div style="display:flex;gap:8px;align-items:stretch;margin-bottom:12px;height:28px;">
<daw-transport for="editor" style="display:contents;">
<daw-play-button></daw-play-button>
<daw-pause-button></daw-pause-button>
<daw-stop-button></daw-stop-button>
</daw-transport>
<span style="width:1px;background:rgba(255,255,255,0.15);"></span>
<button id="zoom-in" style="cursor:pointer;background:#1a1a2e;color:#e0d4c8;border:1px solid currentColor;padding:0 10px;font:inherit;line-height:1;">+</button>
<button id="zoom-out" style="cursor:pointer;background:#1a1a2e;color:#e0d4c8;border:1px solid currentColor;padding:0 10px;font:inherit;line-height:1;">−</button>
<span id="zoom-level" style="font-family:'Courier New',monospace;font-size:0.75rem;color:#888;display:flex;align-items:center;">1024 spp</span>
</div>
<div id="log"></div>
<script type="module">
import { NativePlayoutAdapter } from '@dawcore/transport';
const editor = document.getElementById('editor');
// Pass AudioContext at 48000 Hz to match .dat peaks
const audioCtx = new AudioContext({ sampleRate: 48000, latencyHint: 0 });
const adapter = new NativePlayoutAdapter(audioCtx);
editor.adapter = adapter;
const log = document.getElementById('log');
function addLog(msg) {
const line = document.createElement('div');
line.textContent = new Date().toLocaleTimeString() + ' ' + msg;
log.prepend(line);
while (log.children.length > 30) log.lastChild.remove();
}
// Zoom controls
const zoomLevels = [128, 256, 512, 1024, 2048, 4096, 8192];
const zoomLabel = document.getElementById('zoom-level');
function updateZoomLabel() {
zoomLabel.textContent = editor.samplesPerPixel + ' spp';
}
document.getElementById('zoom-in').addEventListener('click', () => {
const idx = zoomLevels.indexOf(editor.samplesPerPixel);
if (idx > 0) {
editor.samplesPerPixel = zoomLevels[idx - 1];
updateZoomLabel();
}
});
document.getElementById('zoom-out').addEventListener('click', () => {
const idx = zoomLevels.indexOf(editor.samplesPerPixel);
if (idx < zoomLevels.length - 1) {
editor.samplesPerPixel = zoomLevels[idx + 1];
updateZoomLabel();
}
});
// Editor events
editor.addEventListener('daw-seek', (e) => addLog('seek: ' + e.detail.time.toFixed(3) + 's'));
editor.addEventListener('daw-track-select', (e) => addLog('track-select: ' + e.detail.trackId));
editor.addEventListener('daw-selection', (e) => addLog('selection: ' + e.detail.start.toFixed(3) + ' - ' + e.detail.end.toFixed(3)));
editor.addEventListener('daw-track-ready', (e) => addLog('track-ready: ' + e.detail.trackId));
editor.addEventListener('daw-play', () => addLog('play'));
editor.addEventListener('daw-pause', () => addLog('pause'));
editor.addEventListener('daw-stop', () => addLog('stop'));
editor.addEventListener('daw-clip-move', (e) => addLog('clip-move: ' + e.detail.clipId + ' delta=' + e.detail.deltaSamples));
editor.addEventListener('daw-clip-trim', (e) => addLog('clip-trim: ' + e.detail.clipId + ' ' + e.detail.boundary + ' delta=' + e.detail.deltaSamples));
editor.addEventListener('daw-clip-split', (e) => addLog('clip-split: ' + e.detail.originalClipId + ' → ' + e.detail.leftClipId + ' + ' + e.detail.rightClipId));
</script>
</body>
</html>