Debian Codegraph @

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

raw
1 ;Written by Iain McCurdy, 2006
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
9
10 ;my flags on Ubuntu: -iadc -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=null -m0
11 <CsoundSynthesizer>
12 <CsOptions>
13
14 </CsOptions>
15 <CsInstruments>
16 sr = 44100 ;SAMPLE RATE
17 ksmps = 1 ;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 gisine ftgen 0, 0, 129, 10, 1 ;A SINE WAVE (INTERPOLATING OSCILLATOR OPCODES ARE USED THEREFORE A SMALL TABLE SIZE (+1) CAN BE USED)
23
24
25 instr 1
26 ifreq = 300 ;FREQUENCY OF THE CARRIER
27
28 ;VIBRATO DEPTH - GRADUALLY INCREASES - WHEN VIBRATO FREQUENCY IS HIGH (MORE THAN ABOUT 15 Hz), INCREASES IN VIBRATO DEPTH ARE PERCEIVED AS INCREASES IN THE STRENGTH AND NUMBERS OF THE SIDE BANDS, I.E. SPECTRAL RICHNESS/BRIGHTNESS OF THE TIMBRE
29 kVibratoDepth expseg .001, (4), 30, (8), 1000, (25), 1000, (8), 3000
30
31 ;VIBRATO FREQUENCY - GRADUALLY BUILDS, EVENTUALLY WE ARE NO LONGER ABLE TO PERCEIVE THE PITCH FLUCTUATIONS BUT INSTEAD HEAR 'SIDE BANDS'
32 kVibratoFreq expseg 2, (9), 7, (8), 350, (20), 1000, (8), 1000
33
34 ;THE MODULATOR WAVEFORM IS CREATED
35 aVibrato oscili kVibratoDepth, kVibratoFreq, gisine
36
37 ;THE AUDIO OUTPUT OF THE MODULATOR WAVEFORM (aModulator) IS ADDED TO THE FREQUENCY OF THE CARRIER WAVEFORM
38 aSignal oscili 0.2, ifreq + aVibrato, gisine
39 dispfft aSignal, 0.1, 2048
40 outs aSignal, aSignal
41 ktrig metro 10 ;CREATE A REPEATING TRIGGER SIGNAL
42 if ktrig==1 then
43 outvalue "Vibrato_Depth", kVibratoDepth ;UPDATE VALUE BOX 'gihVibratoDepth' WITH THE VALUE kVibratoDepth WHENEVER A TRIGGER PULSE IS RECEIVED
44 outvalue "Vibrato_Rate", kVibratoFreq ;UPDATE VALUE BOX 'gihVibratoFreq' WITH THE VALUE kVibratoFreq WHENEVER A TRIGGER PULSE IS RECEIVED
45 endif
46 endin
47 </CsInstruments>
48 <CsScore>
49 f 0 3600 ;DUMMY SCORE EVENT - KEEPS REALTIME PERFORMANCE GOING FOR ONE HOUR
50 </CsScore>
51 </CsoundSynthesizer>
52
53 <bsbPanel>
54 <label>Widgets</label>
55 <objectName/>
56 <x>310</x>
57 <y>303</y>
58 <width>1036</width>
59 <height>321</height>
60 <visible>true</visible>
61 <uuid/>
62 <bgcolor mode="background">
63 <r>241</r>
64 <g>226</g>
65 <b>185</b>
66 </bgcolor>
67 <bsbObject version="2" type="BSBLabel">
68 <objectName/>
69 <x>2</x>
70 <y>2</y>
71 <width>515</width>
72 <height>300</height>
73 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
74 <visible>true</visible>
75 <midichan>0</midichan>
76 <midicc>0</midicc>
77 <label> FM Synthesis: Vibrato to Side Bands</label>
78 <alignment>center</alignment>
79 <font>Liberation Sans</font>
80 <fontsize>18</fontsize>
81 <precision>3</precision>
82 <color>
83 <r>255</r>
84 <g>255</g>
85 <b>255</b>
86 </color>
87 <bgcolor mode="background">
88 <r>5</r>
89 <g>27</g>
90 <b>150</b>
91 </bgcolor>
92 <bordermode>border</bordermode>
93 <borderradius>5</borderradius>
94 <borderwidth>2</borderwidth>
95 </bsbObject>
96 <bsbObject version="2" type="BSBLabel">
97 <objectName/>
98 <x>519</x>
99 <y>2</y>
100 <width>495</width>
101 <height>300</height>
102 <uuid>{74928ed2-b701-4668-9a11-74763d317e9b}</uuid>
103 <visible>true</visible>
104 <midichan>0</midichan>
105 <midicc>0</midicc>
106 <label>FM Synthesis: Vibrato to Side Bands</label>
107 <alignment>center</alignment>
108 <font>Liberation Sans</font>
109 <fontsize>18</fontsize>
110 <precision>3</precision>
111 <color>
112 <r>255</r>
113 <g>255</g>
114 <b>255</b>
115 </color>
116 <bgcolor mode="background">
117 <r>5</r>
118 <g>27</g>
119 <b>150</b>
120 </bgcolor>
121 <bordermode>border</bordermode>
122 <borderradius>5</borderradius>
123 <borderwidth>2</borderwidth>
124 </bsbObject>
125 <bsbObject version="2" type="BSBLabel">
126 <objectName/>
127 <x>520</x>
128 <y>28</y>
129 <width>489</width>
130 <height>270</height>
131 <uuid>{d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a}</uuid>
132 <visible>true</visible>
133 <midichan>0</midichan>
134 <midicc>0</midicc>
135 <label>------------------------------------------------------------------------------------------------------------------------
136 This example demonstrates the phenomenon of side bands upon which FM (frequency modulation) synthesis relies. A vibrato function is applied to the frequency control of an oscillator. Gradually the amplitude (depth) and the frequency (speed/rate) of the vibrato are increased. The amplitude (depth) of the vibrato moves from a value of .001 to a final value of 3000. These amplitude values will be added to the frequency of the oscillator. The frequency (speed/rate) of the value rises from a value of 2 Hz to a final value of 3000 Hz. At the beginning of the transformation vibrato is heard but as the frequency (speed/rate) of the vibrato increases we lose the ability to perceive individual pitch fluctuations and instead side bands (additional spectral artefacts) emerge. As the frequency of the vibrato function continues to increase the nature of the spectrum of the new sound continually evolves. As the amplitude of the vibrato function increases beyond the stage where we were still able to perceive vibrato the intensity of the sidebands and therefore the brightness of the new timbre increases.</label>
137 <alignment>left</alignment>
138 <font>Arial</font>
139 <fontsize>14</fontsize>
140 <precision>3</precision>
141 <color>
142 <r>255</r>
143 <g>255</g>
144 <b>255</b>
145 </color>
146 <bgcolor mode="nobackground">
147 <r>255</r>
148 <g>255</g>
149 <b>255</b>
150 </bgcolor>
151 <bordermode>noborder</bordermode>
152 <borderradius>1</borderradius>
153 <borderwidth>1</borderwidth>
154 </bsbObject>
155 <bsbObject version="2" type="BSBButton">
156 <objectName/>
157 <x>6</x>
158 <y>6</y>
159 <width>100</width>
160 <height>30</height>
161 <uuid>{24979132-c53f-4414-ac6b-6b4f503ecfe8}</uuid>
162 <visible>true</visible>
163 <midichan>0</midichan>
164 <midicc>0</midicc>
165 <type>event</type>
166 <pressedValue>1.00000000</pressedValue>
167 <stringvalue/>
168 <text> Play</text>
169 <image>/</image>
170 <eventLine>i 1 0 45</eventLine>
171 <latch>false</latch>
172 <latched>false</latched>
173 </bsbObject>
174 <bsbObject version="2" type="BSBLabel">
175 <objectName/>
176 <x>13</x>
177 <y>52</y>
178 <width>180</width>
179 <height>30</height>
180 <uuid>{c6d7165c-6730-426f-b293-52b411bc73cf}</uuid>
181 <visible>true</visible>
182 <midichan>0</midichan>
183 <midicc>0</midicc>
184 <label>Vibrato Depth</label>
185 <alignment>right</alignment>
186 <font>Arial</font>
187 <fontsize>10</fontsize>
188 <precision>3</precision>
189 <color>
190 <r>255</r>
191 <g>255</g>
192 <b>255</b>
193 </color>
194 <bgcolor mode="nobackground">
195 <r>255</r>
196 <g>255</g>
197 <b>255</b>
198 </bgcolor>
199 <bordermode>noborder</bordermode>
200 <borderradius>1</borderradius>
201 <borderwidth>1</borderwidth>
202 </bsbObject>
203 <bsbObject version="2" type="BSBLabel">
204 <objectName/>
205 <x>13</x>
206 <y>92</y>
207 <width>180</width>
208 <height>30</height>
209 <uuid>{027163fb-bbfe-488e-9351-1c1cd9a9d626}</uuid>
210 <visible>true</visible>
211 <midichan>0</midichan>
212 <midicc>0</midicc>
213 <label>Vibrato Rate (Hz)</label>
214 <alignment>right</alignment>
215 <font>Arial</font>
216 <fontsize>10</fontsize>
217 <precision>3</precision>
218 <color>
219 <r>255</r>
220 <g>255</g>
221 <b>255</b>
222 </color>
223 <bgcolor mode="nobackground">
224 <r>255</r>
225 <g>255</g>
226 <b>255</b>
227 </bgcolor>
228 <bordermode>noborder</bordermode>
229 <borderradius>1</borderradius>
230 <borderwidth>1</borderwidth>
231 </bsbObject>
232 <bsbObject version="2" type="BSBDisplay">
233 <objectName>Vibrato_Depth</objectName>
234 <x>212</x>
235 <y>52</y>
236 <width>80</width>
237 <height>30</height>
238 <uuid>{d0676861-6836-4fab-8f47-512660445182}</uuid>
239 <visible>true</visible>
240 <midichan>0</midichan>
241 <midicc>0</midicc>
242 <label>93.768</label>
243 <alignment>left</alignment>
244 <font>Arial</font>
245 <fontsize>10</fontsize>
246 <precision>3</precision>
247 <color>
248 <r>0</r>
249 <g>0</g>
250 <b>0</b>
251 </color>
252 <bgcolor mode="background">
253 <r>255</r>
254 <g>255</g>
255 <b>255</b>
256 </bgcolor>
257 <bordermode>border</bordermode>
258 <borderradius>1</borderradius>
259 <borderwidth>1</borderwidth>
260 </bsbObject>
261 <bsbObject version="2" type="BSBDisplay">
262 <objectName>Vibrato_Rate</objectName>
263 <x>212</x>
264 <y>92</y>
265 <width>80</width>
266 <height>30</height>
267 <uuid>{a905d977-20bf-462e-8265-d6badf285cbb}</uuid>
268 <visible>true</visible>
269 <midichan>0</midichan>
270 <midicc>0</midicc>
271 <label>5.012</label>
272 <alignment>left</alignment>
273 <font>Arial</font>
274 <fontsize>10</fontsize>
275 <precision>3</precision>
276 <color>
277 <r>0</r>
278 <g>0</g>
279 <b>0</b>
280 </color>
281 <bgcolor mode="background">
282 <r>255</r>
283 <g>255</g>
284 <b>255</b>
285 </bgcolor>
286 <bordermode>border</bordermode>
287 <borderradius>1</borderradius>
288 <borderwidth>1</borderwidth>
289 </bsbObject>
290 <bsbObject version="2" type="BSBScope">
291 <objectName/>
292 <x>9</x>
293 <y>131</y>
294 <width>259</width>
295 <height>159</height>
296 <uuid>{57aca026-ed5a-45dd-9e5c-65bad8e2f077}</uuid>
297 <visible>true</visible>
298 <midichan>0</midichan>
299 <midicc>0</midicc>
300 <value>-255.00000000</value>
301 <type>scope</type>
302 <zoomx>2.00000000</zoomx>
303 <zoomy>1.00000000</zoomy>
304 <dispx>1.00000000</dispx>
305 <dispy>1.00000000</dispy>
306 <mode>0.00000000</mode>
307 </bsbObject>
308 <bsbObject version="2" type="BSBGraph">
309 <objectName/>
310 <x>271</x>
311 <y>131</y>
312 <width>238</width>
313 <height>160</height>
314 <uuid>{30073ad5-99c1-4e7a-ad5a-8d4d43022a67}</uuid>
315 <visible>true</visible>
316 <midichan>0</midichan>
317 <midicc>0</midicc>
318 <value>0</value>
319 <objectName2/>
320 <zoomx>4.00000000</zoomx>
321 <zoomy>1.00000000</zoomy>
322 <dispx>1.00000000</dispx>
323 <dispy>1.00000000</dispy>
324 <modex>lin</modex>
325 <modey>lin</modey>
326 <all>true</all>
327 </bsbObject>
328 </bsbPanel>
329 <bsbPresets>
330 </bsbPresets>
331 <EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="true" loopStart="0" loopEnd="0"> </EventPanel>