-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.html
442 lines (397 loc) · 18.6 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Tool to create music box sheets from midi by converting them to a laser cutter file.">
<meta name="author" content="">
<link rel="shortcut icon" href="favicon.ico">
<title>Midi to lasercutter</title>
<!-- Bootstrap Core CSS -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<!-- Select element CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/css/bootstrap-select.min.css">
<link rel="stylesheet" href="inc/custom.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Wintergatan midi to lasercutter</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>
<a href="#" data-toggle="modal" data-target="#helpModal">How to use</a>
</li>
<li>
<a href="#" data-toggle="modal" data-target="#aboutModal">About</a>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
<!-- Page Content -->
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label for="units">Units</label>
<select id="units" class="selectpicker form-control">
<option>Millimeters</option>
<option>Inches</option>
</select>
</div>
<div class="form-group">
<label for="workpiece-width">Workpiece width</label>
<div class="input-group">
<input type="number" class="form-control" id="workpiece-width" min="0" step="1" max="10000">
<span class="input-group-addon unit-suffix">mm</span>
</div>
</div>
<div class="form-group">
<label for="workpiece-height">Workpiece height</label>
<div class="input-group">
<input type="number" class="form-control" id="workpiece-height" min="0" step="1" max="10000">
<span class="input-group-addon unit-suffix">mm</span>
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="starting-edge">Starting edge</label>
<select id="starting-edge" class="selectpicker form-control">
<option>Straight</option>
<option>Diagonal</option>
<option>Jagged</option>
</select>
</div>
<div class="form-group">
<label for="joint-edge">Joint edge</label>
<select id="joint-edge" class="selectpicker form-control">
<option>Straight</option>
<option>Diagonal</option>
<option>Jagged</option>
</select>
</div>
<div class="form-group">
<label for="ending-edge">Ending edge</label>
<select id="ending-edge" class="selectpicker form-control">
<option>Straight</option>
<option>Diagonal</option>
<option>Jagged</option>
</select>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="hole-shape">Hole shape</label>
<select id="hole-shape" class="selectpicker form-control">
<option>Rounded</option>
<option>Square</option>
</select>
</div>
<div class="form-group">
<label for="hole-width">Hole width</label>
<div class="input-group">
<input type="number" class="form-control" id="hole-width" value="2" min="0" step="1" max="10000">
<span class="input-group-addon unit-suffix">mm</span>
</div>
</div>
<div class="form-group">
<label for="hole-height">Hole height</label>
<div class="input-group">
<input type="number" class="form-control" id="hole-height" value="1.5" min="0" step="1" max="10000">
<span class="input-group-addon unit-suffix">mm</span>
</div>
</div>
</div>
</div>
<!-- /.row -->
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label for="strip-height">Strip height</label>
<div class="input-group">
<input type="number" class="form-control" id="strip-height" value="70" min="0" step="1" max="10000">
<span class="input-group-addon unit-suffix">mm</span>
</div>
</div>
<div class="form-group">
<label for="scale">Scale</label>
<select id="scale" class="selectpicker form-control">
<option>C</option>
</select>
</div>
<div class="form-group">
<label for="scale-type">Scale type</label>
<select id="scale-type" class="selectpicker form-control">
<option>Major</option>
</select>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="amount-of-pins">Amount of pins</label>
<input type="number" class="form-control" id="amount-of-pins" value="20" min="0" step="1" max="10000">
</div>
<div class="form-group">
<label for="file-picker-midi">Midi file</label>
<div class="input-group">
<label class="input-group-btn">
<span class="btn btn-default">
Browse <input id="file-picker-midi" style="display: none;" type="file" accept=".midi,.mid">
</span>
</label>
<input id="midi-file" class="form-control" readonly type="text">
</div>
</div>
<div class="form-group">
<label for="current-scale">Current scale</label>
<input type="text" class="form-control" id="current-scale" value="C D E F G A B" readonly>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="horizontal-margins">Horizontal margins</label>
<div class="input-group">
<input type="number" class="form-control" id="horizontal-margins" value="50" min="0" step="1" max="10000">
<span class="input-group-addon unit-suffix">mm</span>
</div>
</div>
<div class="form-group">
<label for="vertical-margins">Vertical margins</label>
<div class="input-group">
<input type="number" class="form-control" id="vertical-margins" value="6.5" min="0" step="1" max="10000">
<span class="input-group-addon unit-suffix">mm</span>
</div>
</div>
<button type="button" id="import-settings" class="btn btn-default">Import settings</button>
<input id="file-picker-import-settings" style="display: none;" type="file">
<button type="button" id="export-settings" class="btn btn-default pull-right">Export settings</button>
</div>
</div>
<!-- /.row -->
<div class="row">
<div class="col-md-4 col-md-offset-4 text-center">
<button type="button" id="show-preview" class="btn btn-primary">Show Preview</button>
</div>
</div>
<div class="row">
<div class="text-center" id="preview-box" style="width:100%;height:300px;border:0;margin-top:20px;overflow-x:scroll;"></div>
</div>
<div id="export-row" class="row">
<div class="col-md-4">
<div class="form-group">
<label for="export-format">Export format</label>
<select id="export-format" class="selectpicker form-control">
<option value="svg">SVG</option>
<option value="dxf">DXF</option>
<option value="txt">Plain Text</option>
</select>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="line-color">Line color</label>
<div class="input-group">
<input type="color" class="form-control" id="line-color" value="#FF0000">
<span id="color-suffix" class="input-group-addon">#FF0000</span>
</div>
</div>
</div>
<div class="col-md-4 text-center">
<button type="button" id="download-btn" class="btn btn-primary" disabled>Download Laser Cutter plans</button>
</div>
</div>
</div>
<!-- /.container -->
<div class="modal fade" id="aboutModal" tabindex="-1" role="dialog" aria-labelledby="aboutModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="aboutModalLabel">About</h4>
</div>
<div class="modal-body">
This tool automates the process of turning MIDI files into printable or cuttable music box paper tape.
It was inspired by this <a href="https://www.youtube.com/watch?v=HjBhO9iqEc0" target="_blank">Music Box Hole Punch Tutorial</a> made by Martin Molin of Swedish band Wintergatan. In the video, he describes the tedious process of creating the paper tape for music boxes by hand and reaches out to the coding world for a more automated solution.
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="helpModal" tabindex="-1" role="dialog" aria-labelledby="helpModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="helpModalLabel">How To Use</h4>
<p>The application accepts a MIDI file and user settings as input. It then generates an output file in either SVG, DXF or plain text format. The generated output file can be printed or used in a laser-cutter.</p>
<table class="table">
<tr>
<th>Units</th>
<td>Select inches or millimeters for all numerical measurement settings</td>
</tr>
<tr>
<th>Workpiece width</th>
<td>Width of workpiece (not currently used)</td>
</tr>
<tr>
<th>Workpiece height</th>
<td>Height of workpiece (not currently used)</td>
</tr>
<tr>
<th>Strip height</th>
<td>Height of the paper strip</td>
</tr>
<tr>
<th>Scale</th>
<td>Currently limited to Key of C</td>
</tr>
<tr>
<th>Scale type</th>
<td>Currently limited to Major Scale</td>
</tr>
<tr>
<th>Starting edge</th>
<td>The starting edge shape: straight, diagonal or jagged</td>
</tr>
<tr>
<th>Joint edge</th>
<td>Edge shape to be used between sections: straight, diagonal or jagged</td>
</tr>
<tr>
<th>Ending edge</th>
<td>Ending edge shape: straight, diagonal or jagged</td>
</tr>
<tr>
<th>Amount of pins</th>
<td>Number of pins on music box or device</td>
</tr>
<tr>
<th>Midi file</th>
<td>A valid MIDI file is required</td>
</tr>
<tr>
<th>Current scale</th>
<td>Current scale used in the generation (Read-only)</td>
</tr>
<tr>
<th>Hole shape</th>
<td>Corner type for punch holes: Rounded or Square</td>
</tr>
<tr>
<th>Hole width</th>
<td>Width of punch holes</td>
</tr>
<tr>
<th>Hole height</th>
<td>Height of punch holes</td>
</tr>
<tr>
<th>Horizontal margins</th>
<td>Left and right margins</td>
</tr>
<tr>
<th>Vertical margins</th>
<td>Top and bottom margins</td>
</tr>
<tr>
<th>Import settings</th>
<td>Import previously saved settings in JSON format. This will overwrite the current configuration.
Current MIDI file will not be affected.</td>
</tr>
<tr>
<th>Export settings</th>
<td>Export current settings in JSON format. Does not include MIDI file.</td>
</tr>
<tr>
<th>Export format</th>
<td>Format for your output: SVG, DXF or Plain Text</td>
</tr>
<tr>
<th>Line color</th>
<td>Color of track lines in output file</td>
</tr>
<tr>
<th>Show Preview</th>
<td>Generate and display an on-screen, scrollable preview using the current settings</td>
</tr>
<tr>
<th>Download Laser Cutter Plans</th>
<td>Generate and save an output file in the specified format</td>
</tr>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- jQuery Version 3.2.1 -->
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<!-- Bootstrap Core JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- Bootstrap select -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/js/bootstrap-select.min.js"></script>
<script type="text/javascript">
if (!Array.prototype.find) {
Object.defineProperty(Array.prototype, "find", {
value: function (predicate) {
if (this === null) {
throw new TypeError('Array.prototype.find called on null or undefined');
}
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
var list = Object(this);
var length = list.length >>> 0;
var thisArg = arguments[1];
var value;
for (var i = 0; i < length; i++) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) {
return value;
}
}
return undefined;
}
});
}
function compare(a, b) {
if (a > b) return 1;
if (a < b) return -1;
return 0;
}
</script>
<script src="inc/user-interface.js"></script>
<script src="inc/midi-parser.js"></script>
<script src="inc/maker.js"></script>
<script src="inc/scaleandmusicbox.js"></script>
<script src="inc/processing.js"></script>
<script src="inc/drawing.js"></script>
</body>
</html>