Debian Codegraph @

src/Examples/McCurdy Collection/FFT/pvswrite.csd

raw
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
7 ;Notes on modifications from original csd:
8 ; Add table(s) for exp slider
9
10
11 ;my flags on Ubuntu: -iadc -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=null -m0
12 <CsoundSynthesizer>
13 <CsOptions>
14 --env:SADIR+=../../SourceMaterials
15 </CsOptions>
16 <CsInstruments>
17 sr = 44100 ;SAMPLE RATE
18 ksmps = 16 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
19 nchnls = 1 ;NUMBER OF CHANNELS (2=STEREO)
20
21
22 giExp1 ftgen 0, 0, 129, -25, 0, 0.125, 128, 4.0 ;TABLE FOR EXP SLIDER
23
24 strset 1, "Write"
25 strset 2, "Read"
26
27 #define ANALYSISFILE #"pvswriteFile.pvx"#
28
29 instr 10 ;GUI
30 ktrig metro 10
31 if (ktrig == 1) then
32 ;BUTTONS
33 gkwrite invalue "Write"
34 gkread invalue "Read" ;lance i 2 0 3600
35 ;SLIDERS
36 gkptr invalue "Pointer"
37 gkspeed invalue "Speed"
38 ktrans invalue "Transpose"
39 gktrans tablei ktrans, giExp1, 1
40 outvalue "Transpose_Value", gktrans
41 gkGain invalue "Gain"
42 ;MENU
43 gkPtrMode invalue "Mode"
44 endif
45 endin
46
47 instr 1 ;WRITE PVS FILE
48 event_i "i", 3, 0, 0.01, 2, 2 ;to prevent to read while writing
49
50 asigin inch 1 ;READ AUDIO FROM THE LIVE AUDIO INPUT
51 fsigin pvsanal asigin, 1024, 256, 1024, 1 ;ANALYSE THE AUDIO SIGNAL THAT WAS CREATED IN INSTRUMENT 1. OUTPUT AN F-SIGNAL.
52 pvsfwrite fsigin, $ANALYSISFILE
53 endin
54
55 instr 2 ;READ PVS FILE
56 event_i "i", 3, 0, 0.01, 1, 1 ;to prevent to write while reading
57
58 ilen filelen $ANALYSISFILE
59 kporttime linseg 0,0.001,0.05
60
61 if gkPtrMode==0 then
62 kptr portk gkptr, kporttime
63 else
64 kptr phasor gkspeed/ilen
65 endif
66
67 fsig1 pvsfread kptr*ilen,$ANALYSISFILE
68 fsig2 pvscale fsig1, gktrans
69
70 aresyn pvsynth fsig2 ;RESYNTHESIZE THE f-SIGNAL AS AN AUDIO SIGNAL
71 out aresyn*gkGain
72 endin
73
74 instr 3 ;CONTROLS
75 Str strget p5
76 turnoff2 p4, 0, 0
77 outvalue Str, 0
78 turnoff
79 endin
80
81 instr 11 ;INIT
82 outvalue "Gain" , 0.5
83 outvalue "Mode" , 1
84 outvalue "Speed" , 1
85 outvalue "Pointer" , 0.5
86 outvalue "Transpose" , 0.6
87 endin
88 </CsInstruments>
89 <CsScore>
90 ;INSTR | START | DURATION
91 i 10 0 3600 ;GUI
92 i 11 0 0 ;INIT
93 </CsScore>
94 </CsoundSynthesizer>
95
96
97
98 <bsbPanel>
99 <label>Widgets</label>
100 <objectName/>
101 <x>73</x>
102 <y>206</y>
103 <width>865</width>
104 <height>362</height>
105 <visible>true</visible>
106 <uuid/>
107 <bgcolor mode="background">
108 <r>241</r>
109 <g>226</g>
110 <b>185</b>
111 </bgcolor>
112 <bsbObject version="2" type="BSBLabel">
113 <objectName/>
114 <x>2</x>
115 <y>2</y>
116 <width>512</width>
117 <height>360</height>
118 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
119 <visible>true</visible>
120 <midichan>0</midichan>
121 <midicc>0</midicc>
122 <label>pvswrite</label>
123 <alignment>center</alignment>
124 <font>Liberation Sans</font>
125 <fontsize>18</fontsize>
126 <precision>3</precision>
127 <color>
128 <r>0</r>
129 <g>0</g>
130 <b>0</b>
131 </color>
132 <bgcolor mode="background">
133 <r>181</r>
134 <g>199</g>
135 <b>255</b>
136 </bgcolor>
137 <bordermode>border</bordermode>
138 <borderradius>5</borderradius>
139 <borderwidth>2</borderwidth>
140 </bsbObject>
141 <bsbObject version="2" type="BSBLabel">
142 <objectName/>
143 <x>517</x>
144 <y>2</y>
145 <width>348</width>
146 <height>360</height>
147 <uuid>{74928ed2-b701-4668-9a11-74763d317e9b}</uuid>
148 <visible>true</visible>
149 <midichan>0</midichan>
150 <midicc>0</midicc>
151 <label>pvswrite</label>
152 <alignment>center</alignment>
153 <font>Liberation Sans</font>
154 <fontsize>18</fontsize>
155 <precision>3</precision>
156 <color>
157 <r>0</r>
158 <g>0</g>
159 <b>0</b>
160 </color>
161 <bgcolor mode="background">
162 <r>181</r>
163 <g>199</g>
164 <b>255</b>
165 </bgcolor>
166 <bordermode>border</bordermode>
167 <borderradius>5</borderradius>
168 <borderwidth>2</borderwidth>
169 </bsbObject>
170 <bsbObject version="2" type="BSBLabel">
171 <objectName/>
172 <x>520</x>
173 <y>21</y>
174 <width>342</width>
175 <height>336</height>
176 <uuid>{d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a}</uuid>
177 <visible>true</visible>
178 <midichan>0</midichan>
179 <midicc>0</midicc>
180 <label>-----------------------------------------------------------------------------------
181 'pvswrite' allows you to write a streaming f-sig to a pvx file stored on disk. The stored pvx file can be accessed later during that performance or in a completely new performance. In this example the user first records a pvx file to disk using the 'Write' button to start and then stop this procedure. The audio for this pvx file is taken from the computer's live input. This stored file can then be replayed using the 'play' button. 'pvsfread' is used to replay the file and the user can choose between two modes of playback:
182 one in which a pointer through the file is controlled manually and another in which the user controls the playback speed. The user can also modulate the transposition of the file - this is implemented using the 'pvscale' opcode. As the file is loaded once during playback, re-recording a new file will not overwrite the original file loaded into memory, instead performance will need to be restarted.</label>
183 <alignment>left</alignment>
184 <font>Liberation Sans</font>
185 <fontsize>14</fontsize>
186 <precision>3</precision>
187 <color>
188 <r>0</r>
189 <g>0</g>
190 <b>0</b>
191 </color>
192 <bgcolor mode="nobackground">
193 <r>255</r>
194 <g>255</g>
195 <b>255</b>
196 </bgcolor>
197 <bordermode>noborder</bordermode>
198 <borderradius>1</borderradius>
199 <borderwidth>1</borderwidth>
200 </bsbObject>
201 <bsbObject version="2" type="BSBButton">
202 <objectName>Write</objectName>
203 <x>8</x>
204 <y>55</y>
205 <width>80</width>
206 <height>30</height>
207 <uuid>{24979132-c53f-4414-ac6b-6b4f503ecfe8}</uuid>
208 <visible>true</visible>
209 <midichan>0</midichan>
210 <midicc>0</midicc>
211 <type>event</type>
212 <pressedValue>1.00000000</pressedValue>
213 <stringvalue/>
214 <text> Write</text>
215 <image>/</image>
216 <eventLine>i 1 0 -1</eventLine>
217 <latch>true</latch>
218 <latched>false</latched>
219 </bsbObject>
220 <bsbObject version="2" type="BSBDisplay">
221 <objectName>Pointer</objectName>
222 <x>448</x>
223 <y>133</y>
224 <width>60</width>
225 <height>30</height>
226 <uuid>{745d6bee-b951-4a03-9fe8-9e10d5ae4556}</uuid>
227 <visible>true</visible>
228 <midichan>0</midichan>
229 <midicc>0</midicc>
230 <label>0.674</label>
231 <alignment>right</alignment>
232 <font>Arial</font>
233 <fontsize>9</fontsize>
234 <precision>3</precision>
235 <color>
236 <r>0</r>
237 <g>0</g>
238 <b>0</b>
239 </color>
240 <bgcolor mode="nobackground">
241 <r>255</r>
242 <g>255</g>
243 <b>255</b>
244 </bgcolor>
245 <bordermode>noborder</bordermode>
246 <borderradius>1</borderradius>
247 <borderwidth>1</borderwidth>
248 </bsbObject>
249 <bsbObject version="2" type="BSBHSlider">
250 <objectName>Pointer</objectName>
251 <x>8</x>
252 <y>111</y>
253 <width>500</width>
254 <height>27</height>
255 <uuid>{06814721-6151-4baa-84e2-8f39843b07a4}</uuid>
256 <visible>true</visible>
257 <midichan>0</midichan>
258 <midicc>0</midicc>
259 <minimum>0.00000000</minimum>
260 <maximum>1.00000000</maximum>
261 <value>0.67400000</value>
262 <mode>lin</mode>
263 <mouseControl act="jump">continuous</mouseControl>
264 <resolution>-1.00000000</resolution>
265 <randomizable group="0">false</randomizable>
266 </bsbObject>
267 <bsbObject version="2" type="BSBLabel">
268 <objectName/>
269 <x>8</x>
270 <y>133</y>
271 <width>150</width>
272 <height>30</height>
273 <uuid>{c6d7165c-6730-426f-b293-52b411bc73cf}</uuid>
274 <visible>true</visible>
275 <midichan>0</midichan>
276 <midicc>0</midicc>
277 <label>File Pointer</label>
278 <alignment>left</alignment>
279 <font>Liberation Sans</font>
280 <fontsize>10</fontsize>
281 <precision>3</precision>
282 <color>
283 <r>0</r>
284 <g>0</g>
285 <b>0</b>
286 </color>
287 <bgcolor mode="nobackground">
288 <r>255</r>
289 <g>255</g>
290 <b>255</b>
291 </bgcolor>
292 <bordermode>noborder</bordermode>
293 <borderradius>1</borderradius>
294 <borderwidth>1</borderwidth>
295 </bsbObject>
296 <bsbObject version="2" type="BSBDisplay">
297 <objectName>Speed</objectName>
298 <x>448</x>
299 <y>181</y>
300 <width>60</width>
301 <height>30</height>
302 <uuid>{e18e15d6-c58d-4c38-a766-79602b72f947}</uuid>
303 <visible>true</visible>
304 <midichan>0</midichan>
305 <midicc>0</midicc>
306 <label>0.736</label>
307 <alignment>right</alignment>
308 <font>Arial</font>
309 <fontsize>9</fontsize>
310 <precision>3</precision>
311 <color>
312 <r>0</r>
313 <g>0</g>
314 <b>0</b>
315 </color>
316 <bgcolor mode="nobackground">
317 <r>255</r>
318 <g>255</g>
319 <b>255</b>
320 </bgcolor>
321 <bordermode>noborder</bordermode>
322 <borderradius>1</borderradius>
323 <borderwidth>1</borderwidth>
324 </bsbObject>
325 <bsbObject version="2" type="BSBHSlider">
326 <objectName>Speed</objectName>
327 <x>8</x>
328 <y>159</y>
329 <width>500</width>
330 <height>27</height>
331 <uuid>{36779c76-0b42-4e18-819b-e02bf72d22dd}</uuid>
332 <visible>true</visible>
333 <midichan>0</midichan>
334 <midicc>0</midicc>
335 <minimum>-2.00000000</minimum>
336 <maximum>2.00000000</maximum>
337 <value>0.73600000</value>
338 <mode>lin</mode>
339 <mouseControl act="jump">continuous</mouseControl>
340 <resolution>-1.00000000</resolution>
341 <randomizable group="0">false</randomizable>
342 </bsbObject>
343 <bsbObject version="2" type="BSBLabel">
344 <objectName/>
345 <x>8</x>
346 <y>181</y>
347 <width>150</width>
348 <height>30</height>
349 <uuid>{b74148fe-3ba3-4d62-b507-64eb27627e65}</uuid>
350 <visible>true</visible>
351 <midichan>0</midichan>
352 <midicc>0</midicc>
353 <label>Pointer Speed</label>
354 <alignment>left</alignment>
355 <font>Liberation Sans</font>
356 <fontsize>10</fontsize>
357 <precision>3</precision>
358 <color>
359 <r>0</r>
360 <g>0</g>
361 <b>0</b>
362 </color>
363 <bgcolor mode="nobackground">
364 <r>255</r>
365 <g>255</g>
366 <b>255</b>
367 </bgcolor>
368 <bordermode>noborder</bordermode>
369 <borderradius>1</borderradius>
370 <borderwidth>1</borderwidth>
371 </bsbObject>
372 <bsbObject version="2" type="BSBDisplay">
373 <objectName>Transpose_Value</objectName>
374 <x>448</x>
375 <y>229</y>
376 <width>60</width>
377 <height>30</height>
378 <uuid>{3c299cf9-f5e6-4902-9f6c-4d3802f1beb8}</uuid>
379 <visible>true</visible>
380 <midichan>0</midichan>
381 <midicc>0</midicc>
382 <label>1.000</label>
383 <alignment>right</alignment>
384 <font>Arial</font>
385 <fontsize>9</fontsize>
386 <precision>3</precision>
387 <color>
388 <r>0</r>
389 <g>0</g>
390 <b>0</b>
391 </color>
392 <bgcolor mode="nobackground">
393 <r>255</r>
394 <g>255</g>
395 <b>255</b>
396 </bgcolor>
397 <bordermode>noborder</bordermode>
398 <borderradius>1</borderradius>
399 <borderwidth>1</borderwidth>
400 </bsbObject>
401 <bsbObject version="2" type="BSBHSlider">
402 <objectName>Transpose</objectName>
403 <x>8</x>
404 <y>207</y>
405 <width>500</width>
406 <height>27</height>
407 <uuid>{b96a19b5-e2ff-4bc8-9d9c-e1878dc2c7ea}</uuid>
408 <visible>true</visible>
409 <midichan>0</midichan>
410 <midicc>0</midicc>
411 <minimum>0.00000000</minimum>
412 <maximum>1.00000000</maximum>
413 <value>0.60000002</value>
414 <mode>lin</mode>
415 <mouseControl act="jump">continuous</mouseControl>
416 <resolution>-1.00000000</resolution>
417 <randomizable group="0">false</randomizable>
418 </bsbObject>
419 <bsbObject version="2" type="BSBLabel">
420 <objectName/>
421 <x>8</x>
422 <y>229</y>
423 <width>150</width>
424 <height>30</height>
425 <uuid>{3f67483e-a5a5-4c55-8c4c-802b8cb45fcb}</uuid>
426 <visible>true</visible>
427 <midichan>0</midichan>
428 <midicc>0</midicc>
429 <label>Transpose</label>
430 <alignment>left</alignment>
431 <font>Liberation Sans</font>
432 <fontsize>10</fontsize>
433 <precision>3</precision>
434 <color>
435 <r>0</r>
436 <g>0</g>
437 <b>0</b>
438 </color>
439 <bgcolor mode="nobackground">
440 <r>255</r>
441 <g>255</g>
442 <b>255</b>
443 </bgcolor>
444 <bordermode>noborder</bordermode>
445 <borderradius>1</borderradius>
446 <borderwidth>1</borderwidth>
447 </bsbObject>
448 <bsbObject version="2" type="BSBDisplay">
449 <objectName>Gain</objectName>
450 <x>448</x>
451 <y>277</y>
452 <width>60</width>
453 <height>30</height>
454 <uuid>{44e73856-6869-4340-96a9-e5a61ecd5938}</uuid>
455 <visible>true</visible>
456 <midichan>0</midichan>
457 <midicc>0</midicc>
458 <label>0.752</label>
459 <alignment>right</alignment>
460 <font>Arial</font>
461 <fontsize>9</fontsize>
462 <precision>3</precision>
463 <color>
464 <r>0</r>
465 <g>0</g>
466 <b>0</b>
467 </color>
468 <bgcolor mode="nobackground">
469 <r>255</r>
470 <g>255</g>
471 <b>255</b>
472 </bgcolor>
473 <bordermode>noborder</bordermode>
474 <borderradius>1</borderradius>
475 <borderwidth>1</borderwidth>
476 </bsbObject>
477 <bsbObject version="2" type="BSBHSlider">
478 <objectName>Gain</objectName>
479 <x>8</x>
480 <y>255</y>
481 <width>500</width>
482 <height>27</height>
483 <uuid>{484ef1b1-d231-454a-b908-cadd3e9dcbc1}</uuid>
484 <visible>true</visible>
485 <midichan>0</midichan>
486 <midicc>0</midicc>
487 <minimum>0.00000000</minimum>
488 <maximum>1.00000000</maximum>
489 <value>0.75200000</value>
490 <mode>lin</mode>
491 <mouseControl act="jump">continuous</mouseControl>
492 <resolution>-1.00000000</resolution>
493 <randomizable group="0">false</randomizable>
494 </bsbObject>
495 <bsbObject version="2" type="BSBLabel">
496 <objectName/>
497 <x>8</x>
498 <y>277</y>
499 <width>150</width>
500 <height>30</height>
501 <uuid>{07143124-f11e-43ad-9bad-2a731b719732}</uuid>
502 <visible>true</visible>
503 <midichan>0</midichan>
504 <midicc>0</midicc>
505 <label>Gain</label>
506 <alignment>left</alignment>
507 <font>Arial</font>
508 <fontsize>10</fontsize>
509 <precision>3</precision>
510 <color>
511 <r>0</r>
512 <g>0</g>
513 <b>0</b>
514 </color>
515 <bgcolor mode="nobackground">
516 <r>255</r>
517 <g>255</g>
518 <b>255</b>
519 </bgcolor>
520 <bordermode>noborder</bordermode>
521 <borderradius>1</borderradius>
522 <borderwidth>1</borderwidth>
523 </bsbObject>
524 <bsbObject version="2" type="BSBButton">
525 <objectName>Read</objectName>
526 <x>90</x>
527 <y>55</y>
528 <width>80</width>
529 <height>30</height>
530 <uuid>{ff846fa2-9bfa-40c6-a470-b3b3bf2811f1}</uuid>
531 <visible>true</visible>
532 <midichan>0</midichan>
533 <midicc>0</midicc>
534 <type>event</type>
535 <pressedValue>1.00000000</pressedValue>
536 <stringvalue/>
537 <text> Read</text>
538 <image>/</image>
539 <eventLine>i 2 0 -1</eventLine>
540 <latch>true</latch>
541 <latched>true</latched>
542 </bsbObject>
543 <bsbObject version="2" type="BSBDropdown">
544 <objectName>Mode</objectName>
545 <x>240</x>
546 <y>55</y>
547 <width>162</width>
548 <height>30</height>
549 <uuid>{faecd829-2f06-4c0e-b683-f5de4235022b}</uuid>
550 <visible>true</visible>
551 <midichan>0</midichan>
552 <midicc>0</midicc>
553 <bsbDropdownItemList>
554 <bsbDropdownItem>
555 <name>Manual Pointer</name>
556 <value>0</value>
557 <stringvalue/>
558 </bsbDropdownItem>
559 <bsbDropdownItem>
560 <name>Speed Control</name>
561 <value>1</value>
562 <stringvalue/>
563 </bsbDropdownItem>
564 </bsbDropdownItemList>
565 <selectedIndex>0</selectedIndex>
566 <randomizable group="0">false</randomizable>
567 </bsbObject>
568 </bsbPanel>
569 <bsbPresets>
570 </bsbPresets>
571 <EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="true" loopStart="0" loopEnd="0"> </EventPanel>