Initial commit.
[byzantine_scales.git] / byzant.html
blob3cb1cf7d9d10fc3136041d19dd49b3d0ee2a3569
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>Tinnitus</title>
6 </head>
7 <body>
8 <style>
9 input {
10 height: 18px;
11 width: 8.192%;
12 font: Courier;
13 font-size: 1.0em;
14 background-color: magenta;
16 </style>
17 <script>
18 function innerhtml(el, txt)
20 if (txt == undefined){
21 return document.getElementById(el).innerHTML;
23 else document.getElementById(el).innerHTML = txt;
26 function value(el, v)
28 if (v == undefined){
29 return document.getElementById(el).value;
31 else document.getElementById(el).value = v;
34 function fromradio(radio)
36 var l = document.getElementsByName( radio);
37 for(var i=0; i<l.length; i++){
38 if(l[i].checked){
39 return l[i].value;
43 </script>
44 </head>
45 <body>
46 <h3 >Byzantine Scales</h3>
47 <input type="number" id="s" onchange="tune()" value=0.0> Gain [0.0 - 1.0] </input>
48 <h3>Select your favorite pulse shape</h3>
49 <input type="radio" name="shape" value="sine" checked> Sine
50 <input type="radio" name="shape" value="triangle"> Triangle
51 <input type="radio" name="shape" value="sawtooth" > Sawtooth
52 <input type="radio" name="shape" value="square"> Square<br><br>
53 <h3>Keybroad</h3>
54 <input type="text" id="t" onchange="key()" value='m'>
55 <h3>Κλίμακας</h3>
56 <input type="radio" name="scale" onclick="tune()" checked value=0> Διατονικό
57 <input type="radio" name="scale" onclick="tune()" value=1> Χρωματικό μαλακό
58 <input type="radio" name="scale" onclick="tune()" value=2> Χρωματικό σκλερό
59 <input type="radio" name="scale" onclick="tune()" value=3> Εναρμονικό
60 <h3>Φθόγγως</h3>
61 <input type="radio" name="tone" onclick="tune()" value=0 checked> δι </input>
62 <input type="radio" name="tone" onclick="tune()" value=1> κε
63 <input type="radio" name="tone" onclick="tune()" value=2> Ζω
64 <input type="radio" name="tone" onclick="tune()" value=3> Νη
65 <input type="radio" name="tone" onclick="tune()" value=4> Πα
66 <input type="radio" name="tone" onclick="tune()" value=5> Βου
67 <input type="radio" name="tone" onclick="tune()" value=6> Γα
68 <br>
69 <input type="radio" name="tone" onclick="tune()" value=7> Δι
70 <input type="radio" name="tone" onclick="tune()" value=8> Κε
71 <input type="radio" name="tone" onclick="tune()" value=9> Ζω'
72 <input type="radio" name="tone" onclick="tune()" value=10> Νη'
73 <input type="radio" name="tone" onclick="tune()" value=11> Πα'
74 <input type="radio" name="tone" onclick="tune()" value=12> Βου'
75 <input type="radio" name="tone" onclick="tune()" value=13> Γα'
76 <br>
77 <input type="radio" name="tone" onclick="tune()" value=14> Δι'
78 <br><br>
79 <button onclick="startstop()" id="b">Start</button><br>
80 <script>
81 const quant=1.009673533228511;
82 const freq=[
83 0, 12, 12+10,
84 12+10+8,
85 12+10+8+12,
86 12+10+8+12+10,
87 12+10+8+12+10+8,
88 12+10+8+12+10+8+12,
89 12+10+8+12+10+8+12+12,
90 12+10+8+12+10+8+12+12+10,
91 12+10+8+12+10+8+12+12+10+8,
92 12+10+8+12+10+8+12+12+10+8+12,
93 12+10+8+12+10+8+12+12+10+8+12+10,
94 12+10+8+12+10+8+12+12+10+8+12+10+8,
95 12+10+8+12+10+8+12+12+10+8+12+10+8+12,
97 0, 8, 8+14,
98 8+14+8,
99 8+14+8+8,
100 8+14+8+8+14,
101 8+14+8+8+14+8,
102 8+14+8+8+14+8+12,
103 8+14+8+8+14+8+12+8,
104 8+14+8+8+14+8+12+8+14,
105 8+14+8+8+14+8+12+8+14+8,
106 8+14+8+8+14+8+12+8+14+8+8,
107 8+14+8+8+14+8+12+8+14+8+8+14,
108 8+14+8+8+14+8+12+8+14+8+8+14+8,
109 8+14+8+8+14+8+12+8+14+8+8+14+8+12,
111 0, 12, 12+6,
112 12+6+20,
113 12+6+20+4,
114 12+6+20+4+6,
115 12+6+20+4+6+20,
116 12+6+20+4+6+20+4,
117 12+6+20+4+6+20+4+12,
118 12+6+20+4+6+20+4+12+6,
119 12+6+20+4+6+20+4+12+6+20,
120 12+6+20+4+6+20+4+12+6+20+4,
121 12+6+20+4+6+20+4+12+6+20+4+6,
122 12+6+20+4+6+20+4+12+6+20+4+6+20,
123 12+6+20+4+6+20+4+12+6+20+4+6+20+4,
125 0, 12, 12+6,
126 12+6+12,
127 12+6+12+12,
128 12+6+12+12+6,
129 12+6+12+12+6+12,
130 12+6+12+12+6+12+12,
131 12+6+12+12+6+12+12+12,
132 12+6+12+12+6+12+12+12+6,
133 12+6+12+12+6+12+12+12+6+12,
134 12+6+12+12+6+12+12+12+6+12+12,
135 12+6+12+12+6+12+12+12+6+12+12+6,
136 12+6+12+12+6+12+12+12+6+12+12+6+12,
137 12+6+12+12+6+12+12+12+6+12+12+6+12+12,
139 function key()
141 alert(value('t'));
142 value('t', ' ');
143 return;
145 function tune()
147 if(osc0 == undefined){
148 return 0;
150 osc0.type = fromradio("shape");
151 osc0.frequency.value =
152 220.0*quant**freq[15*parseInt(fromradio("scale"))
153 + parseInt(fromradio("tone"))];
154 // console.log(osc0.frequency.value);
155 gainNode0.gain.value = value("s");
156 return 0;
158 function startstop()
160 if (innerhtml('b') == 'Stop'){
161 osc0.stop();
162 delete ctx;
163 innerhtml('b', 'Start');
165 else {
166 ctx = new window.AudioContext();
167 osc0 = ctx.createOscillator();
168 gainNode0 = ctx.createGain();
169 osc0.connect(gainNode0);
170 gainNode0.connect(ctx.destination);
171 tune();
172 osc0.start();
173 innerhtml('b', 'Stop');
176 </script>
177 </body>
178 </html>