| 1 |
;Written by Iain McCurdy 2011 |
| 2 |
|
| 3 |
;Modified for QuteCsound by René, May 2011 |
| 4 |
;Tested on Ubuntu 10.04 with csound-float (git csound5-3c6d155, May 31 2011) and QuteCsound svn rev 848 |
| 5 |
|
| 6 |
;Notes on modifications from original csd: |
| 7 |
|
| 8 |
|
| 9 |
;my flags on Ubuntu: -dm0 -iadc -odac:system:playback_ -+rtaudio=jack -b32 -B4096 -+rtmidi=null |
| 10 |
<CsoundSynthesizer> |
| 11 |
<CsOptions> |
| 12 |
|
| 13 |
</CsOptions> |
| 14 |
<CsInstruments> |
| 15 |
sr = 44100 ;SAMPLE RATE |
| 16 |
ksmps = 32 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE |
| 17 |
nchnls = 1 ;NUMBER OF CHANNELS (2=STEREO) |
| 18 |
0dbfs = 1 ;MAXIMUM SOUND INTENSITY LEVEL REGARDLESS OF BIT DEPTH |
| 19 |
|
| 20 |
|
| 21 |
giwaveform ftgen 0,0,4096,10,1,1/4,1/16,1/32,1/64 ;SINGLE CYCLE OF A HARMONIC TONE |
| 22 |
|
| 23 |
|
| 24 |
instr 1 |
| 25 |
kInGain invalue "Gain" |
| 26 |
kthresh invalue "Threshold" |
| 27 |
kOutGain invalue "OutGain" |
| 28 |
|
| 29 |
asig inch 1 ;READ LIVE AUDIO FROM COMPUTER'S 1ST INPUT CHANNEL |
| 30 |
fsig pvsanal asig*kInGain, 1024, 256, 1024, 1 ;ANALYSE THE AUDIO SIGNAL. OUTPUT AN F-SIGNAL. |
| 31 |
kfr, kamp pvspitch fsig, kthresh ;ANALYSE THE FSIG AND OUTPUT ESTIMATIONS OF FUNDEMENTAL FREQUENCY AND AMPLITUDE |
| 32 |
aout oscili kamp, kfr, giwaveform ;CREATE AN OSCILLATOR, THE FREQUENCY AND AMPLITUDE OF WHICH ARE BASED ON DATA DERIVED FROM THE LIVE INPUT AUDIO STREAM |
| 33 |
out aout*kOutGain ;SEND THE RESCALED, RESYNTHESIZED SIGNAL TO THE AUDIO OUTPUTS |
| 34 |
endin |
| 35 |
</CsInstruments> |
| 36 |
<CsScore> |
| 37 |
f 0 3600 |
| 38 |
</CsScore> |
| 39 |
</CsoundSynthesizer> |
| 40 |
<bsbPanel> |
| 41 |
<label>Widgets</label> |
| 42 |
<objectName/> |
| 43 |
<x>736</x> |
| 44 |
<y>275</y> |
| 45 |
<width>800</width> |
| 46 |
<height>232</height> |
| 47 |
<visible>true</visible> |
| 48 |
<uuid/> |
| 49 |
<bgcolor mode="background"> |
| 50 |
<r>241</r> |
| 51 |
<g>226</g> |
| 52 |
<b>185</b> |
| 53 |
</bgcolor> |
| 54 |
<bsbObject version="2" type="BSBLabel"> |
| 55 |
<objectName/> |
| 56 |
<x>2</x> |
| 57 |
<y>2</y> |
| 58 |
<width>512</width> |
| 59 |
<height>230</height> |
| 60 |
<uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid> |
| 61 |
<visible>true</visible> |
| 62 |
<midichan>0</midichan> |
| 63 |
<midicc>0</midicc> |
| 64 |
<label>pvspitch</label> |
| 65 |
<alignment>center</alignment> |
| 66 |
<font>Liberation Sans</font> |
| 67 |
<fontsize>18</fontsize> |
| 68 |
<precision>3</precision> |
| 69 |
<color> |
| 70 |
<r>0</r> |
| 71 |
<g>0</g> |
| 72 |
<b>0</b> |
| 73 |
</color> |
| 74 |
<bgcolor mode="background"> |
| 75 |
<r>181</r> |
| 76 |
<g>199</g> |
| 77 |
<b>255</b> |
| 78 |
</bgcolor> |
| 79 |
<bordermode>border</bordermode> |
| 80 |
<borderradius>5</borderradius> |
| 81 |
<borderwidth>2</borderwidth> |
| 82 |
</bsbObject> |
| 83 |
<bsbObject version="2" type="BSBLabel"> |
| 84 |
<objectName/> |
| 85 |
<x>516</x> |
| 86 |
<y>2</y> |
| 87 |
<width>284</width> |
| 88 |
<height>230</height> |
| 89 |
<uuid>{74928ed2-b701-4668-9a11-74763d317e9b}</uuid> |
| 90 |
<visible>true</visible> |
| 91 |
<midichan>0</midichan> |
| 92 |
<midicc>0</midicc> |
| 93 |
<label>pvspitch</label> |
| 94 |
<alignment>center</alignment> |
| 95 |
<font>Liberation Sans</font> |
| 96 |
<fontsize>18</fontsize> |
| 97 |
<precision>3</precision> |
| 98 |
<color> |
| 99 |
<r>0</r> |
| 100 |
<g>0</g> |
| 101 |
<b>0</b> |
| 102 |
</color> |
| 103 |
<bgcolor mode="background"> |
| 104 |
<r>181</r> |
| 105 |
<g>199</g> |
| 106 |
<b>255</b> |
| 107 |
</bgcolor> |
| 108 |
<bordermode>border</bordermode> |
| 109 |
<borderradius>5</borderradius> |
| 110 |
<borderwidth>2</borderwidth> |
| 111 |
</bsbObject> |
| 112 |
<bsbObject version="2" type="BSBLabel"> |
| 113 |
<objectName/> |
| 114 |
<x>519</x> |
| 115 |
<y>22</y> |
| 116 |
<width>278</width> |
| 117 |
<height>200</height> |
| 118 |
<uuid>{d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a}</uuid> |
| 119 |
<visible>true</visible> |
| 120 |
<midichan>0</midichan> |
| 121 |
<midicc>0</midicc> |
| 122 |
<label>------------------------------------------------------------------- |
| 123 |
'pvspitch' analyses a fsig and generates k-rate estimates of fundemental frequency and amplitude. In this example the live audio input is analysed and the analysed data is used to define the frequency and amplitude of a synthesized tone. |
| 124 |
Threshold can be used to define a threshold beneath which sound components will be ignored. This can be used to filter out ambient noise between notes from the analysis.</label> |
| 125 |
<alignment>left</alignment> |
| 126 |
<font>Liberation Sans</font> |
| 127 |
<fontsize>14</fontsize> |
| 128 |
<precision>3</precision> |
| 129 |
<color> |
| 130 |
<r>0</r> |
| 131 |
<g>0</g> |
| 132 |
<b>0</b> |
| 133 |
</color> |
| 134 |
<bgcolor mode="nobackground"> |
| 135 |
<r>255</r> |
| 136 |
<g>255</g> |
| 137 |
<b>255</b> |
| 138 |
</bgcolor> |
| 139 |
<bordermode>noborder</bordermode> |
| 140 |
<borderradius>1</borderradius> |
| 141 |
<borderwidth>1</borderwidth> |
| 142 |
</bsbObject> |
| 143 |
<bsbObject version="2" type="BSBButton"> |
| 144 |
<objectName/> |
| 145 |
<x>8</x> |
| 146 |
<y>8</y> |
| 147 |
<width>100</width> |
| 148 |
<height>30</height> |
| 149 |
<uuid>{24979132-c53f-4414-ac6b-6b4f503ecfe8}</uuid> |
| 150 |
<visible>true</visible> |
| 151 |
<midichan>0</midichan> |
| 152 |
<midicc>0</midicc> |
| 153 |
<type>event</type> |
| 154 |
<pressedValue>1.00000000</pressedValue> |
| 155 |
<stringvalue/> |
| 156 |
<text> ON / OFF</text> |
| 157 |
<image>/</image> |
| 158 |
<eventLine>i 1 0 -1</eventLine> |
| 159 |
<latch>true</latch> |
| 160 |
<latched>false</latched> |
| 161 |
</bsbObject> |
| 162 |
<bsbObject version="2" type="BSBDisplay"> |
| 163 |
<objectName>Gain</objectName> |
| 164 |
<x>448</x> |
| 165 |
<y>74</y> |
| 166 |
<width>60</width> |
| 167 |
<height>30</height> |
| 168 |
<uuid>{745d6bee-b951-4a03-9fe8-9e10d5ae4556}</uuid> |
| 169 |
<visible>true</visible> |
| 170 |
<midichan>0</midichan> |
| 171 |
<midicc>0</midicc> |
| 172 |
<label>2.340</label> |
| 173 |
<alignment>right</alignment> |
| 174 |
<font>Arial</font> |
| 175 |
<fontsize>9</fontsize> |
| 176 |
<precision>3</precision> |
| 177 |
<color> |
| 178 |
<r>0</r> |
| 179 |
<g>0</g> |
| 180 |
<b>0</b> |
| 181 |
</color> |
| 182 |
<bgcolor mode="nobackground"> |
| 183 |
<r>255</r> |
| 184 |
<g>255</g> |
| 185 |
<b>255</b> |
| 186 |
</bgcolor> |
| 187 |
<bordermode>noborder</bordermode> |
| 188 |
<borderradius>1</borderradius> |
| 189 |
<borderwidth>1</borderwidth> |
| 190 |
</bsbObject> |
| 191 |
<bsbObject version="2" type="BSBHSlider"> |
| 192 |
<objectName>Gain</objectName> |
| 193 |
<x>8</x> |
| 194 |
<y>51</y> |
| 195 |
<width>500</width> |
| 196 |
<height>27</height> |
| 197 |
<uuid>{06814721-6151-4baa-84e2-8f39843b07a4}</uuid> |
| 198 |
<visible>true</visible> |
| 199 |
<midichan>0</midichan> |
| 200 |
<midicc>0</midicc> |
| 201 |
<minimum>0.00000000</minimum> |
| 202 |
<maximum>3.00000000</maximum> |
| 203 |
<value>2.34000000</value> |
| 204 |
<mode>lin</mode> |
| 205 |
<mouseControl act="jump">continuous</mouseControl> |
| 206 |
<resolution>-1.00000000</resolution> |
| 207 |
<randomizable group="0">false</randomizable> |
| 208 |
</bsbObject> |
| 209 |
<bsbObject version="2" type="BSBLabel"> |
| 210 |
<objectName/> |
| 211 |
<x>8</x> |
| 212 |
<y>74</y> |
| 213 |
<width>180</width> |
| 214 |
<height>30</height> |
| 215 |
<uuid>{c6d7165c-6730-426f-b293-52b411bc73cf}</uuid> |
| 216 |
<visible>true</visible> |
| 217 |
<midichan>0</midichan> |
| 218 |
<midicc>0</midicc> |
| 219 |
<label>Input Gain</label> |
| 220 |
<alignment>left</alignment> |
| 221 |
<font>Arial</font> |
| 222 |
<fontsize>10</fontsize> |
| 223 |
<precision>3</precision> |
| 224 |
<color> |
| 225 |
<r>0</r> |
| 226 |
<g>0</g> |
| 227 |
<b>0</b> |
| 228 |
</color> |
| 229 |
<bgcolor mode="nobackground"> |
| 230 |
<r>255</r> |
| 231 |
<g>255</g> |
| 232 |
<b>255</b> |
| 233 |
</bgcolor> |
| 234 |
<bordermode>noborder</bordermode> |
| 235 |
<borderradius>1</borderradius> |
| 236 |
<borderwidth>1</borderwidth> |
| 237 |
</bsbObject> |
| 238 |
<bsbObject version="2" type="BSBDisplay"> |
| 239 |
<objectName>Threshold</objectName> |
| 240 |
<x>448</x> |
| 241 |
<y>123</y> |
| 242 |
<width>60</width> |
| 243 |
<height>30</height> |
| 244 |
<uuid>{96be62fb-9f2a-4761-9be8-9aef6d88dda7}</uuid> |
| 245 |
<visible>true</visible> |
| 246 |
<midichan>0</midichan> |
| 247 |
<midicc>0</midicc> |
| 248 |
<label>0.085</label> |
| 249 |
<alignment>right</alignment> |
| 250 |
<font>Arial</font> |
| 251 |
<fontsize>9</fontsize> |
| 252 |
<precision>3</precision> |
| 253 |
<color> |
| 254 |
<r>0</r> |
| 255 |
<g>0</g> |
| 256 |
<b>0</b> |
| 257 |
</color> |
| 258 |
<bgcolor mode="nobackground"> |
| 259 |
<r>255</r> |
| 260 |
<g>255</g> |
| 261 |
<b>255</b> |
| 262 |
</bgcolor> |
| 263 |
<bordermode>noborder</bordermode> |
| 264 |
<borderradius>1</borderradius> |
| 265 |
<borderwidth>1</borderwidth> |
| 266 |
</bsbObject> |
| 267 |
<bsbObject version="2" type="BSBHSlider"> |
| 268 |
<objectName>Threshold</objectName> |
| 269 |
<x>8</x> |
| 270 |
<y>100</y> |
| 271 |
<width>500</width> |
| 272 |
<height>27</height> |
| 273 |
<uuid>{592ae49e-376b-419b-aa00-13c6872a64e7}</uuid> |
| 274 |
<visible>true</visible> |
| 275 |
<midichan>0</midichan> |
| 276 |
<midicc>0</midicc> |
| 277 |
<minimum>0.00100000</minimum> |
| 278 |
<maximum>1.00000000</maximum> |
| 279 |
<value>0.08491600</value> |
| 280 |
<mode>lin</mode> |
| 281 |
<mouseControl act="jump">continuous</mouseControl> |
| 282 |
<resolution>-1.00000000</resolution> |
| 283 |
<randomizable group="0">false</randomizable> |
| 284 |
</bsbObject> |
| 285 |
<bsbObject version="2" type="BSBLabel"> |
| 286 |
<objectName/> |
| 287 |
<x>8</x> |
| 288 |
<y>123</y> |
| 289 |
<width>180</width> |
| 290 |
<height>30</height> |
| 291 |
<uuid>{cfbe3e3a-7a32-4ca8-aa84-7da2153cd059}</uuid> |
| 292 |
<visible>true</visible> |
| 293 |
<midichan>0</midichan> |
| 294 |
<midicc>0</midicc> |
| 295 |
<label>Threshold</label> |
| 296 |
<alignment>left</alignment> |
| 297 |
<font>Arial</font> |
| 298 |
<fontsize>10</fontsize> |
| 299 |
<precision>3</precision> |
| 300 |
<color> |
| 301 |
<r>0</r> |
| 302 |
<g>0</g> |
| 303 |
<b>0</b> |
| 304 |
</color> |
| 305 |
<bgcolor mode="nobackground"> |
| 306 |
<r>255</r> |
| 307 |
<g>255</g> |
| 308 |
<b>255</b> |
| 309 |
</bgcolor> |
| 310 |
<bordermode>noborder</bordermode> |
| 311 |
<borderradius>1</borderradius> |
| 312 |
<borderwidth>1</borderwidth> |
| 313 |
</bsbObject> |
| 314 |
<bsbObject version="2" type="BSBDisplay"> |
| 315 |
<objectName>OutGain</objectName> |
| 316 |
<x>448</x> |
| 317 |
<y>172</y> |
| 318 |
<width>60</width> |
| 319 |
<height>30</height> |
| 320 |
<uuid>{59581403-249b-41d7-a156-8fecc4c57eb9}</uuid> |
| 321 |
<visible>true</visible> |
| 322 |
<midichan>0</midichan> |
| 323 |
<midicc>0</midicc> |
| 324 |
<label>0.624</label> |
| 325 |
<alignment>right</alignment> |
| 326 |
<font>Arial</font> |
| 327 |
<fontsize>9</fontsize> |
| 328 |
<precision>3</precision> |
| 329 |
<color> |
| 330 |
<r>0</r> |
| 331 |
<g>0</g> |
| 332 |
<b>0</b> |
| 333 |
</color> |
| 334 |
<bgcolor mode="nobackground"> |
| 335 |
<r>255</r> |
| 336 |
<g>255</g> |
| 337 |
<b>255</b> |
| 338 |
</bgcolor> |
| 339 |
<bordermode>noborder</bordermode> |
| 340 |
<borderradius>1</borderradius> |
| 341 |
<borderwidth>1</borderwidth> |
| 342 |
</bsbObject> |
| 343 |
<bsbObject version="2" type="BSBHSlider"> |
| 344 |
<objectName>OutGain</objectName> |
| 345 |
<x>8</x> |
| 346 |
<y>149</y> |
| 347 |
<width>500</width> |
| 348 |
<height>27</height> |
| 349 |
<uuid>{d0db0fef-0b84-4670-9350-204802c497dc}</uuid> |
| 350 |
<visible>true</visible> |
| 351 |
<midichan>0</midichan> |
| 352 |
<midicc>0</midicc> |
| 353 |
<minimum>0.00000000</minimum> |
| 354 |
<maximum>1.00000000</maximum> |
| 355 |
<value>0.62400000</value> |
| 356 |
<mode>lin</mode> |
| 357 |
<mouseControl act="jump">continuous</mouseControl> |
| 358 |
<resolution>-1.00000000</resolution> |
| 359 |
<randomizable group="0">false</randomizable> |
| 360 |
</bsbObject> |
| 361 |
<bsbObject version="2" type="BSBLabel"> |
| 362 |
<objectName/> |
| 363 |
<x>8</x> |
| 364 |
<y>172</y> |
| 365 |
<width>180</width> |
| 366 |
<height>30</height> |
| 367 |
<uuid>{8cecc9b3-e38a-4be6-8564-0b15fc468eb5}</uuid> |
| 368 |
<visible>true</visible> |
| 369 |
<midichan>0</midichan> |
| 370 |
<midicc>0</midicc> |
| 371 |
<label>Output Gain</label> |
| 372 |
<alignment>left</alignment> |
| 373 |
<font>Arial</font> |
| 374 |
<fontsize>10</fontsize> |
| 375 |
<precision>3</precision> |
| 376 |
<color> |
| 377 |
<r>0</r> |
| 378 |
<g>0</g> |
| 379 |
<b>0</b> |
| 380 |
</color> |
| 381 |
<bgcolor mode="nobackground"> |
| 382 |
<r>255</r> |
| 383 |
<g>255</g> |
| 384 |
<b>255</b> |
| 385 |
</bgcolor> |
| 386 |
<bordermode>noborder</bordermode> |
| 387 |
<borderradius>1</borderradius> |
| 388 |
<borderwidth>1</borderwidth> |
| 389 |
</bsbObject> |
| 390 |
</bsbPanel> |
| 391 |
<bsbPresets> |
| 392 |
</bsbPresets> |
| 393 |
<EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="true" loopStart="0" loopEnd="0"> </EventPanel> |