Csound Csound-dev Csound-tekno Search About

[Csnd] Changing Slope of Discrete Stepped Exponential Curve

Date2014-04-16 14:02
FromDavid Mooney
Subject[Csnd] Changing Slope of Discrete Stepped Exponential Curve
Hello--

Not being a mathematician, this has me stumped. I'm using a calculation to increment a variable in a loop that is driving event_i for another instr. The basic calculation gives me a nice exponential progression of numbers so that the variable changes one step for each instance of the event_i:

loop:
  event_i "i",2,idel,idur,ifreq

  idel = idel+idur

  ;calculate exponential progression for ifreq
  iprog = (icnt-1)*(icnt-1)/((inst-1)*(inst-1))
  ifreq = istart +iprog*(istart-iend)

  ;increment the counter
  icnt = icnt+1

loop_lt indx,1,inst,loop

By trial and error, it seems that changing the incrementation of icnt  is the way to change the slope of the resulting curve:

;increment the counter
icnt = (icnt+icntincr)+islope
islope = islope+islopeincr

icntincr is an increments icnt in place of "1", for example "0.1".
islope and its incrementer, islopeincr, when added to the icnt incrementation
changes the slope of the curve. What I'm stuck on is some way to calculate the value of islopeincr for a given icntincr to get an inst number of steps from istart to iend, rather than having to go the trial and error route to hit upon a value for islopeincr that works.

Will appreciate any thoughts, or alternative ways to get to the same end.

--David Mooney

--
Opaque Melodies
http://opaquemelodies.com

Date2014-04-16 15:30
Fromjoachim heintz
SubjectRe: [Csnd] Changing Slope of Discrete Stepped Exponential Curve
hi david -

sounds like you could use a GEN16 table, and step through it. in such a 
table, you can change the slope very easy by the "type" parameter.

best -

	joachim


Am 16.04.2014 15:02, schrieb David Mooney:
> Hello--
>
> Not being a mathematician, this has me stumped. I'm using a calculation
> to increment a variable in a loop that is driving event_i for another
> instr. The basic calculation gives me a nice exponential progression of
> numbers so that the variable changes one step for each instance of the
> event_i:
>
> loop:
>    event_i "i",2,idel,idur,ifreq
>
>    idel = idel+idur
>
>    ;calculate exponential progression for ifreq
>    iprog = (icnt-1)*(icnt-1)/((inst-1)*(inst-1))
>    ifreq = istart +iprog*(istart-iend)
>
>    ;increment the counter
>    icnt = icnt+1
>
> loop_lt indx,1,inst,loop
>
> By trial and error, it seems that changing the incrementation of icnt
> is the way to change the slope of the resulting curve:
>
> ;increment the counter
> icnt = (icnt+icntincr)+islope
> islope = islope+islopeincr
>
> icntincr is an increments icnt in place of "1", for example "0.1".
> islope and its incrementer, islopeincr, when added to the icnt
> incrementation
> changes the slope of the curve. What I'm stuck on is some way to
> calculate the value of islopeincr for a given icntincr to get an inst
> number of steps from istart to iend, rather than having to go the trial
> and error route to hit upon a value for islopeincr that works.
>
> Will appreciate any thoughts, or alternative ways to get to the same end.
>
> --David Mooney
>
> --
> Opaque Melodies
> http://opaquemelodies.com

Date2014-04-16 23:12
FromDavid Mooney
SubjectRe: [Csnd] Changing Slope of Discrete Stepped Exponential Curve
Joachim--thanks.

I'll give this a try, but not sure this will work. What led me to the calculation was the  requirement of event_i to use i-rate rather than than k-rate variables. I had been using a transeg envelope to fill a table (GEN -2), using a phasor index--similar to the example for GEN 16. When reading the table at k-rate, I can get the values just fine, but trying to step through the table to extract variables at i-rate doesn't really work because the phasor index values aren't integers. I tried a conversion like this:

kndx phasor ......
kndx = kndx*100  ;to go from normalized to raw
kndx = int(kndx)

but this didn't get the integer steps into the table I expected---

[Would the index steps be 1/(table size)?--just thought of this.]

 ---and i(kval) doesn't work inside a loop for event_i.

--David Mooney


On Wed, Apr 16, 2014 at 10:30 AM, joachim heintz <jh@joachimheintz.de> wrote:
hi david -

sounds like you could use a GEN16 table, and step through it. in such a table, you can change the slope very easy by the "type" parameter.

best -

        joachim


Am 16.04.2014 15:02, schrieb David Mooney:

Hello--

Not being a mathematician, this has me stumped. I'm using a calculation
to increment a variable in a loop that is driving event_i for another
instr. The basic calculation gives me a nice exponential progression of
numbers so that the variable changes one step for each instance of the
event_i:

