-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.html
More file actions
494 lines (434 loc) · 15.8 KB
/
index.html
File metadata and controls
494 lines (434 loc) · 15.8 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
<html>
<head>
<title>Notably Music Editor</title>
<meta charset="UTF-8" />
<meta name="description" content="Notably, a simple, lightweight music viewer for nwc (noteworthy composer) files" />
<meta name="keywords" content="Music,Notation,Composer,Scorewriter,Editor,NWC,Noteworthy" />
<meta name="author" content="Joshua Koo" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
/* Companion text fonts for each SMuFL music font */
@font-face { font-family: 'BravuraText'; src: url('vendor/bravura-1.211/otf/BravuraText.otf') format('opentype'); }
@font-face { font-family: 'LelandText'; src: url('vendor/fonts/LelandText.otf') format('opentype'); }
@font-face { font-family: 'PetalumaText'; src: url('vendor/fonts/PetalumaText.otf') format('opentype'); }
@font-face { font-family: 'SebastianText'; src: url('vendor/fonts/SebastianText.otf') format('opentype'); }
@font-face { font-family: 'FinaleMaestroText'; font-weight: normal; font-style: normal; src: url('vendor/fonts/FinaleMaestroText-Regular.otf') format('opentype'); }
@font-face { font-family: 'FinaleMaestroText'; font-weight: bold; font-style: normal; src: url('vendor/fonts/FinaleMaestroText-Bold.otf') format('opentype'); }
@font-face { font-family: 'FinaleMaestroText'; font-weight: normal; font-style: italic; src: url('vendor/fonts/FinaleMaestroText-Italic.otf') format('opentype'); }
@font-face { font-family: 'FinaleMaestroText'; font-weight: bold; font-style: italic; src: url('vendor/fonts/FinaleMaestroText-BoldItalic.otf') format('opentype'); }
@font-face { font-family: 'FinaleBroadwayText'; src: url('vendor/fonts/FinaleBroadwayText.otf') format('opentype'); }
@font-face { font-family: 'FinaleAshText'; src: url('vendor/fonts/FinaleAshText.otf') format('opentype'); }
@font-face { font-family: 'FinaleJazzText'; src: url('vendor/fonts/FinaleJazzText.otf') format('opentype'); }
</style>
</head>
<body>
<style>
:root {
--bg: #222;
--surface: #333;
--surface-hover: #3e3e3e;
--surface-active: #505050;
--text: #eee;
--text-dim: #999;
--border: #444;
--divider: #444;
--accent: #5a8fcc;
--accent-hover: #6ba0dd;
--accent-text: #fff;
--radius: 4px;
--gap: 8px;
}
body {
background: var(--bg);
color: var(--text);
overflow: hidden;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto',
'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans',
'Helvetica Neue', sans-serif;
font-size: 12px;
margin: 0;
padding: 0;
}
#container {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
}
/* Toolbar */
.toolbar {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--gap);
padding: 6px 10px;
}
.toolbar-group {
display: flex;
align-items: center;
gap: 4px;
}
.toolbar-group + .toolbar-group {
border-left: 1px solid var(--divider);
padding-left: var(--gap);
}
.toolbar-label {
font-size: 11px;
color: var(--text-dim);
user-select: none;
}
/* Controls */
button, select {
background: var(--surface);
color: var(--text);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 4px 8px;
font-size: 12px;
font-family: inherit;
cursor: pointer;
outline: none;
}
button:hover, select:hover {
background: var(--surface-hover);
}
button:active {
background: var(--surface-active);
}
button.active {
background: var(--accent);
color: var(--accent-text);
border-color: var(--accent);
}
button.active:hover {
background: var(--accent-hover);
}
input[type="range"] {
accent-color: var(--accent);
cursor: pointer;
}
/* Segmented button group */
.btn-group {
display: inline-flex;
border-radius: var(--radius);
overflow: hidden;
}
.btn-group button {
border-radius: 0;
border-right-color: var(--bg);
margin: 0;
padding: 4px 10px;
}
.btn-group button:first-child {
border-radius: var(--radius) 0 0 var(--radius);
}
.btn-group button:last-child {
border-radius: 0 var(--radius) var(--radius) 0;
border-right-color: var(--border);
}
/* Popover panel */
.popover {
display: none;
position: absolute;
top: calc(100% + 4px);
left: 0;
z-index: 100;
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 12px;
min-width: 260px;
box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.popover.open {
display: flex;
flex-direction: column;
gap: 8px;
}
.popover label {
display: flex;
align-items: center;
gap: 6px;
font-size: 11px;
color: var(--text-dim);
white-space: nowrap;
}
.popover label span:first-child {
min-width: 80px;
}
.popover input[type="range"] {
width: 100px;
}
.popover .slider-value {
min-width: 32px;
text-align: right;
font-variant-numeric: tabular-nums;
}
/* Score area */
#score {
overflow: auto;
flex: 1 0;
padding: 0;
}
canvas {
background: #fff;
position: fixed;
}
#invisible_canvas {
display: block;
opacity: 0.9;
}
/* Misc */
#logo {
font-size: 15px;
font-weight: 600;
letter-spacing: -0.3px;
color: var(--text);
}
#logo:hover {
color: var(--accent);
}
#footer {
padding: 6px 12px;
font-size: 10px;
color: var(--text-dim);
}
a {
color: var(--text-dim);
text-decoration: none;
}
a:hover {
color: var(--text);
}
h4 {
display: inline-block;
}
.time-display {
font-size: 11px;
min-width: 85px;
text-align: center;
font-variant-numeric: tabular-nums;
color: var(--text-dim);
}
</style>
<div id="container">
<div id="top">
<div class="toolbar">
<!-- File -->
<div class="toolbar-group">
<a href="https://github.com/zz85/nwc-viewer" id="logo">Notably</a>
<button id="open">Open</button>
<input type="file" id="opener" accept=".nwc,.nwz,.nwctxt,.mid,.midi" hidden />
<select id="samples"></select>
<a href="nwc2xml_converter.html"><button title="Convert NWC to MusicXML">NWC to XML</button></a>
</div>
<!-- Playback -->
<div class="toolbar-group">
<button id="play" title="Play / Pause">Play</button>
<button id="stop" title="Stop">Stop</button>
<span id="playback_time" class="time-display">0:00 / 0:00</span>
<input type="range" id="progress_bar"
min="0" max="1" step="0.001" value="0"
style="width: 120px;" />
<select id="solo_staff" title="Solo a single staff">
<option value="all">All Staves</option>
</select>
<select id="highlight_mode" title="Playback highlight mode">
<option value="notes">Notes</option>
<option value="glow">Glow</option>
<option value="bar">Bar</option>
<option value="column">Column</option>
<option value="none">Off</option>
</select>
<button id="autoscroll_toggle" class="active" title="Auto-scroll during playback">Auto-scroll</button>
<button id="piano_toggle" class="active" title="Piano keyboard">Piano</button>
</div>
</div>
<div class="toolbar">
<!-- Layout -->
<div class="toolbar-group">
<span class="toolbar-label">Layout</span>
<div class="btn-group" id="layout_group">
<button data-mode="scroll">Scroll</button>
<button data-mode="wrap" class="active">Wrap</button>
<button data-mode="page">Page</button>
</div>
<select id="page_size" style="display: none;" title="Page size">
<option value="letter">Letter</option>
<option value="a4">A4</option>
</select>
<div class="btn-group" id="orientation_group" style="display: none;">
<button data-orient="portrait" class="active">Portrait</button>
<button data-orient="landscape">Landscape</button>
</div>
</div>
<!-- View -->
<div class="toolbar-group">
<span class="toolbar-label">Font</span>
<select id="music_font" title="Music engraving font">
<optgroup label="Modern Engraving">
<option value="bravura">Bravura — modern, clean</option>
<option value="leland">Leland — contemporary</option>
<option value="maestro">Finale Maestro — classic</option>
<option value="engraver">Finale Engraver — traditional</option>
</optgroup>
<optgroup label="Handwritten / Jazz">
<option value="petaluma">Petaluma — hand-drawn</option>
<option value="jazz">Finale Jazz — lead sheets</option>
<option value="ash">Finale Ash — manuscript</option>
</optgroup>
<optgroup label="Historical / Specialty">
<option value="sebastian">Sebastian — elegant</option>
<option value="goldenage">Golden Age — vintage</option>
<option value="leipzig">Leipzig — scholarly</option>
<option value="broadway">Finale Broadway — show music</option>
<option value="legacy">Finale Legacy — classic Finale</option>
</optgroup>
</select>
<span class="toolbar-label">Size</span>
<button id="size_down" title="Decrease staff size">-</button>
<button id="size_up" title="Increase staff size">+</button>
<span class="toolbar-label">Zoom</span>
<input type="range" id="zoom_slider"
min="0.25" max="4.0" step="0.01" value="1.0"
oninput="applyZoom(parseFloat(this.value))"
style="width: 80px;" />
<span id="zoom_label" style="font-size: 11px; min-width: 36px; text-align: center; color: var(--text-dim);">100%</span>
<button id="ink_bleed_toggle" title="Print emulation: ink bleed, paper grain, letterpress effect">Inked</button>
<input type="color" id="ink_paper_color" value="#f1ece3" title="Paper color" style="width: 28px; height: 24px; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; vertical-align: middle;" />
</div>
<!-- Ink bleed controls (popover) -->
<div class="toolbar-group" style="position: relative;">
<button id="ink_controls_toggle" title="Ink bleed parameters">Ink</button>
<div id="ink_controls_panel" class="popover">
<label title="Ink spread amount">
<span>Bleed</span>
<input type="range" id="ink_bleed_slider" min="0" max="100" step="1" value="14" />
<span id="ink_bleed_label" class="slider-value">0.14</span>
</label>
<label title="Edge noise / organic variation">
<span>Roughness</span>
<input type="range" id="ink_roughness_slider" min="0" max="100" step="1" value="58" />
<span id="ink_roughness_label" class="slider-value">0.58</span>
</label>
<label title="Overall ink darkness">
<span>Ink Density</span>
<input type="range" id="ink_density_slider" min="0" max="100" step="1" value="100" />
<span id="ink_density_label" class="slider-value">1.00</span>
</label>
<label title="Paper fiber texture strength">
<span>Paper Grain</span>
<input type="range" id="ink_grain_slider" min="0" max="100" step="1" value="13" />
<span id="ink_grain_label" class="slider-value">0.13</span>
</label>
<label title="Letterpress edge darkening">
<span>Edge Pool</span>
<input type="range" id="ink_pool_slider" min="0" max="100" step="1" value="2" />
<span id="ink_pool_label" class="slider-value">0.02</span>
</label>
</div>
</div>
<!-- Spacing tuning (popover) -->
<div class="toolbar-group" style="position: relative;">
<button id="tuning_toggle" title="Spacing tuning parameters">Advanced</button>
<div id="tuning_panel" class="popover">
<label title="Note spacing density: lower = tighter, higher = looser">
<span>Density</span>
<input type="range" id="density_slider" min="0.5" max="3.0" step="0.05" value="1.5" />
<span id="density_label" class="slider-value">1.50</span>
</label>
<label title="Rod-spring balance: 0 = all rigid, 1 = default, 2 = all elastic">
<span>Rod / Spring</span>
<input type="range" id="rod_spring_slider" min="0.0" max="2.0" step="0.05" value="1.0" />
<span id="rod_spring_label" class="slider-value">1.00</span>
</label>
<label title="Duration proportionality: 0 = uniform, 1 = standard, 2 = duration-proportional">
<span>Visual / Timing</span>
<input type="range" id="proportionality_slider" min="0.0" max="2.0" step="0.05" value="1.0" />
<span id="proportionality_label" class="slider-value">1.00</span>
</label>
</div>
</div>
<!-- Debug (localhost only) -->
<div id="debug_tools" class="toolbar-group" style="display: none;">
<button onclick="window._debug_glyph = !window._debug_glyph; rerender()">Debug glyph</button>
<button id="blank_button">Blank</button>
<button id="new_staff">Add staff</button>
<button onclick="activateEdit()">Edit</button>
<span class="toolbar-label">Parser</span>
<button id="parser_toggle">New</button>
<button>Save</button>
<button>Load</button>
</div>
</div>
</div>
<div id="score">
<div id="invisible_canvas"></div>
</div>
<div id="footer">
Footer
</div>
</div>
<!-- vendor dependencies -->
<script src="vendor/inflate.min.js"></script>
<script src="vendor/opentype.min.js"></script>
<!-- module script -->
<script type="module" src="src/main.js"></script>
<script>
var nextRender
var scoreElm = document.getElementById('score')
function updateScroll() {
quickDraw(data, -scoreElm.scrollLeft, -scoreElm.scrollTop)
nextRender = null
}
scoreElm.addEventListener('scroll', (e) => {
if (!nextRender) nextRender = requestAnimationFrame(updateScroll)
})
scoreElm.style.cursor = 'pointer'
var downx, downy, scrollLeft, scrollTop
scoreElm.addEventListener('mousedown', (e) => {
downx = e.x
downy = e.y
scrollLeft = scoreElm.scrollLeft
scrollTop = scoreElm.scrollTop
window.addEventListener('mousemove', mousedrag)
scoreElm.style.cursor = 'grab'
e.preventDefault()
window.addEventListener('mouseup', (e) => {
window.removeEventListener('mousemove', mousedrag)
scoreElm.style.cursor = 'pointer'
})
})
function mousedrag(e) {
scoreElm.scrollLeft += downx - e.x
scoreElm.scrollTop += downy - e.y
}
// ---- Zoom handler (transform-based, no re-layout) ----
function applyZoom(newLevel) {
var oldZoom = getZoomLevel()
setZoomLevel(newLevel)
var zoom = getZoomLevel() // read back clamped value
// Update slider and label to match the (clamped) value
var slider = document.getElementById('zoom_slider')
var label = document.getElementById('zoom_label')
if (slider) slider.value = zoom
if (label) label.textContent = Math.round(zoom * 100) + '%'
// Center-preserving scroll: keep the same score-space point at
// the viewport center before and after zoom.
var cx = (scoreElm.scrollLeft + scoreElm.clientWidth / 2) / oldZoom
var cy = (scoreElm.scrollTop + scoreElm.clientHeight / 2) / oldZoom
// Resize the invisible_canvas spacer so scroll bounds are correct
// before we set the new scroll position.
var ic = document.getElementById('invisible_canvas')
if (ic && typeof maxCanvasWidth !== 'undefined') {
ic.style.width = (maxCanvasWidth * zoom) + 'px'
ic.style.height = Math.max(maxCanvasHeight * zoom, scoreElm.clientHeight) + 'px'
}
scoreElm.scrollLeft = cx * zoom - scoreElm.clientWidth / 2
scoreElm.scrollTop = cy * zoom - scoreElm.clientHeight / 2
quickDraw(null, -scoreElm.scrollLeft, -scoreElm.scrollTop)
}
window.applyZoom = applyZoom
</script>
</body>
</html>