Maximum Value in ftables

View: New views
14 Messages — Rating Filter:   Alert me  

Maximum Value in ftables

by joachim heintz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello all -

is there an opcode to get the maximum value of a function table? E.g.  
for the table
giTab ftgen 0, 0, 8, -2, 1, 5, 2, -4, -9, 8, 0, 4
it should return 8.

Thanks -

        joachim


Send bugs reports to this list.
To unsubscribe, send email sympa@... with body "unsubscribe csound"

Re: Maximum Value in ftables

by David Akbari :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

This is preallocated for speed, and you may think of something better.
What you might try is setting it up the table indexing using the
looping opcodes inside of a UDO space. This implementation is reading
each point individually, of course with 8 points in the table it's not
such a problem but it will quickly prove inadequate with larger sized
tables. I tried reading the table using the phasor to index it over
time, but the results are not fast and if your ultimate implementation
requires you to get the values "now" for realtime performance, this
may not do. The extra bonus in here to answer your question is the use
of Anthony Kozar's "max" opcode.

<CsoundSynthesizer>
<CsOptions>
-m0 -odac -iadc -d -b128 -B256 -Mhw:2,0 -+rtaudio=alsa -+rtmidi=null
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 128
nchnls = 2

giTab   ftgen   1, 0, 8, -2, 1, 5, 2, -4, -9, 8, 0, 4

/*--- ---*/

                instr 1
;kndx1 phasor 1/(ftlen(1))
;kndx1 = kndx1 * ftlen(1)

ktab1 table 1, 1
ktab2 table 2, 1
ktab3 table 3, 1
ktab4 table 4, 1
ktab5 table 5, 1
ktab6 table 6, 1
ktab7 table 7, 1
ktab8 table 8, 1

kmax max ktab1, ktab2, ktab3, ktab4, ktab5, ktab6, ktab7, ktab8

        printk2 kmax

                endin

/*--- ---*/
</CsInstruments>
<CsScore>
i1 0 100

</CsScore>
</CsoundSynthesizer>

On Sun, Jul 6, 2008 at 1:58 PM, joachim heintz <jh@...> wrote:

> Hello all -
>
> is there an opcode to get the maximum value of a function table? E.g. for
> the table
> giTab   ftgen   0, 0, 8, -2, 1, 5, 2, -4, -9, 8, 0, 4
> it should return 8.
>
> Thanks -
>
>        joachim
>


Send bugs reports to this list.
To unsubscribe, send email sympa@... with body "unsubscribe csound"

Re: Re: Maximum Value in ftables

by Steven Yi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'd say try using a loop; there's code with this ftreverse UDO to start with:

http://www.csounds.com/udo/displayOpcode.php?opcode_id=78

Mixing the loop with David's code should yield something reusable. =)

On Sun, Jul 6, 2008 at 12:27 PM, David Akbari <dakbari@...> wrote:

> Hi,
>
> This is preallocated for speed, and you may think of something better.
> What you might try is setting it up the table indexing using the
> looping opcodes inside of a UDO space. This implementation is reading
> each point individually, of course with 8 points in the table it's not
> such a problem but it will quickly prove inadequate with larger sized
> tables. I tried reading the table using the phasor to index it over
> time, but the results are not fast and if your ultimate implementation
> requires you to get the values "now" for realtime performance, this
> may not do. The extra bonus in here to answer your question is the use
> of Anthony Kozar's "max" opcode.
>
> <CsoundSynthesizer>
> <CsOptions>
> -m0 -odac -iadc -d -b128 -B256 -Mhw:2,0 -+rtaudio=alsa -+rtmidi=null
> </CsOptions>
> <CsInstruments>
>
> sr      =       44100
> ksmps   =       128
> nchnls  =       2
>
> giTab   ftgen   1, 0, 8, -2, 1, 5, 2, -4, -9, 8, 0, 4
>
> /*---   ---*/
>
>                instr   1
> ;kndx1  phasor  1/(ftlen(1))
> ;kndx1  =       kndx1 * ftlen(1)
>
> ktab1   table   1, 1
> ktab2   table   2, 1
> ktab3   table   3, 1
> ktab4   table   4, 1
> ktab5   table   5, 1
> ktab6   table   6, 1
> ktab7   table   7, 1
> ktab8   table   8, 1
>
> kmax    max     ktab1, ktab2, ktab3, ktab4, ktab5, ktab6, ktab7, ktab8
>
>        printk2 kmax
>
>                endin
>
> /*---   ---*/
> </CsInstruments>
> <CsScore>
> i1      0       100
>
> </CsScore>
> </CsoundSynthesizer>
>
> On Sun, Jul 6, 2008 at 1:58 PM, joachim heintz <jh@...> wrote:
>> Hello all -
>>
>> is there an opcode to get the maximum value of a function table? E.g. for
>> the table
>> giTab   ftgen   0, 0, 8, -2, 1, 5, 2, -4, -9, 8, 0, 4
>> it should return 8.
>>
>> Thanks -
>>
>>        joachim
>>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@... with body "unsubscribe csound"
>


