--env:SSDIR+=../../SourceMaterials /*****DIFFERENT METHODS OF CROSS SYNTHESIS*****/ ;example for CsoundQt ;written by joachim heintz ;jan 2010 ;please send bug reports and suggestions ;to jh at joachimheintz.de sr = 44100 nchnls = 2 ksmps = 64 0dbfs = 1 seed 0 opcode FileToPvsBuf1, iik, Siiii ;;writes the first channel of an audio file at the first k-cycle to a fft-buffer (via pvsbuffer) Sfile, ifftsize, ioverlap, iwinsize, iwinshape xin ktimek timeinstk if ktimek == 1 then ilen filelen Sfile kcycles = ilen * kr; number of k-cycles to write the fft-buffer kcount init 0 ichnls filenchnls Sfile if ichnls == 1 then; Mono loopmono: ain soundin Sfile fftin pvsanal ain, ifftsize, ioverlap, iwinsize, iwinshape ibuf, ktim pvsbuffer fftin, ilen + (ifftsize / sr) loop_lt kcount, 1, kcycles, loopmono else; Stereo loopstereo: ain, anull soundin Sfile fftin pvsanal ain, ifftsize, ioverlap, iwinsize, iwinshape ibuf, ktim pvsbuffer fftin, ilen + (ifftsize / sr) loop_lt kcount, 1, kcycles, loopstereo endif xout ibuf, ilen, ktim endif endop opcode ShowLED_a, 0, Sakkk ;shows an audiosignal in an outvalue channel, in dB or raw amplitudes ;Soutchan: string as name of the outvalue channel ;asig: audio signal to be shown ;kdispfreq: refresh frequency of the display (Hz) ;kdb: 1 = show as db, 0 = show as raw amplitudes (both in the range 0-1) ;kdbrange: if idb=1: which dB range is shown Soutchan, asig, ktrig, kdb, kdbrange xin kdispval max_k asig, ktrig, 1 if kdb != 0 then kdb = dbfsamp(kdispval) kval = (kdbrange + kdb) / kdbrange else kval = kdispval endif if ktrig == 1 then outvalue Soutchan, kval endif endop opcode ShowOver_a, 0, Sakk ;shows if asig has been larger than 1 and stays khold seconds ;Soutchan: string as name of the outvalue channel ;kdispfreq: refresh frequency of the display (Hz) Soutchan, asig, ktrig, khold xin kon init 0 ktim times kstart init 0 kend init 0 khold = (khold < .01 ? .01 : khold); avoiding too short hold times kmax max_k asig, ktrig, 1 if kon == 0 && kmax > 1 && ktrig == 1 then kstart = ktim kend = kstart + khold outvalue Soutchan, kmax kon = 1 endif if kon == 1 && ktim > kend && ktrig == 1 then outvalue Soutchan, 0 kon = 0 endif endop instr 1 ;;FILE INPUT AND FFT-BUFFER LOAD Sfile1 invalue "_Browse1" Sfile2 invalue "_Browse2" ifftsize = 1024 ioverlap = ifftsize / 4 iwinsize = ifftsize iwinshape = 1; von-Hann window ibuffer1, ilen1, k01 FileToPvsBuf1 Sfile1, ifftsize, ioverlap, iwinsize, iwinshape ibuffer2, ilen2, k02 FileToPvsBuf1 Sfile2, ifftsize, ioverlap, iwinsize, iwinshape ;;TIME POINTER IN BUFFER 1 AND 2 ;Select method ktimreadmeth invalue "timreadmeth"; 0=phasor, 1=gui, 2=random if ktimreadmeth == 0 then; 1) PHASOR kphaspeed1 invalue "phaspeed1" kphaspeed2 invalue "phaspeed2" kphasfq1 = kphaspeed1 / ilen1 kphasfq2 = kphaspeed2 / ilen2 kphaspnt1 phasor kphasfq1 kphaspnt2 phasor kphasfq2 kpnt1 = kphaspnt1 * ilen1 kpnt2 = kphaspnt2 * ilen2 elseif ktimreadmeth == 1 then; 2) CONTROLLER WIDGET (MOUSE) kpos1 invalue "livepos1"; horizontal (left to right) = position in file 1 kpos2 invalue "livepos2"; vertical (bottom to top) = position in file 2 kpnt1 = kpos1 * ilen1 kpnt2 = kpos2 * ilen2 else; 3) RANDOM POSITIONS AND INTERPOLATIONS kfqnewval1 invalue "fqnewval1"; frequency of new random values for file 1 kfqnewval2 invalue "fqnewval2"; and for file 2 kpnt1 randomi 0, ilen1, kfqnewval1, 3 kpnt2 randomi 0, ilen2, kfqnewval2, 3 endif ;show pointer positions outvalue "kpnt1", kpnt1; time in seconds for display widget outvalue "kpnt2", kpnt2 outvalue "showpos1", kpnt1/ilen1; time 0-1 for controller widget outvalue "showpos2", kpnt2/ilen2 ;;CREATE PVS STREAMS kchangeorder invalue "changeorder" kbuffer1 = (kchangeorder == 0 ? ibuffer1 : ibuffer2) kbuffer2 = (kchangeorder == 0 ? ibuffer2 : ibuffer1) fread1 pvsbufread kpnt1, kbuffer1 fread2 pvsbufread kpnt2, kbuffer2 ;;PERFORM CROSS SYNTHESIS kselcross invalue "selcross" if kselcross == 0 then ;PVSCROSS: freqs from fread1, amps according crossamp from fread1 and fread2 kcrossamp2 invalue "crossamp"; 0-1 kcrossamp1 = 1 - kcrossamp2 fcross pvscross fread1, fread2, kcrossamp1, kcrossamp2 elseif kselcross == 1 then ;PVSFILTER: freqs from fread1, amps from fread1 are multipied by those from fread2 scaled by kfiltdepth kfiltdepth invalue "filtdepth" fcross pvsfilter fread1, fread2, kfiltdepth elseif kselcross == 2 then ;PVSVOC: amps from fread1, freqs from fread2 according to kvocdepth kvocdepth invalue "vocdepth"; freqs from fread1 (0) or fread2 (1) fcross pvsvoc fread1, fread2, kvocdepth, 1 else ;PVSMORPH: interpolates between the freqs and the amps from both streams according to kmorphfreq and kmorphamp kmorphamp invalue "morphamp" kmorphfreq invalue "morphfreq" fcross pvsmorph fread1, fread2, kmorphamp, kmorphfreq endif ;;RESYNTHESIZE across pvsynth fcross kvol invalue "vol" avol = across * kvol outs avol, avol ;;SHOW OUTPUT kshowdb invalue "showdb"; 0=raw amplitudes, 1=db as display in the widgets kdbrange invalue "dbrange"; if kshowdb==1: which db range kTrigDisp metro 10 ShowLED_a "out", avol, kTrigDisp, kshowdb, kdbrange ShowOver_a "outover", avol, kTrigDisp, 2 endin i 1 0 3600 e 147 53 1003 809 true 170 170 127 timreadmeth 832 68 110 25 {2cbcd6fe-f4d6-4d9a-9710-df3bd7967c6d} true 0 -3 Phasor 0 Live 1 Random 2 0 false 525 64 295 32 {168c30b1-7d68-4a87-8158-ea37ea82bd49} true 0 -3 left top Noto Sans 16 3 0 0 0 255 255 255 false 1 0 492 96 473 98 {081f0ad6-9f99-4c24-9ea4-49be2561e886} true 0 -3 phaspeed1 551 126 339 28 {2e02eb2b-d5df-4c0f-a804-1f02c8793592} true 0 -3 -2.00000000 2.00000000 1.00884956 lin continuous -1.00000000 false phaspeed1 889 128 70 26 {4d97c9db-8f7f-42a8-81f8-59eba003b2e3} true 0 -3 right top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 phaspeed2 550 154 339 28 {ccea15fb-2d06-4f1a-ba79-a11e881c1ac6} true 0 -3 -2.00000000 2.00000000 1.03244838 lin continuous -1.00000000 false phaspeed2 888 156 70 26 {3abca60e-f8d0-4f35-90e2-8d05e4e5e21e} true 0 -3 right top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 500 125 52 30 {56b2c881-3b85-47ad-aa0b-1356246164b6} true 0 -3 left top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 499 152 52 30 {191a3830-1496-4beb-9c2d-6a9b4784837f} true 0 -3 left top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 8 258 479 73 {3b051ce0-aec5-45fe-a70a-0cbd563a3c60} true 0 -3 left top Noto Sans 14 3 0 0 0 255 255 255 true 1 1 8 397 479 70 {be3417c3-109a-4eb5-b6b8-8a07e457cbf8} true 0 -3 left top Noto Sans 14 3 0 0 0 255 255 255 true 1 1 8 330 479 68 {f56027f7-40ef-45e3-a2cd-0bb4959f886c} true 0 -3 left top Noto Sans 14 3 0 0 0 255 255 255 true 1 1 8 466 479 134 {0bb4cf06-2b65-49d0-af53-827094c69029} true 0 -3 left top Noto Sans 14 3 0 0 0 255 255 255 true 1 1 crossamp 74 293 275 29 {0d59f168-a4ec-4fae-8dac-a8e71b799f30} true 0 -3 0.00000000 1.00000000 0.68727273 lin continuous -1.00000000 false crossamp 406 295 70 26 {6f1df2fd-883f-4b37-98c8-dac8ef4e09dd} true 0 0 right top DejaVu Sans 14 3 0 0 0 255 255 255 noborder 1 0 17 292 52 30 {968f9b93-9265-4733-98fb-6f50e1c745ad} true 0 -3 right top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 146 265 160 29 {e1f81f66-6b32-4cf5-82fe-244f4e5c390a} true 0 -3 center top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 351 294 52 30 {30652f9b-b5c4-4ca3-b506-d6b2a079bf8f} true 0 -3 right top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 morphfreq 79 559 275 29 {69d2e2c4-fd06-4522-beba-f80dcb6e3454} true 0 -3 0.00000000 1.00000000 0.23636400 lin continuous -1.00000000 false morphfreq 411 561 70 26 {86a5c15f-c431-4c0f-9529-a69fd184ffb0} true 0 -3 right top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 22 558 52 30 {1844ce57-7b46-45c8-9dd5-d4db3ef30c8a} true 0 -3 right top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 88 531 307 29 {50b36f81-7b94-4d77-a8b4-42f3acdc1796} true 0 -3 center top Noto Sans 14 3 0 0 0 255 255 255 false 1 0 356 560 52 30 {8aeb7e20-1038-4d0d-b124-5f5b415bb4a6} true 0 -3 right top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 selcross 355 226 108 30 {d2474762-8299-44f9-9ffb-54562c752970} true 0 0 pvscross 0 pvsfilter 1 pvsvoc 2 pvsmorph 3 1 false 45 226 325 30 {eb3b80e1-f6e8-44d6-8978-147b2c1d6bd1} true 0 -3 left top Noto Sans 16 3 0 0 0 255 255 255 false 1 0 filtdepth 73 362 275 29 {dac15923-90a6-42a3-ad56-5dbd0943441c} true 0 -3 0.00000000 1.00000000 1.00000000 lin continuous -1.00000000 false filtdepth 405 364 70 26 {eec0681a-631d-435b-b7a9-88f518b020dd} true 0 -3 right top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 16 361 52 30 {45d8bfa5-61e5-4282-8013-e3e8bb3767a3} true 0 -3 right top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 82 336 307 29 {d73cd00c-8161-4a9e-8d89-56d1df87f3c8} true 0 -3 center top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 350 363 52 30 {7b0b8888-a340-4ca1-8c89-94e57d45a0ba} true 0 -3 right top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 vocdepth 71 429 275 29 {f21a4bb9-8efd-4893-9aec-0f61190df1bf} true 0 -3 0.00000000 1.00000000 0.94181818 lin continuous -1.00000000 false vocdepth 403 431 70 26 {6deed02e-065f-451c-bf0f-e70b46672cc3} true 0 -3 right top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 14 428 52 30 {18e960e1-b9f9-478c-b0a5-2d4320c52599} true 0 -3 right top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 80 403 307 29 {9e0ea5b8-45ab-4bfb-8df1-8680d08cd749} true 0 -3 center top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 348 430 52 30 {b131b405-391f-4d5b-a189-5fe20c1aad57} true 0 -3 right top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 morphamp 79 497 275 29 {16fe1b07-104d-4d48-a58b-d73395aaec87} true 0 -3 0.00000000 1.00000000 0.72363600 lin continuous -1.00000000 false morphamp 411 499 70 26 {2ca1d067-43f7-4c2f-bc6f-0cf5b77e81aa} true 0 -3 right top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 22 496 52 30 {f04744bb-222e-411a-b82f-9362ccb545e2} true 0 -3 right top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 90 471 307 29 {08bf5006-02cc-41f8-9424-e27db96acc6c} true 0 -3 center top Noto Sans 14 3 0 0 0 255 255 255 false 1 0 356 498 52 30 {4d8b3e36-27f7-4b78-b828-3b956fa02b6a} true 0 -3 right top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 499 101 227 27 {4ef6c3a5-b6a5-48f3-b983-754b6b527625} true 0 -3 left top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 492 196 474 291 {5e320d9a-d312-4c87-96d8-5720376186dc} true 0 -3 502 202 98 267 {950bbec5-894b-471f-bb5b-42f8e7a6b607} true 0 -3 left top Noto Sans 12 3 0 0 0 255 255 255 false 1 0 livepos1 631 201 313 280 {5e0ad7c5-d9a7-404d-8292-78249deb6ca2} true 0 -3 livepos2 0.00000000 1.00000000 0.00000000 1.00000000 0.61980800 0.67857100 crosshair 1 0.00000000 jump noborder #00FF00 0 234 0 false 0 0 0 true 492 490 474 110 {fc78d3a5-b548-4e87-ad81-ebea05de93f2} true 0 -3 498 498 464 44 {146ba05b-f69f-4edd-ae9f-330eda2ff550} true 0 -3 left top Noto Sans 12 3 0 0 0 255 255 255 false 1 0 fqnewval1 518 542 170 27 {32cf9b48-6de5-4d37-9fcb-ea555f6e1371} true 0 -3 0.00000000 2.00000000 0.40000000 lin continuous -1.00000000 false fqnewval1 591 565 61 28 {550185bc-d9a3-4c3a-8a5a-2616e62234a9} true 0 -3 right top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 fqnewval2 728 541 171 28 {7188a16f-e72b-4d38-a20f-e1374dc759ba} true 0 -3 0.00000000 2.00000000 0.07017544 lin continuous -1.00000000 false fqnewval2 799 565 70 29 {ff509908-331c-4876-8717-d5c07cbe3d98} true 0 -3 right top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 536 564 52 30 {fe438499-51e2-44b5-871b-66dbe85c5ab1} true 0 -3 left top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 747 564 52 30 {7ef3ee21-b834-4fa0-9827-cbde14ed0437} true 0 -3 left top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 8 603 736 150 {2ab6d209-e394-45a4-9fc1-f8d60aa437e5} true 0 -3 kpnt1 114 656 81 28 {4b7d9ba8-26d2-49ea-ace1-9a8ce6adbbca} true 0 -3 right top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 12 642 103 43 {d4301dbf-d28a-4e2e-bbe2-2e8d4c16f390} true 0 -3 center top Noto Sans 12 3 0 0 0 255 255 255 false 1 0 kpnt2 115 708 81 28 {e866aefe-21a1-4b31-b495-cdb2ede852c4} true 0 -3 right top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 12 693 103 43 {e474027d-4dcc-4849-ac47-85ac0622bd9b} true 0 -3 center top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 out 372 683 336 22 {e55f4043-6c09-43a3-a29e-f305e09efac0} true 0 -3 out2_post 0.00000000 1.00000000 0.00000000 1.00000000 0.32143248 0.54545500 fill 1 0.00000000 jump noborder #00FF00 0 234 0 false 0 0 0 true outover 706 683 27 22 {50fe09c2-8d24-4a19-83c5-af2f513a8598} true 0 -3 outRover 0.00000000 1.00000000 0.00000000 1.00000000 0.00000000 0.00000000 fill 1 0.00000000 jump noborder #00FF00 196 14 12 false 0 0 0 true dbrange 654 715 80 25 {ddde6659-b233-4f4d-a648-b40639b9a109} true 0 -3 left Lucida Grande 10 0 0 0 255 255 255 0.10000000 -1e+12 1e+12 false 50 575 714 80 26 {9b50cfd2-c51b-45a3-9130-295d06d769c6} true 0 -3 left top Helvetica 14 3 0 0 0 255 255 255 noborder 1 0 372 714 117 25 {f97232e1-a909-463b-b2f2-9d8131327613} true 0 -3 left top Helvetica 14 3 0 0 0 255 255 255 noborder 1 0 showdb 489 714 84 26 {d115e7ab-2af9-48fb-a766-73c7bf646810} true 0 -3 Amplitudes 0 dB 1 1 false vol 373 642 293 31 {ebcfb63c-0632-4c78-b7e1-150fc2f8747f} true 0 -3 0.00000000 4.00000000 1.33788396 lin continuous -1.00000000 false 396 618 307 29 {8bdddf0f-ecc8-4e21-962d-47cdd560ad0d} true 0 -3 center top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 showpos1 202 612 152 130 {f4530b8b-7c19-422c-a575-d893a308ba1a} true 0 -3 showpos2 0.00000000 1.00000000 0.00000000 1.00000000 0.23026316 0.69230769 crosshair 1 0.00000000 jump noborder #00FF00 0 234 0 false 0 0 0 true vol 665 645 69 27 {71104e80-4151-4b49-b061-1499603d3481} true 0 -3 right top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 12 612 147 30 {deaf3cae-bde6-4331-aefd-58404e4e50de} true 0 -3 center top Noto Sans 14 3 0 0 0 255 255 255 false 1 0 8 96 480 123 {b26bcd3f-601c-4261-84d3-81a13969175a} true 0 -3 _Browse1 14 117 358 22 {826e6a48-8782-47df-82d1-4111fbbe416f} true 0 -3 left DejaVu Sans 10 3 0 0 0 239 239 239 nobackground _Browse1 373 115 107 29 {0d65e94b-7973-4189-a45a-0d29fa5f60b3} true 0 -3 value 1.00000000 fox.wav File 1 / false false false 10 _Browse2 14 151 358 22 {43019fb8-7d96-441c-933f-14cfa550a79e} true 0 -3 left DejaVu Sans 10 3 0 0 0 239 239 239 nobackground _Browse2 373 148 107 29 {cb9b3b67-c25f-42cf-a2c4-4b3efb8d2754} true 0 -3 value 1.00000000 wave.wav File 2 / false false false 10 14 184 311 27 {1030ef1f-618b-47ee-919d-588e04fa9869} true 0 -3 left top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 changeorder 324 187 27 19 {c29f5713-6ca8-4c41-8de8-c83b5668742f} true 0 -3 false 43 66 190 30 {656b7160-e58b-4f79-ae41-aeaf91a60d79} true 0 -3 left top Noto Sans 16 3 0 0 0 255 255 255 false 1 0 8 14 958 49 {d3ecca91-b2d8-4fea-b8a2-0748e3685de4} true 0 -3 center top Lucida Grande 26 3 0 0 0 255 255 255 noborder 1 0 747 603 219 150 {ca373e1b-b47e-42c2-9a7f-9b5f84522b22} true 0 -3 left top Lucida Grande 12 3 0 0 0 255 255 255 border 1 1