Csound Csound-dev Csound-tekno Search About

[Csnd] i-rate v k-rate

Date2010-08-30 14:50
Fromjohn ffitch
Subject[Csnd] i-rate v k-rate
> Apparently there is something about i-rate processing in general that  
> I don't get. I have been confused by this in the past, I think.

You and many many others!  I will try to explain what I understand and
others can correct and amplify.

> 
> First, I regret that I do not know how to read:
> 
> > #i0     rnd.i   1
> > krand   =.k     #i0

If I suspect that the rates are not what i suspect I compile with -v,
which I find very useful in understanding stuff.  Amongst other stuff
it gives a commentary on the orchestra.

In the case of your example it says the following.  I have annotated
the text with **** lines

        instr   1
LINE 6:
groups: krand = rnd(1) 
        **** The parser has read line 6 and is about to group it
rnd     (       1       )
        **** but first need to do the expression, which it interprets
        **** as 4 entities
1       rnd
treqd i, tfound c
        **** Now try to work out which rnd you mean.  It has a
        **** constant (c) and the first case is that it looks for
        **** i-rate, and that matches
xincod = 0
treqd i, tfound i
        **** Now the function call is unwrapped to a temporary value
        **** called #i0, i-rate
#i0     rnd.i   1
        **** so we generate "#i0 rnd.i 1" as an opcode
modified opcod: =.k
        **** but the assignment is to a k-rate variable 
treqd z, tfound i
        **** Want z rate (internal code for a or k) so match k-rate by
        **** promotion 
xincod = 0
treqd z, tfound k
krand   =.k     #i0
        **** and we have the second opcode
LINE 7:
groups: krand2 random 0 1 
        **** next line has 4 items
modified opcod: random.k
        **** random opcode promoted to k-rate cos of answer
treqd k, tfound c
        **** Deal with constant 0, wanting k-rate
treqd k, tfound c
        **** Deal with constant 1, wanting k-rate
xincod = 0
treqd k, tfound k
        **** and all is OK
krand2  random.k        0       1
LINE 8:
        **** and so on
groups: printk 2 krand 
treqd o, tfound c
treqd k, tfound k
treqd i, tfound c
       **** th optional argument provided with the default
xincod = 0
        printk  2       krand   0
LINE 9:
groups: printk 2 krand2 5 
treqd o, tfound c
treqd k, tfound k
treqd i, tfound c
xincod = 0
        printk  2       krand2  5
LINE 10:
groups: endin 
 
> 
> Perhaps you can point me to some explanation of this notation. And to  
> some general description of i-rate processing.

So now the orchestra has been explained and matched to
#i0     rnd.i   1
krand   =.k     #i0
        printk  2       krand   0
        printk  2       krand2  5

which is what is obeyed.

All i-rate opcodes and the init-phase of k and a rate are obeyed once
on initiation, and the the k and a rates in performance.  In your
example the rnd.i is only called at init time

Of course if you came to my compiler lectures this would be clearer,
with the blackboard and jokes....

> 
> Second, is it that the "1" inside of rnd(1) is considered to be an  
> irate "variable"?
> 

In some sense yes.  rnd has two forms and it tried to create the
simplest first, and a constant can be though of as i-rate first

> If so, how does the following get processed?
> 
> ktemp = 1
> 

The 1 is considered as constant, and the assignment is =.k so it wants
a z rate
groups: ktemp = 1 
modified opcod: =.k
treqd z, tfound c
xincod = 0
treqd z, tfound k
ktemp   =.k     1

> Is this executed only at i-time, NOT every k-cycle?
> 

Every k cycle as u.k is k-rate

> Third, what is the difference between
> 
> ktemp = 1
> 
> and
> 
> ktemp init 1

=.k is k-rate but init.k is i-rate, so init only happens once at init
time (hence the name)

Hope that is not totally opaque

==John ffitch


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-08-30 15:37
FromVictor Lazzarini
Subject[Csnd] Re: i-rate v k-rate
Wouldn't mind that myself.
On 30 Aug 2010, at 14:50, john ffitch wrote:

> Of course if you came to my compiler lectures this would be clearer,
> with the blackboard and jokes....



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-09-05 14:27
FromRichard Boulanger
Subject[Csnd] Re: i-rate v k-rate
John,

This is such an eye opening mini "lecture"

I am wondering if you might take it both back and further by

1.  Writing an article for The Csound Journal where you take
the reader through several instruments (gradually getting more involved)
and explain what is going on.