Send bugs reports to this list.
To unsubscribe, send email sympa@... with body "unsubscribe csound"

Re: Maximum Value in ftables

by Mark Van Peteghem-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I would like to add that in your example it should return a little less
than one, because the table is normalized. The maximum absolute value is
9, so everything would be divided by 9.

joachim heintz schreef:

> Hello all -
>
> is there an opcode to get the maximum value of a function table? E.g.
> for the table
> giTab    ftgen    0, 0, 8, -2, 1, 5, 2, -4, -9, 8, 0, 4
> it should return 8.
>
> Thanks -
>
>     joachim
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@... with body
> "unsubscribe csound"
>
>

--
  Mark
  _________________________________________
  When you get lemons, you make lemonade.
  When you get hardware, you make software.



Send bugs reports to this list.
To unsubscribe, send email sympa@... with body "unsubscribe csound"

Re: Re: Maximum Value in ftables

by Mike Moser-Booth :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Actually, it would not be normalized because the Gen number is negative.

Mark Van Peteghem wrote:

> I would like to add that in your example it should return a little
> less than one, because the table is normalized. The maximum absolute
> value is 9, so everything would be divided by 9.
>
> joachim heintz schreef:
>> Hello all -
>>
>> is there an opcode to get the maximum value of a function table? E.g.
>> for the table
>> giTab    ftgen    0, 0, 8, -2, 1, 5, 2, -4, -9, 8, 0, 4
>> it should return 8.
>>
>> Thanks -
>>
>>     joachim
>>
>>
>> Send bugs reports to this list.
>> To unsubscribe, send email sympa@... with body
>> "unsubscribe csound"
>>
>>
>



Send bugs reports to this list.
To unsubscribe, send email sympa@... with body "unsubscribe csound"

Re: Re: Re: Maximum Value in ftables

by Mark Van Peteghem-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ah, I mislooked, I thought 8 was the GEN number.

Mike Moser-Booth schreef:

> Actually, it would not be normalized because the Gen number is negative.
>
> Mark Van Peteghem wrote:
>> I would like to add that in your example it should return a little
>> less than one, because the table is normalized. The maximum absolute
>> value is 9, so everything would be divided by 9.
>>
>> joachim heintz schreef:
>>> Hello all -
>>>
>>> is there an opcode to get the maximum value of a function table?
>>> E.g. for the table
>>> giTab    ftgen    0, 0, 8, -2, 1, 5, 2, -4, -9, 8, 0, 4
>>> it should return 8.
>>>
>>> Thanks -
>>>
>>>     joachim
>>>
>>>
>>> Send bugs reports to this list.
>>> To unsubscribe, send email sympa@... with body
>>> "unsubscribe csound"
>>>
>>>
>>
>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@... with body
> "unsubscribe csound"
>
>

--
  Mark
  _________________________________________
  When you get lemons, you make lemonade.
  When you get hardware, you make software.



Send bugs reports to this list.
To unsubscribe, send email sympa@... with body "unsubscribe csound"

Re: Re: Re: Maximum Value in ftables

by joachim heintz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks to all for the suggestions. I'm just wondering the following:
Each time csound displays a function table, it gives a message like
"ftable 121: 16 points, max 2.670".
So csound knows the maximum value.
I think it would be useful to have an access to this value with an  
opcode like this

imax ftmax ifn

(Like ftlen, ftsr and so on.)

What do you, Steven, and the other developers think about this?

        joachim



Am 06.07.2008 um 21:49 schrieb Steven Yi:

> I'd say try using a loop; there's code with this ftreverse UDO to  
> start with:
>
> http://www.csounds.com/udo/displayOpcode.php?opcode_id=78
>
> Mixing the loop with David's code should yield something reusable. =)
>
> On Sun, Jul 6, 2008 at 12:27 PM, David Akbari <dakbari@...>  
> wrote:
>> Hi,
>>
>> This is preallocated for speed, and you may think of something  
>> better.
>> What you might try is setting it up the table indexing using the
>> looping opcodes inside of a UDO space. This implementation is reading
>> each point individually, of course with 8 points in the table it's  
>> not
>> such a problem but it will quickly prove inadequate with larger sized
>> tables. I tried reading the table using the phasor to index it over
>> time, but the results are not fast and if your ultimate  
>> implementation
>> requires you to get the values "now" for realtime performance, this
>> may not do. The extra bonus in here to answer your question is the  
>> use
>> of Anthony Kozar's "max" opcode.
>>
>> <CsoundSynthesizer>
>> <CsOptions>
>> -m0 -odac -iadc -d -b128 -B256 -Mhw:2,0 -+rtaudio=alsa -+rtmidi=null
>> </CsOptions>
>> <CsInstruments>
>>
>> sr      =       44100
>> ksmps   =       128
>> nchnls  =       2
>>
>> giTab   ftgen   1, 0, 8, -2, 1, 5, 2, -4, -9, 8, 0, 4
>>
>> /*---   ---*/
>>
>>                instr   1
>> ;kndx1  phasor  1/(ftlen(1))
>> ;kndx1  =       kndx1 * ftlen(1)
>>
>> ktab1   table   1, 1
>> ktab2   table   2, 1
>> ktab3   table   3, 1
>> ktab4   table   4, 1
>> ktab5   table   5, 1
>> ktab6   table   6, 1
>> ktab7   table   7, 1
>> ktab8   table   8, 1
>>
>> kmax    max     ktab1, ktab2, ktab3, ktab4, ktab5, ktab6, ktab7,  
>> ktab8
>>
>>        printk2 kmax
>>
>>                endin
>>
>> /*---   ---*/
>> </CsInstruments>
>> <CsScore>
>> i1      0       100
>>
>> </CsScore>
>> </CsoundSynthesizer>
>>
>> On Sun, Jul 6, 2008 at 1:58 PM, joachim heintz  
>> <jh@...> wrote:
>>> Hello all -
>>>
>>> is there an opcode to get the maximum value of a function table?  
>>> E.g. for
>>> the table
>>> giTab   ftgen   0, 0, 8, -2, 1, 5, 2, -4, -9, 8, 0, 4
>>> it should return 8.
>>>
>>> Thanks -
>>>
>>>        joachim
>>>
>>
>>
>> Send bugs reports to this list.
>> To unsubscribe, send email sympa@... with body  
>> "unsubscribe csound"
>>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@... with body  
> "unsubscribe csound"



