Debian Codegraph @

src/Examples/CsoundQt/Html5 Support/Styled_Sliders.csd

raw
1 ; Example about using CSS in html section of CSD
2 ; By Michael Gogins 2016
3
4 <CsoundSynthesizer>
5 <CsOptions>
6 -odac
7 </CsOptions>
8 <CsInstruments>
9
10 sr = 44100
11 ksmps = 32
12 nchnls = 2
13 iampdbfs init 32768
14 prints "Default amplitude at 0 dBFS: %9.4f\n", iampdbfs
15 idbafs init dbamp(iampdbfs)
16 prints "dbA at 0 dBFS: %9.4f\n", idbafs
17 iheadroom init 6
18 prints "Headroom (dB): %9.4f\n", iheadroom
19 idbaheadroom init idbafs - iheadroom
20 prints "dbA at headroom: %9.4f\n", idbaheadroom
21 iampheadroom init ampdb(idbaheadroom)
22 prints "Amplitude at headroom: %9.4f\n", iampheadroom
23 prints "Balance so the overall amps at the end of performance -6 dbfs.\n"
24
25 connect "ModerateFM", "outleft", "Reverberation", "inleft"
26 connect "ModerateFM", "outright", "Reverberation", "inright"
27 connect "Reverberation", "outleft", "MasterOutput", "inleft"
28 connect "Reverberation", "outright", "MasterOutput", "inright"
29
30 alwayson "Reverberation"
31 alwayson "MasterOutput"
32 alwayson "Controls"
33
34 gk_FmIndex init 0.5
35 gk_FmCarrier init 1
36 instr ModerateFM
37 //////////////////////////////////////////////
38 // By Michael Gogins.
39 //////////////////////////////////////////////
40 i_instrument = p1
41 i_time = p2
42 i_duration = p3
43 i_midikey = p4
44 i_midivelocity = p5
45 i_phase = p6
46 i_pan = p7
47 i_depth = p8
48 i_height = p9
49 i_pitchclassset = p10
50 i_homogeneity = p11
51 iattack = 0.002
52 isustain = p3
53 idecay = 8
54 irelease = 0.05
55 iHz = cpsmidinn(i_midikey)
56 idB = i_midivelocity
57 iamplitude = ampdb(idB) * 4.0
58 kcarrier = gk_FmCarrier
59 imodulator = 0.5
60 ifmamplitude = 0.25
61 kindex = gk_FmIndex * 20
62 ifrequencyb = iHz * 1.003
63 kcarrierb = kcarrier * 1.004
64 aindenv transeg 0.0, iattack, -11.0, 1.0, idecay, -7.0, 0.025, isustain, 0.0, 0.025, irelease, -7.0, 0.0
65 aindex = aindenv * kindex * ifmamplitude
66 isinetable ftgenonce 0, 0, 65536, 10, 1, 0, .02
67 ; ares foscili xamp, kcps, xcar, xmod, kndx, ifn [, iphs]
68 aouta foscili 1.0, iHz, kcarrier, imodulator, kindex / 4., isinetable
69 aoutb foscili 1.0, ifrequencyb, kcarrierb, imodulator, kindex, isinetable
70 ; Plus amplitude correction.
71 asignal = (aouta + aoutb) * aindenv
72 adeclick linsegr 0, iattack, 1, isustain, 1, irelease, 0
73 asignal = asignal * iamplitude
74 aoutleft, aoutright pan2 asignal * adeclick, i_pan
75 outleta "outleft", aoutleft
76 outleta "outright", aoutright
77 prints "instr %4d t %9.4f d %9.4f k %9.4f v %9.4f p %9.4f\n", p1, p2, p3, p4, p5, p7
78 endin
79
80 gkReverberationWet init .5
81 gk_ReverberationDelay init .6
82 instr Reverberation
83 ainleft inleta "inleft"
84 ainright inleta "inright"
85 aoutleft = ainleft
86 aoutright = ainright
87 kdry = 1.0 - gkReverberationWet
88 awetleft, awetright reverbsc ainleft, ainright, gk_ReverberationDelay, 18000.0
89 aoutleft = ainleft * kdry + awetleft * gkReverberationWet
90 aoutright = ainright * kdry + awetright * gkReverberationWet
91 outleta "outleft", aoutleft
92 outleta "outright", aoutright
93 prints "instr %4d t %9.4f d %9.4f k %9.4f v %9.4f p %9.4f\n", p1, p2, p3, p4, p5, p7
94 endin
95
96 gk_MasterLevel init 1
97 instr MasterOutput
98 ainleft inleta "inleft"
99 ainright inleta "inright"
100 aoutleft = gk_MasterLevel * ainleft
101 aoutright = gk_MasterLevel * ainright
102 outs aoutleft, aoutright
103 prints "instr %4d t %9.4f d %9.4f k %9.4f v %9.4f p %9.4f\n", p1, p2, p3, p4, p5, p7
104 endin
105
106 instr Controls
107
108 gk_FmIndex_ chnget "gk_FmIndex"
109 if gk_FmIndex_ != 0 then
110 gk_FmIndex = gk_FmIndex_
111 endif
112
113 gk_FmCarrier_ chnget "gk_FmCarrier"
114 if gk_FmCarrier_ != 0 then
115 gk_FmCarrier = gk_FmCarrier_
116 endif
117
118 gk_ReverberationDelay_ chnget "gk_ReverberationDelay"
119 if gk_ReverberationDelay_ != 0 then
120 gk_ReverberationDelay = gk_ReverberationDelay_
121 endif
122
123 gk_MasterLevel_ chnget "gk_MasterLevel"
124 if gk_MasterLevel_ != 0 then
125 gk_MasterLevel = gk_MasterLevel_
126 endif
127
128 endin
129
130 </CsInstruments>
131 <html>
132 <head>
133 </head>
134 <style type="text/css">
135 input[type='range'] {
136 -webkit-appearance: none;
137 border-radius: 5px;
138 box-shadow: inset 0 0 5px #333;
139 background-color: #999;
140 height: 10px;
141 width: 100%;
142 vertical-align: middle;
143 }
144 input[type=range]::-webkit-slider-thumb {
145 -webkit-appearance: none;
146 border: none;
147 height: 16px;
148 width: 16px;
149 border-radius: 50%;
150 background: yellow;
151 margin-top: -4px;
152 border-radius: 10px;
153 }
154 table td {
155 border-width: 2px;
156 padding: 8px;
157 border-style: solid;
158 border-color: transparent;
159 color:yellow;
160 background-color: teal;
161 font-family: sans-serif
162 }
163 </style>
164
165 <h1>Score Generator</h1>
166
167 <script>
168
169 var c = 0.99;
170 var y = 0.5;
171 function generate() {
172 csound.message("generate()...\n");
173 for (i = 0; i < 50; i++) {
174 var t = i * (1.0 / 3.0);
175 var y1 = 4.0 * c * y * (1.0 - y);
176 y = y1;
177 var key = Math.round(36.0 + (y * 60.0));
178 var note = "i 1 " + t + " 2.0 " + key + " 60 0.0 0.5\n";
179 csound.readScore(note);
180 };
181 };
182
183 function on_sliderC(value) {
184 c = parseFloat(value);
185 document.querySelector('#sliderCOutput').value = c;
186 }
187
188 function on_sliderFmIndex(value) {
189 var numberValue = parseFloat(value);
190 document.querySelector('#sliderFmIndexOutput').value = numberValue;
191 csound.setControlChannel('gk_FmIndex', numberValue);
192 }
193
194 function on_sliderFmRatio(value) {
195 var numberValue = parseFloat(value);
196 document.querySelector('#sliderFmRatioOutput').value = numberValue;
197 csound.setControlChannel('gk_FmCarrier', numberValue);
198 }
199
200 function on_sliderReverberationDelay(value) {
201 var numberValue = parseFloat(value);
202 document.querySelector('#sliderReverberationDelayOutput').value = numberValue;
203 csound.setControlChannel('gk_ReverberationDelay', numberValue);
204 }
205
206 function on_sliderMasterLevel(value) {
207 var numberValue = parseFloat(value);
208 document.querySelector('#sliderMasterLevelOutput').value = numberValue;
209 csound.setControlChannel('gk_MasterLevel', numberValue);
210 }
211
212 </script>
213
214 <table>
215 <col width="2*">
216 <col width="5*">
217 <col width="100px">
218
219 <tr>
220 <td>
221 <label for=sliderC>c</label>
222 <td>
223 <input type=range min=0 max=1 value=.5 id=sliderC step=0.001 oninput="on_sliderC(value)">
224 <td>
225 <output for=sliderC id=sliderCOutput>.5</output>
226 </tr>
227
228 <tr>
229 <td>
230 <label for=sliderFmIndex>Frequency modulation index</label>
231 <td>
232 <input type=range min=0 max=1 value=.5 id=sliderC step=0.001 oninput="on_sliderFmIndex(value)">
233 <td>
234 <output for=sliderFmIndex id=sliderFmIndexOutput>.5</output>
235 </tr>
236
237 <tr>
238 <td>
239 <label for=sliderFmRatio>Frequency modulation ratio</label>
240 <td>
241 <input type=range min=0 max=1 value=.5 id=sliderFmRatio step=0.001 oninput="on_sliderFmRatio(value)">
242 <td>
243 <output for=sliderFmRatio id=sliderFmRatioOutput>.5</output>
244 </tr>
245
246 <tr>
247 <td>
248 <label for=sliderReverberationDelay>Reverberation delay</label>
249 <td>
250 <input type=range min=0 max=1 value=.5 id=sliderReverberationDelay step=0.001 oninput="on_sliderReverberationDelay(value)">
251 <td>
252 <output for=sliderReverberationDelay id=sliderReverberationDelayOutput>.5</output>
253 </tr>
254
255 <tr>
256 <td>
257 <label for=sliderMasterLevel>Master output level</label>
258 <td>
259 <input type=range min=0 max=1 value=.5 id=sliderMasterLevel step=0.001 oninput="on_sliderMasterLevel(value)">
260 <td>
261 <output for=sliderMasterLevel id=sliderMasterLevelOutput>.5</output>
262 </tr>
263
264 <tr>
265 <td>
266 <button onclick="generate()"> Generate score </button>
267 </td>
268 </tr>
269
270 </table>
271
272 </html>
273 <CsScore>
274 </CsScore>
275 </CsoundSynthesizer>
276 prints "dbA at headroom: %9.4f\n", idbaheadroom
277 iampheadroom init ampdb(idbaheadroom)
278 prints "Amplitude at headroom: %9.4f\n", iampheadroom
279 prints "Balance so the overall amps at the end of performance -6 dbfs.\n"
280
281 connect "ModerateFM", "outleft", "Reverberation", "inleft"
282 connect "ModerateFM", "outright", "Reverberation", "inright"
283 connect "Reverberation", "outleft", "MasterOutput", "inleft"
284 connect "Reverberation", "outright", "MasterOutput", "inright"
285
286 alwayson "Reverberation"
287 alwayson "MasterOutput"
288 alwayson "Controls"
289
290 gk_FmIndex init 0.5
291 gk_FmCarrier init 1
292 instr ModerateFM
293 //////////////////////////////////////////////
294 // By Michael Gogins.
295 //////////////////////////////////////////////
296 i_instrument = p1
297 i_time = p2
298 i_duration = p3
299 i_midikey = p4
300 i_midivelocity = p5
301 i_phase = p6
302 i_pan = p7
303 i_depth = p8
304 i_height = p9
305 i_pitchclassset = p10
306 i_homogeneity = p11
307 iattack = 0.002
308 isustain = p3
309 idecay = 8
310 irelease = 0.05
311 iHz = cpsmidinn(i_midikey)
312 idB = i_midivelocity
313 iamplitude = ampdb(idB) * 4.0
314 kcarrier = gk_FmCarrier
315 imodulator = 0.5
316 ifmamplitude = 0.25
317 kindex = gk_FmIndex * 20
318 ifrequencyb = iHz * 1.003
319 kcarrierb = kcarrier * 1.004
320 aindenv transeg 0.0, iattack, -11.0, 1.0, idecay, -7.0, 0.025, isustain, 0.0, 0.025, irelease, -7.0, 0.0
321 aindex = aindenv * kindex * ifmamplitude
322 isinetable ftgenonce 0, 0, 65536, 10, 1, 0, .02
323 ; ares foscili xamp, kcps, xcar, xmod, kndx, ifn [, iphs]
324 aouta foscili 1.0, iHz, kcarrier, imodulator, kindex / 4., isinetable
325 aoutb foscili 1.0, ifrequencyb, kcarrierb, imodulator, kindex, isinetable
326 ; Plus amplitude correction.
327 asignal = (aouta + aoutb) * aindenv
328 adeclick linsegr 0, iattack, 1, isustain, 1, irelease, 0
329 asignal = asignal * iamplitude
330 aoutleft, aoutright pan2 asignal * adeclick, i_pan
331 outleta "outleft", aoutleft
332 outleta "outright", aoutright
333 prints "instr %4d t %9.4f d %9.4f k %9.4f v %9.4f p %9.4f\n", p1, p2, p3, p4, p5, p7
334 endin
335
336 gkReverberationWet init .5
337 gk_ReverberationDelay init .6
338 instr Reverberation
339 ainleft inleta "inleft"
340 ainright inleta "inright"
341 aoutleft = ainleft
342 aoutright = ainright
343 kdry = 1.0 - gkReverberationWet
344 awetleft, awetright reverbsc ainleft, ainright, gk_ReverberationDelay, 18000.0
345 aoutleft = ainleft * kdry + awetleft * gkReverberationWet
346 aoutright = ainright * kdry + awetright * gkReverberationWet
347 outleta "outleft", aoutleft
348 outleta "outright", aoutright
349 prints "instr %4d t %9.4f d %9.4f k %9.4f v %9.4f p %9.4f\n", p1, p2, p3, p4, p5, p7
350 endin
351
352 gk_MasterLevel init 1
353 instr MasterOutput
354 ainleft inleta "inleft"
355 ainright inleta "inright"
356 aoutleft = gk_MasterLevel * ainleft
357 aoutright = gk_MasterLevel * ainright
358 outs aoutleft, aoutright
359 prints "instr %4d t %9.4f d %9.4f k %9.4f v %9.4f p %9.4f\n", p1, p2, p3, p4, p5, p7
360 endin
361
362 instr Controls
363
364 gk_FmIndex_ chnget "gk_FmIndex"
365 if gk_FmIndex_ != 0 then
366 gk_FmIndex = gk_FmIndex_
367 endif
368
369 gk_FmCarrier_ chnget "gk_FmCarrier"
370 if gk_FmCarrier_ != 0 then
371 gk_FmCarrier = gk_FmCarrier_
372 endif
373
374 gk_ReverberationDelay_ chnget "gk_ReverberationDelay"
375 if gk_ReverberationDelay_ != 0 then
376 gk_ReverberationDelay = gk_ReverberationDelay_
377 endif
378
379 gk_MasterLevel_ chnget "gk_MasterLevel"
380 if gk_MasterLevel_ != 0 then
381 gk_MasterLevel = gk_MasterLevel_
382 endif
383
384 endin
385
386 </CsInstruments>
387 <html>
388 <head>
389 </head>
390 <style type="text/css">
391 input[type='range'] {
392 -webkit-appearance: none;
393 border-radius: 5px;
394 box-shadow: inset 0 0 5px #333;
395 background-color: #999;
396 height: 10px;
397 width: 100%;
398 vertical-align: middle;
399 }
400 input[type=range]::-webkit-slider-thumb {
401 -webkit-appearance: none;
402 border: none;
403 height: 16px;
404 width: 16px;
405 border-radius: 50%;
406 background: yellow;
407 margin-top: -4px;
408 border-radius: 10px;
409 }
410 table td {
411 border-width: 2px;
412 padding: 8px;
413 border-style: solid;
414 border-color: transparent;
415 color:yellow;
416 background-color: teal;
417 font-family: sans-serif
418 }
419 </style>
420
421 <h1>Score Generator</h1>
422
423 <script>
424
425 var c = 0.99;
426 var y = 0.5;
427 function generate() {
428 csound.message("generate()...\n");
429 for (i = 0; i < 50; i++) {
430 var t = i * (1.0 / 3.0);
431 var y1 = 4.0 * c * y * (1.0 - y);
432 y = y1;
433 var key = Math.round(36.0 + (y * 60.0));
434 var note = "i 1 " + t + " 2.0 " + key + " 60 0.0 0.5\n";
435 csound.readScore(note);
436 };
437 };
438
439 function on_sliderC(value) {
440 c = parseFloat(value);
441 document.querySelector('#sliderCOutput').value = c;
442 }
443
444 function on_sliderFmIndex(value) {
445 var numberValue = parseFloat(value);
446 document.querySelector('#sliderFmIndexOutput').value = numberValue;
447 csound.setControlChannel('gk_FmIndex', numberValue);
448 }
449
450 function on_sliderFmRatio(value) {
451 var numberValue = parseFloat(value);
452 document.querySelector('#sliderFmRatioOutput').value = numberValue;
453 csound.setControlChannel('gk_FmCarrier', numberValue);
454 }
455
456 function on_sliderReverberationDelay(value) {
457 var numberValue = parseFloat(value);
458 document.querySelector('#sliderReverberationDelayOutput').value = numberValue;
459 csound.setControlChannel('gk_ReverberationDelay', numberValue);
460 }
461
462 function on_sliderMasterLevel(value) {
463 var numberValue = parseFloat(value);
464 document.querySelector('#sliderMasterLevelOutput').value = numberValue;
465 csound.setControlChannel('gk_MasterLevel', numberValue);
466 }
467
468 </script>
469
470 <table>
471 <col width="2*">
472 <col width="5*">
473 <col width="100px">
474
475 <tr>
476 <td>
477 <label for=sliderC>c</label>
478 <td>
479 <input type=range min=0 max=1 value=.5 id=sliderC step=0.001 oninput="on_sliderC(value)">
480 <td>
481 <output for=sliderC id=sliderCOutput>.5</output>
482 </tr>
483
484 <tr>
485 <td>
486 <label for=sliderFmIndex>Frequency modulation index</label>
487 <td>
488 <input type=range min=0 max=1 value=.5 id=sliderC step=0.001 oninput="on_sliderFmIndex(value)">
489 <td>
490 <output for=sliderFmIndex id=sliderFmIndexOutput>.5</output>
491 </tr>
492
493 <tr>
494 <td>
495 <label for=sliderFmRatio>Frequency modulation ratio</label>
496 <td>
497 <input type=range min=0 max=1 value=.5 id=sliderFmRatio step=0.001 oninput="on_sliderFmRatio(value)">
498 <td>
499 <output for=sliderFmRatio id=sliderFmRatioOutput>.5</output>
500 </tr>
501
502 <tr>
503 <td>
504 <label for=sliderReverberationDelay>Reverberation delay</label>
505 <td>
506 <input type=range min=0 max=1 value=.5 id=sliderReverberationDelay step=0.001 oninput="on_sliderReverberationDelay(value)">
507 <td>
508 <output for=sliderReverberationDelay id=sliderReverberationDelayOutput>.5</output>
509 </tr>
510
511 <tr>
512 <td>
513 <label for=sliderMasterLevel>Master output level</label>
514 <td>
515 <input type=range min=0 max=1 value=.5 id=sliderMasterLevel step=0.001 oninput="on_sliderMasterLevel(value)">
516 <td>
517 <output for=sliderMasterLevel id=sliderMasterLevelOutput>.5</output>
518 </tr>
519
520 <tr>
521 <td>
522 <button onclick="generate()"> Generate score </button>
523 </td>
524 </tr>
525
526 </table>
527
528 </html>
529 <CsScore>
530 </CsScore>
531 </CsoundSynthesizer>
532 <bsbPanel>
533 <label>Widgets</label>
534 <objectName/>
535 <x>100</x>
536 <y>100</y>
537 <width>320</width>
538 <height>240</height>
539 <visible>true</visible>
540 <uuid/>
541 <bgcolor mode="nobackground">
542 <r>255</r>
543 <g>255</g>
544 <b>255</b>
545 </bgcolor>
546 </bsbPanel>
547 <bsbPresets>
548 </bsbPresets>