Csound Csound-dev Csound-tekno Search About

[Csnd] Exponenciation problem

Date2024-05-21 19:30
From"Jeanette C."
Subject[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

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

I'm so curious, what do you think of me <3
(Britney Spears)

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2024-05-21 20:12
FromVictor Lazzarini
SubjectRe: [Csnd] Exponenciation problem
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

> On 21 May 2024, at 19:30, Jeanette C.  wrote:
> 
> 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
> 
> --
> * Website: http://juliencoder.de - for summer is a state of sound
> * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
> * Audiobombs: https://www.audiobombs.com/users/jeanette_c
> * GitHub: https://github.com/jeanette-c
> 
> I'm so curious, what do you think of me <3
> (Britney Spears)
> 
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>       https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2024-05-21 20:27
From"Jeanette C."
SubjectRe: [Csnd] Exponenciation problem
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

>
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
>
>> On 21 May 2024, at 19:30, Jeanette C.  wrote:
>>
>> 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
>>
>> --
>> * Website: http://juliencoder.de - for summer is a state of sound
>> * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
>> * Audiobombs: https://www.audiobombs.com/users/jeanette_c
>> * GitHub: https://github.com/jeanette-c
>>
>> I'm so curious, what do you think of me <3
>> (Britney Spears)
>>
>> Csound mailing list
>> Csound@listserv.heanet.ie
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>> Send bugs reports to
>>       https://github.com/csound/csound/issues
>> Discussions of bugs and features can be posted here
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>        https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
>

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

I'm so curious, what do you think of me <3
(Britney Spears)

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2024-05-22 00:00
From"Jeanette C."
SubjectRe: [Csnd] Exponenciation problem
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: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)
...
Best wishes,

Jeanette

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

I'm so curious, what do you think of me <3
(Britney Spears)

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here