iwfn -- table containing a waveform, usually a sine. Table values are not interpolated for performance reasons, so larger tables provide better quality.
ifreqfn -- table containing frequency values for each partial. ifreqfn may contain beginning frequency values for each partial, but is usually used for generating parameters at runtime with tablew. Frequencies must be relative to kcps. Size must be at least icnt.
iampfn -- table containing amplitude values for each partial. iampfn may contain beginning amplitude values for each partial, but is usually used for generating parameters at runtime with tablew. Amplitudes must be relative to kamp. Size must be at least icnt.
icnt -- number of partials to be generated
iphs -- initial phase of each oscillator, if iphs = -1, initialization is skipped. If iphs > 1, all phases will be initialized with a random value.
Performance
kamp -- amplitude of note
kcps -- base frequency of note. Partial frequencies will be relative to kcps.
Frequency and amplitude of each partial is given in the two tables provided. The purpose of this opcode is to have an instrument generate synthesis parameters at k-rate and write them to global parameter tables with the tablew opcode.
Examples
Here is an example of the adsynt opcode. These two instruments perform additive synthesis. The output of each sounds like a Tibetan bowl. The first one is static, as parameters are only generated at init-time. In the second one, parameters are continuously changed.
<CsoundSynthesizer><CsOptions>; Select audio/midi flags here according to platform-odac;;;realtime audio out-d;;;no display;-iadc ;;;uncomment -iadc if RT audio input is needed too; For Non-realtime ouput leave only the line below:; -o adsynt.wav -W ;;; for file output any platform</CsOptions><CsInstruments>sr=44100ksmps=32nchnls=20dbfs=1; Generate a sinewave table.wave@global:i=ftgen(1,0,1024,10,1); Generate two empty tables for adsynt.frqs@global:i=ftgen(2,0,32,7,0,32,0); A table for freqency and amp parameters.amps@global:i=ftgen(3,0,32,7,0,32,0); Generates parameters at init timeinstr1; Generate 10 voices.cnt:i=10; Init loop index.index=0; Loop only executed at init time.whileindex<cntdo; Define non-harmonic partials.freq:i=pow(index+1,1.5); Define amplitudes.amp:i=1/(index+1); Write to tables.tableiw(freq,index,frqs); Used by adsynt.tableiw(amp,index,amps)index+=1odsig:a=adsynt(0.3,150,wave,frqs,amps,cnt)outs(sig,sig)endin; Generates parameters every k-cycle.instr2; Generate 10 voices.cnt:i=10; Reset loop index.index:k=0; Loop executed every k-cycle.whileindex<cntdo; Generate lfo for frequencies.speed:k=pow(index+1,1.6); Individual phase for each voice.phas:k=phasorbnk(speed*0.7,index,cnt)lfo_sig:k=table(phas,wave,1); Arbitrary parameter twiddling...depth:k=pow(1.4,index)freq:k=pow(index+1,1.5)freq+=lfo_sig*0.006*depth; Write freqs to table for adsynt.tablew(freq,index,frqs); Generate lfo for amplitudes.speed=pow(index+1,0.8); Individual phase for each voice.phas=phasorbnk(speed*0.13,index,cnt,2)lfo_sig=table(phas,wave,1); Arbitrary parameter twiddling...amp:k=pow(1/(index+1),0.4)amp*=(0.3+0.35*(lfo_sig+1)); Write amps to table for adsynt.tablew(amp,index,amps)index+=1odsig:a=adsynt(0.25,150,wave,frqs,amps,cnt)outs(sig,sig)endin</CsInstruments><CsScore>; Play Instrument #1 for 2.5 seconds.i102.5; Play Instrument #2 for 2.5 seconds.i232.5e</CsScore></CsoundSynthesizer>
<CsoundSynthesizer><CsOptions>; Select audio/midi flags here according to platform-odac;;;RT audio out;-iadc ;;;uncomment -iadc if RT audio input is needed too; For Non-realtime ouput leave only the line below:; -o adsynt.wav -W ;;; for file output any platform</CsOptions><CsInstruments>sr=44100ksmps=32nchnls=20dbfs=1; Generate a sinewave table.giwaveftgen1,0,1024,10,1; Generate two empty tables for adsynt.gifrqsftgen2,0,32,7,0,32,0; A table for freqency and amp parameters.giampsftgen3,0,32,7,0,32,0; Generates parameters at init timeinstr1; Generate 10 voices.icnt=10; Init loop index.index=0; Loop only executed at init time.loop:; Define non-harmonic partials.ifreqpowindex+1,1.5; Define amplitudes.iamp=1/(index+1); Write to tables.tableiwifreq,index,gifrqs; Used by adsynt.tableiwiamp,index,giampsindex=index+1; Do loop/if(index<icnt)igotoloopasigadsynt0.3,150,giwave,gifrqs,giamps,icntoutsasig,asigendin; Generates parameters every k-cycle.instr2; Generate 10 voices.icnt=10; Reset loop index.kindex=0; Loop executed every k-cycle.loop:; Generate lfo for frequencies.kspeedpowkindex+1,1.6; Individual phase for each voice.kphasphasorbnkkspeed*0.7,kindex,icntklfotablekphas,giwave,1; Arbitrary parameter twiddling...kdepthpow1.4,kindexkfreqpowkindex+1,1.5kfreq=kfreq+klfo*0.006*kdepth; Write freqs to table for adsynt.tablewkfreq,kindex,gifrqs; Generate lfo for amplitudes.kspeedpowkindex+1,0.8; Individual phase for each voice.kphasphasorbnkkspeed*0.13,kindex,icnt,2klfotablekphas,giwave,1; Arbitrary parameter twiddling...kamppow1/(kindex+1),0.4kamp=kamp*(0.3+0.35*(klfo+1)); Write amps to table for adsynt.tablewkamp,kindex,giampskindex=kindex+1; Do loop.if(kindex<icnt)kgotoloopasigadsynt0.25,150,giwave,gifrqs,giamps,icntoutsasig,asigendin</CsInstruments><CsScore>; Play Instrument #1 for 2.5 seconds.i102.5; Play Instrument #2 for 2.5 seconds.i232.5e</CsScore></CsoundSynthesizer>