Csound Csound-dev Csound-tekno Search About

[Csnd] Do until

Date2012-04-19 09:19
FromTarmo Johannes
Subject[Csnd] Do until

Hello,
I cannot find documentation about do ... until or was it do ... while? construction.
I think it should be there since 5.14 in new parser and I think it looks nicer than loop_le so I would like to give a try

Greetings,
Tarmo


Date2012-04-19 09:29
FromSteven Yi
SubjectRe: [Csnd] Do until

Hi Tarmo,

It is used like:

until (kval >= kmax) do
... Some code...
od

Cheers!
Steven

On Apr 19, 2012 9:19 AM, "Tarmo Johannes" <tarmo.johannes@otsakool.edu.ee> wrote:

Hello,
I cannot find documentation about do ... until or was it do ... while? construction.
I think it should be there since 5.14 in new parser and I think it looks nicer than loop_le so I would like to give a try

Greetings,
Tarmo


Date2012-04-19 10:13
FromTarmo Johannes
SubjectRe: [Csnd] Do until

Thank you!

Just checking, do I understand correctly that if I want to get N indepent jspline curvers it is nonsense to do something like:

until (kindex<ilimit) do
  tval[kindex] jspline 1, 1, 4
  kindex=kindex+1
od

since there is only one instance of jspline in the memory and all values of the tval array will be the same?

I imagine it is most logical to create another inwtrument that calculates the jspline and it will be started N times from a loop.

But could there be also a way to call N instances of an opcode within a loop? I imagine it would be faster and less memory consuming than calling another instrument? And less lines in the code... Do I get it right?

Tarmo

On 19.04.2012 11:29, "Steven Yi" <stevenyi@gmail.com> wrote:

Hi Tarmo,

It is used like:

until (kval >= kmax) do
... Some code...
od

Cheers!
Steven

On Apr 19, 2012 9:19 AM, "Tarmo Johannes" <tarmo.johannes@otsakool.edu.ee> wrote:

Hello,
I cannot find documentation about do ... until or was it do ... while? construction.
I think it should be there since 5.14 in new parser and I think it looks nicer than loop_le so I would like to give a try

Greetings,
Tarmo


Date2012-04-19 10:59
FromSteven Yi
SubjectRe: [Csnd] Do until
Hi Tarmo,

You are correct that calling the same opcode in a loop won't work.
For that kind of thing, you should use a recursive UDO.  There's an
example of it in an article I wrote for the Csound Journal:

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

There's a technical explanation closer to the bottom that explains the
reasoning.  Another example of a recursive UDO is this mode2 UDO I've
been working on:

	opcode mode2,a,akkkkko

ain, kfreq, kfreqmultiplier, kq, kampmultiplier, kqmultiplier, icounter xin

;kcurrentfreq = kfreq * (icounter + 1)

itie tival

aout mode ain, kfreq, kq, itie
;printk 1, kcurrentfreq
if (icounter < 128) then

kfreqnext = kfreq + (kfreq * kfreqmultiplier)

if (kfreqnext < (sr * .3) && icounter < 128) then

aout2 mode2 ain * kampmultiplier, kfreqnext, kfreqmultiplier, kq *
kqmultiplier, kampmultiplier, kqmultiplier, icounter + 1
aout sum aout, aout2

endif

endif

xout aout

	endop

This creates a bank of mode filters.  You could create something like
this and call it jspline_bank or something like that, and recurse to
get n-number of instances of jspline.  Also, be careful to have some
condition that will terminate the recursion.

Hope that helps!
steven

On Thu, Apr 19, 2012 at 5:13 AM, Tarmo Johannes
 wrote:
> Thank you!
>
> Just checking, do I understand correctly that if I want to get N indepent
> jspline curvers it is nonsense to do something like:
>
> until (kindex   tval[kindex] jspline 1, 1, 4
>   kindex=kindex+1
> od
>
> since there is only one instance of jspline in the memory and all values of
> the tval array will be the same?
>
> I imagine it is most logical to create another inwtrument that calculates
> the jspline and it will be started N times from a loop.
>
> But could there be also a way to call N instances of an opcode within a
> loop? I imagine it would be faster and less memory consuming than calling
> another instrument? And less lines in the code... Do I get it right?
>
> Tarmo
>
> On 19.04.2012 11:29, "Steven Yi"  wrote:
>>
>> Hi Tarmo,
>>
>> It is used like:
>>
>> until (kval >= kmax) do
>> ... Some code...
>> od
>>
>> Cheers!
>> Steven
>>
>> On Apr 19, 2012 9:19 AM, "Tarmo Johannes" 
>> wrote:
>>>
>>> Hello,
>>> I cannot find documentation about do ... until or was it do ... while?
>>> construction.
>>> I think it should be there since 5.14 in new parser and I think it looks
>>> nicer than loop_le so I would like to give a try
>>>
>>> Greetings,
>>> Tarmo