-m128
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
//receiving the values A and B is now interpreted as
//receiving the frequency and the amplitude of a partial
//exercise: substitute the code of "ReceivePartial" with the code from
//the instrument we coded in the first part of the workshop
//version in functional style
instr SendPartials
;two arrays of the same length, with frequencies and amplitudes
iAmps[] = fillarray(0.5, 0.3, 0.2, 0.1, 0.1)
iFreqs[] = fillarray(100, 200, 300, 400, 500)
index = 0
while (index < lenarray(iFreqs)) do
;get the frequency and the amplitude for a certain partial
iAmp = iAmps[index]
iFreq = iFreqs[index]
;... and send them as p4 and p5 (p3 is set to this p3)
schedule("ReceivePartials", 0, p3, iAmp, iFreq)
index += 1
od
endin
instr ReceivePartials
;receive the freq and the amp
iAmp = p4
iFreq = p5
print(iAmp, iFreq)
;create partial
aEnv = transeg:a(iAmp, p3, -4, 0)
aPartial = poscil:a(aEnv, iFreq)
;output
out(aPartial, aPartial)
endin
i "SendPartials" 0 5
100100320240true255255255