Send bugs reports to this list.
To unsubscribe, send email sympa@... with body "unsubscribe csound"

Re: Re: Re: Re: Maximum Value in ftables

by Steven Yi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Joachim,

Following what I mentioned earlier, here's code for a UDO that will do
what are asking about:

        opcode ftmax,i,i

itablenum xin

ilen = ftlen(itablenum)

imax table 0, itablenum

icount = 1

loopStart:

itemp   table icount, itablenum

imax = (itemp > imax) ? itemp : imax

icount = icount + 1

if (icount < ilen) goto loopStart

xout imax

        endop

steven

On Mon, Jul 7, 2008 at 12:22 PM, joachim heintz <jh@...> wrote:

> Thanks to all for the suggestions. I'm just wondering the following:
> Each time csound displays a function table, it gives a message like
> "ftable 121: 16 points, max 2.670".
> So csound knows the maximum value.
> I think it would be useful to have an access to this value with an opcode
> like this
>
> imax            ftmax           ifn
>
> (Like ftlen, ftsr and so on.)
>
> What do you, Steven, and the other developers think about this?
>
>        joachim
>
>
>
> Am 06.07.2008 um 21:49 schrieb Steven Yi:
>
>> I'd say try using a loop; there's code with this ftreverse UDO to start
>> with:
>>
>> http://www.csounds.com/udo/displayOpcode.php?opcode_id=78
>>
>> Mixing the loop with David's code should yield something reusable. =)
>>
>> On Sun, Jul 6, 2008 at 12:27 PM, David Akbari <dakbari@...> wrote:
>>>
>>> Hi,
>>>
>>> This is preallocated for speed, and you may think of something better.
>>> What you might try is setting it up the table indexing using the
>>> looping opcodes inside of a UDO space. This implementation is reading
>>> each point individually, of course with 8 points in the table it's not
>>> such a problem but it will quickly prove inadequate with larger sized
>>> tables. I tried reading the table using the phasor to index it over
>>> time, but the results are not fast and if your ultimate implementation
>>> requires you to get the values "now" for realtime performance, this
>>> may not do. The extra bonus in here to answer your question is the use
>>> of Anthony Kozar's "max" opcode.
>>>
>>> <CsoundSynthesizer>
>>> <CsOptions>
>>> -m0 -odac -iadc -d -b128 -B256 -Mhw:2,0 -+rtaudio=alsa -+rtmidi=null
>>> </CsOptions>
>>> <CsInstruments>
>>>
>>> sr      =       44100
>>> ksmps   =       128
>>> nchnls  =       2
>>>
>>> giTab   ftgen   1, 0, 8, -2, 1, 5, 2, -4, -9, 8, 0, 4
>>>
>>> /*---   ---*/
>>>
>>>               instr   1
>>> ;kndx1  phasor  1/(ftlen(1))
>>> ;kndx1  =       kndx1 * ftlen(1)
>>>
>>> ktab1   table   1, 1
>>> ktab2   table   2, 1
>>> ktab3   table   3, 1
>>> ktab4   table   4, 1
>>> ktab5   table   5, 1
>>> ktab6   table   6, 1
>>> ktab7   table   7, 1
>>> ktab8   table   8, 1
>>>
>>> kmax    max     ktab1, ktab2, ktab3, ktab4, ktab5, ktab6, ktab7, ktab8
>>>
>>>       printk2 kmax
>>>
>>>               endin
>>>
>>> /*---   ---*/
>>> </CsInstruments>
>>> <CsScore>
>>> i1      0       100
>>>
>>> </CsScore>
>>> </CsoundSynthesizer>
>>>
>>> On Sun, Jul 6, 2008 at 1:58 PM, joachim heintz <jh@...>
>>> wrote:
>>>>
>>>> Hello all -
>>>>
>>>> is there an opcode to get the maximum value of a function table? E.g.
>>>> for
>>>> the table
>>>> giTab   ftgen   0, 0, 8, -2, 1, 5, 2, -4, -9, 8, 0, 4
>>>> it should return 8.
>>>>
>>>> Thanks -
>>>>
>>>>       joachim
>>>>
>>>
>>>
>>> Send bugs reports to this list.
>>> To unsubscribe, send email sympa@... with body "unsubscribe
>>> csound"
>>>
>>
>>
>> Send bugs reports to this list.
>> To unsubscribe, send email sympa@... with body "unsubscribe
>> csound"
>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@... with body "unsubscribe
> csound"
>


