Csound Csound-dev Csound-tekno Search About

Another loop issue

Date2017-04-16 09:53
From"Jeanette C."
SubjectAnother loop issue
Attachmentsrf_test.csd  
Hi list,
Attached you find a csd file with a UDO. Inside the UDO I use a loop at 
k-rate to calculate parallel filters. The table3 opcodes look OK, but the 
output definitely doesn't yield the expected results.

Could someone have a look at the loop starting at line 70 and going up to line 
78? I'm out of my depth.

Best wishes and thanks,

Jeanette

--------
When you need someone, you just turn around and I will be there <3

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

Date2017-04-16 15:37
FromSteven Yi
SubjectRe: Another loop issue
Hi Jeanette,

That loop won't work as you're running the same opcode instances
within the loop, and opcodes can have state.  This can be addressed by
using recursion (have your UDO call itself to process only a single
partial at a time, then return the audio and sum on the way back up
the recursion calls), or manually doing processing in the loop to
handle each of the processing steps by hand (i.e., manage and
calculate phases and increments, manage butterbp state vars for each
filter instance, etc.).  The second option might be a bit painful if
you didn't want to get into writing signal processing code. The first
option to use recursion would probably be much simpler and not too
difficult to do, something like:

opcode m_risset_filter_proc, a, akkk....
  ... kpartial xin

  asig = 0
  if(kpartial < kmaxPartial) then
    aphs phasor krate
    afm table3 (kdirfac * (aphs +kndx/kioct))*(kioct/10), iwindow, 1, 0, 1
    afreqmod = afm * kstart_freq
    aam table3 (kdirfac * (aphs + kndx/kioct)), irise, 1, 0, 1
    asig butterbp ain*aam, k(afreqmod), kq
    asig += m_risset_filter_proc(ain, ..., kpartial + 1)
  endif
 xout asig
endop

(I just cut/paste the processing code, so I'm not sure if the above is
really working and treat as pseudo-code.)

Hope that helps!
steven

On Sun, Apr 16, 2017 at 4:53 AM, Jeanette C.  wrote:
> Hi list,
> Attached you find a csd file with a UDO. Inside the UDO I use a loop at
> k-rate to calculate parallel filters. The table3 opcodes look OK, but the
> output definitely doesn't yield the expected results.
>
> Could someone have a look at the loop starting at line 70 and going up to
> line 78? I'm out of my depth.
>
> Best wishes and thanks,
>
> Jeanette
>
> --------
> When you need someone, you just turn around and I will be there <3
>
> 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

Date2017-04-16 15:45
From"Jeanette C."
SubjectRe: Another loop issue
Apr 16 2017, Steven Yi has written:
...
> This can be addressed by
> using recursion (have your UDO call itself to process only a single
> partial at a time, then return the audio and sum on the way back up
> the recursion calls),
...
I knew about that solution, but thought I could be clever and avoid the
recursion. Thanks for pointing out the error of my ways. :) At least
this particular stupidity helped me uncover other issues with my code,
which I now solved.

Best wishes and thanks Steven,

Jeanette

--------
When you need someone, you just turn around and I will be there <3

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