Csound Csound-dev Csound-tekno Search About

[Csnd] Several instances of an UDO in an UDO

Date2010-03-09 10:50
Fromjoachim heintz
Subject[Csnd] Several instances of an UDO in an UDO
Hi all -

I've written a simple sound producing UDO called "Plopp". Now I'd like  
to have another UDO which has n (say: 10) layers of Plopp. Is there  
another solution than writing
   opcode Ploppsum, a, 0
a1	 Plopp
a2	 Plopp
a3	 Plopp
a4	 Plopp
a5	 Plopp
a6	 Plopp
a7	 Plopp
a8	 Plopp
a9	 Plopp
a10	 Plopp
aout	 sum	 a1, a2, a3, a4, a5, a6, a7, a8, a9, a10
xout	 aout
   endop

?

Thanks -

	joachim


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"

Date2010-03-09 13:22
FromRory Walsh
Subject[Csnd] Re: Several instances of an UDO in an UDO
Can't you build a recursive UDO that calls itself N number of times?
Victor has a good example of this in his Vocoder UDO in the database.

On 9 March 2010 10:50, joachim heintz  wrote:
> Hi all -
>
> I've written a simple sound producing UDO called "Plopp". Now I'd like to
> have another UDO which has n (say: 10) layers of Plopp. Is there another
> solution than writing
>  opcode Ploppsum, a, 0
> a1       Plopp
> a2       Plopp
> a3       Plopp
> a4       Plopp
> a5       Plopp
> a6       Plopp
> a7       Plopp
> a8       Plopp
> a9       Plopp
> a10      Plopp
> aout     sum     a1, a2, a3, a4, a5, a6, a7, a8, a9, a10
> xout     aout
>  endop
>
> ?
>
> Thanks -
>
>        joachim
>
>
> Send bugs reports to the Sourceforge bug tracker
>           https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
> csound"
>
>


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"


Date2010-03-09 13:38
FromSteven Yi
Subject[Csnd] Re: Re: Several instances of an UDO in an UDO
I'm with Rory and would recommend either making the original UDO
recursive or make a second recursive UDO that calls the original UDO.
I thought I'd also mention an article I wrote that covers recursion:

http://csounds.com/journal/2006summer/controlFlow_part2.html

It explains why for-loops won't work in csound for something like this
and why recursion is necessary.


So, for something like Ploppsum, you could use something like:

opcode Ploppsum, a, i

icount xin
aout Plopp

if(icount > 0) then
  atmp Ploppsum (icount - 1)
  aout sum aout, atmp
endif

xout aout

endop

then you could call it like:

asig Ploppsum 10; use 10 instances of Plopp

On Tue, Mar 9, 2010 at 8:22 AM, Rory Walsh  wrote:
> Can't you build a recursive UDO that calls itself N number of times?
> Victor has a good example of this in his Vocoder UDO in the database.
>
> On 9 March 2010 10:50, joachim heintz  wrote:
>> Hi all -
>>
>> I've written a simple sound producing UDO called "Plopp". Now I'd like to
>> have another UDO which has n (say: 10) layers of Plopp. Is there another
>> solution than writing
>>  opcode Ploppsum, a, 0
>> a1       Plopp
>> a2       Plopp
>> a3       Plopp
>> a4       Plopp
>> a5       Plopp
>> a6       Plopp
>> a7       Plopp
>> a8       Plopp
>> a9       Plopp
>> a10      Plopp
>> aout     sum     a1, a2, a3, a4, a5, a6, a7, a8, a9, a10
>> xout     aout
>>  endop
>>
>> ?
>>
>> Thanks -
>>
>>        joachim
>>
>>
>> Send bugs reports to the Sourceforge bug tracker
>>           https://sourceforge.net/tracker/?group_id=81968&atid=564599
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>> csound"
>>
>>
>
>
> Send bugs reports to the Sourceforge bug tracker
>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>
>


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"


Date2010-03-09 13:58
FromRory Walsh
Subject[Csnd] Re: Re: Re: Several instances of an UDO in an UDO
It took me a while to get my head around recursive UDOs but I must
admit it's one of the funkier features of UDOs.

