| 1 |
; Minimal example about using html section in CSD |
| 2 |
; by Tarmo Johannes [email protected] 2016 |
| 3 |
|
| 4 |
<CsoundSynthesizer> |
| 5 |
<CsOptions> |
| 6 |
-odac -d |
| 7 |
</CsOptions> |
| 8 |
<html> |
| 9 |
<head> |
| 10 |
</head> |
| 11 |
<body bgcolor="lightblue"> |
| 12 |
<script> |
| 13 |
function onGetControlChannelCallback(value) { |
| 14 |
document.getElementById('testChannel').innerHTML = value; |
| 15 |
} // to test csound.getControlChannel with QtWebEngine |
| 16 |
</script> |
| 17 |
<h2>Minimal Csound-Html5 example</h2><br> |
| 18 |
<br> |
| 19 |
Frequency: |
| 20 |
<input type="range" id="slider" oninput='csound.setControlChannel("testChannel",this.value/100.0); '></input><br> |
| 21 |
<button id="button" onclick='csound.readScore("i 1 0 3")' >Event</button> |
| 22 |
<br><br> |
| 23 |
Get channel from csound with callback (QtWebchannel): <label id="getchannel"></label> <button onclick='csound.getControlChannel("testChannel", onGetControlChannelCallback)' >Get</button><br> |
| 24 |
Value from channel "testChannel": <label id="testChannel"></label><br> |
| 25 |
<br> |
| 26 |
Get as return value (QtWebkit) <button onclick='alert("TestChannel: "+csound.getControlChannel("testChannel"))'>Get as retrun value</button> |
| 27 |
|
| 28 |
<br> |
| 29 |
</body> |
| 30 |
</html> |
| 31 |
<CsInstruments> |
| 32 |
|
| 33 |
sr = 44100 |
| 34 |
nchnls = 2 |
| 35 |
0dbfs = 1 |
| 36 |
ksmps = 32 |
| 37 |
|
| 38 |
chnset 0.5, "testChannel" ; to test chnget in the host |
| 39 |
|
| 40 |
instr 1 |
| 41 |
kfreq= 200+chnget:k("testChannel")*500 |
| 42 |
printk2 kfreq |
| 43 |
aenv linen 1,0.1,p3,0.25 |
| 44 |
out poscil(0.5,kfreq)*aenv |
| 45 |
endin |
| 46 |
|
| 47 |
; schedule 1,0,0.1, 1 |
| 48 |
|
| 49 |
</CsInstruments> |
| 50 |
<CsScore> |
| 51 |
i 1 0 0.5 ; to hear if Csound is loaded |
| 52 |
f 0 3600 |
| 53 |
</CsScore> |
| 54 |
</CsoundSynthesizer> |
| 55 |
|
| 56 |
|
| 57 |
<bsbPanel> |
| 58 |
<label>Widgets</label> |
| 59 |
<objectName/> |
| 60 |
<x>100</x> |
| 61 |
<y>100</y> |
| 62 |
<width>320</width> |
| 63 |
<height>240</height> |
| 64 |
<visible>true</visible> |
| 65 |
<uuid/> |
| 66 |
<bgcolor mode="nobackground"> |
| 67 |
<r>255</r> |
| 68 |
<g>255</g> |
| 69 |
<b>255</b> |
| 70 |
</bgcolor> |
| 71 |
<bsbObject type="BSBButton" version="2"> |
| 72 |
<objectName>button0</objectName> |
| 73 |
<x>10</x> |
| 74 |
<y>19</y> |
| 75 |
<width>100</width> |
| 76 |
<height>30</height> |
| 77 |
<uuid>{d5a1d1e3-eb6f-461c-90dc-95647307dc87}</uuid> |
| 78 |
<visible>true</visible> |
| 79 |
<midichan>0</midichan> |
| 80 |
<midicc>0</midicc> |
| 81 |
<type>event</type> |
| 82 |
<pressedValue>1.00000000</pressedValue> |
| 83 |
<stringvalue/> |
| 84 |
<text>Play</text> |
| 85 |
<image>/</image> |
| 86 |
<eventLine>i1 0 1</eventLine> |
| 87 |
<latch>false</latch> |
| 88 |
<latched>false</latched> |
| 89 |
</bsbObject> |
| 90 |
</bsbPanel> |
| 91 |
<bsbPresets> |
| 92 |
</bsbPresets> |