Csound Csound-dev Csound-tekno Search About

[Csnd] Loop problem

Date2014-05-09 19:28
FromAskwazzup
Subject[Csnd] Loop problem
         instr 2

 ktrig         metro      1
 kcount     init 1
 kcount     = kcount + ktrig
 kcount2    init 1
 
 loop:
 gkamp      random     0, 100
 kcount2    += 1
 if kcount2 < kcount then
 goto          loop
 endif
 
 endin

Hello!

I'm trying to make an instrument (experimenting actually) that generates a
random value every time the metro opcode ticks, however i suspect that there
is a logic problem in the if function, thus the loop gets stuck. I am sure
that there are a million ways of doing this in a much simpler fashion, but
i'm also interested to find out why this one doesn't work.

Would appreciate some help.




--
View this message in context: http://csound.1045644.n5.nabble.com/Loop-problem-tp5735064.html
Sent from the Csound - General mailing list archive at Nabble.com.

Date2014-05-09 20:26
FromRory Walsh
SubjectRe: [Csnd] Loop problem
I'm finding it hard to follow the logic of your code but the following
will do what you want(untested):

k1 metro 1
kTrig changed k1
kRand random     0, 100
if kTrig == 1 then
printks "Random Value:%d", 0, kRand
endif

or with Csound6

if metro(1)==1 then
printks "Random Value:%d", 0, random:k(0, 100)
endif

On 9 May 2014 20:28, Askwazzup  wrote:
>          instr 2
>
>  ktrig         metro      1
>  kcount     init 1
>  kcount     = kcount + ktrig
>  kcount2    init 1
>
>  loop:
>  gkamp      random     0, 100
>  kcount2    += 1
>  if kcount2 < kcount then
>  goto          loop
>  endif
>
>  endin
>
> Hello!
>
> I'm trying to make an instrument (experimenting actually) that generates a
> random value every time the metro opcode ticks, however i suspect that there
> is a logic problem in the if function, thus the loop gets stuck. I am sure
> that there are a million ways of doing this in a much simpler fashion, but
> i'm also interested to find out why this one doesn't work.
>
> Would appreciate some help.
>
>
>
>
> --
> View this message in context: http://csound.1045644.n5.nabble.com/Loop-problem-tp5735064.html
> Sent from the Csound - General mailing list archive at Nabble.com.
>
>
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>
>
>

Date2014-05-09 20:31
FromAskwazzup
Subject[Csnd] Re: Loop problem
Thanks Rory, but i already figured out the problem and deleted the post
(which apparently doesn't work). I only had to put the if line above the
counter and now it works perfectly.



--
View this message in context: http://csound.1045644.n5.nabble.com/Re-Loop-problem-tp5735067p5735069.html
Sent from the Csound - General mailing list archive at Nabble.com.