Send bugs reports to this list.
To unsubscribe, send email sympa@... with body "unsubscribe csound"

Re: Re: Re: Re: Re: Maximum Value in ftables

by joachim heintz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks, Steven. Very elegant solution.
In my opinion, the question remains:
Why doing something again, what csound obviously already has, and  
prints out when displaying a function table?

Thanks again and best regards -

        joachim


Am 07.07.2008 um 21:53 schrieb Steven Yi:

> Hi Joachim,
>
> Following what I mentioned earlier, here's code for a UDO that will do
> what are asking about:
>
> opcode ftmax,i,i
>
> itablenum xin
>
> ilen = ftlen(itablenum)
>
> imax table 0, itablenum
>
> icount = 1
>
> loopStart:
>
> itemp   table icount, itablenum
>
> imax = (itemp > imax) ? itemp : imax
>
> icount = icount + 1
>
> if (icount < ilen) goto loopStart
>
> xout imax
>
> endop
>
> steven
>
> On Mon, Jul 7, 2008 at 12:22 PM, joachim heintz  
> <jh@...> wrote:
>> Thanks to all for the suggestions. I'm just wondering the following:
>> Each time csound displays a function table, it gives a message like
>> "ftable 121: 16 points, max 2.670".
>> So csound knows the maximum value.
>> I think it would be useful to have an access to this value with an  
>> opcode
>> like this
>>
>> imax            ftmax           ifn
>>
>> (Like ftlen, ftsr and so on.)
>>
>> What do you, Steven, and the other developers think about this?
>>
>>        joachim
>>
>>
>>
>> Am 06.07.2008 um 21:49 schrieb Steven Yi:
>>
>>> I'd say try using a loop; there's code with this ftreverse UDO to  
>>> start
>>> with:
>>>
>>> http://www.csounds.com/udo/displayOpcode.php?opcode_id=78
>>>
>>> Mixing the loop with David's code should yield something  
>>> reusable. =)
>>>
>>> On Sun, Jul 6, 2008 at 12:27 PM, David Akbari <dakbari@...>  
>>> wrote:
>>>>
>>>> Hi,
>>>>
>>>> This is preallocated for speed, and you may think of something  
>>>> better.
>>>> What you might try is setting it up the table indexing using the
>>>> looping opcodes inside of a UDO space. This implementation is  
>>>> reading
>>>> each point individually, of course with 8 points in the table  
>>>> it's not
>>>> such a problem but it will quickly prove inadequate with larger  
>>>> sized
>>>> tables. I tried reading the table using the phasor to index it over
>>>> time, but the results are not fast and if your ultimate  
>>>> implementation
>>>> requires you to get the values "now" for realtime performance, this
>>>> may not do. The extra bonus in here to answer your question is  
>>>> the use
>>>> of Anthony Kozar's "max" opcode.
>>>>
>>>> <CsoundSynthesizer>
>>>> <CsOptions>
>>>> -m0 -odac -iadc -d -b128 -B256 -Mhw:2,0 -+rtaudio=alsa -
>>>> +rtmidi=null
>>>> </CsOptions>
>>>> <CsInstruments>
>>>>
>>>> sr      =       44100
>>>> ksmps   =       128
>>>> nchnls  =       2
>>>>
>>>> giTab   ftgen   1, 0, 8, -2, 1, 5, 2, -4, -9, 8, 0, 4
>>>>
>>>> /*---   ---*/
>>>>
>>>>               instr   1
>>>> ;kndx1  phasor  1/(ftlen(1))
>>>> ;kndx1  =       kndx1 * ftlen(1)
>>>>
>>>> ktab1   table   1, 1
>>>> ktab2   table   2, 1
>>>> ktab3   table   3, 1
>>>> ktab4   table   4, 1
>>>> ktab5   table   5, 1
>>>> ktab6   table   6, 1
>>>> ktab7   table   7, 1
>>>> ktab8   table   8, 1
>>>>
>>>> kmax    max     ktab1, ktab2, ktab3, ktab4, ktab5, ktab6, ktab7,  
>>>> ktab8
>>>>
>>>>       printk2 kmax
>>>>
>>>>               endin
>>>>
>>>> /*---   ---*/
>>>> </CsInstruments>
>>>> <CsScore>
>>>> i1      0       100
>>>>
>>>> </CsScore>
>>>> </CsoundSynthesizer>
>>>>
>>>> On Sun, Jul 6, 2008 at 1:58 PM, joachim heintz  
>>>> <jh@...>
>>>> wrote:
>>>>>
>>>>> Hello all -
>>>>>
>>>>> is there an opcode to get the maximum value of a function  
>>>>> table? E.g.
>>>>> for
>>>>> the table
>>>>> giTab   ftgen   0, 0, 8, -2, 1, 5, 2, -4, -9, 8, 0, 4
>>>>> it should return 8.
>>>>>
>>>>> Thanks -
>>>>>
>>>>>       joachim
>>>>>
>>>>
>>>>
>>>> Send bugs reports to this list.
>>>> To unsubscribe, send email sympa@... with body  
>>>> "unsubscribe
>>>> csound"
>>>>
>>>
>>>
>>> Send bugs reports to this list.
>>> To unsubscribe, send email sympa@... with body  
>>> "unsubscribe
>>> csound"
>>
>>
>>
>> Send bugs reports to this list.
>> To unsubscribe, send email sympa@... with body  
>> "unsubscribe
>> csound"
>>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@... with body  
> "unsubscribe csound"



