Csound Csound-dev Csound-tekno Search About

[Cs-dev] issue with functional syntax in k-rate loop

Date2013-07-14 18:55
Fromjoachim heintz
Subject[Cs-dev] issue with functional syntax in k-rate loop
Attachmentstest2.csd  None  None  
hi -

when i use rnd31 in a k-rate loop, it gives a constant value in this 
loop, instead of being updated. so, this works:

kIndx = 0
until kIndx == lenarray(kArr) do
kVal rnd31 10, 0
kArr[kIndx] = kVal
kIndx += 1
od

bit this does not:
kIndx = 0
until kIndx == lenarray(kArr) do
kArr[kIndx] = rnd31(10, 0)
kIndx += 1
od

as the output shows:
kArr[0] = -4,374842
kArr[1] = -7,973382
kArr[2] = -8,632477
kArr[3] = -6,041560
kArr[4] = -0,505397
kArr[5] = 5,786851
kArr[6] = -0,396027
kArr[7] = 3,980599
kArr[8] = 1,934689
kArr[9] = -3,681660

kArr[0] = 3,203606
kArr[1] = 3,203606
kArr[2] = 3,203606
kArr[3] = 3,203606
kArr[4] = 3,203606
kArr[5] = 3,203606
kArr[6] = 3,203606
kArr[7] = 3,203606
kArr[8] = 3,203606
kArr[9] = 3,203606

complete example below and attached.
best -

	joachim




-nm128



instr 1 ;works in traditional syntax
;create array
kArr[] init 10

;fill with random elements
kIndx = 0
until kIndx == lenarray(kArr) do
kVal rnd31 10, 0
kArr[kIndx] = kVal
kIndx += 1
od

;print out values
kIndx = 0
until kIndx == lenarray(kArr) do
printf("kArr[%d] = %f\n", kIndx+1, kIndx, kArr[kIndx])
kIndx += 1
od

turnoff
endin


instr 2 ;does not in functional syntax
;create array
kArr[] init 10
printks "\n", 0

;fill with random elements
kIndx = 0
until kIndx == lenarray(kArr) do
kArr[kIndx] = rnd31(10, 0) ;this is the difference
kIndx += 1
od

;print out values
kIndx = 0
until kIndx == lenarray(kArr) do
printf("kArr[%d] = %f\n", kIndx+1, kIndx, kArr[kIndx])
kIndx += 1
od

turnoff
endin


i 1 0 .1
i 2 0 .1





Date2013-07-14 19:39
FromSteven Yi
SubjectRe: [Cs-dev] issue with functional syntax in k-rate loop
Hi Joachim,

I think this is an issue where the i-type version of the opcode is
being used by default.  Could you try using

kArr[kIndx] = rnd31:k(10, 0)

to type hint the function?  Also, this may work:

kArr[kIndx]  rnd31 10, 0

I actually get a crash with this test2.csd here.  I'm not sure if
others get it too, or if it's because I'm in the middle of some other
debugging.  Maybe someone else here could give it a try too.

Thanks!
steven

