-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
221 lines (204 loc) · 6.59 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
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Websynth</title>
<script defer src="https://cdn.jsdelivr.net/npm/webmidi" charset="utf-8"></script>
<script defer src="./src/websynth-envelope.js" charset="utf-8"></script>
<script type="module" src="main.js" charset="utf-8"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Aldrich&display=swap">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="css/keyboard.css">
<link rel="shortcut icon" href="favicon.ico">
</head>
<body>
<form id="controller-form" class="hidden">
<label for="controller-select">Select your MIDI controller</label>
<select id="controller-select"></select>
<label for="channel-select">Channel</label>
<select id="channel-select"></select>
<button type="submit">Select</button>
</form>
<div id="audio-sources">
<nav>
<label for="source-select">Mode</label>
<select id="source-select">
<option value="additive-oscillators">Additive</option>
<option value="harmonic-series">Harmonics</option>
<option value="bytebeat">Bytebeat</option>
<option value="wasmbeat">Wasmbeat</option>
</select>
</nav>
<div id="additive-oscillators" class="panel">
<button id="add-oscillator" class="add">+</button>
<ol id="oscillator-panel"></ol>
<template id="oscillator-template">
<li class="oscillator">
<label>Waveform
<select class="waveform">
<option value="sine" selected>Sine</option>
<option value="triangle">Triangle</option>
<option value="square">Square</option>
<option value="sawtooth">Sawtooth</option>
</select>
</label>
<label>Gain
<input type="range" class="gain" value="0.5" min="0" max="1" step="any">
</label>
<label>Detune
<input type="number" class="detune" value="0" min="-100" max="100" step="any">
</label>
<label>Note Offset
<input type="number" class="note-offset" value="0" min="-11" max="11">
</label>
<label>Octave
<input type="number" class="octave" value="0" min="-6" max="6">
</label>
<label><abbr title="Invert phase">Ø</abbr>
<input type="checkbox" class="invert-phase">
</label>
<button class="remove-oscillator remove">-</button>
</li>
</template>
</div>
<div id="harmonic-series" class="hidden panel">
<form id="harmonic-inputs">
<label for="harmonic-count"><math><mi>N</mi><mo>=</mo></math></label>
<input type="number" id="harmonic-count" class="validate" value="10" min="1" max="16">
<label for="harmonic-function">
<math>
<mi>f</mi>
<mo stretch="false">(</mo>
<mi>k</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
</math>
</label>
<input
type="text"
id="harmonic-function"
class="validate"
value="2 ^ k"
placeholder="Reciprocal of the amplitude of the kth harmonic"
spellcheck="false">
</form>
<math id="harmonic-formula" display="block">
<mrow>
<mi>F</mi>
<mo stretch="false">(</mo>
<mi>x</mi>
<mo stretch="false">)</mo>
<mo>=</mo>
<munderover>
<mo>∑</mo>
<mrow><mi>k</mi><mo>=</mo><mn>1</mn></mrow>
<mrow><mi>N</mi></mrow>
</munderover>
<mrow><mrow id="harmonic-user-formula">
<mfrac>
<mn>1</mn>
<mi>f</mi>
<mo stretchy="false">(</mo>
<mi>k</mi>
<mo stretchy="false">)</mo>
</mfrac>
</mrow>
</mrow>
<mo>·</mo>
<msup>
<mi>e</mi>
<mrow><mi>i</mi><mi>k</mi><mi>x</mi></mrow>
</msup>
</mrow>
</math>
</div>
<div id="bytebeat" class="hidden">
<div class="panel">
<label for="bytebeat-mode">Bytebeat Mode</label>
<select id="bytebeat-mode">
<option value="byte">Bytebeat</option>
<option value="float">Floatbeat</option>
</select>
</div>
<textarea id="bytebeat-code" class="validate" rows="20" cols="40" spellcheck="false">t & t >> (8 + 2 & tt >> 7)</textarea>
<details>
<summary>?</summary>
<p>If you're already familiar with bytebeat, this keyboard mode works similarly
to other JS bytebeat software, except <code>t</code> is incremented at a rate relative to
the note played on the keyboard, such that the bytebeat function <code>t</code> plays the same
pitch as the equivalent sawtooth wave in additive mode.
</p>
<p>There is also a second counter, <code>tt</code>, which is incremented so that
<code>1 & tt >> 11</code> produces quarter notes at the set tempo. This can be
used to produce rhythms that will be at the same tempo across all notes.
<code>tt</code> is incremented at 8kHz about 113bpm, 11kHz and its multiples
at about 163bpm.
</p>
<p>The <code>Math</code> object is included, as well as the function
<code>int(string, index)</code> for C-style char-to-int indexing and conversion.
</p>
<p>If you still have no idea what's going on, <a href="guide.html">here's a more in-depth guide.</a></p>
</details>
</div>
<div id="wasmbeat" class="hidden">
<div id="wasm-options" class="panel">
<label for="wasm-language">Syntax</label>
<select id="wasm-language">
<option value="wasm-wat-code">WebAssembly Text format</option>
<option value="wasm-rpn-code">GlitchMachine RPN</option>
</select>
</div>
<div id="wasm-code-blocks">
<textarea id="wasm-wat-code" class="validate" rows="20" cols="40" spellcheck="false">
local.get $t
local.get $t
i32.const 8
i32.shr_u
i32.and
</textarea>
<textarea id="wasm-rpn-code" class="validate hidden" rows="20" cols="40" spellcheck="false">t t 8 >> &</textarea>
</div>
</div>
</div>
<section id="global-controls">
<section id="preset-panel" class="panel">
<select id="preset-list">
<optgroup label="Factory Presets" id="factory-presets"></optgroup>
<optgroup label="Custom Presets" id="custom-presets"></optgroup>
</select>
<button id="load-preset">Load</button>
<input type="text" id="preset-name" placeholder="Preset Name">
<div class="flexrow">
<button id="add-preset" class="add">+</button>
<button id="remove-preset" class="remove">-</button>
</div>
</section>
<section id="note-controls" class="panel">
<label for="velocity-sensitive">Velocity Sensitive</label>
<input type="checkbox" checked id="velocity-sensitive">
<label for="note-offset">Note Offset</label>
<input id="note-offset" type="number" value="0" min="-11" max="11">
<label for="octave">Octave</label>
<input id="octave" type="number" value="0" min="-6" max="6">
</section>
<websynth-envelope></websynth-envelope>
<section id="master-panel" class="panel">
<label for="panning">Panning</label>
<input type="range" value="0" min="-1" max="1" step="any" id="panning">
<label for="master-gain">Gain</label>
<input type="range" value="0.5" min="0" max="1" step="any" id="master-gain">
<label for="sharp-or-flat">♯/♭</label>
<input type="checkbox" id="sharp-or-flat" checked>
<label for="metronome">Metronome</label>
<input type="checkbox" id="metronome">
<label for="tempo">Tempo</label>
<input type="number" value="120" min="40" max="400" step="any" id="tempo">
</section>
</section>
<output id="chord-name"></output>
<section id="keyboard">
<div id="ebony"></div>
<div id="ivory"></div>
</section>
</body>
</html>