joehughes
joehughes

Reputation: 1

Envelope From Two Tables of Arbitrary Length in CSound

I'm trying to make a pitch envelope out of two function tables. One table holds the pitch values and the other holds corresponding durations. The two tables will be equal length but that length can be any value. Does anyone know any good methods for creating a line with an arbitrary number of points? Or a way of joining two envelopes together one after another? Thanks!

Upvotes: 0

Views: 31

Answers (1)

joachim heintz
joachim heintz

Reputation: 33

this would be one possibility:

instr test
 kPitches[] fillarray 60, 62, 61, 63
 kDurations[] fillarray 1, 2, 3, 1
 kTime init 0
 kIndx init 0
 if kTime <= 0 then
  kPitchLine = kPitches[kIndx]
  kTime = kDurations[kIndx]
  kIndx += 1
 endif
 kTime -= 1/kr
 aTest poscil .2, mtof(kPitchLine)
 out aTest, aTest
endin
schedule("test",0,7)

you can use function table instead of array if you prefer. and you can wrap this into a UDO (see http://write.flossmanuals.net/csound/g-user-defined-opcodes/ for more information).

perhaps you consider to join the csound mailing list. you will get more suggestions there: https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND

Upvotes: 0

Related Questions