Hello everybody!
I’m trying to use arrays as a source for control values. So i was thinking about creating an UDO for this.
And it’s already working but i always get a click between end and beginning of the array which is problematic. Maybe someone can help.
My UDO looks like this:
opcode ctrl_arr,a,kk[]oo
;; reads an array as input and outputs control signals with the
;; option to normalize the indexes of the input array and the output
;; the array is copied into a table to be used with tablei and read
;; out with a phasor
;; input
kSpeed,kArr[],iNormIndex,iNormOutput xin
if iNormOutput == 1 then
scalearray kArr,0,1
endif
iTable ftgen 0,0,lenarray:i(kArr),2,0
copya2ftab kArr,iTable
aIndex phasor kSpeed
aCtrl tablei aIndex,iTable,iNormIndex
;; output
xout aCtrl
endop
And this is my instrument for testing purposes and which clicks:
<CsoundSynthesizer>
<CsOptions>
-d -odac -W -3
</CsOptions>
<CsInstruments>
sr = 48000
ksmps = 64
nchnls = 2
0dbfs = 1.0
opcode ctrl_arr,a,kk[]oo
;; reads an array as input and outputs control signals with the
;; option to normalize the indexes of the input array and the output
;; the array is copied into a table to be used with tablei and read
;; out with a phasor
;; input
kSpeed,kArr[],iNormIndex,iNormOutput xin
if iNormOutput == 1 then
scalearray kArr,0,1
endif
iTable ftgen 0,0,lenarray:i(kArr),2,0
copya2ftab kArr,iTable
aIndex phasor kSpeed
aCtrl tablei aIndex,iTable,iNormIndex
;; output
xout aCtrl
endop
instr 1
;; controls
kSpeed = 0.25
kValues[] fillarray 80,160,40
aAmp ctrl_arr kSpeed,kValues,1,1
aFreq ctrl_arr kSpeed,kValues,1
kAmp = k(aAmp)
;; signals
aSine1 poscil3 kAmp,aFreq
aSine2 poscil3 kAmp,aFreq*0.75
;; output
aOut1 = aSine1
aOut2 = aSine2
outs aOut1,aOut2
endin
;-----------------------------------------------------------
</CsInstruments>
<CsScore>
i1 0 50
</CsScore>
</CsoundSynthesizer>
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here