Csound Csound-dev Csound-tekno Search About

limiting values in a function table

Date2015-10-27 05:09
FromKevin Welsh
Subjectlimiting values in a function table
I'm looking for a way to hard limit values in an ftable that are above
or below an arbitrary limit... similar to using the limit opcode on a
signal, but since I'm not reading this table through an oscillator
etc, limit isn't immediately useful.

Is there an existing opcode to copy/edit a table limiting it's values
in this fashion?

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

Date2015-10-27 05:37
From"F. Silvain"
SubjectRe: limiting values in a function table
Kevin Welsh, Oct 27 2015:
...
> Is there an existing opcode to copy/edit a table limiting it's values
> in this fashion?
If you create ftables with a positive GEN number they are normalised automatically. All values will be between 0 and 1. If necessary you could use table read and write opcodes afterwards to multiply these values and add to them, to get them in a particular value range.

If the normalisation feature doesn't help you at all and you really need the effect of true limiting and not rescaling, you can use tablera and tablewa with the limit opcode used on the audio signal being written.
...

Ta-ta
----
Ffanci
* Homepage: https://freeshell.de/~silvain
* Twitter:  http://twitter.com/ffanci_silvain
* GitHub:   https://github.com/fsilvain

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

Date2015-10-27 05:52
FromKevin Welsh
SubjectRe: limiting values in a function table
Thanks, but no, normalization is not what I'm looking for.  I want to
retain the shape within the specified boundaries, and discard the
rest.  The specific use case is using an ftable for waveshaping with
distort.  The table isn't being read as a signal, so I can't limit it
that way.  If the values in the table extend beyond 1 or -1, I want to
limit it to that (or potentially any other chosen value).