Send bugs reports to this list.
To unsubscribe, send email sympa@... with body "unsubscribe csound"

Re: Re: Re: Re: Re: Re: Maximum Value in ftables

by Andres Cabrera :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Joachim,
I suspect that the print out shows a temporary calculation and the value is not actually stored for performance, but I'm not sure. If the value is stored, an opcode could be made to consult it.

Cheers,
Andrés

On Mon, Jul 7, 2008 at 3:30 PM, joachim heintz <jh@...> wrote:
Thanks, Steven. Very elegant solution.
In my opinion, the question remains:
Why doing something again, what csound obviously already has, and prints out when displaying a function table?

Thanks again and best regards -

       joachim


Am 07.07.2008 um 21:53 schrieb Steven Yi:


Hi Joachim,

Following what I mentioned earlier, here's code for a UDO that will do
what are asking about:

       opcode ftmax,i,i

itablenum xin

ilen = ftlen(itablenum)

imax table 0, itablenum

icount = 1

loopStart:

itemp   table icount, itablenum

imax = (itemp > imax) ? itemp : imax

icount = icount + 1

if (icount < ilen) goto loopStart

xout    imax

       endop

steven

On Mon, Jul 7, 2008 at 12:22 PM, joachim heintz <jh@...> wrote:
Thanks to all for the suggestions. I'm just wondering the following:
Each time csound displays a function table, it gives a message like
"ftable 121: 16 points, max 2.670".
So csound knows the maximum value.
I think it would be useful to have an access to this value with an opcode
like this

imax            ftmax           ifn

(Like ftlen, ftsr and so on.)

What do you, Steven, and the other developers think about this?

      joachim



Am 06.07.2008 um 21:49 schrieb Steven Yi:

I'd say try using a loop; there's code with this ftreverse UDO to start
with:

http://www.csounds.com/udo/displayOpcode.php?opcode_id=78

Mixing the loop with David's code should yield something reusable. =)

On Sun, Jul 6, 2008 at 12:27 PM, David Akbari <dakbari@...> wrote:

Hi,

This is preallocated for speed, and you may think of something better.
What you might try is setting it up the table indexing using the
looping opcodes inside of a UDO space. This implementation is reading
each point individually, of course with 8 points in the table it's not
such a problem but it will quickly prove inadequate with larger sized
tables. I tried reading the table using the phasor to index it over
time, but the results are not fast and if your ultimate implementation
requires you to get the values "now" for realtime performance, this
may not do. The extra bonus in here to answer your question is the use
of Anthony Kozar's "max" opcode.

<CsoundSynthesizer>
<CsOptions>
-m0 -odac -iadc -d -b128 -B256 -Mhw:2,0 -+rtaudio=alsa -+rtmidi=null
</CsOptions>
<CsInstruments>

sr      =       44100
ksmps   =       128
nchnls  =       2

giTab   ftgen   1, 0, 8, -2, 1, 5, 2, -4, -9, 8, 0, 4

/*---   ---*/

             instr   1
;kndx1  phasor  1/(ftlen(1))
;kndx1  =       kndx1 * ftlen(1)

ktab1   table   1, 1
ktab2   table   2, 1
ktab3   table   3, 1
ktab4   table   4, 1
ktab5   table   5, 1
ktab6   table   6, 1
ktab7   table   7, 1
ktab8   table   8, 1

kmax    max     ktab1, ktab2, ktab3, ktab4, ktab5, ktab6, ktab7, ktab8

     printk2 kmax

             endin

/*---   ---*/
</CsInstruments>
<CsScore>
i1      0       100

</CsScore>
</CsoundSynthesizer>

On Sun, Jul 6, 2008 at 1:58 PM, joachim heintz <jh@...>
wrote:

Hello all -

is there an opcode to get the maximum value of a function table? E.g.
for
the table
giTab   ftgen   0, 0, 8, -2, 1, 5, 2, -4, -9, 8, 0, 4
it should return 8.

Thanks -

     joachim



