maparray with UDO
Date | 2017-04-20 07:14 |
From | Oeyvind Brandtsegg |
Subject | maparray with UDO |
Hi,
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
I'm trying to limit the values in an array to a specific range (0 to 1 in my case). I thought maybe I could use maparray, and since I can only use functions with one argument I thought I could try making a UDO of limit with preset values for the uper and lower limit. It seems maparray won't accept UDOs as functions. Is there another way to limit the range of values in an array (and otherwise not changing the values inside the allowed range. Here's my UDO based attempt, which gives INIT ERROR in instr 2: lim not found kArr1 maparray.k kArr "lim" *** opcode lim,k,k k1 xin xout limit(k1,0,1) endop instr 2 kArr[] fillarray .2,.4,.6,.8,1.0,1.2,1.4,1.6,1.8,2.0 kArr1[] maparray kArr, "lim" kmax maxarray kArr1 printk2 kmax endin *** I also tried using "tanh" which sort of could work, but of course it warps the values inside the allowed range and I would prefer to have the option of keeping them linear up to the selected limit. Is there another approach that I could use? Any formulas based on the allowed operations on arrays that could make the trick? Oeyvind Brandtsegg Professor of Music Technology NTNU 7491 Trondheim Norway Cell: +47 92 203 205 http://www.partikkelaudio.com/ http://crossadaptive.hf.ntnu.no http://gdsp.hf.ntnu.no/ http://soundcloud.com/brandtsegg http://flyndresang.no/ http://soundcloud.com/t-emp |
Date | 2017-04-20 10:15 |
From | Rory Walsh |
Subject | Re: maparray with UDO |
Can you not create a UDO that simply takes one array as input and outputs another, limiting values between 0 and 1? On 20 April 2017 at 07:14, Oeyvind Brandtsegg <oyvind.brandtsegg@ntnu.no> wrote:
|
Date | 2017-04-20 14:20 |
From | Guillermo Senna |
Subject | Re: maparray with UDO |
Don't UDOs pass by value? Wouldn't that be copying the entire array twice with that strategy? On 20/04/17 06:15, Rory Walsh wrote: > Can you not create a UDO that simply takes one array as input and outputs > another, limiting values between 0 and 1? > > On 20 April 2017 at 07:14, Oeyvind Brandtsegg |
Date | 2017-04-20 14:47 |
From | Rory Walsh |
Subject | Re: maparray with UDO |
And it would also be doing a value by value copy on each k-pass, which is probably something Oeyvind is trying to avoid I guess.. On 20 April 2017 at 14:20, Guillermo Senna <gsenna@gmail.com> wrote: Don't UDOs pass by value? Wouldn't that be copying the entire array |