Debian Codegraph @

src/Examples/McCurdy Collection/Modulation/PhaseModulationSynthesisCf.csd

raw
1 ;Written by Iain McCurdy, 2008
2
3
4 ; Modified for QuteCsound by René, November 2010
5 ; Tested on Ubuntu 10.04 with csound-double cvs August 2010 and QuteCsound svn rev 733
6
7 ;Notes on modifications from original csd:
8 ; Add table(s) for exp slider
9 ; Instrument 1 is activated by MIDI and by the GUI
10 ; Cannot display more than one space in Label, so can't display the schematic shown below:
11
12 ; Phase Modulation Synthesis: Carrier(with feedback):
13 ; +------+
14 ; V |
15 ; +--+--+ |
16 ; |CAR.1| |(feedback)
17 ; +--+--+ |
18 ; | |
19 ; +------+
20 ; |
21 ; V
22 ; OUT
23
24
25 ;my flags on Ubuntu: -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=alsa -Ma -m0 --midi-key-oct=4 --midi-velocity-amp=5
26 <CsoundSynthesizer>
27 <CsOptions>
28
29 </CsOptions>
30 <CsInstruments>
31 sr = 44100 ;SAMPLE RATE
32 ksmps = 1 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
33 nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
34 0dbfs = 1 ;MAXIMUM AMPLITUDE REGARDLESS OF BIT DEPTH
35
36
37 gisine ftgen 0,0,65537,10,1 ;A SINE WAVE THAT CAN BE REFERENCED BY THE GLOBAL VARIABLE 'gisine'
38 giExp20000 ftgen 0, 0, 129, -25, 0, 20.0, 128, 20000.0 ;TABLES FOR EXP SLIDER
39
40
41 instr 10 ;GUI
42 ktrig metro 10
43 if (ktrig == 1) then
44 kfreq invalue "Base_Frequency"
45 gkfreq tablei kfreq, giExp20000, 1
46 outvalue "Base_Frequency_Value", gkfreq
47 gkAmp invalue "Amplitude"
48 gkFBRatio invalue "Feedback_Ratio"
49 endif
50 endin
51
52 instr 1 ;FM INSTRUMENT
53 if p4!=0 then ;MIDI
54 ioct = p4 ;READ OCT VALUE FROM MIDI INPUT
55 iamp = p5 ;READ midi-velocity-amp FROM MIDI INPUT
56 kAmp = iamp * gkAmp ;SET AMPLITUDE TO RECEIVED p5 RECEIVED FROM INSTR 1 (I.E. MIDI VELOCITY) MULTIPLIED BY SLIDER gkAmp.
57 ;PITCH BEND===========================================================================================================================================================
58 iSemitoneBendRange = 4 ;PITCH BEND RANGE IN SEMITONES
59 imin = 0 ;EQUILIBRIUM POSITION
60 imax = iSemitoneBendRange * .0833333 ;MAX PITCH DISPLACEMENT (IN oct FORMAT)
61 kbend pchbend imin, imax ;PITCH BEND VARIABLE (IN oct FORMAT)
62 kfreq = cpsoct(ioct + kbend) ;SET FUNDEMENTAL FROM MIDI
63 ;=====================================================================================================================================================================
64 else ;GUI
65 kfreq = gkfreq
66 kAmp = gkAmp ;SET kAmp TO SLIDER VALUE gkAmp
67 endif
68
69 iporttime = .02 ;PORTAMENTO FUNCTION (WILL BE USED TO SMOOTH PARAMETER MOVED BY FLTK WIDGETS)
70 kporttime linseg 0,.001,iporttime,1,iporttime ;PORTAMENTO FUNCTION (WILL BE USED TO SMOOTH PARAMETER MOVED BY FLTK WIDGETS)
71
72 kfreq portk kfreq, kporttime ;APPLY SMOOTHING PORTAMENTO TO THE VARIABLE 'kfreq'
73 kFBRatio portk gkFBRatio, kporttime ;APPLY SMOOTHING PORTAMENTO TO THE VARIABLE 'kFBratio'
74 kAmp portk kAmp, kporttime ;APPLY SMOOTHING PORTAMENTO TO THE VARIABLE 'kAmp'
75
76 aFB init 0 ;CREATE AN INITIAL VALUE FOR THE FEEDBACK SIGNAL
77 aCarPhase phasor kfreq ;CREATE A MOVING PHASE VALUE THAT WILL BE USED TO READ CREATE THE CARRIER
78 aCarrier tablei aCarPhase+aFB, gisine,1,0,1 ;CARRIER OSCILLATOR IS CREATED. NOTE THAT FEEDBACK SIGNAL IS ADDED TO THE POINTER VARIABLE
79 aFB = aCarrier * kFBRatio ;FEEDBACK SIGNAL UPDATED FOR THE NEXT PASS
80 aAntiClick linsegr 0,0.001,1,0.01,0 ;ANTI CLICK ENVELOPE
81 outs aCarrier*kAmp*aAntiClick, aCarrier*kAmp*aAntiClick ;SEND THE AUDIO OUTPUT OF THE CARRIER WAVEFORM TO THE OUTPUTS - RESCALE WITH 'kAmp' VARIABLE
82 endin
83 </CsInstruments>
84 <CsScore>
85 ;INSTR | START | DURATION
86 i 10 0 3600 ;GUI
87 </CsScore>
88 </CsoundSynthesizer>
89
90 <bsbPanel>
91 <label>Widgets</label>
92 <objectName/>
93 <x>499</x>
94 <y>349</y>
95 <width>774</width>
96 <height>217</height>
97 <visible>true</visible>
98 <uuid/>
99 <bgcolor mode="background">
100 <r>241</r>
101 <g>226</g>
102 <b>185</b>
103 </bgcolor>
104 <bsbObject version="2" type="BSBLabel">
105 <objectName/>
106 <x>2</x>
107 <y>2</y>
108 <width>512</width>
109 <height>210</height>
110 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
111 <visible>true</visible>
112 <midichan>0</midichan>
113 <midicc>0</midicc>
114 <label/>
115 <alignment>center</alignment>
116 <font>DejaVu Sans</font>
117 <fontsize>18</fontsize>
118 <precision>3</precision>
119 <color>
120 <r>255</r>
121 <g>255</g>
122 <b>255</b>
123 </color>
124 <bgcolor mode="background">
125 <r>5</r>
126 <g>27</g>
127 <b>150</b>
128 </bgcolor>
129 <bordermode>border</bordermode>
130 <borderradius>5</borderradius>
131 <borderwidth>2</borderwidth>
132 </bsbObject>
133 <bsbObject version="2" type="BSBLabel">
134 <objectName/>
135 <x>514</x>
136 <y>2</y>
137 <width>253</width>
138 <height>210</height>
139 <uuid>{74928ed2-b701-4668-9a11-74763d317e9b}</uuid>
140 <visible>true</visible>
141 <midichan>0</midichan>
142 <midicc>0</midicc>
143 <label/>
144 <alignment>center</alignment>
145 <font>DejaVu Sans</font>
146 <fontsize>18</fontsize>
147 <precision>3</precision>
148 <color>
149 <r>255</r>
150 <g>255</g>
151 <b>255</b>
152 </color>
153 <bgcolor mode="background">
154 <r>5</r>
155 <g>27</g>
156 <b>150</b>
157 </bgcolor>
158 <bordermode>border</bordermode>
159 <borderradius>5</borderradius>
160 <borderwidth>2</borderwidth>
161 </bsbObject>
162 <bsbObject version="2" type="BSBLabel">
163 <objectName/>
164 <x>518</x>
165 <y>61</y>
166 <width>243</width>
167 <height>137</height>
168 <uuid>{d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a}</uuid>
169 <visible>true</visible>
170 <midichan>0</midichan>
171 <midicc>0</midicc>
172 <label>----------------------------------------------------------
173 This example implements phase modulation synthesis with a single oscillator self-modulating via a feedback loop modulator.</label>
174 <alignment>left</alignment>
175 <font>Liberation Sans</font>
176 <fontsize>14</fontsize>
177 <precision>3</precision>
178 <color>
179 <r>255</r>
180 <g>255</g>
181 <b>255</b>
182 </color>
183 <bgcolor mode="nobackground">
184 <r>255</r>
185 <g>255</g>
186 <b>255</b>
187 </bgcolor>
188 <bordermode>noborder</bordermode>
189 <borderradius>1</borderradius>
190 <borderwidth>1</borderwidth>
191 </bsbObject>
192 <bsbObject version="2" type="BSBButton">
193 <objectName/>
194 <x>8</x>
195 <y>6</y>
196 <width>124</width>
197 <height>30</height>
198 <uuid>{24979132-c53f-4414-ac6b-6b4f503ecfe8}</uuid>
199 <visible>true</visible>
200 <midichan>0</midichan>
201 <midicc>0</midicc>
202 <type>event</type>
203 <pressedValue>1.00000000</pressedValue>
204 <stringvalue/>
205 <text> ON / OFF (MIDI)</text>
206 <image>/</image>
207 <eventLine>i 1 0 -1</eventLine>
208 <latch>true</latch>
209 <latched>false</latched>
210 </bsbObject>
211 <bsbObject version="2" type="BSBDisplay">
212 <objectName>Feedback_Ratio</objectName>
213 <x>448</x>
214 <y>179</y>
215 <width>60</width>
216 <height>30</height>
217 <uuid>{745d6bee-b951-4a03-9fe8-9e10d5ae4556}</uuid>
218 <visible>true</visible>
219 <midichan>0</midichan>
220 <midicc>0</midicc>
221 <label>0.214</label>
222 <alignment>right</alignment>
223 <font>Liberation Sans</font>
224 <fontsize>9</fontsize>
225 <precision>3</precision>
226 <color>
227 <r>255</r>
228 <g>255</g>
229 <b>255</b>
230 </color>
231 <bgcolor mode="nobackground">
232 <r>255</r>
233 <g>255</g>
234 <b>255</b>
235 </bgcolor>
236 <bordermode>noborder</bordermode>
237 <borderradius>1</borderradius>
238 <borderwidth>1</borderwidth>
239 </bsbObject>
240 <bsbObject version="2" type="BSBHSlider">
241 <objectName>Feedback_Ratio</objectName>
242 <x>8</x>
243 <y>157</y>
244 <width>500</width>
245 <height>27</height>
246 <uuid>{06814721-6151-4baa-84e2-8f39843b07a4}</uuid>
247 <visible>true</visible>
248 <midichan>0</midichan>
249 <midicc>0</midicc>
250 <minimum>0.00000000</minimum>
251 <maximum>1.00000000</maximum>
252 <value>0.21400000</value>
253 <mode>lin</mode>
254 <mouseControl act="jump">continuous</mouseControl>
255 <resolution>-1.00000000</resolution>
256 <randomizable group="0">false</randomizable>
257 </bsbObject>
258 <bsbObject version="2" type="BSBLabel">
259 <objectName/>
260 <x>8</x>
261 <y>179</y>
262 <width>180</width>
263 <height>30</height>
264 <uuid>{c6d7165c-6730-426f-b293-52b411bc73cf}</uuid>
265 <visible>true</visible>
266 <midichan>0</midichan>
267 <midicc>0</midicc>
268 <label>Feedback Ratio</label>
269 <alignment>left</alignment>
270 <font>Liberation Sans</font>
271 <fontsize>10</fontsize>
272 <precision>3</precision>
273 <color>
274 <r>255</r>
275 <g>255</g>
276 <b>255</b>
277 </color>
278 <bgcolor mode="nobackground">
279 <r>255</r>
280 <g>255</g>
281 <b>255</b>
282 </bgcolor>
283 <bordermode>noborder</bordermode>
284 <borderradius>1</borderradius>
285 <borderwidth>1</borderwidth>
286 </bsbObject>
287 <bsbObject version="2" type="BSBLabel">
288 <objectName/>
289 <x>8</x>
290 <y>90</y>
291 <width>180</width>
292 <height>30</height>
293 <uuid>{541ace1b-b1de-4c04-8d84-1de90288dded}</uuid>
294 <visible>true</visible>
295 <midichan>0</midichan>
296 <midicc>0</midicc>
297 <label>Base Frequency</label>
298 <alignment>left</alignment>
299 <font>Liberation Sans</font>
300 <fontsize>10</fontsize>
301 <precision>3</precision>
302 <color>
303 <r>255</r>
304 <g>255</g>
305 <b>255</b>
306 </color>
307 <bgcolor mode="nobackground">
308 <r>255</r>
309 <g>255</g>
310 <b>255</b>
311 </bgcolor>
312 <bordermode>noborder</bordermode>
313 <borderradius>1</borderradius>
314 <borderwidth>1</borderwidth>
315 </bsbObject>
316 <bsbObject version="2" type="BSBHSlider">
317 <objectName>Base_Frequency</objectName>
318 <x>8</x>
319 <y>67</y>
320 <width>500</width>
321 <height>27</height>
322 <uuid>{eac88081-deaa-45c0-b896-32a3ffedc74a}</uuid>
323 <visible>true</visible>
324 <midichan>0</midichan>
325 <midicc>0</midicc>
326 <minimum>0.00000000</minimum>
327 <maximum>1.00000000</maximum>
328 <value>0.23200000</value>
329 <mode>lin</mode>
330 <mouseControl act="jump">continuous</mouseControl>
331 <resolution>-1.00000000</resolution>
332 <randomizable group="0">false</randomizable>
333 </bsbObject>
334 <bsbObject version="2" type="BSBDisplay">
335 <objectName>Base_Frequency_Value</objectName>
336 <x>448</x>
337 <y>90</y>
338 <width>60</width>
339 <height>30</height>
340 <uuid>{3be43919-ad18-4aef-b554-03c4b4d991c3}</uuid>
341 <visible>true</visible>
342 <midichan>0</midichan>
343 <midicc>0</midicc>
344 <label>99.349</label>
345 <alignment>right</alignment>
346 <font>Liberation Sans</font>
347 <fontsize>9</fontsize>
348 <precision>3</precision>
349 <color>
350 <r>255</r>
351 <g>255</g>
352 <b>255</b>
353 </color>
354 <bgcolor mode="nobackground">
355 <r>255</r>
356 <g>255</g>
357 <b>255</b>
358 </bgcolor>
359 <bordermode>noborder</bordermode>
360 <borderradius>1</borderradius>
361 <borderwidth>1</borderwidth>
362 </bsbObject>
363 <bsbObject version="2" type="BSBLabel">
364 <objectName/>
365 <x>155</x>
366 <y>5</y>
367 <width>305</width>
368 <height>35</height>
369 <uuid>{c35c6c13-7799-4395-9775-f3006b3eafcb}</uuid>
370 <visible>true</visible>
371 <midichan>0</midichan>
372 <midicc>0</midicc>
373 <label>Phase Modulation Synthesis</label>
374 <alignment>center</alignment>
375 <font>Liberation Sans</font>
376 <fontsize>18</fontsize>
377 <precision>3</precision>
378 <color>
379 <r>255</r>
380 <g>255</g>
381 <b>255</b>
382 </color>
383 <bgcolor mode="nobackground">
384 <r>255</r>
385 <g>255</g>
386 <b>255</b>
387 </bgcolor>
388 <bordermode>noborder</bordermode>
389 <borderradius>1</borderradius>
390 <borderwidth>1</borderwidth>
391 </bsbObject>
392 <bsbObject version="2" type="BSBLabel">
393 <objectName/>
394 <x>114</x>
395 <y>28</y>
396 <width>387</width>
397 <height>31</height>
398 <uuid>{20b81ac9-e24a-4a60-bdb1-2c3bc2c578cf}</uuid>
399 <visible>true</visible>
400 <midichan>0</midichan>
401 <midicc>0</midicc>
402 <label>Carrier(with feedback)</label>
403 <alignment>center</alignment>
404 <font>Liberation Sans</font>
405 <fontsize>18</fontsize>
406 <precision>3</precision>
407 <color>
408 <r>255</r>
409 <g>255</g>
410 <b>255</b>
411 </color>
412 <bgcolor mode="nobackground">
413 <r>255</r>
414 <g>255</g>
415 <b>255</b>
416 </bgcolor>
417 <bordermode>noborder</bordermode>
418 <borderradius>1</borderradius>
419 <borderwidth>1</borderwidth>
420 </bsbObject>
421 <bsbObject version="2" type="BSBLabel">
422 <objectName/>
423 <x>516</x>
424 <y>28</y>
425 <width>241</width>
426 <height>51</height>
427 <uuid>{dd72e305-5880-4889-b044-bf9d9333880b}</uuid>
428 <visible>true</visible>
429 <midichan>0</midichan>
430 <midicc>0</midicc>
431 <label>Carrier(with feedback)</label>
432 <alignment>center</alignment>
433 <font>Liberation Sans</font>
434 <fontsize>18</fontsize>
435 <precision>3</precision>
436 <color>
437 <r>255</r>
438 <g>255</g>
439 <b>255</b>
440 </color>
441 <bgcolor mode="nobackground">
442 <r>255</r>
443 <g>255</g>
444 <b>255</b>
445 </bgcolor>
446 <bordermode>noborder</bordermode>
447 <borderradius>1</borderradius>
448 <borderwidth>1</borderwidth>
449 </bsbObject>
450 <bsbObject version="2" type="BSBLabel">
451 <objectName/>
452 <x>517</x>
453 <y>5</y>
454 <width>249</width>
455 <height>38</height>
456 <uuid>{28873f9f-f41a-4961-9ae9-c3948ecc50f0}</uuid>
457 <visible>true</visible>
458 <midichan>0</midichan>
459 <midicc>0</midicc>
460 <label>Phase Modulation Synthesis</label>
461 <alignment>center</alignment>
462 <font>Liberation Sans</font>
463 <fontsize>18</fontsize>
464 <precision>3</precision>
465 <color>
466 <r>255</r>
467 <g>255</g>
468 <b>255</b>
469 </color>
470 <bgcolor mode="nobackground">
471 <r>255</r>
472 <g>255</g>
473 <b>255</b>
474 </bgcolor>
475 <bordermode>noborder</bordermode>
476 <borderradius>1</borderradius>
477 <borderwidth>1</borderwidth>
478 </bsbObject>
479 <bsbObject version="2" type="BSBDisplay">
480 <objectName>Amplitude</objectName>
481 <x>448</x>
482 <y>136</y>
483 <width>60</width>
484 <height>30</height>
485 <uuid>{19817529-3f8b-44d0-9a9a-67d17b4b37e7}</uuid>
486 <visible>true</visible>
487 <midichan>0</midichan>
488 <midicc>0</midicc>
489 <label>0.364</label>
490 <alignment>right</alignment>
491 <font>Liberation Sans</font>
492 <fontsize>9</fontsize>
493 <precision>3</precision>
494 <color>
495 <r>255</r>
496 <g>255</g>
497 <b>255</b>
498 </color>
499 <bgcolor mode="nobackground">
500 <r>255</r>
501 <g>255</g>
502 <b>255</b>
503 </bgcolor>
504 <bordermode>noborder</bordermode>
505 <borderradius>1</borderradius>
506 <borderwidth>1</borderwidth>
507 </bsbObject>
508 <bsbObject version="2" type="BSBHSlider">
509 <objectName>Amplitude</objectName>
510 <x>8</x>
511 <y>113</y>
512 <width>500</width>
513 <height>27</height>
514 <uuid>{22c04b50-69c8-4d1e-bd32-2681a17bf37c}</uuid>
515 <visible>true</visible>
516 <midichan>0</midichan>
517 <midicc>0</midicc>
518 <minimum>0.00000000</minimum>
519 <maximum>1.00000000</maximum>
520 <value>0.36400000</value>
521 <mode>lin</mode>
522 <mouseControl act="jump">continuous</mouseControl>
523 <resolution>-1.00000000</resolution>
524 <randomizable group="0">false</randomizable>
525 </bsbObject>
526 <bsbObject version="2" type="BSBLabel">
527 <objectName/>
528 <x>8</x>
529 <y>136</y>
530 <width>180</width>
531 <height>30</height>
532 <uuid>{0568f562-1c69-4e8e-b2c5-d587f753e160}</uuid>
533 <visible>true</visible>
534 <midichan>0</midichan>
535 <midicc>0</midicc>
536 <label>Amplitude</label>
537 <alignment>left</alignment>
538 <font>Liberation Sans</font>
539 <fontsize>10</fontsize>
540 <precision>3</precision>
541 <color>
542 <r>255</r>
543 <g>255</g>
544 <b>255</b>
545 </color>
546 <bgcolor mode="nobackground">
547 <r>255</r>
548 <g>255</g>
549 <b>255</b>
550 </bgcolor>
551 <bordermode>noborder</bordermode>
552 <borderradius>1</borderradius>
553 <borderwidth>1</borderwidth>
554 </bsbObject>
555 </bsbPanel>
556 <bsbPresets>
557 </bsbPresets>
558 <EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="true" loopStart="0" loopEnd="0"> </EventPanel>