| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
</CsOptions> |
| 4 |
<CsInstruments> |
| 5 |
|
| 6 |
sr = 44100 |
| 7 |
ksmps = 128 |
| 8 |
nchnls = 2 |
| 9 |
0dbfs = 1 |
| 10 |
; Based on manual example by schwaheed |
| 11 |
|
| 12 |
massign 0, 0 ; disable triggering of notes |
| 13 |
pgmassign 0, 0 |
| 14 |
|
| 15 |
instr 1 ;Generate MIDI note |
| 16 |
ktime timeinsts |
| 17 |
noteon 1, 60, 100 |
| 18 |
if (ktime > p3/2) then |
| 19 |
reinit endnote |
| 20 |
turnoff |
| 21 |
endif |
| 22 |
goto end |
| 23 |
endnote: |
| 24 |
noteoff 1, 60, 100 |
| 25 |
end: |
| 26 |
endin |
| 27 |
|
| 28 |
instr 130 |
| 29 |
|
| 30 |
knotelength init 0 |
| 31 |
knoteontime init 0 |
| 32 |
|
| 33 |
kstatus, kchan, kdata1, kdata2 midiin |
| 34 |
|
| 35 |
if (kstatus == 128) then |
| 36 |
knoteofftime times |
| 37 |
knotelength = (knoteofftime - knoteontime)*1000 |
| 38 |
Stext sprintfk "Note Off: chan = %d note# = %d velocity = %d length = %d", kchan, kdata1,kdata2, knotelength |
| 39 |
outvalue "note", Stext |
| 40 |
|
| 41 |
elseif (kstatus == 144) then |
| 42 |
if (kdata2 == 0) then |
| 43 |
knoteofftime times |
| 44 |
knotelength = (knoteofftime - knoteontime)*1000 |
| 45 |
printk2 knotelength |
| 46 |
Stext sprintfk "Note On: chan = %d note# = %d velocity = %d length = %d", kchan, kdata1, kdata2, knotelength |
| 47 |
else |
| 48 |
Stext sprintfk "Note On: chan = %d note# = %d velocity = %d", kchan, kdata1, kdata2 |
| 49 |
knoteontime times |
| 50 |
endif |
| 51 |
outvalue "note", Stext |
| 52 |
|
| 53 |
elseif (kstatus == 160) then |
| 54 |
printks "kstatus= %d, kchan = %d, \\tkdata1 = %d, kdata2 = %d \\tPolyphonic Aftertouch\\n", 0, kstatus, kchan, kdata1, kdata2 |
| 55 |
|
| 56 |
elseif (kstatus == 176) then |
| 57 |
Stext sprintfk "%d", kdata1 |
| 58 |
outvalue "cc", Stext |
| 59 |
Stext sprintfk "%d", kdata2 |
| 60 |
outvalue "ccvalue", Stext |
| 61 |
Stext sprintfk "%d", kchan |
| 62 |
outvalue "channel", Stext |
| 63 |
|
| 64 |
elseif (kstatus == 192) then |
| 65 |
printks "kstatus= %d, kchan = %d, \\tkdata1 = %d, kdata2 = %d \\tProgram Change\\n", 0, kstatus, kchan, kdata1, kdata2 |
| 66 |
|
| 67 |
elseif (kstatus == 208) then |
| 68 |
printks "kstatus= %d, kchan = %d, \\tkdata1 = %d, kdata2 = %d \\tChannel Aftertouch\\n", 0, kstatus, kchan, kdata1, kdata2 |
| 69 |
|
| 70 |
elseif (kstatus == 224) then |
| 71 |
printks "kstatus= %d, kchan = %d, \\t ( data1 , kdata2 ) = ( %d, %d )\\tPitch Bend\\n", 0, kstatus, kchan, kdata1, kdata2 |
| 72 |
endif |
| 73 |
|
| 74 |
kcontinuous invalue "continuous" |
| 75 |
if (kcontinuous == 1) then |
| 76 |
ktrigger metro 1 |
| 77 |
schedkwhen ktrigger, 0.2, 2, 1, 0, 0.5 |
| 78 |
endif |
| 79 |
|
| 80 |
endin |
| 81 |
|
| 82 |
|
| 83 |
</CsInstruments> |
| 84 |
<CsScore> |
| 85 |
|
| 86 |
i130 0 3600 |
| 87 |
e |
| 88 |
</CsScore> |
| 89 |
</CsoundSynthesizer> |
| 90 |
<bsbPanel> |
| 91 |
<label>Widgets</label> |
| 92 |
<objectName/> |
| 93 |
<x>0</x> |
| 94 |
<y>0</y> |
| 95 |
<width>387</width> |
| 96 |
<height>245</height> |
| 97 |
<visible>true</visible> |
| 98 |
<uuid/> |
| 99 |
<bgcolor mode="background"> |
| 100 |
<r>0</r> |
| 101 |
<g>162</g> |
| 102 |
<b>207</b> |
| 103 |
</bgcolor> |
| 104 |
<bsbObject version="2" type="BSBLabel"> |
| 105 |
<objectName/> |
| 106 |
<x>4</x> |
| 107 |
<y>44</y> |
| 108 |
<width>382</width> |
| 109 |
<height>82</height> |
| 110 |
<uuid>{a622c79b-7121-4536-a2e0-b015e89d9ce8}</uuid> |
| 111 |
<visible>true</visible> |
| 112 |
<midichan>0</midichan> |
| 113 |
<midicc>-3</midicc> |
| 114 |
<label>Note events:</label> |
| 115 |
<alignment>left</alignment> |
| 116 |
<font>Courier 10 Pitch</font> |
| 117 |
<fontsize>12</fontsize> |
| 118 |
<precision>3</precision> |
| 119 |
<color> |
| 120 |
<r>0</r> |
| 121 |
<g>0</g> |
| 122 |
<b>0</b> |
| 123 |
</color> |
| 124 |
<bgcolor mode="nobackground"> |
| 125 |
<r>255</r> |
| 126 |
<g>255</g> |
| 127 |
<b>255</b> |
| 128 |
</bgcolor> |
| 129 |
<bordermode>border</bordermode> |
| 130 |
<borderradius>1</borderradius> |
| 131 |
<borderwidth>1</borderwidth> |
| 132 |
</bsbObject> |
| 133 |
<bsbObject version="2" type="BSBLabel"> |
| 134 |
<objectName/> |
| 135 |
<x>4</x> |
| 136 |
<y>129</y> |
| 137 |
<width>184</width> |
| 138 |
<height>116</height> |
| 139 |
<uuid>{f06fb4fb-fa71-4a65-b1f9-5059aa8f3f98}</uuid> |
| 140 |
<visible>true</visible> |
| 141 |
<midichan>0</midichan> |
| 142 |
<midicc>-3</midicc> |
| 143 |
<label>Control Change:</label> |
| 144 |
<alignment>left</alignment> |
| 145 |
<font>Courier 10 Pitch</font> |
| 146 |
<fontsize>14</fontsize> |
| 147 |
<precision>3</precision> |
| 148 |
<color> |
| 149 |
<r>0</r> |
| 150 |
<g>0</g> |
| 151 |
<b>0</b> |
| 152 |
</color> |
| 153 |
<bgcolor mode="nobackground"> |
| 154 |
<r>255</r> |
| 155 |
<g>255</g> |
| 156 |
<b>255</b> |
| 157 |
</bgcolor> |
| 158 |
<bordermode>border</bordermode> |
| 159 |
<borderradius>1</borderradius> |
| 160 |
<borderwidth>1</borderwidth> |
| 161 |
</bsbObject> |
| 162 |
<bsbObject version="2" type="BSBDisplay"> |
| 163 |
<objectName>cc</objectName> |
| 164 |
<x>130</x> |
| 165 |
<y>159</y> |
| 166 |
<width>40</width> |
| 167 |
<height>25</height> |
| 168 |
<uuid>{7d5482f8-90ac-4c15-85e9-6686099dea99}</uuid> |
| 169 |
<visible>true</visible> |
| 170 |
<midichan>0</midichan> |
| 171 |
<midicc>-3</midicc> |
| 172 |
<label>0</label> |
| 173 |
<alignment>left</alignment> |
| 174 |
<font>DejaVu Sans</font> |
| 175 |
<fontsize>14</fontsize> |
| 176 |
<precision>3</precision> |
| 177 |
<color> |
| 178 |
<r>0</r> |
| 179 |
<g>0</g> |
| 180 |
<b>0</b> |
| 181 |
</color> |
| 182 |
<bgcolor mode="background"> |
| 183 |
<r>255</r> |
| 184 |
<g>255</g> |
| 185 |
<b>255</b> |
| 186 |
</bgcolor> |
| 187 |
<bordermode>border</bordermode> |
| 188 |
<borderradius>1</borderradius> |
| 189 |
<borderwidth>1</borderwidth> |
| 190 |
</bsbObject> |
| 191 |
<bsbObject version="2" type="BSBDisplay"> |
| 192 |
<objectName>ccvalue</objectName> |
| 193 |
<x>130</x> |
| 194 |
<y>184</y> |
| 195 |
<width>40</width> |
| 196 |
<height>25</height> |
| 197 |
<uuid>{49f26ebe-4789-4aa7-a303-0fd7a0758ca5}</uuid> |
| 198 |
<visible>true</visible> |
| 199 |
<midichan>0</midichan> |
| 200 |
<midicc>-3</midicc> |
| 201 |
<label>0</label> |
| 202 |
<alignment>left</alignment> |
| 203 |
<font>DejaVu Sans</font> |
| 204 |
<fontsize>14</fontsize> |
| 205 |
<precision>3</precision> |
| 206 |
<color> |
| 207 |
<r>0</r> |
| 208 |
<g>0</g> |
| 209 |
<b>0</b> |
| 210 |
</color> |
| 211 |
<bgcolor mode="background"> |
| 212 |
<r>240</r> |
| 213 |
<g>220</g> |
| 214 |
<b>229</b> |
| 215 |
</bgcolor> |
| 216 |
<bordermode>border</bordermode> |
| 217 |
<borderradius>1</borderradius> |
| 218 |
<borderwidth>1</borderwidth> |
| 219 |
</bsbObject> |
| 220 |
<bsbObject version="2" type="BSBDisplay"> |
| 221 |
<objectName>channel</objectName> |
| 222 |
<x>130</x> |
| 223 |
<y>209</y> |
| 224 |
<width>40</width> |
| 225 |
<height>25</height> |
| 226 |
<uuid>{b69d20a4-4a3a-43b9-be8d-365f892654e9}</uuid> |
| 227 |
<visible>true</visible> |
| 228 |
<midichan>0</midichan> |
| 229 |
<midicc>-3</midicc> |
| 230 |
<label>0</label> |
| 231 |
<alignment>left</alignment> |
| 232 |
<font>DejaVu Sans</font> |
| 233 |
<fontsize>14</fontsize> |
| 234 |
<precision>3</precision> |
| 235 |
<color> |
| 236 |
<r>0</r> |
| 237 |
<g>0</g> |
| 238 |
<b>0</b> |
| 239 |
</color> |
| 240 |
<bgcolor mode="background"> |
| 241 |
<r>220</r> |
| 242 |
<g>217</g> |
| 243 |
<b>255</b> |
| 244 |
</bgcolor> |
| 245 |
<bordermode>border</bordermode> |
| 246 |
<borderradius>1</borderradius> |
| 247 |
<borderwidth>1</borderwidth> |
| 248 |
</bsbObject> |
| 249 |
<bsbObject version="2" type="BSBButton"> |
| 250 |
<objectName>button1</objectName> |
| 251 |
<x>201</x> |
| 252 |
<y>133</y> |
| 253 |
<width>179</width> |
| 254 |
<height>26</height> |
| 255 |
<uuid>{e610428b-9613-492f-981a-ec823dddd59f}</uuid> |
| 256 |
<visible>true</visible> |
| 257 |
<midichan>0</midichan> |
| 258 |
<midicc>-3</midicc> |
| 259 |
<type>event</type> |
| 260 |
<pressedValue>1.00000000</pressedValue> |
| 261 |
<stringvalue/> |
| 262 |
<text>Generate note</text> |
| 263 |
<image>/</image> |
| 264 |
<eventLine>i1 0 1</eventLine> |
| 265 |
<latch>false</latch> |
| 266 |
<latched>false</latched> |
| 267 |
</bsbObject> |
| 268 |
<bsbObject version="2" type="BSBCheckBox"> |
| 269 |
<objectName>continuous</objectName> |
| 270 |
<x>205</x> |
| 271 |
<y>171</y> |
| 272 |
<width>20</width> |
| 273 |
<height>20</height> |
| 274 |
<uuid>{3d9b96f9-6f0f-4dde-b950-a21cd70da655}</uuid> |
| 275 |
<visible>true</visible> |
| 276 |
<midichan>0</midichan> |
| 277 |
<midicc>-3</midicc> |
| 278 |
<selected>false</selected> |
| 279 |
<label/> |
| 280 |
<pressedValue>1</pressedValue> |
| 281 |
<randomizable group="0">false</randomizable> |
| 282 |
</bsbObject> |
| 283 |
<bsbObject version="2" type="BSBLabel"> |
| 284 |
<objectName/> |
| 285 |
<x>223</x> |
| 286 |
<y>166</y> |
| 287 |
<width>164</width> |
| 288 |
<height>29</height> |
| 289 |
<uuid>{bda319e2-b5c7-4c0d-bb0c-d18a8fd6ead6}</uuid> |
| 290 |
<visible>true</visible> |
| 291 |
<midichan>0</midichan> |
| 292 |
<midicc>-3</midicc> |
| 293 |
<label>Generate continuously</label> |
| 294 |
<alignment>left</alignment> |
| 295 |
<font>DejaVu Sans</font> |
| 296 |
<fontsize>14</fontsize> |
| 297 |
<precision>3</precision> |
| 298 |
<color> |
| 299 |
<r>0</r> |
| 300 |
<g>0</g> |
| 301 |
<b>0</b> |
| 302 |
</color> |
| 303 |
<bgcolor mode="nobackground"> |
| 304 |
<r>255</r> |
| 305 |
<g>255</g> |
| 306 |
<b>255</b> |
| 307 |
</bgcolor> |
| 308 |
<bordermode>noborder</bordermode> |
| 309 |
<borderradius>1</borderradius> |
| 310 |
<borderwidth>1</borderwidth> |
| 311 |
</bsbObject> |
| 312 |
<bsbObject version="2" type="BSBLabel"> |
| 313 |
<objectName/> |
| 314 |
<x>4</x> |
| 315 |
<y>162</y> |
| 316 |
<width>125</width> |
| 317 |
<height>24</height> |
| 318 |
<uuid>{c59e3dc3-2170-4a7e-a86c-98a87c617b34}</uuid> |
| 319 |
<visible>true</visible> |
| 320 |
<midichan>0</midichan> |
| 321 |
<midicc>-3</midicc> |
| 322 |
<label>Controller number CC#</label> |
| 323 |
<alignment>right</alignment> |
| 324 |
<font>DejaVu Sans</font> |
| 325 |
<fontsize>10</fontsize> |
| 326 |
<precision>3</precision> |
| 327 |
<color> |
| 328 |
<r>0</r> |
| 329 |
<g>0</g> |
| 330 |
<b>0</b> |
| 331 |
</color> |
| 332 |
<bgcolor mode="nobackground"> |
| 333 |
<r>255</r> |
| 334 |
<g>255</g> |
| 335 |
<b>255</b> |
| 336 |
</bgcolor> |
| 337 |
<bordermode>noborder</bordermode> |
| 338 |
<borderradius>1</borderradius> |
| 339 |
<borderwidth>1</borderwidth> |
| 340 |
</bsbObject> |
| 341 |
<bsbObject version="2" type="BSBLabel"> |
| 342 |
<objectName/> |
| 343 |
<x>19</x> |
| 344 |
<y>187</y> |
| 345 |
<width>110</width> |
| 346 |
<height>25</height> |
| 347 |
<uuid>{3eebf83b-458e-4146-b6b0-24785b1ed43b}</uuid> |
| 348 |
<visible>true</visible> |
| 349 |
<midichan>0</midichan> |
| 350 |
<midicc>-3</midicc> |
| 351 |
<label>Value</label> |
| 352 |
<alignment>right</alignment> |
| 353 |
<font>DejaVu Sans</font> |
| 354 |
<fontsize>10</fontsize> |
| 355 |
<precision>3</precision> |
| 356 |
<color> |
| 357 |
<r>0</r> |
| 358 |
<g>0</g> |
| 359 |
<b>0</b> |
| 360 |
</color> |
| 361 |
<bgcolor mode="nobackground"> |
| 362 |
<r>255</r> |
| 363 |
<g>255</g> |
| 364 |
<b>255</b> |
| 365 |
</bgcolor> |
| 366 |
<bordermode>noborder</bordermode> |
| 367 |
<borderradius>1</borderradius> |
| 368 |
<borderwidth>1</borderwidth> |
| 369 |
</bsbObject> |
| 370 |
<bsbObject version="2" type="BSBLabel"> |
| 371 |
<objectName/> |
| 372 |
<x>33</x> |
| 373 |
<y>211</y> |
| 374 |
<width>96</width> |
| 375 |
<height>25</height> |
| 376 |
<uuid>{36be481e-3963-438c-8e92-ea9f9cc7f0cf}</uuid> |
| 377 |
<visible>true</visible> |
| 378 |
<midichan>0</midichan> |
| 379 |
<midicc>-3</midicc> |
| 380 |
<label>Channel</label> |
| 381 |
<alignment>right</alignment> |
| 382 |
<font>DejaVu Sans</font> |
| 383 |
<fontsize>10</fontsize> |
| 384 |
<precision>3</precision> |
| 385 |
<color> |
| 386 |
<r>0</r> |
| 387 |
<g>0</g> |
| 388 |
<b>0</b> |
| 389 |
</color> |
| 390 |
<bgcolor mode="nobackground"> |
| 391 |
<r>255</r> |
| 392 |
<g>255</g> |
| 393 |
<b>255</b> |
| 394 |
</bgcolor> |
| 395 |
<bordermode>noborder</bordermode> |
| 396 |
<borderradius>1</borderradius> |
| 397 |
<borderwidth>1</borderwidth> |
| 398 |
</bsbObject> |
| 399 |
<bsbObject version="2" type="BSBLabel"> |
| 400 |
<objectName>note</objectName> |
| 401 |
<x>4</x> |
| 402 |
<y>67</y> |
| 403 |
<width>381</width> |
| 404 |
<height>53</height> |
| 405 |
<uuid>{a8853b05-75b5-401d-b391-04e2eb716b5f}</uuid> |
| 406 |
<visible>true</visible> |
| 407 |
<midichan>0</midichan> |
| 408 |
<midicc>-3</midicc> |
| 409 |
<label>Note On: chan = 0 note# = 0 velocity = 0</label> |
| 410 |
<alignment>left</alignment> |
| 411 |
<font>DejaVu Sans</font> |
| 412 |
<fontsize>18</fontsize> |
| 413 |
<precision>3</precision> |
| 414 |
<color> |
| 415 |
<r>0</r> |
| 416 |
<g>0</g> |
| 417 |
<b>0</b> |
| 418 |
</color> |
| 419 |
<bgcolor mode="nobackground"> |
| 420 |
<r>255</r> |
| 421 |
<g>255</g> |
| 422 |
<b>255</b> |
| 423 |
</bgcolor> |
| 424 |
<bordermode>noborder</bordermode> |
| 425 |
<borderradius>1</borderradius> |
| 426 |
<borderwidth>1</borderwidth> |
| 427 |
</bsbObject> |
| 428 |
<bsbObject version="2" type="BSBLabel"> |
| 429 |
<objectName/> |
| 430 |
<x>5</x> |
| 431 |
<y>7</y> |
| 432 |
<width>382</width> |
| 433 |
<height>32</height> |
| 434 |
<uuid>{2b23d88f-41e4-4238-9dbd-cdfbb0a91c65}</uuid> |
| 435 |
<visible>true</visible> |
| 436 |
<midichan>0</midichan> |
| 437 |
<midicc>-3</midicc> |
| 438 |
<label>MIDI I/O</label> |
| 439 |
<alignment>center</alignment> |
| 440 |
<font>DejaVu Sans Mono</font> |
| 441 |
<fontsize>22</fontsize> |
| 442 |
<precision>3</precision> |
| 443 |
<color> |
| 444 |
<r>0</r> |
| 445 |
<g>0</g> |
| 446 |
<b>0</b> |
| 447 |
</color> |
| 448 |
<bgcolor mode="background"> |
| 449 |
<r>255</r> |
| 450 |
<g>255</g> |
| 451 |
<b>255</b> |
| 452 |
</bgcolor> |
| 453 |
<bordermode>noborder</bordermode> |
| 454 |
<borderradius>1</borderradius> |
| 455 |
<borderwidth>1</borderwidth> |
| 456 |
</bsbObject> |
| 457 |
</bsbPanel> |
| 458 |
<bsbPresets> |
| 459 |
</bsbPresets> |
| 460 |
<MacOptions> |
| 461 |
Version: 3 |
| 462 |
Render: Real |
| 463 |
Ask: Yes |
| 464 |
Functions: ioObject |
| 465 |
Listing: Window |
| 466 |
WindowBounds: 329 376 406 285 |
| 467 |
CurrentView: io |
| 468 |
IOViewEdit: On |
| 469 |
Options: -b128 -A -s -m167 -R |
| 470 |
</MacOptions> |
| 471 |
<MacGUI> |
| 472 |
ioView background {0, 41634, 53199} |
| 473 |
ioText {4, 44} {382, 82} label 0.000000 0.00100 "" left "Courier 10 Pitch" 12 {0, 0, 0} {59392, 59392, 59392} nobackground noborder Note events: |
| 474 |
ioText {4, 129} {184, 116} label 0.000000 0.00100 "" left "Courier 10 Pitch" 14 {0, 0, 0} {59392, 59392, 59392} nobackground noborder Control Change: |
| 475 |
ioText {130, 159} {40, 25} display 0.000000 0.00100 "cc" left "DejaVu Sans" 14 {0, 0, 0} {65280, 65280, 65280} nobackground noborder 0 |
| 476 |
ioText {130, 184} {40, 25} display 0.000000 0.00100 "ccvalue" left "DejaVu Sans" 14 {0, 0, 0} {61440, 56320, 58624} nobackground noborder 0 |
| 477 |
ioText {130, 209} {40, 25} display 0.000000 0.00100 "channel" left "DejaVu Sans" 14 {0, 0, 0} {56320, 55552, 65280} nobackground noborder 0 |
| 478 |
ioButton {201, 133} {179, 26} event 1.000000 "button1" "Generate note" "/" i1 0 1 |
| 479 |
ioCheckbox {205, 171} {20, 20} off continuous |
| 480 |
ioText {223, 166} {164, 29} label 0.000000 0.00100 "" left "DejaVu Sans" 14 {0, 0, 0} {59392, 59392, 59392} nobackground noborder Generate continuously |
| 481 |
ioText {4, 162} {125, 24} label 0.000000 0.00100 "" right "DejaVu Sans" 10 {0, 0, 0} {59392, 59392, 59392} nobackground noborder Controller number CC# |
| 482 |
ioText {19, 187} {110, 25} label 0.000000 0.00100 "" right "DejaVu Sans" 10 {0, 0, 0} {59392, 59392, 59392} nobackground noborder Value |
| 483 |
ioText {33, 211} {96, 25} label 0.000000 0.00100 "" right "DejaVu Sans" 10 {0, 0, 0} {59392, 59392, 59392} nobackground noborder Channel |
| 484 |
ioText {4, 67} {381, 53} label 0.000000 0.00100 "note" left "DejaVu Sans" 18 {0, 0, 0} {59392, 59392, 59392} nobackground noborder Note On: chan = 0 note# = 0 velocity = 0 |
| 485 |
ioText {5, 7} {382, 32} label 0.000000 0.00100 "" center "DejaVu Sans Mono" 22 {0, 0, 0} {65280, 65280, 65280} nobackground noborder MIDI I/O |
| 486 |
</MacGUI> |