Debian Codegraph @

src/Examples/McCurdy Collection/Miscellaneous/limit_mirror_wrap.csd

raw
1 ;Written by Iain McCurdy, 2009
2
3 ;Modified for QuteCsound by René, February 2011
4 ;Tested on Ubuntu 10.04 with csound-float 5.13.0 and QuteCsound svn rev 817
5
6 ;Notes on modifications from original csd:
7
8
9 ;my flags on Ubuntu: -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=null -m0
10 <CsoundSynthesizer>
11 <CsOptions>
12
13 </CsOptions>
14 <CsInstruments>
15 sr = 44100 ;SAMPLE RATE
16 ksmps = 16 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
17 nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
18
19
20 instr 1 ;ALWAYS ON - SEE SCORE
21 ktrig metro 10
22 if (ktrig == 1) then
23 gkinput invalue "Input"
24 gkmin invalue "Minimum"
25 gkmax invalue "Maximum"
26 gkmode invalue "Mode"
27 endif
28
29 ktrigger changed gkinput ;GENERATE A MOMENTARY '1' PULSE IN OUTPUT 'ktrigger' IF gkinput CHANGES (gkoutput SLIDER WILL BE UPDATED)
30
31 if gkmode=0 then ;IF MODE 0 (limit) IS SELECTED..
32 koutput limit gkinput, gkmin, gkmax ;APPLY 'limit' TO gkinput VALUES
33 elseif gkmode=1 then ;IF MODE 1 (mirror) IS SELECTED..
34 koutput mirror gkinput, gkmin, gkmax ;APPLY 'mirror' TO gkinput VALUES
35 else ;IF MODE 2 (wrap) IS SELECTED..
36 koutput wrap gkinput, gkmin, gkmax ;APPLY 'wrap' TO gkinput VALUES
37 endif ;END OF CONDITIONAL BRANCHING
38
39 if ktrigger = 1 then
40 outvalue "Output", koutput ;UPDATE gkoutput SLIDER
41 endif
42 endin
43 </CsInstruments>
44 <CsScore>
45 i 1 0 3600 ;INSTRUMENT 1 PLAYS FOR 1 HOUR
46 </CsScore>
47 </CsoundSynthesizer>
48 <bsbPanel>
49 <label>Widgets</label>
50 <objectName/>
51 <x>770</x>
52 <y>326</y>
53 <width>1034</width>
54 <height>302</height>
55 <visible>true</visible>
56 <uuid/>
57 <bgcolor mode="background">
58 <r>241</r>
59 <g>226</g>
60 <b>185</b>
61 </bgcolor>
62 <bsbObject version="2" type="BSBLabel">
63 <objectName/>
64 <x>516</x>
65 <y>2</y>
66 <width>515</width>
67 <height>300</height>
68 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
69 <visible>true</visible>
70 <midichan>0</midichan>
71 <midicc>0</midicc>
72 <label>limit,mirror,wrap</label>
73 <alignment>center</alignment>
74 <font>Liberation Sans</font>
75 <fontsize>18</fontsize>
76 <precision>3</precision>
77 <color>
78 <r>255</r>
79 <g>255</g>
80 <b>255</b>
81 </color>
82 <bgcolor mode="background">
83 <r>5</r>
84 <g>27</g>
85 <b>150</b>
86 </bgcolor>
87 <bordermode>border</bordermode>
88 <borderradius>5</borderradius>
89 <borderwidth>2</borderwidth>
90 </bsbObject>
91 <bsbObject version="2" type="BSBLabel">
92 <objectName/>
93 <x>520</x>
94 <y>21</y>
95 <width>510</width>
96 <height>277</height>
97 <uuid>{e41f02b8-6ad4-46dc-805c-0b2eeafbd476}</uuid>
98 <visible>true</visible>
99 <midichan>0</midichan>
100 <midicc>0</midicc>
101 <label>--------------------------------------------------------------------------------------------------------------------------
102 koutput limit kinput, kminimum, kmaximum
103 koutput mirror kinput, kminimum, kmaximum
104 koutput wrap kinput, kminimum, kmaximum
105 Limit, mirror and wrap are opcodes that prevent a variable going beyond a user defined maximum and minimum. How out of range values are dealt with varies between opcodes. 'Limit' applies a 'brick wall' style limitation by freezing excessively large or small value at the maxima and minima. 'Mirror' reflects back out of range values by the amount by which thay have exceeded the boundary. If reflections attempt to go beyond the opposite boundary they are reflected again. 'Wrap' forces out of range values to re-emerge next to the opposite boundary. All three opcodes can operate at i, k or a rate. These opcodes can be useful in algorithmic composition, for preventing filter cutoff frequencies from exceeding sensible limits and when dealing with function table indexes. Use the radio buttons to choose between 'limit', 'mirror' and 'wrap'.
106 THIS EXAMPLE PRODUCES NO SOUND.</label>
107 <alignment>left</alignment>
108 <font>Liberation Sans</font>
109 <fontsize>14</fontsize>
110 <precision>3</precision>
111 <color>
112 <r>255</r>
113 <g>255</g>
114 <b>255</b>
115 </color>
116 <bgcolor mode="nobackground">
117 <r>255</r>
118 <g>255</g>
119 <b>255</b>
120 </bgcolor>
121 <bordermode>noborder</bordermode>
122 <borderradius>1</borderradius>
123 <borderwidth>1</borderwidth>
124 </bsbObject>
125 <bsbObject version="2" type="BSBLabel">
126 <objectName/>
127 <x>2</x>
128 <y>2</y>
129 <width>514</width>
130 <height>300</height>
131 <uuid>{049f4dd4-ff71-4d6d-9157-43c84efad8a4}</uuid>
132 <visible>true</visible>
133 <midichan>0</midichan>
134 <midicc>0</midicc>
135 <label>limit,mirror,wrap</label>
136 <alignment>center</alignment>
137 <font>Liberation Sans</font>
138 <fontsize>18</fontsize>
139 <precision>3</precision>
140 <color>
141 <r>255</r>
142 <g>255</g>
143 <b>255</b>
144 </color>
145 <bgcolor mode="background">
146 <r>5</r>
147 <g>27</g>
148 <b>150</b>
149 </bgcolor>
150 <bordermode>border</bordermode>
151 <borderradius>5</borderradius>
152 <borderwidth>2</borderwidth>
153 </bsbObject>
154 <bsbObject version="2" type="BSBLabel">
155 <objectName/>
156 <x>9</x>
157 <y>125</y>
158 <width>200</width>
159 <height>30</height>
160 <uuid>{3ebc1139-1fdb-48dc-9150-49ee8dfdbd4a}</uuid>
161 <visible>true</visible>
162 <midichan>0</midichan>
163 <midicc>0</midicc>
164 <label>Minimum</label>
165 <alignment>left</alignment>
166 <font>Liberation Sans</font>
167 <fontsize>10</fontsize>
168 <precision>3</precision>
169 <color>
170 <r>255</r>
171 <g>255</g>
172 <b>255</b>
173 </color>
174 <bgcolor mode="nobackground">
175 <r>255</r>
176 <g>255</g>
177 <b>255</b>
178 </bgcolor>
179 <bordermode>noborder</bordermode>
180 <borderradius>1</borderradius>
181 <borderwidth>1</borderwidth>
182 </bsbObject>
183 <bsbObject version="2" type="BSBDisplay">
184 <objectName>Minimum</objectName>
185 <x>449</x>
186 <y>125</y>
187 <width>60</width>
188 <height>30</height>
189 <uuid>{e54486c5-f9aa-4d0e-9a67-6506dae3c790}</uuid>
190 <visible>true</visible>
191 <midichan>0</midichan>
192 <midicc>0</midicc>
193 <label>-1.296</label>
194 <alignment>right</alignment>
195 <font>Liberation Sans</font>
196 <fontsize>9</fontsize>
197 <precision>3</precision>
198 <color>
199 <r>255</r>
200 <g>255</g>
201 <b>255</b>
202 </color>
203 <bgcolor mode="nobackground">
204 <r>255</r>
205 <g>255</g>
206 <b>255</b>
207 </bgcolor>
208 <bordermode>noborder</bordermode>
209 <borderradius>1</borderradius>
210 <borderwidth>1</borderwidth>
211 </bsbObject>
212 <bsbObject version="2" type="BSBLabel">
213 <objectName/>
214 <x>9</x>
215 <y>72</y>
216 <width>200</width>
217 <height>30</height>
218 <uuid>{78a7e9cd-fb57-421c-8e1f-40b60a90dfc0}</uuid>
219 <visible>true</visible>
220 <midichan>0</midichan>
221 <midicc>0</midicc>
222 <label>Input Value</label>
223 <alignment>left</alignment>
224 <font>Liberation Sans</font>
225 <fontsize>10</fontsize>
226 <precision>3</precision>
227 <color>
228 <r>255</r>
229 <g>255</g>
230 <b>255</b>
231 </color>
232 <bgcolor mode="nobackground">
233 <r>255</r>
234 <g>255</g>
235 <b>255</b>
236 </bgcolor>
237 <bordermode>noborder</bordermode>
238 <borderradius>1</borderradius>
239 <borderwidth>1</borderwidth>
240 </bsbObject>
241 <bsbObject version="2" type="BSBHSlider">
242 <objectName>Input</objectName>
243 <x>9</x>
244 <y>49</y>
245 <width>500</width>
246 <height>27</height>
247 <uuid>{4b5d3fba-55d0-43d1-a94a-457bc9144a31}</uuid>
248 <visible>true</visible>
249 <midichan>0</midichan>
250 <midicc>0</midicc>
251 <minimum>-2.00000000</minimum>
252 <maximum>2.00000000</maximum>
253 <value>-0.20800000</value>
254 <mode>lin</mode>
255 <mouseControl act="jump">continuous</mouseControl>
256 <resolution>-1.00000000</resolution>
257 <randomizable group="0">false</randomizable>
258 </bsbObject>
259 <bsbObject version="2" type="BSBDisplay">
260 <objectName>Input</objectName>
261 <x>449</x>
262 <y>72</y>
263 <width>60</width>
264 <height>30</height>
265 <uuid>{58265963-6245-459e-8071-9ed8bba850a4}</uuid>
266 <visible>true</visible>
267 <midichan>0</midichan>
268 <midicc>0</midicc>
269 <label>-0.208</label>
270 <alignment>right</alignment>
271 <font>Liberation Sans</font>
272 <fontsize>9</fontsize>
273 <precision>3</precision>
274 <color>
275 <r>255</r>
276 <g>255</g>
277 <b>255</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>9</x>
291 <y>231</y>
292 <width>200</width>
293 <height>30</height>
294 <uuid>{1c02d7bd-4198-417f-a816-a560f4133e23}</uuid>
295 <visible>true</visible>
296 <midichan>0</midichan>
297 <midicc>0</midicc>
298 <label>Output Value</label>
299 <alignment>left</alignment>
300 <font>Liberation Sans</font>
301 <fontsize>10</fontsize>
302 <precision>3</precision>
303 <color>
304 <r>255</r>
305 <g>255</g>
306 <b>255</b>
307 </color>
308 <bgcolor mode="nobackground">
309 <r>255</r>
310 <g>255</g>
311 <b>255</b>
312 </bgcolor>
313 <bordermode>noborder</bordermode>
314 <borderradius>1</borderradius>
315 <borderwidth>1</borderwidth>
316 </bsbObject>
317 <bsbObject version="2" type="BSBDisplay">
318 <objectName>Output</objectName>
319 <x>449</x>
320 <y>231</y>
321 <width>60</width>
322 <height>30</height>
323 <uuid>{8341c14a-4acb-4d3d-824f-675147975768}</uuid>
324 <visible>true</visible>
325 <midichan>0</midichan>
326 <midicc>0</midicc>
327 <label>-0.208</label>
328 <alignment>right</alignment>
329 <font>Liberation Sans</font>
330 <fontsize>9</fontsize>
331 <precision>3</precision>
332 <color>
333 <r>255</r>
334 <g>255</g>
335 <b>255</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>9</x>
349 <y>178</y>
350 <width>200</width>
351 <height>30</height>
352 <uuid>{fd3ea893-7f4f-4d74-a6c6-2ed00b696056}</uuid>
353 <visible>true</visible>
354 <midichan>0</midichan>
355 <midicc>0</midicc>
356 <label>Maximum</label>
357 <alignment>left</alignment>
358 <font>Liberation Sans</font>
359 <fontsize>10</fontsize>
360 <precision>3</precision>
361 <color>
362 <r>255</r>
363 <g>255</g>
364 <b>255</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="BSBDisplay">
376 <objectName>Maximum</objectName>
377 <x>449</x>
378 <y>178</y>
379 <width>60</width>
380 <height>30</height>
381 <uuid>{78473677-bb47-45c2-bf88-fa6930dca759}</uuid>
382 <visible>true</visible>
383 <midichan>0</midichan>
384 <midicc>0</midicc>
385 <label>0.992</label>
386 <alignment>right</alignment>
387 <font>Liberation Sans</font>
388 <fontsize>9</fontsize>
389 <precision>3</precision>
390 <color>
391 <r>255</r>
392 <g>255</g>
393 <b>255</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="BSBDropdown">
405 <objectName>Mode</objectName>
406 <x>252</x>
407 <y>256</y>
408 <width>100</width>
409 <height>30</height>
410 <uuid>{f695c468-f468-4eca-a7df-bd7d79c39231}</uuid>
411 <visible>true</visible>
412 <midichan>0</midichan>
413 <midicc>0</midicc>
414 <bsbDropdownItemList>
415 <bsbDropdownItem>
416 <name>limit</name>
417 <value>0</value>
418 <stringvalue/>
419 </bsbDropdownItem>
420 <bsbDropdownItem>
421 <name>mirror</name>
422 <value>1</value>
423 <stringvalue/>
424 </bsbDropdownItem>
425 <bsbDropdownItem>
426 <name>wrap</name>
427 <value>2</value>
428 <stringvalue/>
429 </bsbDropdownItem>
430 </bsbDropdownItemList>
431 <selectedIndex>2</selectedIndex>
432 <randomizable group="0">false</randomizable>
433 </bsbObject>
434 <bsbObject version="2" type="BSBController">
435 <objectName>Minimum</objectName>
436 <x>9</x>
437 <y>102</y>
438 <width>500</width>
439 <height>25</height>
440 <uuid>{35864613-8f38-4d4d-96f5-a90fb9ac2055}</uuid>
441 <visible>true</visible>
442 <midichan>0</midichan>
443 <midicc>0</midicc>
444 <objectName2/>
445 <xMin>-2.00000000</xMin>
446 <xMax>2.00000000</xMax>
447 <yMin>0.00000000</yMin>
448 <yMax>1.00000000</yMax>
449 <xValue>-1.29600000</xValue>
450 <yValue>0.00000000</yValue>
451 <type>fill</type>
452 <pointsize>1</pointsize>
453 <fadeSpeed>0.00000000</fadeSpeed>
454 <mouseControl act="press">jump</mouseControl>
455 <color>
456 <r>255</r>
457 <g>255</g>
458 <b>0</b>
459 </color>
460 <randomizable mode="both" group="0">false</randomizable>
461 <bgcolor>
462 <r>0</r>
463 <g>0</g>
464 <b>0</b>
465 </bgcolor>
466 </bsbObject>
467 <bsbObject version="2" type="BSBController">
468 <objectName>Maximum</objectName>
469 <x>9</x>
470 <y>154</y>
471 <width>500</width>
472 <height>25</height>
473 <uuid>{21f5b62d-c5f7-4db9-ad0e-3be2406df1fa}</uuid>
474 <visible>true</visible>
475 <midichan>0</midichan>
476 <midicc>0</midicc>
477 <objectName2/>
478 <xMin>-2.00000000</xMin>
479 <xMax>2.00000000</xMax>
480 <yMin>0.00000000</yMin>
481 <yMax>1.00000000</yMax>
482 <xValue>0.99200000</xValue>
483 <yValue>0.00000000</yValue>
484 <type>llif</type>
485 <pointsize>1</pointsize>
486 <fadeSpeed>0.00000000</fadeSpeed>
487 <mouseControl act="press">jump</mouseControl>
488 <color>
489 <r>255</r>
490 <g>255</g>
491 <b>0</b>
492 </color>
493 <randomizable mode="both" group="0">false</randomizable>
494 <bgcolor>
495 <r>0</r>
496 <g>0</g>
497 <b>0</b>
498 </bgcolor>
499 </bsbObject>
500 <bsbObject version="2" type="BSBController">
501 <objectName>Output</objectName>
502 <x>9</x>
503 <y>206</y>
504 <width>500</width>
505 <height>25</height>
506 <uuid>{1a825598-2c67-45de-a655-a35148350306}</uuid>
507 <visible>true</visible>
508 <midichan>0</midichan>
509 <midicc>0</midicc>
510 <objectName2/>
511 <xMin>-2.00000000</xMin>
512 <xMax>2.00000000</xMax>
513 <yMin>0.00000000</yMin>
514 <yMax>1.00000000</yMax>
515 <xValue>-0.20800000</xValue>
516 <yValue>0.00000000</yValue>
517 <type>line</type>
518 <pointsize>1</pointsize>
519 <fadeSpeed>0.00000000</fadeSpeed>
520 <mouseControl act="press">jump</mouseControl>
521 <color>
522 <r>0</r>
523 <g>255</g>
524 <b>0</b>
525 </color>
526 <randomizable mode="both" group="0">false</randomizable>
527 <bgcolor>
528 <r>0</r>
529 <g>0</g>
530 <b>0</b>
531 </bgcolor>
532 </bsbObject>
533 </bsbPanel>
534 <bsbPresets>
535 </bsbPresets>
536 <EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="true" loopStart="0" loopEnd="0"> </EventPanel>