On Sun, Jul 14, 2013 at 1:55 PM, joachim heintz  wrote:
> hi -
>
> when i use rnd31 in a k-rate loop, it gives a constant value in this loop,
> instead of being updated. so, this works:
>
> kIndx = 0
> until kIndx == lenarray(kArr) do
> kVal rnd31 10, 0
> kArr[kIndx] = kVal
> kIndx += 1
> od
>
> bit this does not:
> kIndx = 0
> until kIndx == lenarray(kArr) do
> kArr[kIndx] = rnd31(10, 0)
> kIndx += 1
> od
>
> as the output shows:
> kArr[0] = -4,374842
> kArr[1] = -7,973382
> kArr[2] = -8,632477
> kArr[3] = -6,041560
> kArr[4] = -0,505397
> kArr[5] = 5,786851
> kArr[6] = -0,396027
> kArr[7] = 3,980599
> kArr[8] = 1,934689
> kArr[9] = -3,681660
>
> kArr[0] = 3,203606
> kArr[1] = 3,203606
> kArr[2] = 3,203606
> kArr[3] = 3,203606
> kArr[4] = 3,203606
> kArr[5] = 3,203606
> kArr[6] = 3,203606
> kArr[7] = 3,203606
> kArr[8] = 3,203606
> kArr[9] = 3,203606
>
> complete example below and attached.
> best -
>
>         joachim
>
>
> 
> 
> -nm128
> 
> 
>
> instr 1 ;works in traditional syntax
> ;create array
> kArr[] init 10
>
> ;fill with random elements
> kIndx = 0
> until kIndx == lenarray(kArr) do
> kVal rnd31 10, 0
> kArr[kIndx] = kVal
> kIndx += 1
> od
>
> ;print out values
> kIndx = 0
> until kIndx == lenarray(kArr) do
> printf("kArr[%d] = %f\n", kIndx+1, kIndx, kArr[kIndx])
> kIndx += 1
> od
>
> turnoff
> endin
>
>
> instr 2 ;does not in functional syntax
> ;create array
> kArr[] init 10
> printks "\n", 0
>
> ;fill with random elements
> kIndx = 0
> until kIndx == lenarray(kArr) do
> kArr[kIndx] = rnd31(10, 0) ;this is the difference
> kIndx += 1
> od
>
> ;print out values
> kIndx = 0
> until kIndx == lenarray(kArr) do
> printf("kArr[%d] = %f\n", kIndx+1, kIndx, kArr[kIndx])
> kIndx += 1
> od
>
> turnoff
> endin
> 
> 
> i 1 0 .1
> i 2 0 .1
> 
> 
>
>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2013-07-14 19:39
Fromjpff@cs.bath.ac.uk
SubjectRe: [Cs-dev] issue with functional syntax in k-rate loop
I suspect rnd31(10, 0) is being evaluated at i-time and then being
promoted to k-rate on assignmemt.  Using -v opion would verify that.

In your non-functional case the k-rate answer determines the type

==John

> hi -
>
> when i use rnd31 in a k-rate loop, it gives a constant value in this
> loop, instead of being updated. so, this works:
>
> kIndx = 0
> until kIndx == lenarray(kArr) do
> kVal rnd31 10, 0
> kArr[kIndx] = kVal
> kIndx += 1
> od
>
> bit this does not:
> kIndx = 0
> until kIndx == lenarray(kArr) do
> kArr[kIndx] = rnd31(10, 0)
> kIndx += 1
> od
>
> as the output shows:
> kArr[0] = -4,374842
> kArr[1] = -7,973382
> kArr[2] = -8,632477
> kArr[3] = -6,041560
> kArr[4] = -0,505397
> kArr[5] = 5,786851
> kArr[6] = -0,396027
> kArr[7] = 3,980599
> kArr[8] = 1,934689
> kArr[9] = -3,681660
>
> kArr[0] = 3,203606
> kArr[1] = 3,203606
> kArr[2] = 3,203606
> kArr[3] = 3,203606
> kArr[4] = 3,203606
> kArr[5] = 3,203606
> kArr[6] = 3,203606
> kArr[7] = 3,203606
> kArr[8] = 3,203606
> kArr[9] = 3,203606
>
> complete example below and attached.
> best -
>
> 	joachim
>
>
> 
> 
> -nm128
> 
> 
>
> instr 1 ;works in traditional syntax
> ;create array
> kArr[] init 10
>
> ;fill with random elements
> kIndx = 0
> until kIndx == lenarray(kArr) do
> kVal rnd31 10, 0
> kArr[kIndx] = kVal
> kIndx += 1
> od
>
> ;print out values
> kIndx = 0
> until kIndx == lenarray(kArr) do
> printf("kArr[%d] = %f\n", kIndx+1, kIndx, kArr[kIndx])
> kIndx += 1
> od
>
> turnoff
> endin
>
>
> instr 2 ;does not in functional syntax
> ;create array
> kArr[] init 10
> printks "\n", 0
>
> ;fill with random elements
> kIndx = 0
> until kIndx == lenarray(kArr) do
> kArr[kIndx] = rnd31(10, 0) ;this is the difference
> kIndx += 1
> od
>
> ;print out values
> kIndx = 0
> until kIndx == lenarray(kArr) do
> printf("kArr[%d] = %f\n", kIndx+1, kIndx, kArr[kIndx])
> kIndx += 1
> od
>
> turnoff
> endin
> 
> 
> i 1 0 .1
> i 2 0 .1
> 
> 
>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk_______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>