Send bugs reports to this list.
To unsubscribe, send email sympa@... with body "unsubscribe
csound"



Send bugs reports to this list.
To unsubscribe, send email sympa@... with body "unsubscribe
csound"



Send bugs reports to this list.
To unsubscribe, send email sympa@... with body "unsubscribe
csound"



Send bugs reports to this list.
To unsubscribe, send email sympa@... with body "unsubscribe csound"



Send bugs reports to this list.
To unsubscribe, send email sympa@... with body "unsubscribe csound"


Re: Re: Re: Re: Re: Re: Re: Maximum Value in ftables

by Oeyvind Brandtsegg-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

For various algorithmic composition purposes it would be good to have
opcodes for this kind of table query. Like ftablemax, ftablemin,
ftableaverage... and probably a whole family of related queries.
best
Oeyvind

2008/7/8, Andres Cabrera <mantaraya36@...>:

> Hi Joachim,
> I suspect that the print out shows a temporary calculation and the value is
> not actually stored for performance, but I'm not sure. If the value is
> stored, an opcode could be made to consult it.
>
> Cheers,
> Andrés
>
>
> On Mon, Jul 7, 2008 at 3:30 PM, joachim heintz <jh@...> wrote:
> > Thanks, Steven. Very elegant solution.
> > In my opinion, the question remains:
> > Why doing something again, what csound obviously already has, and prints
> out when displaying a function table?
> >
> > Thanks again and best regards -
> >
> >        joachim
> >
> >
> > Am 07.07.2008 um 21:53 schrieb Steven Yi:
> >
> >
> >
> >
> >
> > > Hi Joachim,
> > >
> > > Following what I mentioned earlier, here's code for a UDO that will do
> > > what are asking about:
> > >
> > >        opcode ftmax,i,i
> > >
> > > itablenum xin
> > >
> > > ilen = ftlen(itablenum)
> > >
> > > imax table 0, itablenum
> > >
> > > icount = 1
> > >
> > > loopStart:
> > >
> > > itemp   table icount, itablenum
> > >
> > > imax = (itemp > imax) ? itemp : imax
> > >
> > > icount = icount + 1
> > >
> > > if (icount < ilen) goto loopStart
> > >
> > > xout    imax
> > >
> > >        endop
> > >
> > > steven
> > >
> > > On Mon, Jul 7, 2008 at 12:22 PM, joachim heintz <jh@...>
> wrote:
> > >
> > > > Thanks to all for the suggestions. I'm just wondering the following:
> > > > Each time csound displays a function table, it gives a message like
> > > > "ftable 121: 16 points, max 2.670".
> > > > So csound knows the maximum value.
> > > > I think it would be useful to have an access to this value with an
> opcode
> > > > like this
> > > >
> > > > imax            ftmax           ifn
> > > >
> > > > (Like ftlen, ftsr and so on.)
> > > >
> > > > What do you, Steven, and the other developers think about this?
> > > >
> > > >       joachim
> > > >
> > > >
> > > >
> > > > Am 06.07.2008 um 21:49 schrieb Steven Yi:
> > > >
> > > >
> > > > > I'd say try using a loop; there's code with this ftreverse UDO to
> start
> > > > > with:
> > > > >
> > > > >
> http://www.csounds.com/udo/displayOpcode.php?opcode_id=78
> > > > >
> > > > > Mixing the loop with David's code should yield something reusable.
> =)
> > > > >
> > > > > On Sun, Jul 6, 2008 at 12:27 PM, David Akbari <dakbari@...>
> wrote:
> > > > >
> > > > > >
> > > > > > Hi,
> > > > > >
> > > > > > This is preallocated for speed, and you may think of something
> better.
> > > > > > What you might try is setting it up the table indexing using the
> > > > > > looping opcodes inside of a UDO space. This implementation is
> reading
> > > > > > each point individually, of course with 8 points in the table it's
> not
> > > > > > such a problem but it will quickly prove inadequate with larger
> sized
> > > > > > tables. I tried reading the table using the phasor to index it
> over
> > > > > > time, but the results are not fast and if your ultimate
> implementation
> > > > > > requires you to get the values "now" for realtime performance,
> this
> > > > > > may not do. The extra bonus in here to answer your question is the
> use
> > > > > > of Anthony Kozar's "max" opcode.
> > > > > >
> > > > > > <CsoundSynthesizer>
> > > > > > <CsOptions>
> > > > > > -m0 -odac -iadc -d -b128 -B256 -Mhw:2,0 -+rtaudio=alsa
> -+rtmidi=null
> > > > > > </CsOptions>
> > > > > > <CsInstruments>
> > > > > >
> > > > > > sr      =       44100
> > > > > > ksmps   =       128
> > > > > > nchnls  =       2
> > > > > >
> > > > > > giTab   ftgen   1, 0, 8, -2, 1, 5, 2, -4, -9, 8, 0, 4
> > > > > >
> > > > > > /*---   ---*/
> > > > > >
> > > > > >              instr   1
> > > > > > ;kndx1  phasor  1/(ftlen(1))
> > > > > > ;kndx1  =       kndx1 * ftlen(1)
> > > > > >
> > > > > > ktab1   table   1, 1
> > > > > > ktab2   table   2, 1
> > > > > > ktab3   table   3, 1
> > > > > > ktab4   table   4, 1
> > > > > > ktab5   table   5, 1
> > > > > > ktab6   table   6, 1
> > > > > > ktab7   table   7, 1
> > > > > > ktab8   table   8, 1
> > > > > >
> > > > > > kmax    max     ktab1, ktab2, ktab3, ktab4, ktab5, ktab6, ktab7,
> ktab8
> > > > > >
> > > > > >      printk2 kmax
> > > > > >
> > > > > >              endin
> > > > > >
> > > > > > /*---   ---*/
> > > > > > </CsInstruments>
> > > > > > <CsScore>
> > > > > > i1      0       100
> > > > > >
> > > > > > </CsScore>
> > > > > > </CsoundSynthesizer>
> > > > > >
> > > > > > On Sun, Jul 6, 2008 at 1:58 PM, joachim heintz
> <jh@...>
> > > > > > wrote:
> > > > > >
> > > > > > >
> > > > > > > Hello all -
> > > > > > >
> > > > > > > is there an opcode to get the maximum value of a function table?
> E.g.
> > > > > > > for
> > > > > > > the table
> > > > > > > giTab   ftgen   0, 0, 8, -2, 1, 5, 2, -4, -9, 8, 0, 4
> > > > > > > it should return 8.
> > > > > > >
> > > > > > > Thanks -
> > > > > > >
> > > > > > >      joachim
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > > Send bugs reports to this list.
> > > > > > To unsubscribe, send email sympa@... with body
> "unsubscribe
> > > > > > csound"
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > > Send bugs reports to this list.
> > > > > To unsubscribe, send email sympa@... with body
> "unsubscribe
> > > > > csound"
> > > > >
> > > >
> > > >
> > > >
> > > > Send bugs reports to this list.
> > > > To unsubscribe, send email sympa@... with body
> "unsubscribe
> > > > csound"
> > > >
> > > >
> > >
> > >
> > > Send bugs reports to this list.
> > > To unsubscribe, send email sympa@... with body "unsubscribe
> csound"
> > >
> >
> >
> >
> > Send bugs reports to this list.
> > To unsubscribe, send email sympa@... with body "unsubscribe
> csound"
> >
>
>


