[Csnd] Exponenciation problem

Hey hey,
I have an issue with exponents. I'm working on an envelope. It works by linearly transforming a phasor signal. To achieve different curve shapes I use an exponent. Consider this code:
kExponent init 16 ; the curve shape, 1 is linear
aPhasor = phasor:a(2) ; the phasor, statically at 2Hz here
aPhasor = aPhasor^kExponent ; this results in a quiet output between 1/3 and
   ; 1/4 of what it should be
kEnv = linlin:k(k(aPhasor), 1, 0) ; the linear transform, it's a downward
   ; curve
;kEnv = kEnv^kExponent ; this works much better, although the exponents must
   ; be the other way round, so kExponent = 16
aOut = oscil:a(kEnv, 330) ; just to test
outs(aOut, aOut)

This is a minimal example, so there are good reasons for aPhasor instead of kPhasor.

In this example kEnv^kExponent works, but for more complex envelope shapes that don't always rise and fall between 0 and 1, this will not work. It would change the value ranges.

The question is: why does it make such a big difference? The phasor moves between 0 and 1. 1^x = 1, never mind what x is. 0^x should also always be 0, if one excludes x=0 so 0^0. This is excluded! It's as if the phasor won't exactly start at 0, thus linlin can never produce the exactly value of 1.

Does anyone have a different solution? logcurve and expcurve will work on k-rate signals, so they could be applied to the k-rate envelope output, but again they would change the value ranges and it would mean creating a completely different method for an a-rate envelope.

Any thoughts or hints are welcome!

Best wishes,

Jeanette

Not sure what you want exactly but I just like to point out that x^n is a nth-order polynomial, you can draw it on a table with GEN3 and use an oscillator or table reader to get its values.

Prof. Victor Lazzarini
Maynooth University
Ireland

May 21 2024, Victor Lazzarini has written:

Not sure what you want exactly but I just like to point out that x^n is a nth-order polynomial, you can draw it on a table with GEN3 and use an oscillator or table reader to get its values.

True, but I'd like to be able to change this in realtime. Think of
synthesizers with envelopes that offer variable slopes, just like
transeg does in Csound. And x^n won't exactly mimic that, but it does a
good job. Having listened to a few examples, I find that they "sound
right".

Best wishes,

Jeanette

Hi again,
sorry, there was a typo in the code
May 21 2024, Jeanette C. has written:
...

kExponent init 1/16 ; the curve shape, 1 is linear
aPhasor = phasor:a2 ; the phasor, statically at 2Hz here
aPhasor = aPhasor^kExponent ; this results in a quiet output between 1/3 and
; 1/4 of what it should be
kEnv = linlin:kk\(aPhasor, 1, 0) ; the linear transform, it's a downward
; curve
;kEnv = kEnv^kExponent ; this works much better, although the exponents must
; be the other way round, so kExponent = 16
aOut = oscil:akEnv, 330 ; just to test
outsaOut, aOut

...
Best wishes,

Jeanette