| That'll work, but what I meant was more like
instr 1
kcnt init 0
EnvReinit:
kenv linseg 0, iatt, 1, idec, 0
if ( kcnt == k_condition_for_retrigger ) rigoto EnvReinit
rireturn
etc etc
However, in the above in one wants to use krate variables for the
controls of the envelope ( I look them up in tables that may be changing
any time ) you have two options. You can freeze them in the beginning of
the reinit section:
EnvReinit:
iatt = i(katt)
iadec = i(kdec)
kenv linseg 0, iatt, 1, idec, 0
rireturn
Or you can tweak the envelope generator to handle dynamic time values
properly ( logically? or least the way you want them too ). The former
makes sense in that once the evelope has started it will always run
properly, but does not allow changing values during run time as you can
on an analog env generator, and requires a lot of code. So my line tweak
is meant to simplify the process and cut out the reinit section. I think
it will probably run slower, but one can redirect the envelope after it
has started which is nice for really long envelope values and simulating
flying faders. Once I have it behaving as I like the best, I intend to
do an exp, pow of two, and segmented version. Any input on desired
behaviour is appreciated. I think it may do something like have a mode
button that is an AND mask bit setting conditions for retrigger ( ie
refire or retrig on new kstart, kdur, kend, etc. ) as well as a trigger
variable. Was thinkig something like:
linek kstart, kdur, kend, kgliss, ktrig, kmode
Gliss would be minimum time to go from one discontinuity to another, as
would happen if you changed certain values during certain phases.
Iain
Victor Lazzarini wrote:
> Here's an example of what I (and probably Iain too) mean,
> it creates a linen-like envelope:
>
> instr 1
>
> kcnt init 0
> kenv init 0
>
> iamp = p4
> iatt = 0.5
> idec = 0.1
> ifreq = p5
>
> /* linen-like envelope generator */
> ifact = ksmps/sr
> incr = ifact/iatt
> idcr = ifact/idec
> if kcnt < iatt then
> kenv = kenv + incr
> elseif kcnt > p3-idec then
> kenv = kenv - idcr
> endif
> kcnt = kcnt + ifact
> /* end envelope generator code */
>
> aosc oscil kenv, ifreq, 1
> out aosc*iamp
>
> endin
>
>
> Victor
>
>>Yeah, that's what I usually do too, and I kinda did that
>>within the line opcode. Once I have it's appropriate
>>behaviour figured out I'll submit for use within csound
>>but I'm still figuring out how I want it to behave. Works
>>great for emulating real time envelope generators so far!
>>
>>Iain
>>
>>Victor Lazzarini wrote:
>>
>>>Why dom't you try using some sort of
>>>counter with a k variable. That way you
>>>can initialise k=0 when you want to
>>>start again. You can use if... then... elseif...
>>>to select the different branches.
>>>
>>>Remember that if you do
>>>
>>>k1 = k1 + 1
>>>
>>>k1 will count k-periods. If you want samples, you can
>>>multiply it by kmsps. If you want seconds you can
>>>multiply by ksmps/sr.
>>>
>>>Victor
>>>
>>>
>>>>Did you try the reinit opcode? They are a little
>>
>>confusing >>but I can help you out with them, I used them
>>a ton in my >>monosynths. I have not tried them with a
>>udo, but I >>haven't seen any mention that they won't
>>work there. On >>the other hand, I did write a varient of
>>the line opcode >>myself that restarts on certain krate
>>conditions and that >>worked fine within a UDO. So I'm
>>sure you could do that >>easily enough. Here's the code
>>for my resteerable line >>opcode I'm working on if you
>>want to take a look. You >>could change the reinit
>>condition to an additional trigger >>variable instead
>>easily enough. >>
>>
>>>>Iain
>>>>
>>>>David Akbari wrote:
>>>>
>>>>
>>>>>Hi List,
>>>>>
>>>>>I'm working on a UDO and I seem to have run into a
>>
>>small >>>problem with using the line opcode. It seems
>>that in >>>this UDO, I am trying to index a table for use
>>with >>>fading out the dac. The problem is that I'm using
>>line >>
>>
>>>>to do the table index. So it works, but only ONCE. You
>>>>
>>>>
>>>>>press the space bar and it fades out, you press the
>>>>>number 1 and it fades back in, but then once both
>>
>>lines >>>have been executed, the value is held.
>>
>>>>>How is it possible to reinitialize the line opcode
>>>>>within the UDO block? Any help on this matter is most
>>>>>appreciated!
>>>>>
>>>>>
>>>>>
>>>>>sr = 44100
>>>>>kr = 441
>>>>>ksmps = 100
>>>>>nchnls = 2
>>>>>
>>>>>itmp ftgen 1, 0, 16384, 7, 0, 16384, 1
>>>>>;itmp ftgen 1, 0, 16384, 5, 0.000001, 16384, 1
>>>>>;itmp ftgen 1, 0, 16384, 20, 9, 1
>>>>>
>>>>>/*--- ---*/
>>>>>
>>>>> opcode fadedac, aa, aaii
>>>>>
>>>>>ist init 1
>>>>>iend init 0
>>>>>
>>>>>aLin, aRin, ifadtime, itable xin
>>>>>
>>>>>kval sensekey
>>>>>
>>>>>; space bar fades out
>>>>>; number 1 fades in
>>>>>
>>>>>if (kval == 32) kgoto truf1
>>>>>if (kval == 49) kgoto truf2
>>>>> kgoto cont
>>>>>
>>>>>truf1:
>>>>>ktrue = 1
>>>>> kgoto cont
>>>>>
>>>>>truf2:
>>>>>ktrue = 2
>>>>> kgoto cont
>>>>>
>>>>>cont:
>>>>> if (ktrue == 1) then
>>>>>kndx line ist, ifadtime, iend
>>>>>kndx = kndx * ftlen(itable)
>>>>>klin table kndx, itable
>>>>>aL = aLin * klin
>>>>>aR = aRin * klin
>>>>>;ktrue = 0
>>>>>elseif (ktrue == 2) then
>>>>>kndx line iend, ifadtime, ist
>>>>>kndx = kndx * ftlen(itable)
>>>>>klin table kndx, itable
>>>>>aL = aLin * klin
>>>>>aR = aRin * klin
>>>>>;ktrue = 0
>>>>>else
>>>>>aL = aLin
>>>>>aR = aRin
>>>>> endif
>>>>>
>>>>> xout aL, aR
>>>>>
>>>>> endop
>>>>>
>>>>>/*--- ---*/
>>>>>
>>>>> instr 1
>>>>>
>>>>>; put your sample here
>>>>>a1, a2 diskin2
>>>>>"/Volumes/Neuromancer/sup2/a1lasflutas16", 1, 0, 1
>>>>>a00, a01 fadedac a1, a2, (sr/ftlen(1)), 1
>>>>>
>>>>> outs a00, a01
>>>>>
>>>>> endin
>>>>>
>>>>>/*--- ---*/
>>>>>
>>>>>
>>>>>i1 0 1000
>>>>>
>>>>>e
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>-David
>>>>>
>>>>
>>>>
>>>>[Attachment: mylinek.c]
>>
>>--
>>Send bugs reports to this list.
>>To unsubscribe, send email to
>>csound-unsubscribe@lists.bath.ac.uk |