-odac
/*
LIVE DEALY AND FEEDBACK
*/
;example for CsoundQt
;written by joachim heintz
;may 2011
;please send bug reports and suggestions
;to jh at joachimheintz.de
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
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; master instrument
;;set maximum delay
imaxdel = 10
;;get live input
kinchnl invalue "inchnl"
aLiveInPre inch kinchnl
kingaindb invalue "ingaindb"
kLiveInGain = ampdb(kingaindb)
aLiveInPost = aLiveInPre * kLiveInGain
;;show live input
gkTrigDisp metro 10
gkshowdb invalue "showdb"
gkdbrange invalue "dbrange"
ShowLED_a "LiveInPre", aLiveInPre, gkTrigDisp, gkshowdb, gkdbrange
ShowOver_a "LiveInPreOver", aLiveInPre, gkTrigDisp, 2
ShowLED_a "LiveInPost", aLiveInPost, gkTrigDisp, gkshowdb, gkdbrange
ShowOver_a "LiveInPostOver", aLiveInPost, gkTrigDisp, 2
;;delay and feedback amount
kdeltim invalue "deltim" ;delay time in seconds
kfbamnt invalue "fbamnt" ;feedback amount 0-1
adeltim = kdeltim
adel init 0
adelin = aLiveInPost + adel * kfbamnt
adel vdelay3 adelin, adeltim*1000, imaxdel*1000
;;mix and output
kmix invalue "mix"
koutgaindb invalue "outgaindb"
kgain = ampdb(koutgaindb)
amix = adel * kmix + aLiveInPost * (1-kmix)
aout = amix * kgain
outch 1, aout, 2, aout
;;show output
ShowLED_a "out", aout, gkTrigDisp, gkshowdb, gkdbrange
ShowOver_a "outover", aout, gkTrigDisp, 2
endin
i 1 0 36000
e
287124908582true2202202209988644{2a56f609-3f3a-49a2-8ef2-04e1041ed49f}true00centertop
DejaVu Sans
263000255255255noborder1095888666{49b99e1e-2b4b-4aef-b413-95171c64b350}true00lefttop
DejaVu Sans
143000255255255noborder1011132484148{e39c91d6-a0bd-4681-8dbc-e384493e578c}true0-3lefttop
Lucida Grande
183000255255255border11LiveInPre12016433622{7286a833-c0b0-4f55-8ecc-837453106e15}true0-3out1_post0.000000001.000000000.000000001.000000000.423160700.73076900fill10.00000000jumpnoborder#00FF0002340false000trueLiveInPreOver4541642722{42e31476-6cb3-42b4-a1fd-8f48e76892ac}true0-3outLover0.000000001.000000000.000000001.000000000.000000000.00000000fill10.00000000jumpnoborder#00FF001961412false000trueLiveInPost11624033622{77fcb44e-b9a2-423d-9764-52f01754d96d}true0-3out2_post0.000000001.000000000.000000001.000000000.426360700.59090900fill10.00000000jumpnoborder#00FF0002340false000trueLiveInPostOver4502402722{3e4c2001-fd4f-4b10-bd75-1766b5d1bbde}true0-3outRover0.000000001.000000000.000000001.000000000.000000000.00000000fill10.00000000jumpnoborder#00FF001961412false000true211649328{9dd7688d-d7d4-4863-bbe8-44c1e622f2bd}true0-3lefttop
Lucida Grande
143000255255255noborder10192409729{a6c9d0da-7821-4528-b193-9ee9af3d441f}true0-3lefttop
Lucida Grande
143000255255255noborder10202029331{bdebe2b5-07c1-4f1f-b7cb-d2f29a26a5f8}true0-3lefttop
Lucida Grande
143000255255255noborder10518131380215{e748e0c8-197c-4d4d-b893-9501e50ae02b}true0-3lefttop
Lucida Grande
183000255255255border11out52819733824{133bd5e9-655f-4ba7-895d-45c9c8e54eb3}true0-3out0.000000001.000000000.000000001.000000000.697707830.69770783fill10.00000000jumpnoborder#00FF0002340false000trueoutover8631972624{dc5f0c73-a680-4e93-9855-6706fbd5180d}true0-3outRover0.000000001.000000000.000000001.000000000.000000000.00000000fill10.00000000jumpnoborder#00FF001961412false000truedbrange4162927927{81528aba-64e8-4dc7-b127-daa1434195a2}true00left
Noto Sans
140002552552550.1000000011e+12false03292919029{cc0e0187-e5c9-4b44-b8c0-28d00d45cb89}true00righttop
Nimbus Sans L
143000255255255noborder1014029211027{df57c2f7-4a74-460f-9f7f-b3efb8106306}true00righttop
Nimbus Sans L
143000255255255noborder10showdb2492928028{d09ab184-f4b1-4340-8730-e73b870bcf9a}true00raw amps0dB11false525228368105{c385ef49-3efa-4ec3-806a-ff883343cb9c}true0-3-255.00000000scope2.000000001.000000001.000000001.000000000.00000000NoTrigger6355893118{f470cb16-0510-44e6-b6e0-c532a68e3409}true00lefttop
DejaVu Sans
183000255255255border115291649527{dcc76929-4dec-4912-b228-fcab4a27e75f}true0-3lefttop
Lucida Grande
143000255255255noborder10deltim1239367530{7d5be814-ed5a-4fae-9218-23741e0c7182}true000.0000000010.000000000.38518519lincontinuous-1.00000000false79239510029{dfd615a7-269f-432b-a1f2-8f8214cb6142}true00lefttop
DejaVu Sans
143000255255255noborder10deltim68939510031{4c0bb428-1aaa-48c8-acaf-a292a51a01aa}true00right
Liberation Sans
140002552552550.00001000010false074543214628{0d90798d-f4cd-4370-baf7-d117997cae4e}true00lefttop
DejaVu Sans
143000255255255noborder10fbamnt1243363030{f94c1dd8-f4bc-4012-bf82-2409efa23912}true000.000000001.000000000.96825397lincontinuous-1.00000000falseinchnl1002934727{2fce6993-35f8-4dd7-bedd-f809c0803989}true00right
DejaVu Sans
140002552552551.0000000011e+12false1029210229{df02308f-b978-4275-817e-1ad38c5b30d5}true00righttop
Nimbus Sans L
143000255255255noborder10fbamnt64343110031{ae17eb1a-5e2c-4360-8eb6-89bc757feca9}true00right
Liberation Sans
140002552552550.0000010001false0548189383{fdb837ea-37dc-43f0-bdfc-f94641af0523}true00lefttop
DejaVu Sans
183000255255255border11mix12552160030{2c21e717-afb3-4849-8624-11a48c50d7f1}true000.000000001.000000001.00000000lincontinuous-1.00000000false73552116029{70273572-faf2-403d-9ea2-5b6cb3173e03}true00lefttop
DejaVu Sans
143000255255255noborder10952111029{f7bcff50-3912-4ff9-b380-6d709533473d}true00righttop
DejaVu Sans
143000255255255noborder10mix39048610031{782f9c11-50cd-4693-919d-b6c44af00de1}true00right
Liberation Sans
140002552552550.0000010001false0ingaindb11620426026{64de8264-0345-4faf-b16c-4af284a95268}true00-12.0000000012.000000000.27692308lincontinuous-1.00000000false4492043031{eecbf48f-983f-4ce5-bdcc-e6b1ae657b20}true00righttop
DejaVu Sans
143000255255255noborder10ingaindb3752047627{a44b45c8-8c22-4c53-9442-75339608f708}true00left
Liberation Sans
140002552552550.00100000-1e+121e+12false0outgaindb62816415524{2735c656-a8f6-429d-acc3-2fe0db7e078a}true00-12.0000000012.00000000-0.69677419lincontinuous-1.00000000false8621623031{a5947f34-1e11-490f-bd5d-c543d6e4494e}true00righttop
DejaVu Sans
143000255255255noborder10outgaindb7861647627{52bb78bb-8e63-44a1-a86a-5def867d5311}true00left
Liberation Sans
140002552552550.00100000-1e+121e+12false0