loop:
   event_i "i",2,idel,idur,ifreq

   idel = idel+idur

   ;calculate exponential progression for ifreq
   iprog = (icnt-1)*(icnt-1)/((inst-1)*(inst-1))
   ifreq = istart +iprog*(istart-iend)

   ;increment the counter
   icnt = icnt+1

loop_lt indx,1,inst,loop

By trial and error, it seems that changing the incrementation of icnt
is the way to change the slope of the resulting curve:

;increment the counter
icnt = (icnt+icntincr)+islope
islope = islope+islopeincr

icntincr is an increments icnt in place of "1", for example "0.1".
islope and its incrementer, islopeincr, when added to the icnt
incrementation
changes the slope of the curve. What I'm stuck on is some way to
calculate the value of islopeincr for a given icntincr to get an inst
number of steps from istart to iend, rather than having to go the trial
and error route to hit upon a value for islopeincr that works.

Will appreciate any thoughts, or alternative ways to get to the same end.

--David Mooney

--
Opaque Melodies
http://opaquemelodies.com


Send bugs reports to
       https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"






--
Opaque Melodies
http://opaquemelodies.com

Date2014-04-17 10:08
Fromjoachim heintz
SubjectRe: [Csnd] Changing Slope of Discrete Stepped Exponential Curve
hi david -

what i had in mind was something like this:



giCurve ftgen 0, 0, 1024, -16, 0, 1023, 6, 100
instr 1
;read the giCurve table with regular increments
iIncr = .1
iIndx = 0
loop:
iVal table iIndx, giCurve, 1
prints "Table value at position %.1f = %f\n", iIndx, iVal
loop_le iIndx, iIncr, 1, loop
endin


i 1 0 0


which returns:
Table value at position 0.0 = 0.000000
Table value at position 0.1 = 0.203493
Table value at position 0.2 = 0.573630
Table value at position 0.3 = 1.255675
Table value at position 0.4 = 2.487460
Table value at position 0.5 = 4.757245
Table value at position 0.6 = 8.856521
Table value at position 0.7 = 16.312757
Table value at position 0.8 = 30.052217
Table value at position 0.9 = 54.865938
Table value at position 1.0 = 100.000000


not sure this is what you need, but it's i-rate. best -
	joachim


Am 17.04.2014 00:12, schrieb David Mooney:
> Joachim--thanks.
>
> I'll give this a try, but not sure this will work. What led me to the
> calculation was the  requirement of event_i to use i-rate rather than
> than k-rate variables. I had been using a transeg envelope to fill a
> table (GEN -2), using a phasor index--similar to the example for GEN 16.
> When reading the table at k-rate, I can get the values just fine, but
> trying to step through the table to extract variables at i-rate doesn't
> really work because the phasor index values aren't integers. I tried a
> conversion like this:
>
> kndx phasor ......
> kndx = kndx*100  ;to go from normalized to raw
> kndx = int(kndx)
>
> but this didn't get the integer steps into the table I expected---
>
> [Would the index steps be 1/(table size)?--just thought of this.]
>
>   ---and i(kval) doesn't work inside a loop for event_i.
>
> --David Mooney
>
>
> On Wed, Apr 16, 2014 at 10:30 AM, joachim heintz  > wrote:
>
>     hi david -
>
>     sounds like you could use a GEN16 table, and step through it. in
>     such a table, you can change the slope very easy by the "type"
>     parameter.
>
>     best -
>
>              joachim
>
>
>     Am 16.04.2014 15:02, schrieb David Mooney:
>
>         Hello--
>
>         Not being a mathematician, this has me stumped. I'm using a
>         calculation
>         to increment a variable in a loop that is driving event_i for
>         another
>         instr. The basic calculation gives me a nice exponential
>         progression of
>         numbers so that the variable changes one step for each instance
>         of the
>         event_i:
>
>         loop:
>             event_i "i",2,idel,idur,ifreq
>
>             idel = idel+idur
>
>             ;calculate exponential progression for ifreq
>             iprog = (icnt-1)*(icnt-1)/((inst-1)*(__inst-1))
>             ifreq = istart +iprog*(istart-iend)
>
>             ;increment the counter
>             icnt = icnt+1
>
>         loop_lt indx,1,inst,loop
>
>         By trial and error, it seems that changing the incrementation of
>         icnt
>         is the way to change the slope of the resulting curve:
>
>         ;increment the counter
>         icnt = (icnt+icntincr)+islope
>         islope = islope+islopeincr
>
>         icntincr is an increments icnt in place of "1", for example "0.1".
>         islope and its incrementer, islopeincr, when added to the icnt
>         incrementation
>         changes the slope of the curve. What I'm stuck on is some way to
>         calculate the value of islopeincr for a given icntincr to get an
>         inst
>         number of steps from istart to iend, rather than having to go
>         the trial
>         and error route to hit upon a value for islopeincr that works.
>
>         Will appreciate any thoughts, or alternative ways to get to the
>         same end.
>
>         --David Mooney
>
>         --
>         Opaque Melodies
>         http://opaquemelodies.com
>
>
>
>     Send bugs reports to
>     https://github.com/csound/__csound/issues
>     
>     Discussions of bugs and features can be posted here
>     To unsubscribe, send email sympa@lists.bath.ac.uk
>      with body "unsubscribe csound"
>
>
>
>
>
>
> --
> Opaque Melodies
> http://opaquemelodies.com

