1/* Getting Started .. Realtime Interaction: Widgets-Checkbox 2 3Open the Widgets-Panel. 4 5It contains an arrangement of checkboxes and a controller-window. 6 7The controller window is a two dimensional fader, so it sends values on two different channels. 8 9Checkboxes work similar to buttons, but keep their last state. They work very well, to turn on/off parts of an instrument. 10The checkbox condition can be verified while the instrument runs. This is made with the "if .. then .. endif" construct. 11The "if" part checks the condition. If it is <true>, then the "then" part will be executed, if it is <false>, it jumps directly to the endif. 12 13To find out more about the possibilities and usage of widgets, have a look into the widgets reference. (Examples->Widgets) 14*/ 15 16<CsoundSynthesizer> 17<CsOptions> 18</CsOptions> 19<CsInstruments> 20 21sr = 44100 22ksmps = 128 23nchnls = 1 240dbfs = 1 25 26instr 1 27; read checkboxes 28kRead invalue "read" 29kSound invalue "sound" 30kDance invalue "dance" 31 32 33if kRead == 1 then 34 ; Read Point values 35 kpoint_x invalue "point_x" 36 kpoint_y invalue "point_y" 37 printks "(x: %f, y: %f)%n", 0.2, kpoint_x, kpoint_y 38endif 39 40if kSound == 1 then 41 ; Sound Point 42 kpoint_x invalue "point_x" 43 kpoint_y invalue "point_y" 44 apoint_x interp kpoint_x ; casts both k-signals ... 45 apoint_y interp kpoint_y ; ... to audiorate 46 aOut oscili apoint_y, apoint_x*1000, 1 47 out aOut 48endif 49 50if kDance == 1 then 51 ; Dance Point 52 knew_x randomh 0, 1, 15 53 knew_y randomh 0, 1, 15 54 outvalue "point_x", knew_x 55 outvalue "point_y", knew_y 56endif 57endin 58 59 60</CsInstruments> 61<CsScore> 62f 1 0 1024 10 1 63i 1 0 3600 64e 65</CsScore> 66</CsoundSynthesizer> 67; written by Alex Hofmann (Dec. 2009) - Incontri HMT-Hannover 68 69 70 71 72 73 74<bsbPanel> 75 <label>Widgets</label> 76 <objectName/> 77 <x>1013</x> 78 <y>279</y> 79 <width>563</width> 80 <height>397</height> 81 <visible>true</visible> 82 <uuid/> 83 <bgcolor mode="background"> 84 <r>132</r> 85 <g>162</g> 86 <b>8</b> 87 </bgcolor> 88 <bsbObject version="2" type="BSBController"> 89 <objectName>point_y</objectName> 90 <x>30</x> 91 <y>195</y> 92 <width>318</width> 93 <height>253</height> 94 <uuid>{7b88d65c-1539-4552-8c37-0c566fb3c631}</uuid> 95 <visible>true</visible> 96 <midichan>0</midichan> 97 <midicc>-3</midicc> 98 <objectName2>point_x</objectName2> 99 <xMin>0.00000000</xMin> 100 <xMax>1.00000000</xMax> 101 <yMin>0.00000000</yMin> 102 <yMax>1.00000000</yMax> 103 <xValue>0.61348438</xValue> 104 <yValue>0.47489458</yValue> 105 <type>point</type> 106 <pointsize>7</pointsize> 107 <fadeSpeed>0.00000000</fadeSpeed> 108 <mouseControl act="press">jump</mouseControl> 109 <color> 110 <r>0</r> 111 <g>234</g> 112 <b>0</b> 113 </color> 114 <randomizable mode="both" group="0">false</randomizable> 115 <bgcolor> 116 <r>0</r> 117 <g>0</g> 118 <b>0</b> 119 </bgcolor> 120 </bsbObject> 121 <bsbObject version="2" type="BSBLabel"> 122 <objectName/> 123 <x>31</x> 124 <y>32</y> 125 <width>134</width> 126 <height>30</height> 127 <uuid>{5d76e7c2-5c54-4aa6-b637-344e10818acd}</uuid> 128 <visible>true</visible> 129 <midichan>0</midichan> 130 <midicc>-3</midicc> 131 <label>1. Run Csound</label> 132 <alignment>left</alignment> 133 <font>Helvetica</font> 134 <fontsize>14</fontsize> 135 <precision>3</precision> 136 <color> 137 <r>0</r> 138 <g>0</g> 139 <b>0</b> 140 </color> 141 <bgcolor mode="nobackground"> 142 <r>255</r> 143 <g>255</g> 144 <b>255</b> 145 </bgcolor> 146 <bordermode>noborder</bordermode> 147 <borderradius>1</borderradius> 148 <borderwidth>1</borderwidth> 149 </bsbObject> 150 <bsbObject version="2" type="BSBLabel"> 151 <objectName/> 152 <x>31</x> 153 <y>123</y> 154 <width>135</width> 155 <height>73</height> 156 <uuid>{a61ce639-4796-4143-9d31-67e36f6ce9d5}</uuid> 157 <visible>true</visible> 158 <midichan>0</midichan> 159 <midicc>-3</midicc> 160 <label>Read out the point position and print it to the console.</label> 161 <alignment>left</alignment> 162 <font>Lucida Grande</font> 163 <fontsize>10</fontsize> 164 <precision>3</precision> 165 <color> 166 <r>0</r> 167 <g>0</g> 168 <b>0</b> 169 </color> 170 <bgcolor mode="nobackground"> 171 <r>255</r> 172 <g>255</g> 173 <b>255</b> 174 </bgcolor> 175 <bordermode>noborder</bordermode> 176 <borderradius>1</borderradius> 177 <borderwidth>1</borderwidth> 178 </bsbObject> 179 <bsbObject version="2" type="BSBLabel"> 180 <objectName/> 181 <x>361</x> 182 <y>123</y> 183 <width>120</width> 184 <height>70</height> 185 <uuid>{85a10aea-c364-4c4e-a872-505d4d0c0776}</uuid> 186 <visible>true</visible> 187 <midichan>0</midichan> 188 <midicc>-3</midicc> 189 <label>Send random position data to the point.</label> 190 <alignment>left</alignment> 191 <font>Lucida Grande</font> 192 <fontsize>10</fontsize> 193 <precision>3</precision> 194 <color> 195 <r>0</r> 196 <g>0</g> 197 <b>0</b> 198 </color> 199 <bgcolor mode="nobackground"> 200 <r>255</r> 201 <g>255</g> 202 <b>255</b> 203 </bgcolor> 204 <bordermode>noborder</bordermode> 205 <borderradius>1</borderradius> 206 <borderwidth>1</borderwidth> 207 </bsbObject> 208 <bsbObject version="2" type="BSBLabel"> 209 <objectName/> 210 <x>182</x> 211 <y>124</y> 212 <width>161</width> 213 <height>64</height> 214 <uuid>{224f540f-525e-43d3-98b1-f5367dd76d89}</uuid> 215 <visible>true</visible> 216 <midichan>0</midichan> 217 <midicc>-3</midicc> 218 <label>Use point position data to control an oscils amplitude and frequency.</label> 219 <alignment>left</alignment> 220 <font>Lucida Grande</font> 221 <fontsize>10</fontsize> 222 <precision>3</precision> 223 <color> 224 <r>0</r> 225 <g>0</g> 226 <b>0</b> 227 </color> 228 <bgcolor mode="nobackground"> 229 <r>255</r> 230 <g>255</g> 231 <b>255</b> 232 </bgcolor> 233 <bordermode>noborder</bordermode> 234 <borderradius>1</borderradius> 235 <borderwidth>1</borderwidth> 236 </bsbObject> 237 <bsbObject version="2" type="BSBConsole"> 238 <objectName/> 239 <x>361</x> 240 <y>195</y> 241 <width>183</width> 242 <height>252</height> 243 <uuid>{a75f9ef6-a277-4f6b-bcf7-4b3d0ddfc6fe}</uuid> 244 <visible>true</visible> 245 <midichan>0</midichan> 246 <midicc>-3</midicc> 247 <font>Courier</font> 248 <fontsize>8</fontsize> 249 <color> 250 <r>0</r> 251 <g>0</g> 252 <b>0</b> 253 </color> 254 <bgcolor mode="nobackground"> 255 <r>255</r> 256 <g>255</g> 257 <b>255</b> 258 </bgcolor> 259 </bsbObject> 260 <bsbObject version="2" type="BSBLabel"> 261 <objectName/> 262 <x>30</x> 263 <y>66</y> 264 <width>514</width> 265 <height>39</height> 266 <uuid>{5e3f1106-b2bd-4a74-98a1-2023743bda81}</uuid> 267 <visible>true</visible> 268 <midichan>0</midichan> 269 <midicc>-3</midicc> 270 <label>2. Press one of these three buttons and move the point.</label> 271 <alignment>left</alignment> 272 <font>Helvetica</font> 273 <fontsize>14</fontsize> 274 <precision>3</precision> 275 <color> 276 <r>0</r> 277 <g>0</g> 278 <b>0</b> 279 </color> 280 <bgcolor mode="nobackground"> 281 <r>255</r> 282 <g>255</g> 283 <b>255</b> 284 </bgcolor> 285 <bordermode>noborder</bordermode> 286 <borderradius>1</borderradius> 287 <borderwidth>1</borderwidth> 288 </bsbObject> 289 <bsbObject version="2" type="BSBButton"> 290 <objectName>_Play</objectName> 291 <x>173</x> 292 <y>32</y> 293 <width>100</width> 294 <height>30</height> 295 <uuid>{b8851d94-4074-488b-95f4-9cfb9d01a4aa}</uuid> 296 <visible>true</visible> 297 <midichan>0</midichan> 298 <midicc>-3</midicc> 299 <type>value</type> 300 <pressedValue>1.00000000</pressedValue> 301 <stringvalue/> 302 <text>Run Csound</text> 303 <image>/</image> 304 <eventLine>i1 0 10</eventLine> 305 <latch>false</latch> 306 <latched>false</latched> 307 </bsbObject> 308 <bsbObject version="2" type="BSBCheckBox"> 309 <objectName>read</objectName> 310 <x>30</x> 311 <y>103</y> 312 <width>20</width> 313 <height>20</height> 314 <uuid>{15e01f48-48f0-4107-8a0d-ca8e9a9c2b5f}</uuid> 315 <visible>true</visible> 316 <midichan>0</midichan> 317 <midicc>-3</midicc> 318 <selected>false</selected> 319 <label/> 320 <pressedValue>1</pressedValue> 321 <randomizable group="0">false</randomizable> 322 </bsbObject> 323 <bsbObject version="2" type="BSBCheckBox"> 324 <objectName>sound</objectName> 325 <x>183</x> 326 <y>103</y> 327 <width>20</width> 328 <height>20</height> 329 <uuid>{cfba4b21-f2fd-4235-bd00-2d1078632488}</uuid> 330 <visible>true</visible> 331 <midichan>0</midichan> 332 <midicc>-3</midicc> 333 <selected>false</selected> 334 <label/> 335 <pressedValue>1</pressedValue> 336 <randomizable group="0">false</randomizable> 337 </bsbObject> 338 <bsbObject version="2" type="BSBCheckBox"> 339 <objectName>dance</objectName> 340 <x>360</x> 341 <y>105</y> 342 <width>20</width> 343 <height>20</height> 344 <uuid>{281f87bc-d138-4dbf-b70e-fc8ca1ed78ab}</uuid> 345 <visible>true</visible> 346 <midichan>0</midichan> 347 <midicc>-3</midicc> 348 <selected>false</selected> 349 <label/> 350 <pressedValue>1</pressedValue> 351 <randomizable group="0">false</randomizable> 352 </bsbObject> 353</bsbPanel> 354<bsbPresets> 355</bsbPresets> 356<EventPanel name="" tempo="60.00000000" loop="8.00000000" x="320" y="218" width="604" height="322" visible="true" loopStart="0" loopEnd="0"> </EventPanel> 357