Raises each element of a vector to a scalar power.
Note
Up to Csound 6, this opcode was called vpow_i.
Syntax
vpowi(ifn,ival,ielements[,idstoffset])
vpow_iifn,ival,ielements[,idstoffset]
Initialization
ifn - number of the table hosting the vectorial signal to be processed
ielements - number of elements of the vector
ival - scalar value to which the elements of ifn will be raised
idstoffset - index offset for the destination table
Performance
vpowi elevates each element of the vector contained in the table ifn to the power of ival, starting from table index idstoffset. This enables you to process a specific section of a table by specifying the offset and the number of elements to be processed. Offset is counted starting from 0, so if no offset is specified (or set to 0), the table will be modified from the beginning.
This opcode runs only on initialization, there is a k-rate version of this opcode called vpow.
Negative values for idstoffset are valid. Elements from the vector that are outside the table, will be discarded, and they will not wrap around the table.
In all these opcodes, the resulting vectors are stored in ifn, overriding the intial vectors. If you want to keep initial vector, use vcopy or vcopyi to copy it in another table. All these operators are designed to be used together with other opcodes that operate with vectorial signals such as vcella, adsynt, adsynt2, etc. They can also be useful in conjunction with the spectral opcodes pvsftw and pvsftr.
Examples
Here is an example of the vpowi opcode. It uses the file vpowi.csd.
<CsoundSynthesizer><CsOptions>; Select audio/midi flags here according to platform; Audio out Audio in-odac -iadc ;;;RT audio I/O; For Non-realtime ouput leave only the line below:; -o cigoto.wav -W ;;; for file output any platform</CsOptions><CsInstruments>sr=44100ksmps=128nchnls=2instr1fn1:i=p4val:i=p5elements:i=p6dstoffset:i=p7vpowi(fn1,val,elements,dstoffset)endininstr2; Print tableTable:i=p4size:i=ftlen(Table)Count:k=init(0)val:k=table(Count,Table)printk2(val)ifCount==sizethenturnoff()endifCount+=1endin</CsInstruments><CsScore>f1016-711617i20.00.21i10.40.011234i20.80.21i11.00.0110.55-3i21.20.21i11.40.0111.51012i21.60.21e</CsScore></CsoundSynthesizer>
Here is another example of the vpowi opcode. It uses the file vpowi-2.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 vpowi-2.wav -W ;;; for file output any platform</CsOptions><CsInstruments>sr=44100ksmps=32nchnls=20dbfs=1fil@global:i=ftgen(1,0,0,1,"fox.wav",0,0,1)instr1val:i=p4;different distortion settingselements:i=p5dstoffset:i=p6;index offsetvpowi(1,val,elements,dstoffset)sig:a=lposcil(1,1,0,0,1)out(sig,sig)endin</CsInstruments><CsScore>i102.70.5700000; no offseti132.70.015000070000; add another period of distortion,; starting at sample 70000 e</CsScore></CsoundSynthesizer>
Here is an example of the vpow_i opcode. It uses the file vpow_i.csd.
<CsoundSynthesizer><CsOptions>; Select audio/midi flags here according to platform; Audio out Audio in-odac -iadc ;;;RT audio I/O; For Non-realtime ouput leave only the line below:; -o cigoto.wav -W ;;; for file output any platform</CsOptions><CsInstruments>sr=44100ksmps=128nchnls=2instr1ifn1=p4ival=p5ielements=p6idstoffset=p7vpow_iifn1,ival,ielements,idstoffsetendininstr2;Printtableitable=p4isize=ftlen(itable)kcountinit0kvaltablekcount,itableprintk2kvalif(kcount==isize)thenturnoffendifkcount=kcount+1endin</CsInstruments><CsScore>f1016-711617i20.00.21i10.40.011234i20.80.21i11.00.0110.55-3i21.20.21i11.40.0111.51012i21.60.21e</CsScore></CsoundSynthesizer>
Here is another example of the vpow_i opcode. It uses the file vpow_i-2.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 vpow_i-2.wav -W ;;; for file output any platform</CsOptions><CsInstruments>sr=44100ksmps=32nchnls=20dbfs=1gifilftgen1,0,0,1,"fox.wav",0,0,1instr1ival=p4;different distortion settingsielements=p5idstoffset=p6;index offsetvpow_i1,ival,ielements,idstoffsetasiglposcil1,1,0,0,1outsasig,asigendin</CsInstruments><CsScore>i102.7.5700000;no offseti132.7.015000070000;add another period of distortion, starting at sample 70000 e</CsScore></CsoundSynthesizer>