The best I can think (assuming there's not already an opcode for it)
would be to have a loop running through the length of the table
reading each indexed value, limiting it, and writing it back out to
the table... probably not too difficult of a UDO to come up with, but
I figured I'd ask here first.  I'm not too familiar with all of the
table opcodes, so I hoped maybe one already existed that does this.


On Tue, Oct 27, 2015 at 1:37 AM, F. Silvain  wrote:
> Kevin Welsh, Oct 27 2015:
> ...
>>
>> Is there an existing opcode to copy/edit a table limiting it's values
>> in this fashion?
>
> If you create ftables with a positive GEN number they are normalised
> automatically. All values will be between 0 and 1. If necessary you could
> use table read and write opcodes afterwards to multiply these values and add
> to them, to get them in a particular value range.
>
> If the normalisation feature doesn't help you at all and you really need the
> effect of true limiting and not rescaling, you can use tablera and tablewa
> with the limit opcode used on the audio signal being written.
> ...
>
> Ta-ta
> ----
> Ffanci
> * Homepage: https://freeshell.de/~silvain
> * Twitter:  http://twitter.com/ffanci_silvain
> * GitHub:   https://github.com/fsilvain
>
> 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

Date2015-10-27 06:57
FromKevin Welsh
SubjectRe: limiting values in a function table
Ok, I think this gives a rough idea of what I'm trying to do, but it
doesn't seem to be working... at least not as I would have
hoped/expected.  I need this to be an immediate transformation, not
happening in real time at k or a rate, which is what seems to be
happening with this... plus for some reason I don't understand it
seems like the loop continues incrementing well past the point of the
table length, but that may be a red herring.

Any suggestions?

opcode tablelimit,0,ipj
  ift, imax, imin xin
  ilen ftlen ift
  kidx init 0
  loop_start:
    kval table kidx, ift, 0
    kval limit kval, imin, imax
    tablew kval, kidx, ift
  loop_lt kidx, 1, ilen, loop_start
endop

On Tue, Oct 27, 2015 at 1:52 AM, Kevin Welsh  wrote:
> Thanks, but no, normalization is not what I'm looking for.  I want to
> retain the shape within the specified boundaries, and discard the
> rest.  The specific use case is using an ftable for waveshaping with
> distort.  The table isn't being read as a signal, so I can't limit it
> that way.  If the values in the table extend beyond 1 or -1, I want to
> limit it to that (or potentially any other chosen value).
>
> The best I can think (assuming there's not already an opcode for it)
> would be to have a loop running through the length of the table
> reading each indexed value, limiting it, and writing it back out to
> the table... probably not too difficult of a UDO to come up with, but
> I figured I'd ask here first.  I'm not too familiar with all of the
> table opcodes, so I hoped maybe one already existed that does this.
>
>
> On Tue, Oct 27, 2015 at 1:37 AM, F. Silvain  wrote:
>> Kevin Welsh, Oct 27 2015:
>> ...
>>>
>>> Is there an existing opcode to copy/edit a table limiting it's values
>>> in this fashion?
>>
>> If you create ftables with a positive GEN number they are normalised
>> automatically. All values will be between 0 and 1. If necessary you could
>> use table read and write opcodes afterwards to multiply these values and add
>> to them, to get them in a particular value range.
>>
>> If the normalisation feature doesn't help you at all and you really need the
>> effect of true limiting and not rescaling, you can use tablera and tablewa
>> with the limit opcode used on the audio signal being written.
>> ...
>>
>> Ta-ta
>> ----
>> Ffanci
>> * Homepage: https://freeshell.de/~silvain
>> * Twitter:  http://twitter.com/ffanci_silvain
>> * GitHub:   https://github.com/fsilvain
>>
>> 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

Date2015-10-27 07:06
FromKevin Welsh
SubjectRe: limiting values in a function table
Well duh, I think I may have gotten it by stumbling into "tableiw", I
needed this all to happen in init time, and that seems to do the
trick!

opcode tablelimit,0,ipj
  ift, imax, imin xin
  ilen ftlen ift
  iidx init 0
  loop_start:
    ival table iidx, ift, 0
    ival limit ival, imin, imax
    tableiw ival, iidx, ift
  loop_lt iidx, 1, ilen, loop_start
endop

On Tue, Oct 27, 2015 at 2:57 AM, Kevin Welsh  wrote:
> Ok, I think this gives a rough idea of what I'm trying to do, but it
> doesn't seem to be working... at least not as I would have
> hoped/expected.  I need this to be an immediate transformation, not
> happening in real time at k or a rate, which is what seems to be
> happening with this... plus for some reason I don't understand it
> seems like the loop continues incrementing well past the point of the
> table length, but that may be a red herring.
>
> Any suggestions?
>
> opcode tablelimit,0,ipj
>   ift, imax, imin xin
>   ilen ftlen ift
>   kidx init 0
>   loop_start:
>     kval table kidx, ift, 0
>     kval limit kval, imin, imax
>     tablew kval, kidx, ift
>   loop_lt kidx, 1, ilen, loop_start
> endop
>
> On Tue, Oct 27, 2015 at 1:52 AM, Kevin Welsh  wrote:
>> Thanks, but no, normalization is not what I'm looking for.  I want to
>> retain the shape within the specified boundaries, and discard the
>> rest.  The specific use case is using an ftable for waveshaping with
>> distort.  The table isn't being read as a signal, so I can't limit it
>> that way.  If the values in the table extend beyond 1 or -1, I want to
>> limit it to that (or potentially any other chosen value).
>>
>> The best I can think (assuming there's not already an opcode for it)
>> would be to have a loop running through the length of the table
>> reading each indexed value, limiting it, and writing it back out to
>> the table... probably not too difficult of a UDO to come up with, but
>> I figured I'd ask here first.  I'm not too familiar with all of the
>> table opcodes, so I hoped maybe one already existed that does this.
>>
>>
>> On Tue, Oct 27, 2015 at 1:37 AM, F. Silvain  wrote:
>>> Kevin Welsh, Oct 27 2015:
>>> ...
>>>>
>>>> Is there an existing opcode to copy/edit a table limiting it's values
>>>> in this fashion?
>>>
>>> If you create ftables with a positive GEN number they are normalised
>>> automatically. All values will be between 0 and 1. If necessary you could
>>> use table read and write opcodes afterwards to multiply these values and add
>>> to them, to get them in a particular value range.
>>>
>>> If the normalisation feature doesn't help you at all and you really need the
>>> effect of true limiting and not rescaling, you can use tablera and tablewa
>>> with the limit opcode used on the audio signal being written.
>>> ...
>>>
>>> Ta-ta
>>> ----
>>> Ffanci
>>> * Homepage: https://freeshell.de/~silvain
>>> * Twitter:  http://twitter.com/ffanci_silvain
>>> * GitHub:   https://github.com/fsilvain
>>>
>>> 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

Date2015-10-27 08:35
FromOeyvind Brandtsegg
SubjectRe: limiting values in a function table
Nice that it worked out,
nothing like posting to the list, ...and solvinng it yourself :-)
The solution the same as I'd do too.
best
Oeyvind

2015-10-27 8:06 GMT+01:00 Kevin Welsh :
> Well duh, I think I may have gotten it by stumbling into "tableiw", I
> needed this all to happen in init time, and that seems to do the
> trick!
>
> opcode tablelimit,0,ipj
>   ift, imax, imin xin
>   ilen ftlen ift
>   iidx init 0
>   loop_start:
>     ival table iidx, ift, 0
>     ival limit ival, imin, imax
>     tableiw ival, iidx, ift
>   loop_lt iidx, 1, ilen, loop_start
> endop
>
> On Tue, Oct 27, 2015 at 2:57 AM, Kevin Welsh  wrote:
>> Ok, I think this gives a rough idea of what I'm trying to do, but it
>> doesn't seem to be working... at least not as I would have
>> hoped/expected.  I need this to be an immediate transformation, not
>> happening in real time at k or a rate, which is what seems to be
>> happening with this... plus for some reason I don't understand it
>> seems like the loop continues incrementing well past the point of the
>> table length, but that may be a red herring.
>>
>> Any suggestions?
>>
>> opcode tablelimit,0,ipj
>>   ift, imax, imin xin
>>   ilen ftlen ift
>>   kidx init 0
>>   loop_start:
>>     kval table kidx, ift, 0
>>     kval limit kval, imin, imax
>>     tablew kval, kidx, ift
>>   loop_lt kidx, 1, ilen, loop_start
>> endop
>>
>> On Tue, Oct 27, 2015 at 1:52 AM, Kevin Welsh  wrote:
>>> Thanks, but no, normalization is not what I'm looking for.  I want to
>>> retain the shape within the specified boundaries, and discard the
>>> rest.  The specific use case is using an ftable for waveshaping with
>>> distort.  The table isn't being read as a signal, so I can't limit it
>>> that way.  If the values in the table extend beyond 1 or -1, I want to
>>> limit it to that (or potentially any other chosen value).
>>>
>>> The best I can think (assuming there's not already an opcode for it)
>>> would be to have a loop running through the length of the table
>>> reading each indexed value, limiting it, and writing it back out to
>>> the table... probably not too difficult of a UDO to come up with, but
>>> I figured I'd ask here first.  I'm not too familiar with all of the
>>> table opcodes, so I hoped maybe one already existed that does this.
>>>
>>>
>>> On Tue, Oct 27, 2015 at 1:37 AM, F. Silvain  wrote:
>>>> Kevin Welsh, Oct 27 2015:
>>>> ...
>>>>>
>>>>> Is there an existing opcode to copy/edit a table limiting it's values
>>>>> in this fashion?
>>>>
>>>> If you create ftables with a positive GEN number they are normalised
>>>> automatically. All values will be between 0 and 1. If necessary you could
>>>> use table read and write opcodes afterwards to multiply these values and add
>>>> to them, to get them in a particular value range.
>>>>
>>>> If the normalisation feature doesn't help you at all and you really need the
>>>> effect of true limiting and not rescaling, you can use tablera and tablewa
>>>> with the limit opcode used on the audio signal being written.
>>>> ...
>>>>
>>>> Ta-ta
>>>> ----
>>>> Ffanci
>>>> * Homepage: https://freeshell.de/~silvain
>>>> * Twitter:  http://twitter.com/ffanci_silvain
>>>> * GitHub:   https://github.com/fsilvain
>>>>
>>>> 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