Debian Codegraph @

src/Examples/CsoundQt/Getting Started/Realtime_Interaction/MIDI_Control_Data.csd

raw
1 /*Getting started.. Realtime Interaction: MIDI Controller 01 (Modulation)
2
3 The quickest way to control instruments with MIDI control-data (Modulation, Aftertouch, etc.) can be set up, by using 'ctrl7' opcode. It can be used directly in an instrument definition, and outputs the desired k-rate data.
4 ..
5 kMidiCC ctrl7 1, 1, 10, 5000 ; read 7-bit MIDI CC data from Ch.1, CC 01, and map to a range between 10-5000
6 aSrc oscili 0.8, kMidiCC, 1 ; now CC 01 controlls the frequency of this oscillator
7 ..
8 The disadvantage of that method would be, that you have no communication with the Widget-GUI.
9
10 In the example below, a separate instrument (instr 100) is built to receive the MIDI CC 01 (Modulation) constantly and send its values on channel "filter_freq".
11 In Instrument 101 the data from this channel is read and mapped to the filters frequency input.
12
13 By sending MIDI-Control-Data 01 on Channel 1 (CC 01 - with your keyboards modualtion wheel, or any other MIDI faderbox) you see the Widget-fader moving and can hear the filter adjustments in realtime, when playing a note. Adjusting the fader with the mouse is also still possible.
14 */
15
16 <CsoundSynthesizer>
17 <CsOptions>
18 --midi-key-cps=4 --midi-velocity=5
19 </CsOptions>
20 <CsInstruments>
21
22 sr = 44100
23 ksmps = 32
24 nchnls = 2
25 0dbfs = 1
26
27 massign 1, 101 ; send notes on MIDI Ch.1 to instr 101
28 gaOut init 0.0
29
30 instr 100 ; MIDI Controller Receive Instrument
31 kFilterCC1 ctrl7 1, 1, 10, 5000 ; read 7-bit MIDI CC data from Ch.1, CC1, and map to a range between 10-5000
32 printk2 kFilterCC1 ; print the value to the console
33 kChanged changed kFilterCC1 ; check if new values are incoming
34 if kChanged == 1 then ; so if, update the chanel..
35 outvalue "filter_freq", kFilterCC1 ; send the value to the widgetpanel
36 endif
37 endin
38
39
40 instr 101 ; Sawthooth Oscillator triggered by notes on MIDI CH: 1
41 icps = p4
42 iamp = p5/127
43 kFfreq invalue "filter_freq"
44 kFfreq port kFfreq, 0.05
45 aSrc oscili iamp, icps, 1
46 aFiltered moogvcf aSrc, kFfreq, 0.1
47 aEnv madsr 0.01, 0.1, 0.9, 0.01
48 gaOut = gaOut + aFiltered*aEnv
49 endin
50
51 instr 102 ; Global Feedback Delay
52 kDryWet invalue "d_w_delay"
53 kDelTime invalue "time_delay"
54 kFeedback invalue "feedb_delay"
55 kDelTime port kDelTime, 0.05
56 aDelTime = a(kDelTime)
57 aDelay delayr 1
58 aWet deltapi aDelTime
59 delayw gaOut+(aWet*kFeedback)
60 gaOut = (1-kDryWet) * gaOut + (kDryWet * aWet)
61 endin
62
63 instr 103 ; Global Reverb
64 kroomsize init 0.4
65 khfdamp init 0.8
66 kDryWet invalue "d_w_reverb"
67 aWetL, aWetR freeverb gaOut, gaOut, kroomsize, khfdamp
68 aOutL = (1-kDryWet) * gaOut + (kDryWet * aWetL)
69 aOutR = (1-kDryWet) * gaOut + (kDryWet * aWetR)
70 outs aOutL, aOutR
71 gaOut = 0.0
72 endin
73
74
75
76 </CsInstruments>
77 <CsScore>
78 f 1 0 256 7 0 128 1 0 -1 128 0
79 i 100 0 3600 ; the MIDI CC 01will become received for one hour
80 i 102 0 3600 ; the delay runs for one hour
81 i 103 0 3600 ; the reverb runs for one hour
82 e
83 </CsScore>
84 </CsoundSynthesizer>
85 ; written by Alex Hofmann (Dec. 2009) - Incontri HMT-Hannover
86 <bsbPanel>
87 <label>Widgets</label>
88 <objectName/>
89 <x>0</x>
90 <y>0</y>
91 <width>599</width>
92 <height>453</height>
93 <visible>true</visible>
94 <uuid/>
95 <bgcolor mode="background">
96 <r>182</r>
97 <g>109</g>
98 <b>0</b>
99 </bgcolor>
100 <bsbObject version="2" type="BSBHSlider">
101 <objectName>d_w_reverb</objectName>
102 <x>22</x>
103 <y>458</y>
104 <width>311</width>
105 <height>38</height>
106 <uuid>{a933ecca-4f6f-4c37-8612-e80ccaeab1ff}</uuid>
107 <visible>true</visible>
108 <midichan>0</midichan>
109 <midicc>-3</midicc>
110 <minimum>0.00000000</minimum>
111 <maximum>1.00000000</maximum>
112 <value>0.24437300</value>
113 <mode>lin</mode>
114 <mouseControl act="jump">continuous</mouseControl>
115 <resolution>-1.00000000</resolution>
116 <randomizable group="0">false</randomizable>
117 </bsbObject>
118 <bsbObject version="2" type="BSBLabel">
119 <objectName/>
120 <x>22</x>
121 <y>421</y>
122 <width>131</width>
123 <height>35</height>
124 <uuid>{8c2bf2d5-2f2a-4aa8-95f5-fd459644d3b3}</uuid>
125 <visible>true</visible>
126 <midichan>0</midichan>
127 <midicc>-3</midicc>
128 <label>Reverb Mix</label>
129 <alignment>left</alignment>
130 <font>Lucida Grande</font>
131 <fontsize>18</fontsize>
132 <precision>3</precision>
133 <color>
134 <r>0</r>
135 <g>0</g>
136 <b>0</b>
137 </color>
138 <bgcolor mode="nobackground">
139 <r>255</r>
140 <g>255</g>
141 <b>255</b>
142 </bgcolor>
143 <bordermode>noborder</bordermode>
144 <borderradius>1</borderradius>
145 <borderwidth>1</borderwidth>
146 </bsbObject>
147 <bsbObject version="2" type="BSBHSlider">
148 <objectName>d_w_delay</objectName>
149 <x>22</x>
150 <y>277</y>
151 <width>311</width>
152 <height>38</height>
153 <uuid>{252c3435-b659-4c63-a7eb-6d8ba725081a}</uuid>
154 <visible>true</visible>
155 <midichan>0</midichan>
156 <midicc>-3</midicc>
157 <minimum>0.00000000</minimum>
158 <maximum>1.00000000</maximum>
159 <value>0.25723500</value>
160 <mode>lin</mode>
161 <mouseControl act="jump">continuous</mouseControl>
162 <resolution>-1.00000000</resolution>
163 <randomizable group="0">false</randomizable>
164 </bsbObject>
165 <bsbObject version="2" type="BSBLabel">
166 <objectName/>
167 <x>22</x>
168 <y>240</y>
169 <width>131</width>
170 <height>35</height>
171 <uuid>{b2a47e2f-a70f-4ac8-afd0-89ebec44cf27}</uuid>
172 <visible>true</visible>
173 <midichan>0</midichan>
174 <midicc>-3</midicc>
175 <label>Delay Mix</label>
176 <alignment>left</alignment>
177 <font>Lucida Grande</font>
178 <fontsize>18</fontsize>
179 <precision>3</precision>
180 <color>
181 <r>0</r>
182 <g>0</g>
183 <b>0</b>
184 </color>
185 <bgcolor mode="nobackground">
186 <r>255</r>
187 <g>255</g>
188 <b>255</b>
189 </bgcolor>
190 <bordermode>noborder</bordermode>
191 <borderradius>1</borderradius>
192 <borderwidth>1</borderwidth>
193 </bsbObject>
194 <bsbObject version="2" type="BSBVSlider">
195 <objectName>time_delay</objectName>
196 <x>244</x>
197 <y>147</y>
198 <width>20</width>
199 <height>100</height>
200 <uuid>{9eda359f-2e35-416a-9486-75e2b8609bac}</uuid>
201 <visible>true</visible>
202 <midichan>0</midichan>
203 <midicc>-3</midicc>
204 <minimum>0.05000000</minimum>
205 <maximum>1.00000000</maximum>
206 <value>0.40150000</value>
207 <mode>lin</mode>
208 <mouseControl act="jump">continuous</mouseControl>
209 <resolution>-1.00000000</resolution>
210 <randomizable group="0">false</randomizable>
211 </bsbObject>
212 <bsbObject version="2" type="BSBVSlider">
213 <objectName>feedb_delay</objectName>
214 <x>313</x>
215 <y>148</y>
216 <width>20</width>
217 <height>100</height>
218 <uuid>{9b9faa01-b3b1-42b6-b3ea-942190c61015}</uuid>
219 <visible>true</visible>
220 <midichan>0</midichan>
221 <midicc>-3</midicc>
222 <minimum>0.05000000</minimum>
223 <maximum>1.00000000</maximum>
224 <value>0.31600000</value>
225 <mode>lin</mode>
226 <mouseControl act="jump">continuous</mouseControl>
227 <resolution>-1.00000000</resolution>
228 <randomizable group="0">false</randomizable>
229 </bsbObject>
230 <bsbObject version="2" type="BSBLabel">
231 <objectName/>
232 <x>235</x>
233 <y>121</y>
234 <width>45</width>
235 <height>23</height>
236 <uuid>{a34714d9-8caa-4e71-993d-adc95b6d4ef6}</uuid>
237 <visible>true</visible>
238 <midichan>0</midichan>
239 <midicc>-3</midicc>
240 <label>Time</label>
241 <alignment>left</alignment>
242 <font>Lucida Grande</font>
243 <fontsize>10</fontsize>
244 <precision>3</precision>
245 <color>
246 <r>0</r>
247 <g>0</g>
248 <b>0</b>
249 </color>
250 <bgcolor mode="nobackground">
251 <r>255</r>
252 <g>255</g>
253 <b>255</b>
254 </bgcolor>
255 <bordermode>noborder</bordermode>
256 <borderradius>1</borderradius>
257 <borderwidth>1</borderwidth>
258 </bsbObject>
259 <bsbObject version="2" type="BSBLabel">
260 <objectName/>
261 <x>294</x>
262 <y>121</y>
263 <width>57</width>
264 <height>23</height>
265 <uuid>{38d17cf1-8311-44a5-bbcd-e89f2a0a341e}</uuid>
266 <visible>true</visible>
267 <midichan>0</midichan>
268 <midicc>-3</midicc>
269 <label>Feedback</label>
270 <alignment>left</alignment>
271 <font>Lucida Grande</font>
272 <fontsize>10</fontsize>
273 <precision>3</precision>
274 <color>
275 <r>0</r>
276 <g>0</g>
277 <b>0</b>
278 </color>
279 <bgcolor mode="nobackground">
280 <r>255</r>
281 <g>255</g>
282 <b>255</b>
283 </bgcolor>
284 <bordermode>noborder</bordermode>
285 <borderradius>1</borderradius>
286 <borderwidth>1</borderwidth>
287 </bsbObject>
288 <bsbObject version="2" type="BSBLabel">
289 <objectName/>
290 <x>22</x>
291 <y>116</y>
292 <width>184</width>
293 <height>35</height>
294 <uuid>{00c81148-ef01-44bb-af39-743e7597a9a3}</uuid>
295 <visible>true</visible>
296 <midichan>0</midichan>
297 <midicc>-3</midicc>
298 <label>DELAY SECTION</label>
299 <alignment>left</alignment>
300 <font>Lucida Grande</font>
301 <fontsize>22</fontsize>
302 <precision>3</precision>
303 <color>
304 <r>0</r>
305 <g>0</g>
306 <b>0</b>
307 </color>
308 <bgcolor mode="nobackground">
309 <r>255</r>
310 <g>255</g>
311 <b>255</b>
312 </bgcolor>
313 <bordermode>border</bordermode>
314 <borderradius>1</borderradius>
315 <borderwidth>1</borderwidth>
316 </bsbObject>
317 <bsbObject version="2" type="BSBLabel">
318 <objectName/>
319 <x>21</x>
320 <y>313</y>
321 <width>80</width>
322 <height>25</height>
323 <uuid>{ff2f6506-d383-4b73-8cc8-325a13c76301}</uuid>
324 <visible>true</visible>
325 <midichan>0</midichan>
326 <midicc>-3</midicc>
327 <label>Dry</label>
328 <alignment>left</alignment>
329 <font>Lucida Grande</font>
330 <fontsize>10</fontsize>
331 <precision>3</precision>
332 <color>
333 <r>0</r>
334 <g>0</g>
335 <b>0</b>
336 </color>
337 <bgcolor mode="nobackground">
338 <r>255</r>
339 <g>255</g>
340 <b>255</b>
341 </bgcolor>
342 <bordermode>noborder</bordermode>
343 <borderradius>1</borderradius>
344 <borderwidth>1</borderwidth>
345 </bsbObject>
346 <bsbObject version="2" type="BSBLabel">
347 <objectName/>
348 <x>294</x>
349 <y>315</y>
350 <width>37</width>
351 <height>27</height>
352 <uuid>{deb507a6-bbc9-4875-ab32-b98d0fd9ca21}</uuid>
353 <visible>true</visible>
354 <midichan>0</midichan>
355 <midicc>-3</midicc>
356 <label>Wet</label>
357 <alignment>left</alignment>
358 <font>Lucida Grande</font>
359 <fontsize>10</fontsize>
360 <precision>3</precision>
361 <color>
362 <r>0</r>
363 <g>0</g>
364 <b>0</b>
365 </color>
366 <bgcolor mode="nobackground">
367 <r>255</r>
368 <g>255</g>
369 <b>255</b>
370 </bgcolor>
371 <bordermode>noborder</bordermode>
372 <borderradius>1</borderradius>
373 <borderwidth>1</borderwidth>
374 </bsbObject>
375 <bsbObject version="2" type="BSBLabel">
376 <objectName/>
377 <x>22</x>
378 <y>494</y>
379 <width>80</width>
380 <height>25</height>
381 <uuid>{1a2bb9cb-d541-4c5f-8c71-07b4c279ed43}</uuid>
382 <visible>true</visible>
383 <midichan>0</midichan>
384 <midicc>-3</midicc>
385 <label>Dry</label>
386 <alignment>left</alignment>
387 <font>Lucida Grande</font>
388 <fontsize>10</fontsize>
389 <precision>3</precision>
390 <color>
391 <r>0</r>
392 <g>0</g>
393 <b>0</b>
394 </color>
395 <bgcolor mode="nobackground">
396 <r>255</r>
397 <g>255</g>
398 <b>255</b>
399 </bgcolor>
400 <bordermode>noborder</bordermode>
401 <borderradius>1</borderradius>
402 <borderwidth>1</borderwidth>
403 </bsbObject>
404 <bsbObject version="2" type="BSBLabel">
405 <objectName/>
406 <x>296</x>
407 <y>494</y>
408 <width>37</width>
409 <height>25</height>
410 <uuid>{c0a097a0-f5e0-4041-a760-cb8edbe42625}</uuid>
411 <visible>true</visible>
412 <midichan>0</midichan>
413 <midicc>-3</midicc>
414 <label>Wet</label>
415 <alignment>left</alignment>
416 <font>Lucida Grande</font>
417 <fontsize>10</fontsize>
418 <precision>3</precision>
419 <color>
420 <r>0</r>
421 <g>0</g>
422 <b>0</b>
423 </color>
424 <bgcolor mode="nobackground">
425 <r>255</r>
426 <g>255</g>
427 <b>255</b>
428 </bgcolor>
429 <bordermode>noborder</bordermode>
430 <borderradius>1</borderradius>
431 <borderwidth>1</borderwidth>
432 </bsbObject>
433 <bsbObject version="2" type="BSBLabel">
434 <objectName/>
435 <x>20</x>
436 <y>381</y>
437 <width>184</width>
438 <height>35</height>
439 <uuid>{6a214d2b-c15f-4749-81a6-00a359668d41}</uuid>
440 <visible>true</visible>
441 <midichan>0</midichan>
442 <midicc>-3</midicc>
443 <label>REVERB SECTION</label>
444 <alignment>left</alignment>
445 <font>Lucida Grande</font>
446 <fontsize>22</fontsize>
447 <precision>3</precision>
448 <color>
449 <r>0</r>
450 <g>0</g>
451 <b>0</b>
452 </color>
453 <bgcolor mode="nobackground">
454 <r>255</r>
455 <g>255</g>
456 <b>255</b>
457 </bgcolor>
458 <bordermode>border</bordermode>
459 <borderradius>1</borderradius>
460 <borderwidth>1</borderwidth>
461 </bsbObject>
462 <bsbObject version="2" type="BSBLabel">
463 <objectName/>
464 <x>223</x>
465 <y>250</y>
466 <width>69</width>
467 <height>24</height>
468 <uuid>{c6be046b-6565-487b-82aa-7153da5ce460}</uuid>
469 <visible>true</visible>
470 <midichan>0</midichan>
471 <midicc>-3</midicc>
472 <label>50-1000 ms</label>
473 <alignment>left</alignment>
474 <font>Lucida Grande</font>
475 <fontsize>10</fontsize>
476 <precision>3</precision>
477 <color>
478 <r>0</r>
479 <g>0</g>
480 <b>0</b>
481 </color>
482 <bgcolor mode="nobackground">
483 <r>255</r>
484 <g>255</g>
485 <b>255</b>
486 </bgcolor>
487 <bordermode>noborder</bordermode>
488 <borderradius>1</borderradius>
489 <borderwidth>1</borderwidth>
490 </bsbObject>
491 <bsbObject version="2" type="BSBLabel">
492 <objectName/>
493 <x>300</x>
494 <y>251</y>
495 <width>69</width>
496 <height>24</height>
497 <uuid>{9dcc5341-ac6e-4568-b661-9a08ffa7bafd}</uuid>
498 <visible>true</visible>
499 <midichan>0</midichan>
500 <midicc>-3</midicc>
501 <label>0-100 %</label>
502 <alignment>left</alignment>
503 <font>Lucida Grande</font>
504 <fontsize>10</fontsize>
505 <precision>3</precision>
506 <color>
507 <r>0</r>
508 <g>0</g>
509 <b>0</b>
510 </color>
511 <bgcolor mode="nobackground">
512 <r>255</r>
513 <g>255</g>
514 <b>255</b>
515 </bgcolor>
516 <bordermode>noborder</bordermode>
517 <borderradius>1</borderradius>
518 <borderwidth>1</borderwidth>
519 </bsbObject>
520 <bsbObject version="2" type="BSBLabel">
521 <objectName/>
522 <x>19</x>
523 <y>44</y>
524 <width>273</width>
525 <height>25</height>
526 <uuid>{5f7f6f96-32f1-47ba-a896-ca4f6e4eaf11}</uuid>
527 <visible>true</visible>
528 <midichan>0</midichan>
529 <midicc>-3</midicc>
530 <label>Filterfrequency Control with CC 01 (Modulation)</label>
531 <alignment>left</alignment>
532 <font>Lucida Grande</font>
533 <fontsize>10</fontsize>
534 <precision>3</precision>
535 <color>
536 <r>0</r>
537 <g>0</g>
538 <b>0</b>
539 </color>
540 <bgcolor mode="nobackground">
541 <r>255</r>
542 <g>255</g>
543 <b>255</b>
544 </bgcolor>
545 <bordermode>noborder</bordermode>
546 <borderradius>1</borderradius>
547 <borderwidth>1</borderwidth>
548 </bsbObject>
549 <bsbObject version="2" type="BSBLabel">
550 <objectName/>
551 <x>20</x>
552 <y>10</y>
553 <width>184</width>
554 <height>35</height>
555 <uuid>{2f8d8395-c26a-4531-a1a5-d94df807fac9}</uuid>
556 <visible>true</visible>
557 <midichan>0</midichan>
558 <midicc>-3</midicc>
559 <label>SYNTH SECTION</label>
560 <alignment>left</alignment>
561 <font>Lucida Grande</font>
562 <fontsize>22</fontsize>
563 <precision>3</precision>
564 <color>
565 <r>0</r>
566 <g>0</g>
567 <b>0</b>
568 </color>
569 <bgcolor mode="nobackground">
570 <r>255</r>
571 <g>255</g>
572 <b>255</b>
573 </bgcolor>
574 <bordermode>border</bordermode>
575 <borderradius>1</borderradius>
576 <borderwidth>1</borderwidth>
577 </bsbObject>
578 <bsbObject version="2" type="BSBHSlider">
579 <objectName>filter_freq</objectName>
580 <x>18</x>
581 <y>68</y>
582 <width>311</width>
583 <height>38</height>
584 <uuid>{e0262b2c-5f78-4d11-9b16-1fd70b8bbefd}</uuid>
585 <visible>true</visible>
586 <midichan>0</midichan>
587 <midicc>-3</midicc>
588 <minimum>10.00000000</minimum>
589 <maximum>5000.00000000</maximum>
590 <value>2288.39228300</value>
591 <mode>lin</mode>
592 <mouseControl act="jump">continuous</mouseControl>
593 <resolution>-1.00000000</resolution>
594 <randomizable group="0">false</randomizable>
595 </bsbObject>
596 </bsbPanel>
597 <bsbPresets>
598 </bsbPresets>
599 <EventPanel name="Events" tempo="60.00000000" loop="8.00000000" x="383" y="237" width="513" height="322" visible="true" loopStart="0" loopEnd="0"> </EventPanel>