licence information provided
[byzantine_scales.git] / byzant.html
blobb829a239164a4e081f081320b408f71f26d9ea32
1 <!-- This file is part of byzantine_scales. -->
3 <!-- byzantine_scales is free software: you can redistribute it and/or modify it -->
4 <!-- under the terms of the GNU General Public License as published by the -->
5 <!-- Free Software Foundation, either version 3 of the License, or (at your -->
6 <!-- option) any later version. -->
8 <!-- byzantine_scales is distributed in the hope that it will be useful, but WITHOUT -->
9 <!-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -->
10 <!-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -->
11 <!-- for more details. -->
13 <!-- You should have received a copy of the GNU General Public License -->
14 <!-- along with byzantine_scales. If not, see <https://www.gnu.org/licenses/>. -->
16 <!DOCTYPE html>
17 <html>
18 <head>
19 <meta charset="utf-8">
20 <title>Byzantine_Scales</title>
21 </head>
22 <body>
23 <style>
24 input {
25 height: 18px;
26 width: 8.192%;
27 font: Courier;
28 font-size: 1.0em;
29 background-color: magenta;
31 </style>
32 <script>
33 function innerhtml(el, txt)
35 if (txt == undefined){
36 return document.getElementById(el).innerHTML;
38 else document.getElementById(el).innerHTML = txt;
41 function value(el, v)
43 if (v == undefined){
44 return document.getElementById(el).value;
46 else document.getElementById(el).value = v;
49 function fromradio(radio)
51 var l = document.getElementsByName( radio);
52 for(var i=0; i<l.length; i++){
53 if(l[i].checked){
54 return l[i].value;
58 </script>
59 </head>
60 <body>
61 <h3 >Byzantine Scales</h3>
62 <input type="number" id="s" onchange="tune()" value=0.0> Gain [0.0 - 1.0] </input>
63 <h3>Select your favorite pulse shape</h3>
64 <input type="radio" name="shape" value="sine" checked> Sine
65 <input type="radio" name="shape" value="triangle"> Triangle
66 <input type="radio" name="shape" value="sawtooth" > Sawtooth
67 <input type="radio" name="shape" value="square"> Square<br><br>
68 <h3>Keybroad</h3>
69 <input type="text" id="t" onchange="key()" value='m'>
70 <h3>Κλίμακας</h3>
71 <input type="radio" name="scale" onclick="tune()" checked value=0> Διατονικό
72 <input type="radio" name="scale" onclick="tune()" value=1> Χρωματικό μαλακό
73 <input type="radio" name="scale" onclick="tune()" value=2> Χρωματικό σκλερό
74 <input type="radio" name="scale" onclick="tune()" value=3> Εναρμονικό
75 <h3>Φθόγγως</h3>
76 <input type="radio" name="tone" onclick="tune()" value=0 checked> δι </input>
77 <input type="radio" name="tone" onclick="tune()" value=1> κε
78 <input type="radio" name="tone" onclick="tune()" value=2> Ζω
79 <input type="radio" name="tone" onclick="tune()" value=3> Νη
80 <input type="radio" name="tone" onclick="tune()" value=4> Πα
81 <input type="radio" name="tone" onclick="tune()" value=5> Βου
82 <input type="radio" name="tone" onclick="tune()" value=6> Γα
83 <br>
84 <input type="radio" name="tone" onclick="tune()" value=7> Δι
85 <input type="radio" name="tone" onclick="tune()" value=8> Κε
86 <input type="radio" name="tone" onclick="tune()" value=9> Ζω'
87 <input type="radio" name="tone" onclick="tune()" value=10> Νη'
88 <input type="radio" name="tone" onclick="tune()" value=11> Πα'
89 <input type="radio" name="tone" onclick="tune()" value=12> Βου'
90 <input type="radio" name="tone" onclick="tune()" value=13> Γα'
91 <br>
92 <input type="radio" name="tone" onclick="tune()" value=14> Δι'
93 <br><br>
94 <button onclick="startstop()" id="b">Start</button><br>
95 <script>
96 const quant=1.009673533228511;
97 const freq=[
98 0, 12, 12+10,
99 12+10+8,
100 12+10+8+12,
101 12+10+8+12+10,
102 12+10+8+12+10+8,
103 12+10+8+12+10+8+12,
104 12+10+8+12+10+8+12+12,
105 12+10+8+12+10+8+12+12+10,
106 12+10+8+12+10+8+12+12+10+8,
107 12+10+8+12+10+8+12+12+10+8+12,
108 12+10+8+12+10+8+12+12+10+8+12+10,
109 12+10+8+12+10+8+12+12+10+8+12+10+8,
110 12+10+8+12+10+8+12+12+10+8+12+10+8+12,
112 0, 8, 8+14,
113 8+14+8,
114 8+14+8+8,
115 8+14+8+8+14,
116 8+14+8+8+14+8,
117 8+14+8+8+14+8+12,
118 8+14+8+8+14+8+12+8,
119 8+14+8+8+14+8+12+8+14,
120 8+14+8+8+14+8+12+8+14+8,
121 8+14+8+8+14+8+12+8+14+8+8,
122 8+14+8+8+14+8+12+8+14+8+8+14,
123 8+14+8+8+14+8+12+8+14+8+8+14+8,
124 8+14+8+8+14+8+12+8+14+8+8+14+8+12,
126 0, 12, 12+6,
127 12+6+20,
128 12+6+20+4,
129 12+6+20+4+6,
130 12+6+20+4+6+20,
131 12+6+20+4+6+20+4,
132 12+6+20+4+6+20+4+12,
133 12+6+20+4+6+20+4+12+6,
134 12+6+20+4+6+20+4+12+6+20,
135 12+6+20+4+6+20+4+12+6+20+4,
136 12+6+20+4+6+20+4+12+6+20+4+6,
137 12+6+20+4+6+20+4+12+6+20+4+6+20,
138 12+6+20+4+6+20+4+12+6+20+4+6+20+4,
140 0, 12, 12+6,
141 12+6+12,
142 12+6+12+12,
143 12+6+12+12+6,
144 12+6+12+12+6+12,
145 12+6+12+12+6+12+12,
146 12+6+12+12+6+12+12+12,
147 12+6+12+12+6+12+12+12+6,
148 12+6+12+12+6+12+12+12+6+12,
149 12+6+12+12+6+12+12+12+6+12+12,
150 12+6+12+12+6+12+12+12+6+12+12+6,
151 12+6+12+12+6+12+12+12+6+12+12+6+12,
152 12+6+12+12+6+12+12+12+6+12+12+6+12+12,
154 function key()
156 alert(value('t'));
157 value('t', ' ');
158 return;
160 function tune()
162 if(osc0 == undefined){
163 return 0;
165 osc0.type = fromradio("shape");
166 osc0.frequency.value =
167 220.0*quant**freq[15*parseInt(fromradio("scale"))
168 + parseInt(fromradio("tone"))];
169 // console.log(osc0.frequency.value);
170 gainNode0.gain.value = value("s");
171 return 0;
173 function startstop()
175 if (innerhtml('b') == 'Stop'){
176 osc0.stop();
177 delete ctx;
178 innerhtml('b', 'Start');
180 else {
181 ctx = new window.AudioContext();
182 osc0 = ctx.createOscillator();
183 gainNode0 = ctx.createGain();
184 osc0.connect(gainNode0);
185 gainNode0.connect(ctx.destination);
186 tune();
187 osc0.start();
188 innerhtml('b', 'Stop');
191 </script>
192 </body>
193 </html>