Instrument
Console Output (maybe with or without some bugs)
-V (verbose output) showing what Csound is really doing with the "code"

OR BY

2. Add a few pages to the manual that show the "beginner to intermediate" Csounder
how to Interpret this Verbose output (as you have below)


or both....

When you finish ParCS and The new Parser?

Best,

Rick


On Aug 30, 2010, at 9:50 AM, john ffitch wrote:

>> Apparently there is something about i-rate processing in general that  
>> I don't get. I have been confused by this in the past, I think.
> 
> You and many many others!  I will try to explain what I understand and
> others can correct and amplify.
> 
>> 
>> First, I regret that I do not know how to read:
>> 
>>> #i0     rnd.i   1
>>> krand   =.k     #i0
> 
> If I suspect that the rates are not what i suspect I compile with -v,
> which I find very useful in understanding stuff.  Amongst other stuff
> it gives a commentary on the orchestra.
> 
> In the case of your example it says the following.  I have annotated
> the text with **** lines
> 
>        instr   1
> LINE 6:
> groups: krand = rnd(1) 
>        **** The parser has read line 6 and is about to group it
> rnd     (       1       )
>        **** but first need to do the expression, which it interprets
>        **** as 4 entities
> 1       rnd
> treqd i, tfound c
>        **** Now try to work out which rnd you mean.  It has a
>        **** constant (c) and the first case is that it looks for
>        **** i-rate, and that matches
> xincod = 0
> treqd i, tfound i
>        **** Now the function call is unwrapped to a temporary value
>        **** called #i0, i-rate
> #i0     rnd.i   1
>        **** so we generate "#i0 rnd.i 1" as an opcode
> modified opcod: =.k
>        **** but the assignment is to a k-rate variable 
> treqd z, tfound i
>        **** Want z rate (internal code for a or k) so match k-rate by
>        **** promotion 
> xincod = 0
> treqd z, tfound k
> krand   =.k     #i0
>        **** and we have the second opcode
> LINE 7:
> groups: krand2 random 0 1 
>        **** next line has 4 items
> modified opcod: random.k
>        **** random opcode promoted to k-rate cos of answer
> treqd k, tfound c
>        **** Deal with constant 0, wanting k-rate
> treqd k, tfound c
>        **** Deal with constant 1, wanting k-rate
> xincod = 0
> treqd k, tfound k
>        **** and all is OK
> krand2  random.k        0       1
> LINE 8:
>        **** and so on
> groups: printk 2 krand 
> treqd o, tfound c
> treqd k, tfound k
> treqd i, tfound c
>       **** th optional argument provided with the default
> xincod = 0
>        printk  2       krand   0
> LINE 9:
> groups: printk 2 krand2 5 
> treqd o, tfound c
> treqd k, tfound k
> treqd i, tfound c
> xincod = 0
>        printk  2       krand2  5
> LINE 10:
> groups: endin 
> 
>> 
>> Perhaps you can point me to some explanation of this notation. And to  
>> some general description of i-rate processing.
> 
> So now the orchestra has been explained and matched to
> #i0     rnd.i   1
> krand   =.k     #i0
>        printk  2       krand   0
>        printk  2       krand2  5
> 
> which is what is obeyed.
> 
> All i-rate opcodes and the init-phase of k and a rate are obeyed once
> on initiation, and the the k and a rates in performance.  In your
> example the rnd.i is only called at init time
> 
> Of course if you came to my compiler lectures this would be clearer,
> with the blackboard and jokes....
> 
>> 
>> Second, is it that the "1" inside of rnd(1) is considered to be an  
>> irate "variable"?
>> 
> 
> In some sense yes.  rnd has two forms and it tried to create the
> simplest first, and a constant can be though of as i-rate first
> 
>> If so, how does the following get processed?
>> 
>> ktemp = 1
>> 
> 
> The 1 is considered as constant, and the assignment is =.k so it wants
> a z rate
> groups: ktemp = 1 
> modified opcod: =.k
> treqd z, tfound c
> xincod = 0
> treqd z, tfound k
> ktemp   =.k     1
> 
>> Is this executed only at i-time, NOT every k-cycle?
>> 
> 
> Every k cycle as u.k is k-rate
> 
>> Third, what is the difference between
>> 
>> ktemp = 1
>> 
>> and
>> 
>> ktemp init 1
> 
> =.k is k-rate but init.k is i-rate, so init only happens once at init
> time (hence the name)
> 
> Hope that is not totally opaque
> 
> ==John ffitch
> 
> 
> 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"