Thank you for your patient responses Rory.
I understand what you are saying. I managed to do something similar with LFOs like such:
gkbpm chnget "HOST_BPM
----------------------------------- ; then within the FM instrument block:
klfo1select chnget "LFO1Sync" ; control for lfo rhythm select
kFreq1 chnget "ModFreq1" ; Operator 1 modulation rate
; Operator 1 lfo rhythm selection conditionals. If set to anything other that '0' then ModFreq1 GUI control bypassed.
if (klfo1select == 0) then
kFreq1 = kFreq1 ; Mod Freq1 rslider engaged. If on any other value then rslider bypassed.
elseif (klfo1select == 1) then
kFreq1 = gkbpm/240 ; whole note: 0.5hz
elseif (klfo1select == 2) then
kFreq1 = gkbpm/120 ; half notes: 1hz
elseif (klfo1select == 3) then
kFreq1 = gkbpm/60 ; quarter notes: 2hz
elseif (klfo1select == 4) then
kFreq1 = gkbpm/30 ; 8th notes: 4hz
elseif (klfo1select == 5) then
kFreq1 = gkbpm/15 ; 16th notes: 8hz
elseif (klfo1select == 6) then
kFreq1 = gkbpm/7.5 ; 32nd notes: 16hz
elseif (klfo1select == 7) then
kFreq1 = gkbpm/179.910044977511244 ; dotted half note: 0.667hz
elseif (klfo1select == 8) then
kFreq1 = gkbpm/90.022505626406602 ; dotted quarter note: 1.333hz
elseif (klfo1select == 9) then
kFreq1 = gkbpm/44.99437570303712 ; dotted 8th note: 2.667hz
elseif (klfo1select == 10) then
kFreq1 = gkbpm/22.501406337896119 ; dotted 16th note: 5.333hz
elseif (klfo1select == 11) then
kFreq1 = gkbpm/11.249648448485985 ; dotted 32nd note: 10.667hz
elseif (klfo1select == 12) then
kFreq1 = gkbpm/80 ; half note triplets: 1.5hz
elseif (klfo1select == 13) then
kFreq1 = gkbpm/40 ; quarter note triplets: 3hz
elseif (klfo1select == 14) then
kFreq1 = gkbpm/20 ; 8th note triplets: 6hz
elseif (klfo1select == 15) then
kFreq1 = gkbpm/10 ; 16th note triplets: 12hz
elseif (klfo1select == 16) then
kFreq1 = gkbpm/5 ; 32nd note triplets: 24hz
kMod1Env madsr iop1ampattack, iop1ampdecay, iop1ampsustain, iop1amprelease
kMod2Env madsr iop2ampattack, iop2ampdecay, iop2ampsustain, iop2amprelease
kMod3Env madsr iop3ampattack, iop3ampdecay, iop3ampsustain, iop3amprelease
aEnv madsr iattack, idecay, isustain, irelease
aMod1 oscilikt kAmp1*kMod1Env, kFreq1, kOp1WaveShape
aMod2 oscilikt kAmp2*kMod2Env, kFreq2, kOp2WaveShape
aMod3 oscilikt kAmp3*kMod3Env, kFreq3, kOp3WaveShape
aCar oscilikt kamp, kfreq+aMod1+aMod2+aMod3, kCarrierWaveShape
aBPfil butterbp aCar, kBPcutoff, kBwidth
outs aBPfil*aEnv, aBPfil*aEnv
(I haven't included the whole code - just the relevant parts)
This enables me to load the plugin into Reaper, and no matter how many times I change the BPM setting in Reaper, the LFOs will return the same rhythms synced in time.
So what I would like is for something similar with the Envelopes - so values of 'seconds' will automatically adjust to values of 'beats' whatever BPM I arbitrarily decide to set.
This is where my knowledge falls short.
so something like:
aEnv madsr iattack*(60/gkbpm), idecay*(60/gkbpm), isustain*(60/gkbpm), irelease*(60/gkbpm)
Obviously this is wrong (I'm completely guessing) - and the output shows the following.
error: Unable to find opcode entry for 'madsr' with matching argument types:
Found: a madsr kkkk
I assume this has something to do with i-rate and k-rate.