-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 287 124 908 582 true 220 220 220 9 9 886 44 {2a56f609-3f3a-49a2-8ef2-04e1041ed49f} true 0 0 center top DejaVu Sans 26 3 0 0 0 255 255 255 noborder 1 0 9 58 886 66 {49b99e1e-2b4b-4aef-b413-95171c64b350} true 0 0 left top DejaVu Sans 14 3 0 0 0 255 255 255 noborder 1 0 11 132 484 148 {e39c91d6-a0bd-4681-8dbc-e384493e578c} true 0 -3 left top Lucida Grande 18 3 0 0 0 255 255 255 border 1 1 LiveInPre 120 164 336 22 {7286a833-c0b0-4f55-8ecc-837453106e15} true 0 -3 out1_post 0.00000000 1.00000000 0.00000000 1.00000000 0.42316070 0.73076900 fill 1 0.00000000 jump noborder #00FF00 0 234 0 false 0 0 0 true LiveInPreOver 454 164 27 22 {42e31476-6cb3-42b4-a1fd-8f48e76892ac} true 0 -3 outLover 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 LiveInPost 116 240 336 22 {77fcb44e-b9a2-423d-9764-52f01754d96d} true 0 -3 out2_post 0.00000000 1.00000000 0.00000000 1.00000000 0.42636070 0.59090900 fill 1 0.00000000 jump noborder #00FF00 0 234 0 false 0 0 0 true LiveInPostOver 450 240 27 22 {3e4c2001-fd4f-4b10-bd75-1766b5d1bbde} 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 21 164 93 28 {9dd7688d-d7d4-4863-bbe8-44c1e622f2bd} true 0 -3 left top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 19 240 97 29 {a6c9d0da-7821-4528-b193-9ee9af3d441f} true 0 -3 left top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 20 202 93 31 {bdebe2b5-07c1-4f1f-b7cb-d2f29a26a5f8} true 0 -3 left top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 518 131 380 215 {e748e0c8-197c-4d4d-b893-9501e50ae02b} true 0 -3 left top Lucida Grande 18 3 0 0 0 255 255 255 border 1 1 out 528 197 338 24 {133bd5e9-655f-4ba7-895d-45c9c8e54eb3} true 0 -3 out 0.00000000 1.00000000 0.00000000 1.00000000 0.69770783 0.69770783 fill 1 0.00000000 jump noborder #00FF00 0 234 0 false 0 0 0 true outover 863 197 26 24 {dc5f0c73-a680-4e93-9855-6706fbd5180d} 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 416 292 79 27 {81528aba-64e8-4dc7-b127-daa1434195a2} true 0 0 left Noto Sans 14 0 0 0 255 255 255 0.10000000 1 1e+12 false 0 329 291 90 29 {cc0e0187-e5c9-4b44-b8c0-28d00d45cb89} true 0 0 right top Nimbus Sans L 14 3 0 0 0 255 255 255 noborder 1 0 140 292 110 27 {df57c2f7-4a74-460f-9f7f-b3efb8106306} true 0 0 right top Nimbus Sans L 14 3 0 0 0 255 255 255 noborder 1 0 showdb 249 292 80 28 {d09ab184-f4b1-4340-8730-e73b870bcf9a} true 0 0 raw amps 0 dB 1 1 false 525 228 368 105 {c385ef49-3efa-4ec3-806a-ff883343cb9c} true 0 -3 -255.00000000 scope 2.00000000 1.00000000 1.00000000 1.00000000 0.00000000 NoTrigger 6 355 893 118 {f470cb16-0510-44e6-b6e0-c532a68e3409} true 0 0 left top DejaVu Sans 18 3 0 0 0 255 255 255 border 1 1 529 164 95 27 {dcc76929-4dec-4912-b228-fcab4a27e75f} true 0 -3 left top Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 0 deltim 12 393 675 30 {7d5be814-ed5a-4fae-9218-23741e0c7182} true 0 0 0.00000000 10.00000000 0.38518519 lin continuous -1.00000000 false 792 395 100 29 {dfd615a7-269f-432b-a1f2-8f8214cb6142} true 0 0 left top DejaVu Sans 14 3 0 0 0 255 255 255 noborder 1 0 deltim 689 395 100 31 {4c0bb428-1aaa-48c8-acaf-a292a51a01aa} true 0 0 right Liberation Sans 14 0 0 0 255 255 255 0.00001000 0 10 false 0 745 432 146 28 {0d90798d-f4cd-4370-baf7-d117997cae4e} true 0 0 left top DejaVu Sans 14 3 0 0 0 255 255 255 noborder 1 0 fbamnt 12 433 630 30 {f94c1dd8-f4bc-4012-bf82-2409efa23912} true 0 0 0.00000000 1.00000000 0.96825397 lin continuous -1.00000000 false inchnl 100 293 47 27 {2fce6993-35f8-4dd7-bedd-f809c0803989} true 0 0 right DejaVu Sans 14 0 0 0 255 255 255 1.00000000 1 1e+12 false 1 0 292 102 29 {df02308f-b978-4275-817e-1ad38c5b30d5} true 0 0 right top Nimbus Sans L 14 3 0 0 0 255 255 255 noborder 1 0 fbamnt 643 431 100 31 {ae17eb1a-5e2c-4360-8eb6-89bc757feca9} true 0 0 right Liberation Sans 14 0 0 0 255 255 255 0.00000100 0 1 false 0 5 481 893 83 {fdb837ea-37dc-43f0-bdfc-f94641af0523} true 0 0 left top DejaVu Sans 18 3 0 0 0 255 255 255 border 1 1 mix 125 521 600 30 {2c21e717-afb3-4849-8624-11a48c50d7f1} true 0 0 0.00000000 1.00000000 1.00000000 lin continuous -1.00000000 false 735 521 160 29 {70273572-faf2-403d-9ea2-5b6cb3173e03} true 0 0 left top DejaVu Sans 14 3 0 0 0 255 255 255 noborder 1 0 9 521 110 29 {f7bcff50-3912-4ff9-b380-6d709533473d} true 0 0 right top DejaVu Sans 14 3 0 0 0 255 255 255 noborder 1 0 mix 390 486 100 31 {782f9c11-50cd-4693-919d-b6c44af00de1} true 0 0 right Liberation Sans 14 0 0 0 255 255 255 0.00000100 0 1 false 0 ingaindb 116 204 260 26 {64de8264-0345-4faf-b16c-4af284a95268} true 0 0 -12.00000000 12.00000000 0.27692308 lin continuous -1.00000000 false 449 204 30 31 {eecbf48f-983f-4ce5-bdcc-e6b1ae657b20} true 0 0 right top DejaVu Sans 14 3 0 0 0 255 255 255 noborder 1 0 ingaindb 375 204 76 27 {a44b45c8-8c22-4c53-9442-75339608f708} true 0 0 left Liberation Sans 14 0 0 0 255 255 255 0.00100000 -1e+12 1e+12 false 0 outgaindb 628 164 155 24 {2735c656-a8f6-429d-acc3-2fe0db7e078a} true 0 0 -12.00000000 12.00000000 -0.69677419 lin continuous -1.00000000 false 862 162 30 31 {a5947f34-1e11-490f-bd5d-c543d6e4494e} true 0 0 right top DejaVu Sans 14 3 0 0 0 255 255 255 noborder 1 0 outgaindb 786 164 76 27 {52bb78bb-8e63-44a1-a86a-5def867d5311} true 0 0 left Liberation Sans 14 0 0 0 255 255 255 0.00100000 -1e+12 1e+12 false 0