On 9 March 2010 13:38, Steven Yi  wrote:
> I'm with Rory and would recommend either making the original UDO
> recursive or make a second recursive UDO that calls the original UDO.
> I thought I'd also mention an article I wrote that covers recursion:
>
> http://csounds.com/journal/2006summer/controlFlow_part2.html
>
> It explains why for-loops won't work in csound for something like this
> and why recursion is necessary.
>
>
> So, for something like Ploppsum, you could use something like:
>
> opcode Ploppsum, a, i
>
> icount xin
> aout Plopp
>
> if(icount > 0) then
>  atmp Ploppsum (icount - 1)
>  aout sum aout, atmp
> endif
>
> xout aout
>
> endop
>
> then you could call it like:
>
> asig Ploppsum 10; use 10 instances of Plopp
>
> On Tue, Mar 9, 2010 at 8:22 AM, Rory Walsh  wrote:
>> Can't you build a recursive UDO that calls itself N number of times?
>> Victor has a good example of this in his Vocoder UDO in the database.
>>
>> On 9 March 2010 10:50, joachim heintz  wrote:
>>> Hi all -
>>>
>>> I've written a simple sound producing UDO called "Plopp". Now I'd like to
>>> have another UDO which has n (say: 10) layers of Plopp. Is there another
>>> solution than writing
>>>  opcode Ploppsum, a, 0
>>> a1       Plopp
>>> a2       Plopp
>>> a3       Plopp
>>> a4       Plopp
>>> a5       Plopp
>>> a6       Plopp
>>> a7       Plopp
>>> a8       Plopp
>>> a9       Plopp
>>> a10      Plopp
>>> aout     sum     a1, a2, a3, a4, a5, a6, a7, a8, a9, a10
>>> xout     aout
>>>  endop
>>>
>>> ?
>>>
>>> Thanks -
>>>
>>>        joachim
>>>
>>>
>>> Send bugs reports to the Sourceforge bug tracker
>>>           https://sourceforge.net/tracker/?group_id=81968&atid=564599
>>> Discussions of bugs and features can be posted here
>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>>> csound"
>>>
>>>
>>
>>
>> Send bugs reports to the Sourceforge bug tracker
>>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>>
>>
>
>
> Send bugs reports to the Sourceforge bug tracker
>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>
>


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"


Date2010-03-09 14:27
Fromjoachim heintz
Subject[Csnd] Re: Re: Re: Several instances of an UDO in an UDO
Wow - thanks a lot, Steven and Rory. I didn't know that this kind of  
recursion is possible in UDOs. Fantastic feature!
Thanks, too, for the instructive examples of Victor, and your solution  
for my problem, Steven. I just made a little change for being able to  
have 0 as icount:

   opcode Plopps, a, i
icount	 xin
aout	 init	 0
if icount > 0 then
aout	 Plopp
atmp	 Plopps	 icount-1
aout	 sum	 aout, atmp
endif
xout	 aout
   endop

Thanks again -

	joachim


Am 09.03.2010 um 14:38 schrieb Steven Yi:

> I'm with Rory and would recommend either making the original UDO
> recursive or make a second recursive UDO that calls the original UDO.
> I thought I'd also mention an article I wrote that covers recursion:
>
> http://csounds.com/journal/2006summer/controlFlow_part2.html
>
> It explains why for-loops won't work in csound for something like this
> and why recursion is necessary.
>
>
> So, for something like Ploppsum, you could use something like:
>
> opcode Ploppsum, a, i
>
> icount xin
> aout Plopp
>
> if(icount > 0) then
>  atmp Ploppsum (icount - 1)
>  aout sum aout, atmp
> endif
>
> xout aout
>
> endop
>
> then you could call it like:
>
> asig Ploppsum 10; use 10 instances of Plopp
>
> On Tue, Mar 9, 2010 at 8:22 AM, Rory Walsh  wrote:
>> Can't you build a recursive UDO that calls itself N number of times?
>> Victor has a good example of this in his Vocoder UDO in the database.
>>
>> On 9 March 2010 10:50, joachim heintz  wrote:
>>> Hi all -
>>>
>>> I've written a simple sound producing UDO called "Plopp". Now I'd  
>>> like to
>>> have another UDO which has n (say: 10) layers of Plopp. Is there  
>>> another
>>> solution than writing
>>>  opcode Ploppsum, a, 0
>>> a1       Plopp
>>> a2       Plopp
>>> a3       Plopp
>>> a4       Plopp
>>> a5       Plopp
>>> a6       Plopp
>>> a7       Plopp
>>> a8       Plopp
>>> a9       Plopp
>>> a10      Plopp
>>> aout     sum     a1, a2, a3, a4, a5, a6, a7, a8, a9, a10
>>> xout     aout
>>>  endop
>>>
>>> ?
>>>
>>> Thanks -
>>>
>>>        joachim
>>>
>>>
>>> Send bugs reports to the Sourceforge bug tracker
>>>           https://sourceforge.net/tracker/? 
>>> group_id=81968&atid=564599
>>> Discussions of bugs and features can be posted here
>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
>>> "unsubscribe
>>> csound"
>>>
>>>
>>
>>
>> Send bugs reports to the Sourceforge bug tracker
>>            https://sourceforge.net/tracker/? 
>> group_id=81968&atid=564599
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
>> "unsubscribe csound"
>>
>>
>
>
> Send bugs reports to the Sourceforge bug tracker
>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
> "unsubscribe csound"
>
>



Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"