<CsoundSynthesizer><CsOptions>; Select audio/midi flags here according to platform-odac ;;;realtime audio out;-iadc ;;;uncomment -iadc if realtime audio input is needed too; For Non-realtime ouput leave only the line below:; -o chnmix.wav -W ;;; for file output any platform</CsOptions><CsInstruments>;Example by Joachim Heintzsr=44100ksmps=32nchnls=20dbfs=1instr1; send i-valueschnset(1,"sio")chnset(-1,"non")endininstr2; send k-valuesfreq:k=randomi(100,300,1)chnset(freq,"cntrfreq")bw:k=freq/10chnset(bw,"bandw")endininstr3; send a-valuesnois:a=rand(0.1)chnset(nois,"noise")loop:dur:i=random(0.3,1.5)timout(0,dur,do_)reinit(loop)do_:freq:i=random(400,1200)amp:i=random(0.1,0.3)sig:a=oscils(amp,freq,0)env:a=transeg(1,dur,-10,0)sine:a=sig*envchnset(sine,"sine")endininstr11; receive some chn values and send againval1:i=chnget("sio")val2:i=chnget("non")print(val1,val2)cntfreq:k=chnget("cntrfreq")bandw:k=chnget("bandw")nois:a=chnget("noise")filt:a=reson(nois,cntfreq,bandw)filt=balance(filt,nois)chnset(filt,"filtered")endininstr12; mix the two audio signalsmix1:a=chnget("sine")mix2:a=chnget("filtered")chnmix(mix1,"mix")chnmix(mix2,"mix")endininstr20; receive and reverbmix:a=chnget("mix")aL,aR=freeverb(mix,mix,0.8,0.5)outs(aL,aR)endininstr100; clearchnclear("mix")endin</CsInstruments><CsScore>i1020i2020i3020i11020i12020i20020i100020</CsScore></CsoundSynthesizer>
Here is an example of the chnmix opcode. It uses the file chnmix.csd.
<CsoundSynthesizer><CsOptions>; Select audio/midi flags here according to platform-odac ;;;realtime audio out;-iadc ;;;uncomment -iadc if realtime audio input is needed too; For Non-realtime ouput leave only the line below:; -o chnmix.wav -W ;;; for file output any platform</CsOptions><CsInstruments>;Example by Joachim Heintzsr=44100ksmps=32nchnls=20dbfs=1instr1; send i-valueschnset1,"sio"chnset-1,"non"endininstr2; send k-valueskfreqrandomi100,300,1chnsetkfreq,"cntrfreq"kbw=kfreq/10chnsetkbw,"bandw"endininstr3; send a-valuesanoisrand.1chnsetanois,"noise"loop:idurrandom.3,1.5timout0,idur,do_reinitloopdo_:ifreqrandom400,1200iamprandom.1,.3asigoscilsiamp,ifreq,0aenvtranseg1,idur,-10,0asine=asig*aenvchnsetasine,"sine"endininstr11; receive some chn values and send againival1chnget"sio"ival2chnget"non"printival1,ival2kcntfreqchnget"cntrfreq"kbandwchnget"bandw"anoisechnget"noise"afiltresonanoise,kcntfreq,kbandwafiltbalanceafilt,anoisechnsetafilt,"filtered"endininstr12; mix the two audio signalsamix1chnget"sine"amix2chnget"filtered"chnmixamix1,"mix"chnmixamix2,"mix"endininstr20; receive and reverbamixchnget"mix"aL,aRfreeverbamix,amix,.8,.5outsaL,aRendininstr100; clearchnclear"mix"endin</CsInstruments><CsScore>i1020i2020i3020i11020i12020i20020i100020</CsScore></CsoundSynthesizer>