Debian Codegraph @

src/Examples/McCurdy Collection/LiveAudioIn/meters.csd

raw
1 ;Written by Iain McCurdy
2
3 ; Modified for QuteCsound by René, January 2011
4 ; Tested on Ubuntu 10.04 with csound-float 5.13.0 January 2011 and QuteCsound svn rev 817
5
6
7 ;Notes on modifications from original csd:
8
9
10 ;my flags on Ubuntu: -dm0 -iadc -odac -+rtaudio=jack -b16 -B4096 --expression-opt -+rtmidi=null
11 <CsoundSynthesizer>
12 <CsOptions>
13
14 </CsOptions>
15 <CsInstruments>
16 sr = 44100 ;SAMPLE RATE
17 ksmps = 64 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
18 nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
19 0dbfs = 1 ;MAXIMUM AMPLITUDE REGARDLESS OF BIT DEPTH
20
21
22 instr 1 ;ALWAYS ON - SEE SCORE
23
24 kgainL invalue "Gain_L"
25 kgainR invalue "Gain_R"
26 kpanL invalue "Pan_L"
27 kpanR invalue "Pan_R"
28
29 ainL, ainR ins ;READ AUDIO FROM THE COMPUTER'S INPUT
30 ainL = ainL * kgainL ;APPLY GAIN CONTROL
31 ainR = ainR * kgainR ;APPLY GAIN CONTROL
32 aL = (ainL * (1-kpanL)) + (ainR * (1 - kpanR)) ;APPLY PANNING CONTROL
33 aR = (ainL * kpanL) + (ainR * kpanR) ;APPLY PANNING CONTROL
34 ameterL follow aL, .01 ;CREATE AN AMPLITUDE FOLLOWING UNIPOLAR SIGNAL (NEEDED FOR THE AMPLITUDE METERS)
35 ameterR follow aR, .01 ;CREATE AN AMPLITUDE FOLLOWING UNIPOLAR SIGNAL (NEEDED FOR THE AMPLITUDE METERS)
36
37 kmeterL downsamp ameterL ;CONVERT AMPLITUDE FOLLOWING SIGNAL TO K-RATE
38 kmeterR downsamp ameterR ;CONVERT AMPLITUDE FOLLOWING SIGNAL TO K-RATE
39 kmeterL portk kmeterL, .1 ;SMOOTH THE MOVEMENT OF THE AMPLITUDE FOLLOWING SIGNAL - THIS WILL MAKE THE METERS EASIER TO VIEW
40 kmeterR portk kmeterR, .1 ;SMOOTH THE MOVEMENT OF THE AMPLITUDE FOLLOWING SIGNAL - THIS WILL MAKE THE METERS EASIER TO VIEW
41 ktrig changed kmeterL, kmeterR ;IF THE AMPLIUDE FOLLOWING SIGNAL CHANGES GENERATE A TRIGGER SIGNAL (A MOMENTARY '1' VALUE)
42
43 kreadouttrig metro 10 ;METRONOMIC TRIGGER (USED BY NUMBER BOX READOUTS) - 2 PER SECOND
44 if kreadouttrig == 1 && ktrig == 1 then
45 outvalue "Meter_L", kmeterL ;UPDATE NUMBER BOX READOUTS
46 outvalue "Meter_R", kmeterR ;UPDATE NUMBER BOX READOUTS
47 endif
48 outs aL, aR ;SEND THE AUDIO SIGNAL TO THE SPEAKERS
49 endin
50 </CsInstruments>
51 <CsScore>
52 ;INSTR | START | DURATION
53 i 1 0 3600 ;INSTRUMENT 1 PLAYS FOR 1 HOUR (AND KEEPS PERFORMANCE GOING)
54 </CsScore>
55 </CsoundSynthesizer><bsbPanel>
56 <label>Widgets</label>
57 <objectName/>
58 <x>72</x>
59 <y>179</y>
60 <width>400</width>
61 <height>200</height>
62 <visible>true</visible>
63 <uuid/>
64 <bgcolor mode="background">
65 <r>241</r>
66 <g>226</g>
67 <b>185</b>
68 </bgcolor>
69 <bsbObject version="2" type="BSBLabel">
70 <objectName/>
71 <x>2</x>
72 <y>2</y>
73 <width>472</width>
74 <height>188</height>
75 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
76 <visible>true</visible>
77 <midichan>0</midichan>
78 <midicc>0</midicc>
79 <label>Level Meters</label>
80 <alignment>center</alignment>
81 <font>Liberation Sans</font>
82 <fontsize>18</fontsize>
83 <precision>3</precision>
84 <color>
85 <r>0</r>
86 <g>0</g>
87 <b>0</b>
88 </color>
89 <bgcolor mode="background">
90 <r>158</r>
91 <g>220</g>
92 <b>158</b>
93 </bgcolor>
94 <bordermode>border</bordermode>
95 <borderradius>5</borderradius>
96 <borderwidth>2</borderwidth>
97 </bsbObject>
98 <bsbObject version="2" type="BSBLabel">
99 <objectName/>
100 <x>8</x>
101 <y>64</y>
102 <width>100</width>
103 <height>30</height>
104 <uuid>{2c897206-0dbc-47b5-ba68-915d83839ab6}</uuid>
105 <visible>true</visible>
106 <midichan>0</midichan>
107 <midicc>0</midicc>
108 <label>Gain L</label>
109 <alignment>left</alignment>
110 <font>Liberation Sans</font>
111 <fontsize>10</fontsize>
112 <precision>3</precision>
113 <color>
114 <r>0</r>
115 <g>0</g>
116 <b>0</b>
117 </color>
118 <bgcolor mode="nobackground">
119 <r>255</r>
120 <g>255</g>
121 <b>255</b>
122 </bgcolor>
123 <bordermode>noborder</bordermode>
124 <borderradius>1</borderradius>
125 <borderwidth>1</borderwidth>
126 </bsbObject>
127 <bsbObject version="2" type="BSBHSlider">
128 <objectName>Gain_L</objectName>
129 <x>8</x>
130 <y>47</y>
131 <width>300</width>
132 <height>27</height>
133 <uuid>{304e78d8-b320-453a-b28f-86b0ca872b86}</uuid>
134 <visible>true</visible>
135 <midichan>0</midichan>
136 <midicc>0</midicc>
137 <minimum>0.00000000</minimum>
138 <maximum>20.00000000</maximum>
139 <value>0.80000000</value>
140 <mode>lin</mode>
141 <mouseControl act="jump">continuous</mouseControl>
142 <resolution>-1.00000000</resolution>
143 <randomizable group="0">false</randomizable>
144 </bsbObject>
145 <bsbObject version="2" type="BSBDisplay">
146 <objectName>Gain_L</objectName>
147 <x>248</x>
148 <y>64</y>
149 <width>60</width>
150 <height>30</height>
151 <uuid>{94c7e961-7981-4d21-942f-80bcc647daf5}</uuid>
152 <visible>true</visible>
153 <midichan>0</midichan>
154 <midicc>0</midicc>
155 <label>0.800</label>
156 <alignment>right</alignment>
157 <font>Liberation Sans</font>
158 <fontsize>9</fontsize>
159 <precision>3</precision>
160 <color>
161 <r>0</r>
162 <g>0</g>
163 <b>0</b>
164 </color>
165 <bgcolor mode="nobackground">
166 <r>255</r>
167 <g>255</g>
168 <b>255</b>
169 </bgcolor>
170 <bordermode>noborder</bordermode>
171 <borderradius>1</borderradius>
172 <borderwidth>1</borderwidth>
173 </bsbObject>
174 <bsbObject version="2" type="BSBLabel">
175 <objectName/>
176 <x>477</x>
177 <y>2</y>
178 <width>489</width>
179 <height>188</height>
180 <uuid>{cebe7e5c-304d-4db6-8da2-0e27c0616bab}</uuid>
181 <visible>true</visible>
182 <midichan>0</midichan>
183 <midicc>0</midicc>
184 <label>Level Meters</label>
185 <alignment>center</alignment>
186 <font>Liberation Sans</font>
187 <fontsize>18</fontsize>
188 <precision>3</precision>
189 <color>
190 <r>0</r>
191 <g>0</g>
192 <b>0</b>
193 </color>
194 <bgcolor mode="background">
195 <r>158</r>
196 <g>220</g>
197 <b>158</b>
198 </bgcolor>
199 <bordermode>border</bordermode>
200 <borderradius>5</borderradius>
201 <borderwidth>2</borderwidth>
202 </bsbObject>
203 <bsbObject version="2" type="BSBLabel">
204 <objectName/>
205 <x>481</x>
206 <y>21</y>
207 <width>481</width>
208 <height>159</height>
209 <uuid>{c24a85f3-363e-476e-81da-37729ad65bb7}</uuid>
210 <visible>true</visible>
211 <midichan>0</midichan>
212 <midicc>0</midicc>
213 <label>---------------------------------------------------------------------------------------------------------------------
214 This example adds some features to the previous example that, again whilst not aurally spectacular, may prove useful in managing a live input signal in a larger realtime audio processing Csound orchestra.
215 Individual volume controls for each channel of the stereo input have been added.
216 Each channel can be panned independently.
217 Visual meters monitor amplitude levels and number boxes give textual confimation of these values.</label>
218 <alignment>left</alignment>
219 <font>Liberation Sans</font>
220 <fontsize>14</fontsize>
221 <precision>3</precision>
222 <color>
223 <r>0</r>
224 <g>0</g>
225 <b>0</b>
226 </color>
227 <bgcolor mode="nobackground">
228 <r>158</r>
229 <g>220</g>
230 <b>158</b>
231 </bgcolor>
232 <bordermode>noborder</bordermode>
233 <borderradius>1</borderradius>
234 <borderwidth>1</borderwidth>
235 </bsbObject>
236 <bsbObject version="2" type="BSBLabel">
237 <objectName/>
238 <x>8</x>
239 <y>103</y>
240 <width>100</width>
241 <height>30</height>
242 <uuid>{322c6985-0f80-4582-91e3-210b00046e85}</uuid>
243 <visible>true</visible>
244 <midichan>0</midichan>
245 <midicc>0</midicc>
246 <label>Gain R</label>
247 <alignment>left</alignment>
248 <font>Liberation Sans</font>
249 <fontsize>10</fontsize>
250 <precision>3</precision>
251 <color>
252 <r>0</r>
253 <g>0</g>
254 <b>0</b>
255 </color>
256 <bgcolor mode="nobackground">
257 <r>255</r>
258 <g>255</g>
259 <b>255</b>
260 </bgcolor>
261 <bordermode>noborder</bordermode>
262 <borderradius>1</borderradius>
263 <borderwidth>1</borderwidth>
264 </bsbObject>
265 <bsbObject version="2" type="BSBHSlider">
266 <objectName>Gain_R</objectName>
267 <x>8</x>
268 <y>86</y>
269 <width>300</width>
270 <height>27</height>
271 <uuid>{ff585363-a115-4dfe-8f64-1d8b9dc91bcd}</uuid>
272 <visible>true</visible>
273 <midichan>0</midichan>
274 <midicc>0</midicc>
275 <minimum>0.00000000</minimum>
276 <maximum>20.00000000</maximum>
277 <value>0.80000000</value>
278 <mode>lin</mode>
279 <mouseControl act="jump">continuous</mouseControl>
280 <resolution>-1.00000000</resolution>
281 <randomizable group="0">false</randomizable>
282 </bsbObject>
283 <bsbObject version="2" type="BSBDisplay">
284 <objectName>Gain_R</objectName>
285 <x>248</x>
286 <y>103</y>
287 <width>60</width>
288 <height>30</height>
289 <uuid>{a17ebb72-5cba-4282-a33d-4a9f72ff9915}</uuid>
290 <visible>true</visible>
291 <midichan>0</midichan>
292 <midicc>0</midicc>
293 <label>0.800</label>
294 <alignment>right</alignment>
295 <font>Liberation Sans</font>
296 <fontsize>9</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="BSBKnob">
313 <objectName>Pan_L</objectName>
314 <x>339</x>
315 <y>37</y>
316 <width>60</width>
317 <height>60</height>
318 <uuid>{2113663f-1b1d-4a74-bcda-87143abe7d58}</uuid>
319 <visible>true</visible>
320 <midichan>0</midichan>
321 <midicc>0</midicc>
322 <minimum>0.00000000</minimum>
323 <maximum>1.00000000</maximum>
324 <value>1.00000000</value>
325 <mode>lin</mode>
326 <mouseControl act="jump">continuous</mouseControl>
327 <resolution>0.01000000</resolution>
328 <randomizable group="0">false</randomizable>
329 </bsbObject>
330 <bsbObject version="2" type="BSBDisplay">
331 <objectName>Pan_L</objectName>
332 <x>339</x>
333 <y>110</y>
334 <width>60</width>
335 <height>30</height>
336 <uuid>{54632fef-9411-46c4-8e28-e24274a8b096}</uuid>
337 <visible>true</visible>
338 <midichan>0</midichan>
339 <midicc>0</midicc>
340 <label>1.000</label>
341 <alignment>center</alignment>
342 <font>Liberation Sans</font>
343 <fontsize>9</fontsize>
344 <precision>3</precision>
345 <color>
346 <r>0</r>
347 <g>0</g>
348 <b>0</b>
349 </color>
350 <bgcolor mode="nobackground">
351 <r>255</r>
352 <g>255</g>
353 <b>255</b>
354 </bgcolor>
355 <bordermode>noborder</bordermode>
356 <borderradius>1</borderradius>
357 <borderwidth>1</borderwidth>
358 </bsbObject>
359 <bsbObject version="2" type="BSBLabel">
360 <objectName/>
361 <x>339</x>
362 <y>95</y>
363 <width>60</width>
364 <height>30</height>
365 <uuid>{dd84a32c-32a9-4b1e-8113-4f0b999d54cf}</uuid>
366 <visible>true</visible>
367 <midichan>0</midichan>
368 <midicc>0</midicc>
369 <label>Pan L</label>
370 <alignment>center</alignment>
371 <font>Liberation Sans</font>
372 <fontsize>10</fontsize>
373 <precision>3</precision>
374 <color>
375 <r>0</r>
376 <g>0</g>
377 <b>0</b>
378 </color>
379 <bgcolor mode="nobackground">
380 <r>255</r>
381 <g>255</g>
382 <b>255</b>
383 </bgcolor>
384 <bordermode>noborder</bordermode>
385 <borderradius>1</borderradius>
386 <borderwidth>1</borderwidth>
387 </bsbObject>
388 <bsbObject version="2" type="BSBKnob">
389 <objectName>Pan_R</objectName>
390 <x>409</x>
391 <y>37</y>
392 <width>60</width>
393 <height>60</height>
394 <uuid>{c1ce0c6a-987b-4181-b0a3-aa3b7a8f4298}</uuid>
395 <visible>true</visible>
396 <midichan>0</midichan>
397 <midicc>0</midicc>
398 <minimum>0.00000000</minimum>
399 <maximum>1.00000000</maximum>
400 <value>0.00000000</value>
401 <mode>lin</mode>
402 <mouseControl act="jump">continuous</mouseControl>
403 <resolution>0.01000000</resolution>
404 <randomizable group="0">false</randomizable>
405 </bsbObject>
406 <bsbObject version="2" type="BSBDisplay">
407 <objectName>Pan_R</objectName>
408 <x>409</x>
409 <y>110</y>
410 <width>60</width>
411 <height>30</height>
412 <uuid>{57976c16-ee9e-46df-9826-50cb3dd84817}</uuid>
413 <visible>true</visible>
414 <midichan>0</midichan>
415 <midicc>0</midicc>
416 <label>0.000</label>
417 <alignment>center</alignment>
418 <font>Liberation Sans</font>
419 <fontsize>9</fontsize>
420 <precision>3</precision>
421 <color>
422 <r>0</r>
423 <g>0</g>
424 <b>0</b>
425 </color>
426 <bgcolor mode="nobackground">
427 <r>255</r>
428 <g>255</g>
429 <b>255</b>
430 </bgcolor>
431 <bordermode>noborder</bordermode>
432 <borderradius>1</borderradius>
433 <borderwidth>1</borderwidth>
434 </bsbObject>
435 <bsbObject version="2" type="BSBLabel">
436 <objectName/>
437 <x>409</x>
438 <y>95</y>
439 <width>60</width>
440 <height>30</height>
441 <uuid>{1123ce5e-57e6-43ed-b6d8-958dc5e7382e}</uuid>
442 <visible>true</visible>
443 <midichan>0</midichan>
444 <midicc>0</midicc>
445 <label>Pan R</label>
446 <alignment>center</alignment>
447 <font>Liberation Sans</font>
448 <fontsize>10</fontsize>
449 <precision>3</precision>
450 <color>
451 <r>0</r>
452 <g>0</g>
453 <b>0</b>
454 </color>
455 <bgcolor mode="nobackground">
456 <r>255</r>
457 <g>255</g>
458 <b>255</b>
459 </bgcolor>
460 <bordermode>noborder</bordermode>
461 <borderradius>1</borderradius>
462 <borderwidth>1</borderwidth>
463 </bsbObject>
464 <bsbObject version="2" type="BSBController">
465 <objectName>Meter_L</objectName>
466 <x>8</x>
467 <y>147</y>
468 <width>415</width>
469 <height>9</height>
470 <uuid>{62c7b289-2e6d-4604-bb01-e3cfe5d79438}</uuid>
471 <visible>true</visible>
472 <midichan>0</midichan>
473 <midicc>0</midicc>
474 <objectName2/>
475 <xMin>0.00000000</xMin>
476 <xMax>1.00000000</xMax>
477 <yMin>0.00000000</yMin>
478 <yMax>1.00000000</yMax>
479 <xValue>0.51675668</xValue>
480 <yValue>0.00000000</yValue>
481 <type>fill</type>
482 <pointsize>1</pointsize>
483 <fadeSpeed>0.00000000</fadeSpeed>
484 <mouseControl act="press">jump</mouseControl>
485 <color>
486 <r>255</r>
487 <g>0</g>
488 <b>0</b>
489 </color>
490 <randomizable mode="both" group="0">false</randomizable>
491 <bgcolor>
492 <r>0</r>
493 <g>0</g>
494 <b>0</b>
495 </bgcolor>
496 </bsbObject>
497 <bsbObject version="2" type="BSBDisplay">
498 <objectName>Meter_L</objectName>
499 <x>422</x>
500 <y>140</y>
501 <width>60</width>
502 <height>30</height>
503 <uuid>{dbaac762-0630-468d-a155-84211833082c}</uuid>
504 <visible>true</visible>
505 <midichan>0</midichan>
506 <midicc>0</midicc>
507 <label>0.517</label>
508 <alignment>left</alignment>
509 <font>Liberation Sans</font>
510 <fontsize>9</fontsize>
511 <precision>3</precision>
512 <color>
513 <r>0</r>
514 <g>0</g>
515 <b>0</b>
516 </color>
517 <bgcolor mode="nobackground">
518 <r>255</r>
519 <g>255</g>
520 <b>255</b>
521 </bgcolor>
522 <bordermode>noborder</bordermode>
523 <borderradius>1</borderradius>
524 <borderwidth>1</borderwidth>
525 </bsbObject>
526 <bsbObject version="2" type="BSBController">
527 <objectName>Meter_R</objectName>
528 <x>8</x>
529 <y>161</y>
530 <width>415</width>
531 <height>9</height>
532 <uuid>{30aa812f-6955-4b4a-bdaa-995875ea6d82}</uuid>
533 <visible>true</visible>
534 <midichan>0</midichan>
535 <midicc>0</midicc>
536 <objectName2/>
537 <xMin>0.00000000</xMin>
538 <xMax>1.00000000</xMax>
539 <yMin>0.00000000</yMin>
540 <yMax>1.00000000</yMax>
541 <xValue>0.55793618</xValue>
542 <yValue>0.00000000</yValue>
543 <type>fill</type>
544 <pointsize>1</pointsize>
545 <fadeSpeed>0.00000000</fadeSpeed>
546 <mouseControl act="press">jump</mouseControl>
547 <color>
548 <r>255</r>
549 <g>0</g>
550 <b>0</b>
551 </color>
552 <randomizable mode="both" group="0">false</randomizable>
553 <bgcolor>
554 <r>0</r>
555 <g>0</g>
556 <b>0</b>
557 </bgcolor>
558 </bsbObject>
559 <bsbObject version="2" type="BSBDisplay">
560 <objectName>Meter_R</objectName>
561 <x>422</x>
562 <y>154</y>
563 <width>60</width>
564 <height>30</height>
565 <uuid>{d610653d-fcd0-4f1a-adbc-47ea01e299cf}</uuid>
566 <visible>true</visible>
567 <midichan>0</midichan>
568 <midicc>0</midicc>
569 <label>0.558</label>
570 <alignment>left</alignment>
571 <font>Liberation Sans</font>
572 <fontsize>9</fontsize>
573 <precision>3</precision>
574 <color>
575 <r>0</r>
576 <g>0</g>
577 <b>0</b>
578 </color>
579 <bgcolor mode="nobackground">
580 <r>255</r>
581 <g>255</g>
582 <b>255</b>
583 </bgcolor>
584 <bordermode>noborder</bordermode>
585 <borderradius>1</borderradius>
586 <borderwidth>1</borderwidth>
587 </bsbObject>
588 </bsbPanel>
589 <bsbPresets>
590 </bsbPresets>
591 <EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="true" loopStart="0" loopEnd="0"> </EventPanel>