Send bugs reports to this list.
To unsubscribe, send email sympa@... with body "unsubscribe csound"

Re: Re: Re: Re: Re: Re: Re: Re: Maximum Value in ftables

by Steven Yi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Oevyind,

Since I already coded up one, the others wouldn't be hard.  If you can
make a list of useful operations, I can code and add them to the UDO
repository.

steven

On Wed, Jul 9, 2008 at 11:30 AM, Oeyvind Brandtsegg <obrandts@...> wrote:

> For various algorithmic composition purposes it would be good to have
> opcodes for this kind of table query. Like ftablemax, ftablemin,
> ftableaverage... and probably a whole family of related queries.
> best
> Oeyvind
>
> 2008/7/8, Andres Cabrera <mantaraya36@...>:
>> Hi Joachim,
>> I suspect that the print out shows a temporary calculation and the value is
>> not actually stored for performance, but I'm not sure. If the value is
>> stored, an opcode could be made to consult it.
>>
>> Cheers,
>> Andrés
>>
>>
>> On Mon, Jul 7, 2008 at 3:30 PM, joachim heintz <jh@...> wrote:
>> > Thanks, Steven. Very elegant solution.
>> > In my opinion, the question remains:
>> > Why doing something again, what csound obviously already has, and prints
>> out when displaying a function table?
>> >
>> > Thanks again and best regards -
>> >
>> >        joachim
>> >
>> >
>> > Am 07.07.2008 um 21:53 schrieb Steven Yi:
>> >
>> >
>> >
>> >
>> >
>> > > Hi Joachim,
>> > >
>> > > Following what I mentioned earlier, here's code for a UDO that will do
>> > > what are asking about:
>> > >
>> > >        opcode ftmax,i,i
>> > >
>> > > itablenum xin
>> > >
>> > > ilen = ftlen(itablenum)
>> > >
>> > > imax table 0, itablenum
>> > >
>> > > icount = 1
>> > >
>> > > loopStart:
>> > >
>> > > itemp   table icount, itablenum
>> > >
>> > > imax = (itemp > imax) ? itemp : imax
>> > >
>> > > icount = icount + 1
>> > >
>> > > if (icount < ilen) goto loopStart
>> > >
>> > > xout    imax
>> > >
>> > >        endop
>> > >
>> > > steven
>> > >
>> > > On Mon, Jul 7, 2008 at 12:22 PM, joachim heintz <jh@...>
>> wrote:
>> > >
>> > > > Thanks to all for the suggestions. I'm just wondering the following:
>> > > > Each time csound displays a function table, it gives a message like
>> > > > "ftable 121: 16 points, max 2.670".
>> > > > So csound knows the maximum value.
>> > > > I think it would be useful to have an access to this value with an
>> opcode
>> > > > like this
>> > > >
>> > > > imax            ftmax           ifn
>> > > >
>> > > > (Like ftlen, ftsr and so on.)
>> > > >
>> > > > What do you, Steven, and the other developers think about this?
>> > > >
>> > > >       joachim
>> > > >
>> > > >
>> > > >
>> > > > Am 06.07.2008 um 21:49 schrieb Steven Yi:
>> > > >
>> > > >
>> > > > > I'd say try using a loop; there's code with this ftreverse UDO to
>> start
>> > > > > with:
>> > > > >
>> > > > >
>> http://www.csounds.com/udo/displayOpcode.php?opcode_id=78
>> > > > >
>> > > > > Mixing the loop with David's code should yield something reusable.
>> =)
>> > > > >
>> > > > > On Sun, Jul 6, 2008 at 12:27 PM, David Akbari <dakbari@...>
>> wrote:
>> > > > >
>> > > > > >
>> > > > > > Hi,
>> > > > > >
>> > > > > > This is preallocated for speed, and you may think of something
>> better.
>> > > > > > What you might try is setting it up the table indexing using the
>> > > > > > looping opcodes inside of a UDO space. This implementation is
>> reading
>> > > > > > each point individually, of course with 8 points in the table it's
>> not
>> > > > > > such a problem but it will quickly prove inadequate with larger
>> sized
>> > > > > > tables. I tried reading the table using the phasor to index it
>> over
>> > > > > > time, but the results are not fast and if your ultimate
>> implementation
>> > > > > > requires you to get the values "now" for realtime performance,
>> this
>> > > > > > may not do. The extra bonus in here to answer your question is the
>> use
>> > > > > > of Anthony Kozar's "max" opcode.
>> > > > > >
>> > > > > > <CsoundSynthesizer>
>> > > > > > <CsOptions>
>> > > > > > -m0 -odac -iadc -d -b128 -B256 -Mhw:2,0 -+rtaudio=alsa
>> -+rtmidi=null
>> > > > > > </CsOptions>
>> > > > > > <CsInstruments>
>> > > > > >
>> > > > > > sr      =       44100
>> > > > > > ksmps   =       128
>> > > > > > nchnls  =       2
>> > > > > >
>> > > > > > giTab   ftgen   1, 0, 8, -2, 1, 5, 2, -4, -9, 8, 0, 4
>> > > > > >
>> > > > > > /*---   ---*/
>> > > > > >
>> > > > > >              instr   1
>> > > > > > ;kndx1  phasor  1/(ftlen(1))
>> > > > > > ;kndx1  =       kndx1 * ftlen(1)
>> > > > > >
>> > > > > > ktab1   table   1, 1
>> > > > > > ktab2   table   2, 1
>> > > > > > ktab3   table   3, 1
>> > > > > > ktab4   table   4, 1
>> > > > > > ktab5   table   5, 1
>> > > > > > ktab6   table   6, 1
>> > > > > > ktab7   table   7, 1
>> > > > > > ktab8   table   8, 1
>> > > > > >
>> > > > > > kmax    max     ktab1, ktab2, ktab3, ktab4, ktab5, ktab6, ktab7,
>> ktab8
>> > > > > >
>> > > > > >      printk2 kmax
>> > > > > >
>> > > > > >              endin
>> > > > > >
>> > > > > > /*---   ---*/
>> > > > > > </CsInstruments>
>> > > > > > <CsScore>
>> > > > > > i1      0       100
>> > > > > >
>> > > > > > </CsScore>
>> > > > > > </CsoundSynthesizer>
>> > > > > >
>> > > > > > On Sun, Jul 6, 2008 at 1:58 PM, joachim heintz
>> <jh@...>
>> > > > > > wrote:
>> > > > > >
>> > > > > > >
>> > > > > > > Hello all -
>> > > > > > >
>> > > > > > > is there an opcode to get the maximum value of a function table?
>> E.g.
>> > > > > > > for
>> > > > > > > the table
>> > > > > > > giTab   ftgen   0, 0, 8, -2, 1, 5, 2, -4, -9, 8, 0, 4
>> > > > > > > it should return 8.
>> > > > > > >
>> > > > > > > Thanks -
>> > > > > > >
>> > > > > > >      joachim
>> > > > > > >
>> > > > > > >
>> > > > > >
>> > > > > >
>> > > > > > Send bugs reports to this list.
>> > > > > > To unsubscribe, send email sympa@... with body
>> "unsubscribe
>> > > > > > csound"
>> > > > > >
>> > > > > >
>> > > > >
>> > > > >
>> > > > > Send bugs reports to this list.
>> > > > > To unsubscribe, send email sympa@... with body
>> "unsubscribe
>> > > > > csound"
>> > > > >
>> > > >
>> > > >
>> > > >
>> > > > Send bugs reports to this list.
>> > > > To unsubscribe, send email sympa@... with body
>> "unsubscribe
>> > > > csound"
>> > > >
>> > > >
>> > >
>> > >
>> > > Send bugs reports to this list.
>> > > To unsubscribe, send email