-odac
/*
LIVE RING MODULATION / AMPLITUDE MODULATION
*/
;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
gisine ftgen 0, 0, 1024, 10, 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
;;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
;;ring modulation
kmodfreq invalue "modfreq"
asine poscil 1, kmodfreq, gisine
amod = aLiveInPost * asine
;;mix
kmix invalue "mix"
koutgaindb invalue "outgaindb"
aout = (amod * (1-kmix) + aLiveInPost * kmix) * ampdb(koutgaindb)
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
126228899473true2202142079988644{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
183000255255255border11LiveInPre11616433622{7286a833-c0b0-4f55-8ecc-837453106e15}true00out1_post0.000000001.000000000.000000001.000000000.115098420.73076900fill10.00000000jumpnoborder#00ff0002340false222222trueLiveInPreOver4501642722{42e31476-6cb3-42b4-a1fd-8f48e76892ac}true00outLover0.000000001.000000000.000000001.000000000.000000000.00000000fill10.00000000jumpnoborder#00ff001961412false222222trueLiveInPost11624033622{77fcb44e-b9a2-423d-9764-52f01754d96d}true00out2_post0.000000001.000000000.000000001.000000000.096636810.59090900fill10.00000000jumpnoborder#00ff0002340false222222trueLiveInPostOver4502402722{3e4c2001-fd4f-4b10-bd75-1766b5d1bbde}true00outRover0.000000001.000000000.000000001.000000000.000000000.00000000fill10.00000000jumpnoborder#00ff001961412false222222true211649328{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.069512940.06951294fill10.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}true00-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
143000255255255noborder10modfreq1239356930{7d5be814-ed5a-4fae-9218-23741e0c7182}true000.0000000010000.00000000316.34446397lincontinuous-1.00000000false71939417329{dfd615a7-269f-432b-a1f2-8f8214cb6142}true00lefttop
DejaVu Sans
143000255255255noborder10modfreq58339213231{4c0bb428-1aaa-48c8-acaf-a292a51a01aa}true00right
Liberation Sans
140002552552550.0010000001e+12false054743334628{0d90798d-f4cd-4370-baf7-d117997cae4e}true00lefttop
DejaVu Sans
143000255255255noborder10mix1243046532{f94c1dd8-f4bc-4012-bf82-2409efa23912}true000.000000001.000000000.07311828lincontinuous-1.00000000falsemix4804336127{6b1b6eb4-701f-4303-9293-714436c3cf04}true00righttop
DejaVu Sans
143000255255255noborder10inchnl1002934727{2fce6993-35f8-4dd7-bedd-f809c0803989}true00right
DejaVu Sans
140002552552551.0000000011e+12false1029210229{df02308f-b978-4275-817e-1ad38c5b30d5}true00righttop
Nimbus Sans L
143000255255255noborder10ingaindb11820426026{64de8264-0345-4faf-b16c-4af284a95268}true00-12.0000000012.00000000-0.92307692lincontinuous-1.00000000false4562033031{eecbf48f-983f-4ce5-bdcc-e6b1ae657b20}true00righttop
DejaVu Sans
143000255255255noborder10ingaindb3782057627{a44b45c8-8c22-4c53-9442-75339608f708}true00left
Liberation Sans
140002552552550.00100000-1e+121e+12false0outgaindb62516515524{2735c656-a8f6-429d-acc3-2fe0db7e078a}true00-12.0000000012.00000000-0.85161290lincontinuous-1.00000000false8611633031{a5947f34-1e11-490f-bd5d-c543d6e4494e}true00righttop
DejaVu Sans
143000255255255noborder10outgaindb7811647627{52bb78bb-8e63-44a1-a86a-5def867d5311}true00left
Liberation Sans
140002552552550.00100000-1e+121e+12false0