Date2014-04-17 21:17
FromDavid Mooney
SubjectRe: [Csnd] Changing Slope of Discrete Stepped Exponential Curve
Thank you!! This is it exactly. I see now that my problem all along was not understanding the proper way to increment the index for reading the table.

--David Mooney


On Thu, Apr 17, 2014 at 5:08 AM, joachim heintz <jh@joachimheintz.de> wrote:
hi david -

what i had in mind was something like this:

<CsoundSynthesizer>
<CsInstruments>
giCurve ftgen 0, 0, 1024, -16, 0, 1023, 6, 100
instr 1
;read the giCurve table with regular increments
iIncr = .1
iIndx = 0
loop:
iVal table iIndx, giCurve, 1
prints "Table value at position %.1f = %f\n", iIndx, iVal
loop_le iIndx, iIncr, 1, loop
endin
</CsInstruments>
<CsScore>
i 1 0 0
</CsScore>

which returns:
Table value at position 0.0 = 0.000000
Table value at position 0.1 = 0.203493
Table value at position 0.2 = 0.573630
Table value at position 0.3 = 1.255675
Table value at position 0.4 = 2.487460
Table value at position 0.5 = 4.757245
Table value at position 0.6 = 8.856521
Table value at position 0.7 = 16.312757
Table value at position 0.8 = 30.052217
Table value at position 0.9 = 54.865938
Table value at position 1.0 = 100.000000


not sure this is what you need, but it's i-rate. best -
        joachim


Am 17.04.2014 00:12, schrieb David Mooney:
Joachim--thanks.

I'll give this a try, but not sure this will work. What led me to the
calculation was the  requirement of event_i to use i-rate rather than
than k-rate variables. I had been using a transeg envelope to fill a
table (GEN -2), using a phasor index--similar to the example for GEN 16.
When reading the table at k-rate, I can get the values just fine, but
trying to step through the table to extract variables at i-rate doesn't
really work because the phasor index values aren't integers. I tried a
conversion like this:

kndx phasor ......
kndx = kndx*100  ;to go from normalized to raw
kndx = int(kndx)

but this didn't get the integer steps into the table I expected---

[Would the index steps be 1/(table size)?--just thought of this.]

  ---and i(kval) doesn't work inside a loop for event_i.

--David Mooney


On Wed, Apr 16, 2014 at 10:30 AM, joachim heintz <jh@joachimheintz.de
<mailto:jh@joachimheintz.de>> wrote:

    hi david -

    sounds like you could use a GEN16 table, and step through it. in
    such a table, you can change the slope very easy by the "type"
    parameter.

    best -

             joachim


    Am 16.04.2014 15:02, schrieb David Mooney:

        Hello--

        Not being a mathematician, this has me stumped. I'm using a
        calculation
        to increment a variable in a loop that is driving event_i for
        another
        instr. The basic calculation gives me a nice exponential
        progression of
        numbers so that the variable changes one step for each instance
        of the
        event_i:

        loop:
            event_i "i",2,idel,idur,ifreq

            idel = idel+idur

            ;calculate exponential progression for ifreq
            iprog = (icnt-1)*(icnt-1)/((inst-1)*(__inst-1))

            ifreq = istart +iprog*(istart-iend)

            ;increment the counter
            icnt = icnt+1

        loop_lt indx,1,inst,loop

        By trial and error, it seems that changing the incrementation of
        icnt
        is the way to change the slope of the resulting curve:

        ;increment the counter
        icnt = (icnt+icntincr)+islope
        islope = islope+islopeincr

        icntincr is an increments icnt in place of "1", for example "0.1".
        islope and its incrementer, islopeincr, when added to the icnt
        incrementation
        changes the slope of the curve. What I'm stuck on is some way to
        calculate the value of islopeincr for a given icntincr to get an
        inst
        number of steps from istart to iend, rather than having to go
        the trial
        and error route to hit upon a value for islopeincr that works.

        Will appreciate any thoughts, or alternative ways to get to the
        same end.

        --David Mooney

        --
        Opaque Melodies
        http://opaquemelodies.com



    Send bugs reports to
    https://github.com/csound/__csound/issues

    <https://github.com/csound/csound/issues>
    Discussions of bugs and features can be posted here
    To unsubscribe, send email sympa@lists.bath.ac.uk
    <mailto:sympa@lists.bath.ac.uk> with body "unsubscribe csound"







--
Opaque Melodies
http://opaquemelodies.com


Send bugs reports to
       https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"






--
Opaque Melodies
http://opaquemelodies.com