--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
147531003809true170170127timreadmeth8326811025{2cbcd6fe-f4d6-4d9a-9710-df3bd7967c6d}true0-3Phasor0Live1Random20false5256429532{168c30b1-7d68-4a87-8158-ea37ea82bd49}true0-3lefttop
Noto Sans
163000255255255false104929647398{081f0ad6-9f99-4c24-9ea4-49be2561e886}true0-3lefttop
Lucida Grande
143000255255255border11phaspeed155112633928{2e02eb2b-d5df-4c0f-a804-1f02c8793592}true0-3-2.000000002.000000001.00884956lincontinuous-1.00000000falsephaspeed18891287026{4d97c9db-8f7f-42a8-81f8-59eba003b2e3}true0-3righttop
Lucida Grande
143000255255255noborder10phaspeed255015433928{ccea15fb-2d06-4f1a-ba79-a11e881c1ac6}true0-3-2.000000002.000000001.03244838lincontinuous-1.00000000falsephaspeed28881567026{3abca60e-f8d0-4f35-90e2-8d05e4e5e21e}true0-3righttop
Lucida Grande
143000255255255noborder105001255230{56b2c881-3b85-47ad-aa0b-1356246164b6}true0-3lefttop
Lucida Grande
143000255255255noborder104991525230{191a3830-1496-4beb-9c2d-6a9b4784837f}true0-3lefttop
Lucida Grande
143000255255255noborder10825847973{3b051ce0-aec5-45fe-a70a-0cbd563a3c60}true0-3lefttop
Noto Sans
143000255255255true11839747970{be3417c3-109a-4eb5-b6b8-8a07e457cbf8}true0-3lefttop
Noto Sans
143000255255255true11833047968{f56027f7-40ef-45e3-a2cd-0bb4959f886c}true0-3lefttop
Noto Sans
143000255255255true118466479134{0bb4cf06-2b65-49d0-af53-827094c69029}true0-3lefttop
Noto Sans
143000255255255true11crossamp7429327529{0d59f168-a4ec-4fae-8dac-a8e71b799f30}true0-30.000000001.000000000.68727273lincontinuous-1.00000000falsecrossamp4062957026{6f1df2fd-883f-4b37-98c8-dac8ef4e09dd}true00righttop
DejaVu Sans
143000255255255noborder10172925230{968f9b93-9265-4733-98fb-6f50e1c745ad}true0-3righttop
Lucida Grande
143000255255255noborder1014626516029{e1f81f66-6b32-4cf5-82fe-244f4e5c390a}true0-3centertop
Lucida Grande
143000255255255noborder103512945230{30652f9b-b5c4-4ca3-b506-d6b2a079bf8f}true0-3righttop
Lucida Grande
143000255255255noborder10morphfreq7955927529{69d2e2c4-fd06-4522-beba-f80dcb6e3454}true0-30.000000001.000000000.23636400lincontinuous-1.00000000falsemorphfreq4115617026{86a5c15f-c431-4c0f-9529-a69fd184ffb0}true0-3righttop
Lucida Grande
143000255255255noborder10225585230{1844ce57-7b46-45c8-9dd5-d4db3ef30c8a}true0-3righttop
Lucida Grande
143000255255255noborder108853130729{50b36f81-7b94-4d77-a8b4-42f3acdc1796}true0-3centertop
Noto Sans
143000255255255false103565605230{8aeb7e20-1038-4d0d-b124-5f5b415bb4a6}true0-3righttop
Lucida Grande
143000255255255noborder10selcross35522610830{d2474762-8299-44f9-9ffb-54562c752970}true00pvscross0pvsfilter1pvsvoc2pvsmorph31false4522632530{eb3b80e1-f6e8-44d6-8978-147b2c1d6bd1}true0-3lefttop
Noto Sans
163000255255255false10filtdepth7336227529{dac15923-90a6-42a3-ad56-5dbd0943441c}true0-30.000000001.000000001.00000000lincontinuous-1.00000000falsefiltdepth4053647026{eec0681a-631d-435b-b7a9-88f518b020dd}true0-3righttop
Lucida Grande
143000255255255noborder10163615230{45d8bfa5-61e5-4282-8013-e3e8bb3767a3}true0-3righttop
Lucida Grande
143000255255255noborder108233630729{d73cd00c-8161-4a9e-8d89-56d1df87f3c8}true0-3centertop
Lucida Grande
143000255255255noborder103503635230{7b0b8888-a340-4ca1-8c89-94e57d45a0ba}true0-3righttop
Lucida Grande
143000255255255noborder10vocdepth7142927529{f21a4bb9-8efd-4893-9aec-0f61190df1bf}true0-30.000000001.000000000.94181818lincontinuous-1.00000000falsevocdepth4034317026{6deed02e-065f-451c-bf0f-e70b46672cc3}true0-3righttop
Lucida Grande
143000255255255noborder10144285230{18e960e1-b9f9-478c-b0a5-2d4320c52599}true0-3righttop
Lucida Grande
143000255255255noborder108040330729{9e0ea5b8-45ab-4bfb-8df1-8680d08cd749}true0-3centertop
Lucida Grande
143000255255255noborder103484305230{b131b405-391f-4d5b-a189-5fe20c1aad57}true0-3righttop
Lucida Grande
143000255255255noborder10morphamp7949727529{16fe1b07-104d-4d48-a58b-d73395aaec87}true0-30.000000001.000000000.72363600lincontinuous-1.00000000falsemorphamp4114997026{2ca1d067-43f7-4c2f-bc6f-0cf5b77e81aa}true0-3righttop
Lucida Grande
143000255255255noborder10224965230{f04744bb-222e-411a-b82f-9362ccb545e2}true0-3righttop
Lucida Grande
143000255255255noborder109047130729{08bf5006-02cc-41f8-9424-e27db96acc6c}true0-3centertop
Noto Sans
143000255255255false103564985230{4d8b3e36-27f7-4b78-b828-3b956fa02b6a}true0-3righttop
Lucida Grande
143000255255255noborder1049910122727{4ef6c3a5-b6a5-48f3-b983-754b6b527625}true0-3lefttop
Lucida Grande
143000255255255noborder10492196474291{5e320d9a-d312-4c87-96d8-5720376186dc}true0-3lefttop
Lucida Grande
143000255255255border1150220298267{950bbec5-894b-471f-bb5b-42f8e7a6b607}true0-3lefttop
Noto Sans
123000255255255false10livepos1631201313280{5e0ad7c5-d9a7-404d-8292-78249deb6ca2}true0-3livepos20.000000001.000000000.000000001.000000000.619808000.67857100crosshair10.00000000jumpnoborder#00FF0002340false000true492490474110{fc78d3a5-b548-4e87-ad81-ebea05de93f2}true0-3lefttop
Lucida Grande
143000255255255border1149849846444{146ba05b-f69f-4edd-ae9f-330eda2ff550}true0-3lefttop
Noto Sans
123000255255255false10fqnewval151854217027{32cf9b48-6de5-4d37-9fcb-ea555f6e1371}true0-30.000000002.000000000.40000000lincontinuous-1.00000000falsefqnewval15915656128{550185bc-d9a3-4c3a-8a5a-2616e62234a9}true0-3righttop
Lucida Grande
143000255255255noborder10fqnewval272854117128{7188a16f-e72b-4d38-a20f-e1374dc759ba}true0-30.000000002.000000000.07017544lincontinuous-1.00000000falsefqnewval27995657029{ff509908-331c-4876-8717-d5c07cbe3d98}true0-3righttop
Lucida Grande
143000255255255noborder105365645230{fe438499-51e2-44b5-871b-66dbe85c5ab1}true0-3lefttop
Lucida Grande
143000255255255noborder107475645230{7ef3ee21-b834-4fa0-9827-cbde14ed0437}true0-3lefttop
Lucida Grande
143000255255255noborder108603736150{2ab6d209-e394-45a4-9fc1-f8d60aa437e5}true0-3lefttop
Lucida Grande
103000255255255border11kpnt11146568128{4b7d9ba8-26d2-49ea-ace1-9a8ce6adbbca}true0-3righttop
Lucida Grande
143000255255255noborder101264210343{d4301dbf-d28a-4e2e-bbe2-2e8d4c16f390}true0-3centertop
Noto Sans
123000255255255false10kpnt21157088128{e866aefe-21a1-4b31-b495-cdb2ede852c4}true0-3righttop
Lucida Grande
143000255255255noborder101269310343{e474027d-4dcc-4849-ac47-85ac0622bd9b}true0-3centertop
Lucida Grande
143000255255255noborder10out37268333622{e55f4043-6c09-43a3-a29e-f305e09efac0}true0-3out2_post0.000000001.000000000.000000001.000000000.321432480.54545500fill10.00000000jumpnoborder#00FF0002340false000trueoutover7066832722{50fe09c2-8d24-4a19-83c5-af2f513a8598}true0-3outRover0.000000001.000000000.000000001.000000000.000000000.00000000fill10.00000000jumpnoborder#00FF001961412false000truedbrange6547158025{ddde6659-b233-4f4d-a648-b40639b9a109}true0-3left
Lucida Grande
100002552552550.10000000-1e+121e+12false505757148026{9b50cfd2-c51b-45a3-9130-295d06d769c6}true0-3lefttop
Helvetica
143000255255255noborder1037271411725{f97232e1-a909-463b-b2f2-9d8131327613}true0-3lefttop
Helvetica
143000255255255noborder10showdb4897148426{d115e7ab-2af9-48fb-a766-73c7bf646810}true0-3Amplitudes0dB11falsevol37364229331{ebcfb63c-0632-4c78-b7e1-150fc2f8747f}true0-30.000000004.000000001.33788396lincontinuous-1.00000000false39661830729{8bdddf0f-ecc8-4e21-962d-47cdd560ad0d}true0-3centertop
Lucida Grande
143000255255255noborder10showpos1202612152130{f4530b8b-7c19-422c-a575-d893a308ba1a}true0-3showpos20.000000001.000000000.000000001.000000000.230263160.69230769crosshair10.00000000jumpnoborder#00FF0002340false000truevol6656456927{71104e80-4151-4b49-b061-1499603d3481}true0-3righttop
Lucida Grande
143000255255255noborder101261214730{deaf3cae-bde6-4331-aefd-58404e4e50de}true0-3centertop
Noto Sans
143000255255255false10896480123{b26bcd3f-601c-4261-84d3-81a13969175a}true0-3lefttop
Lucida Grande
103000255255255border11_Browse11411735822{826e6a48-8782-47df-82d1-4111fbbe416f}true0-3left
DejaVu Sans
103000239239239nobackground_Browse137311510729{0d65e94b-7973-4189-a45a-0d29fa5f60b3}true0-3value1.00000000fox.wavFile 1/falsefalsefalse10_Browse21415135822{43019fb8-7d96-441c-933f-14cfa550a79e}true0-3left
DejaVu Sans
103000239239239nobackground_Browse237314810729{cb9b3b67-c25f-42cf-a2c4-4b3efb8d2754}true0-3value1.00000000wave.wavFile 2/falsefalsefalse101418431127{1030ef1f-618b-47ee-919d-588e04fa9869}true0-3lefttop
Lucida Grande
143000255255255noborder10changeorder3241872719{c29f5713-6ca8-4c41-8de8-c83b5668742f}true0-3false1false436619030{656b7160-e58b-4f79-ae41-aeaf91a60d79}true0-3lefttop
Noto Sans
163000255255255false1081495849{d3ecca91-b2d8-4fea-b8a2-0748e3685de4}true0-3centertop
Lucida Grande
263000255255255noborder10747603219150{ca373e1b-b47e-42c2-9a7f-9b5f84522b22}true0-3lefttop
Lucida Grande
123000255255255border11