------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2013-07-14 22:13
Fromjoachim heintz
SubjectRe: [Cs-dev] issue with functional syntax in k-rate loop
thanks, steven and john -

yes -- i wasn't aware of the i-time issue. both solutions:

kArr[kIndx] = rnd31:k(10, 0)

and:

kArr[kIndx] rnd31 10, 0

work without any problem. good ...

	j


Am 14.07.2013 20:39, schrieb Steven Yi:
> Hi Joachim,
>
> I think this is an issue where the i-type version of the opcode is
> being used by default.  Could you try using
>
> kArr[kIndx] = rnd31:k(10, 0)
>
> to type hint the function?  Also, this may work:
>
> kArr[kIndx]  rnd31 10, 0
>
> I actually get a crash with this test2.csd here.  I'm not sure if
> others get it too, or if it's because I'm in the middle of some other
> debugging.  Maybe someone else here could give it a try too.
>
> Thanks!
> steven
>
> On Sun, Jul 14, 2013 at 1:55 PM, joachim heintz  wrote:
>> hi -
>>
>> when i use rnd31 in a k-rate loop, it gives a constant value in this loop,
>> instead of being updated. so, this works:
>>
>> kIndx = 0
>> until kIndx == lenarray(kArr) do
>> kVal rnd31 10, 0
>> kArr[kIndx] = kVal
>> kIndx += 1
>> od
>>
>> bit this does not:
>> kIndx = 0
>> until kIndx == lenarray(kArr) do
>> kArr[kIndx] = rnd31(10, 0)
>> kIndx += 1
>> od
>>
>> as the output shows:
>> kArr[0] = -4,374842
>> kArr[1] = -7,973382
>> kArr[2] = -8,632477
>> kArr[3] = -6,041560
>> kArr[4] = -0,505397
>> kArr[5] = 5,786851
>> kArr[6] = -0,396027
>> kArr[7] = 3,980599
>> kArr[8] = 1,934689
>> kArr[9] = -3,681660
>>
>> kArr[0] = 3,203606
>> kArr[1] = 3,203606
>> kArr[2] = 3,203606
>> kArr[3] = 3,203606
>> kArr[4] = 3,203606
>> kArr[5] = 3,203606
>> kArr[6] = 3,203606
>> kArr[7] = 3,203606
>> kArr[8] = 3,203606
>> kArr[9] = 3,203606
>>
>> complete example below and attached.
>> best -
>>
>>          joachim
>>
>>
>> 
>> 
>> -nm128
>> 
>> 
>>
>> instr 1 ;works in traditional syntax
>> ;create array
>> kArr[] init 10
>>
>> ;fill with random elements
>> kIndx = 0
>> until kIndx == lenarray(kArr) do
>> kVal rnd31 10, 0
>> kArr[kIndx] = kVal
>> kIndx += 1
>> od
>>
>> ;print out values
>> kIndx = 0
>> until kIndx == lenarray(kArr) do
>> printf("kArr[%d] = %f\n", kIndx+1, kIndx, kArr[kIndx])
>> kIndx += 1
>> od
>>
>> turnoff
>> endin
>>
>>
>> instr 2 ;does not in functional syntax
>> ;create array
>> kArr[] init 10
>> printks "\n", 0
>>
>> ;fill with random elements
>> kIndx = 0
>> until kIndx == lenarray(kArr) do
>> kArr[kIndx] = rnd31(10, 0) ;this is the difference
>> kIndx += 1
>> od
>>
>> ;print out values
>> kIndx = 0
>> until kIndx == lenarray(kArr) do
>> printf("kArr[%d] = %f\n", kIndx+1, kIndx, kArr[kIndx])
>> kIndx += 1
>> od
>>
>> turnoff
>> endin
>> 
>> 
>> i 1 0 .1
>> i 2 0 .1
>> 
>> 
>>
>>
>>
>> ------------------------------------------------------------------------------
>> See everything from the browser to the database with AppDynamics
>> Get end-to-end visibility with application monitoring from AppDynamics
>> Isolate bottlenecks and diagnose root cause in seconds.
>> Start your free trial of AppDynamics Pro today!
>> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net