[Cs-dev] Csound 6 Issues
Date | 2013-04-13 16:24 |
From | Jacob Joaquin |
Subject | [Cs-dev] Csound 6 Issues |
Attachments | None None |
Hey Devs,
I started rendering my personal backlog of Csound files with C6 and plan to post anything that isn't working as expected. I've spent a lot of time poking and prodding Csound and have collected a sizable library of tests, so hopefully this will be of some use.
I found issue with this script, Sine Waves of Hanoi: It plays back properly in C5, but not C6. The timing of the events sounds like it's quantized funny. Best, jake |
Date | 2013-04-13 23:45 |
From | Steven Yi |
Subject | Re: [Cs-dev] Csound 6 Issues |
Hi Jake, I took a look and reproduced the odd timing results. The printouts show different results: Move plate 1 from 1 to 3 at 0.100000 Move plate 2 from 1 to 2 at 0.200000 Move plate 1 from 3 to 2 at 0.300000 Move plate 3 from 1 to 3 at 0.400000 Move plate 1 from 2 to 1 at 0.500000 Move plate 2 from 2 to 3 at 0.600000 Move plate 1 from 1 to 3 at 0.700000 Move plate 4 from 1 to 2 at 0.800000 Move plate 1 from 3 to 2 at 0.900000 Move plate 2 from 3 to 1 at 1.000000 which is expected as the $DURATION is set to .1. With CS6 though, the output shows: Move plate 0 from 1 to 2 at 0.000000 Move plate 1 from 1 to 3 at 0.100000 Move plate 0 from 2 to 3 at 0.100000 Move plate 2 from 1 to 2 at 0.300000 Move plate 0 from 3 to 1 at 0.300000 Move plate 1 from 3 to 2 at 0.400000 Move plate 0 from 1 to 2 at 0.400000 Move plate 3 from 1 to 3 at 0.700000 Move plate 0 from 2 to 3 at 0.700000 Move plate 1 from 2 to 1 at 0.800000 Move plate 0 from 3 to 1 at 0.800000 which has a plate 0 moving in between each of the ones that would show up in CS5's output. With the UDO code, that printf with plate 0 should never happen, as the if block explicitly checks for i_n != 0 before going into the block with printf. I took a look at the output from using "--verbose -I" and that lead to me fix a couple of other bugs, but I'm still not sure what is going on with this bug. I'm a bit stumped at this point, but I get the bad suspicion some memory is getting shared with the recursive UDO calls, but it's just a hunch. Perhaps others might see what the problem is. Thanks, steven On Sat, Apr 13, 2013 at 4:24 PM, Jacob Joaquin |
Date | 2013-04-14 00:07 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Csound 6 Issues |
I am looking at this too, but could this issue be to do with rates and how if-then-else deals with it? I noticed that if I put a print i_n after the if i_n == 0, I never get a i_n = 0, which is to be expected. The thing is, event is k-rate and so is printf, so I am wondering whether there is confusion going on there. Victor On 13 Apr 2013, at 23:45, Steven Yi wrote: > Hi Jake, > > I took a look and reproduced the odd timing results. The printouts > show different results: > > Move plate 1 from 1 to 3 at 0.100000 > Move plate 2 from 1 to 2 at 0.200000 > Move plate 1 from 3 to 2 at 0.300000 > Move plate 3 from 1 to 3 at 0.400000 > Move plate 1 from 2 to 1 at 0.500000 > Move plate 2 from 2 to 3 at 0.600000 > Move plate 1 from 1 to 3 at 0.700000 > Move plate 4 from 1 to 2 at 0.800000 > Move plate 1 from 3 to 2 at 0.900000 > Move plate 2 from 3 to 1 at 1.000000 > > which is expected as the $DURATION is set to .1. With CS6 though, the > output shows: > > Move plate 0 from 1 to 2 at 0.000000 > Move plate 1 from 1 to 3 at 0.100000 > Move plate 0 from 2 to 3 at 0.100000 > Move plate 2 from 1 to 2 at 0.300000 > Move plate 0 from 3 to 1 at 0.300000 > Move plate 1 from 3 to 2 at 0.400000 > Move plate 0 from 1 to 2 at 0.400000 > Move plate 3 from 1 to 3 at 0.700000 > Move plate 0 from 2 to 3 at 0.700000 > Move plate 1 from 2 to 1 at 0.800000 > Move plate 0 from 3 to 1 at 0.800000 > > which has a plate 0 moving in between each of the ones that would show > up in CS5's output. With the UDO code, that printf with plate 0 should > never happen, as the if block explicitly checks for i_n != 0 before > going into the block with printf. > > I took a look at the output from using "--verbose -I" and that lead to > me fix a couple of other bugs, but I'm still not sure what is going on > with this bug. I'm a bit stumped at this point, but I get the bad > suspicion some memory is getting shared with the recursive UDO calls, > but it's just a hunch. Perhaps others might see what the problem is. > > Thanks, > steven > > On Sat, Apr 13, 2013 at 4:24 PM, Jacob Joaquin |
Date | 2013-04-14 00:12 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Csound 6 Issues |
In fact, when we make printf printf_i, the printout inconsistencies disappear. I am sure this is a rate thing. I am wondering if this orc exploited some bug in the original code that has now been put right. On 14 Apr 2013, at 00:07, Victor Lazzarini wrote: > I am looking at this too, but could this issue be to do with rates and how if-then-else deals with it? I noticed that if I put > a print i_n after the if i_n == 0, I never get a i_n = 0, which is to be expected. The thing is, event is k-rate and so is printf, so I am wondering whether > there is confusion going on there. > > Victor > On 13 Apr 2013, at 23:45, Steven Yi wrote: > >> Hi Jake, >> >> I took a look and reproduced the odd timing results. The printouts >> show different results: >> >> Move plate 1 from 1 to 3 at 0.100000 >> Move plate 2 from 1 to 2 at 0.200000 >> Move plate 1 from 3 to 2 at 0.300000 >> Move plate 3 from 1 to 3 at 0.400000 >> Move plate 1 from 2 to 1 at 0.500000 >> Move plate 2 from 2 to 3 at 0.600000 >> Move plate 1 from 1 to 3 at 0.700000 >> Move plate 4 from 1 to 2 at 0.800000 >> Move plate 1 from 3 to 2 at 0.900000 >> Move plate 2 from 3 to 1 at 1.000000 >> >> which is expected as the $DURATION is set to .1. With CS6 though, the >> output shows: >> >> Move plate 0 from 1 to 2 at 0.000000 >> Move plate 1 from 1 to 3 at 0.100000 >> Move plate 0 from 2 to 3 at 0.100000 >> Move plate 2 from 1 to 2 at 0.300000 >> Move plate 0 from 3 to 1 at 0.300000 >> Move plate 1 from 3 to 2 at 0.400000 >> Move plate 0 from 1 to 2 at 0.400000 >> Move plate 3 from 1 to 3 at 0.700000 >> Move plate 0 from 2 to 3 at 0.700000 >> Move plate 1 from 2 to 1 at 0.800000 >> Move plate 0 from 3 to 1 at 0.800000 >> >> which has a plate 0 moving in between each of the ones that would show >> up in CS5's output. With the UDO code, that printf with plate 0 should >> never happen, as the if block explicitly checks for i_n != 0 before >> going into the block with printf. >> >> I took a look at the output from using "--verbose -I" and that lead to >> me fix a couple of other bugs, but I'm still not sure what is going on >> with this bug. I'm a bit stumped at this point, but I get the bad >> suspicion some memory is getting shared with the recursive UDO calls, >> but it's just a hunch. Perhaps others might see what the problem is. >> >> Thanks, >> steven >> >> On Sat, Apr 13, 2013 at 4:24 PM, Jacob Joaquin |
Date | 2013-04-14 00:19 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Csound 6 Issues |
I am pretty sure it is to do with rates. If I add a printk2 to the 'else' block: opcode Hanoi, i, iiii i_n, ia, ic, ib xin if i_n != 0 then ifoo Hanoi i_n - 1, ia, ib, ic event "i", $Sine, gk_c, 1, i_n, ia, ic printf "Move plate %i from %i to %i at %f\n", 1, i_n, ia, ic, gk_c ifoo Hanoi i_n - 1, ib, ic, ia else printk2 gk_c gk_c = gk_c + $DURATION endif xout 1 endop I get this printout on csound 5: new alloc for instr 1: i1 0.00000 Move plate 1 from 1 to 3 at 0.100000 i1 0.10000 Move plate 2 from 1 to 2 at 0.200000 i1 0.20000 Move plate 1 from 3 to 2 at 0.300000 i1 0.30000 Move plate 3 from 1 to 3 at 0.400000 i1 0.40000 Move plate 1 from 2 to 1 at 0.500000 i1 0.50000 Move plate 2 from 2 to 3 at 0.600000 i1 0.60000 Move plate 1 from 1 to 3 at 0.700000 i1 0.70000 Move plate 4 from 1 to 2 at 0.800000 i1 0.80000 Move plate 1 from 3 to 2 at 0.900000 i1 0.90000 and this one on csound 6: new alloc for instr 1: Move plate 0 from 1 to 2 at 0.000000 i1 0.00000 Move plate 1 from 1 to 3 at 0.100000 Move plate 0 from 2 to 3 at 0.100000 i1 0.10000 i1 0.20000 Move plate 2 from 1 to 2 at 0.300000 Move plate 0 from 3 to 1 at 0.300000 i1 0.30000 Move plate 1 from 3 to 2 at 0.400000 Move plate 0 from 1 to 2 at 0.400000 i1 0.40000 i1 0.50000 i1 0.60000 Move plate 3 from 1 to 3 at 0.700000 Move plate 0 from 2 to 3 at 0.700000 i1 0.70000 Move plate 1 from 2 to 1 at 0.800000 Move plate 0 from 3 to 1 at 0.800000 i1 0.80000 i1 0.90000 Move plate 2 from 2 to 3 at 1.000000 On 14 Apr 2013, at 00:12, Victor Lazzarini wrote: > In fact, when we make printf printf_i, the printout inconsistencies disappear. I am sure this is a rate thing. I am wondering if this orc exploited some bug in the original code that has now been put right. > On 14 Apr 2013, at 00:07, Victor Lazzarini wrote: > >> I am looking at this too, but could this issue be to do with rates and how if-then-else deals with it? I noticed that if I put >> a print i_n after the if i_n == 0, I never get a i_n = 0, which is to be expected. The thing is, event is k-rate and so is printf, so I am wondering whether >> there is confusion going on there. >> >> Victor >> On 13 Apr 2013, at 23:45, Steven Yi wrote: >> >>> Hi Jake, >>> >>> I took a look and reproduced the odd timing results. The printouts >>> show different results: >>> >>> Move plate 1 from 1 to 3 at 0.100000 >>> Move plate 2 from 1 to 2 at 0.200000 >>> Move plate 1 from 3 to 2 at 0.300000 >>> Move plate 3 from 1 to 3 at 0.400000 >>> Move plate 1 from 2 to 1 at 0.500000 >>> Move plate 2 from 2 to 3 at 0.600000 >>> Move plate 1 from 1 to 3 at 0.700000 >>> Move plate 4 from 1 to 2 at 0.800000 >>> Move plate 1 from 3 to 2 at 0.900000 >>> Move plate 2 from 3 to 1 at 1.000000 >>> >>> which is expected as the $DURATION is set to .1. With CS6 though, the >>> output shows: >>> >>> Move plate 0 from 1 to 2 at 0.000000 >>> Move plate 1 from 1 to 3 at 0.100000 >>> Move plate 0 from 2 to 3 at 0.100000 >>> Move plate 2 from 1 to 2 at 0.300000 >>> Move plate 0 from 3 to 1 at 0.300000 >>> Move plate 1 from 3 to 2 at 0.400000 >>> Move plate 0 from 1 to 2 at 0.400000 >>> Move plate 3 from 1 to 3 at 0.700000 >>> Move plate 0 from 2 to 3 at 0.700000 >>> Move plate 1 from 2 to 1 at 0.800000 >>> Move plate 0 from 3 to 1 at 0.800000 >>> >>> which has a plate 0 moving in between each of the ones that would show >>> up in CS5's output. With the UDO code, that printf with plate 0 should >>> never happen, as the if block explicitly checks for i_n != 0 before >>> going into the block with printf. >>> >>> I took a look at the output from using "--verbose -I" and that lead to >>> me fix a couple of other bugs, but I'm still not sure what is going on >>> with this bug. I'm a bit stumped at this point, but I get the bad >>> suspicion some memory is getting shared with the recursive UDO calls, >>> but it's just a hunch. Perhaps others might see what the problem is. >>> >>> Thanks, >>> steven >>> >>> On Sat, Apr 13, 2013 at 4:24 PM, Jacob Joaquin |
Date | 2013-04-14 01:26 |
From | Victor Lazzarini |
Subject | [Cs-dev] if-else issue (was Re: Csound 6 Issues) |
Attachments | None None |
I think I got to the bottom of this now. The issue seems to boil down to this: if-else code like this instr 1 i1 = 0 if i1 == 0 then print i1 else print i1+1 endif endin in csound5: new alloc for instr 1: instr 1: i1 = 0.000 B 0.000 .. 1.000 T 1.000 TT 1.000 M: 0.0 0.0 in csound6: new alloc for instr 1: instr 1: i1 = 0.000 instr 1: #i0 = 1.000 B 0.000 .. 1.000 T 1.000 TT 1.000 M: 0.0 0.0 There is a fall-through that is not there in Csound 5. I modified the hanoi UDO to use init-time code only (event_i and printf_i), but the code still did not work as in Csound 5. So I looked closer and found this difference. Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-04-14 09:21 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] if-else issue (was Re: Csound 6 Issues) |
Attachments | None None |
Maybe this explains it: <treenext type="278" name="T_OPCODE" opname="kgoto" loc="0:0"> Isn't that the wrong opcode? Victor On 14 Apr 2013, at 01:26, Victor Lazzarini wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-04-14 10:18 |
From | Steven Yi |
Subject | Re: [Cs-dev] if-else issue (was Re: Csound 6 Issues) |
Hi Victor, I think you may have not pulled from GIT before testing as I had pushed a fix last night for the goto token to get the correct rate (goto vs. kgoto). I still get the wrong timing here after that fix. Just woke up here but am looking at it now (I'll be on IRC if you want to discuss). Thanks! steven On Sun, Apr 14, 2013 at 9:21 AM, Victor Lazzarini |
Date | 2013-04-14 10:40 |
From | Steven Yi |
Subject | Re: [Cs-dev] if-else issue (was Re: Csound 6 Issues) |
Just some more analysis, the output from cs5 and cs6 witih --verbose is listed below. There's a difference in output between the two in terms of how it's reported, but you can compare to see that the opcodes that are found and used are the same. CS5: =.r argndxs: 13 2 =.r argndxs: 14 2 =.r argndxs: 15 3 =.r argndxs: 16 4 =.r argndxs: 18 3 init.k argndxs: 22 1 xin argndxs: -4 -5 -6 -7 != argndxs: -8 -4 1 cngoto argndxs: -8 ***lbl sub.ii argndxs: -9 -4 3 Hanoi argndxs: -10 -9 -5 -7 -6 1 event argndxs: 2013265922 4 22 3 -4 -5 -6 printf argndxs: 2013265923 3 -4 -5 -6 22 sub.ii argndxs: -11 -4 3 Hanoi argndxs: -10 -11 -7 -6 -5 1 goto argndxs: ***lbl add.kk argndxs: 22 22 5 xout argndxs: 3 =.i argndxs: -5 -4 Hanoi argndxs: -6 -5 3 4 6 1 turnoff argndxs: =.i argndxs: -3 5 =.i argndxs: -7 -3 =.i argndxs: -8 -4 sub.ii argndxs: -9 -5 3 div.ii argndxs: -10 -9 4 sub.ii argndxs: -11 -6 3 div.ii argndxs: -12 -11 4 sub.ii argndxs: -13 -7 7 linseg argndxs: -16 1 8 3 -13 3 8 1 mul.ka argndxs: -17 9 -16 sub.ii argndxs: -14 10 -8 mul.ii argndxs: -15 11 -14 oscil.ak argndxs: -18 -17 -15 3 12 line argndxs: -19 -10 -7 -12 sqrt.a argndxs: -20 -19 mul.aa argndxs: -21 -18 -20 sub.ka argndxs: -22 3 -19 sqrt.a argndxs: -23 -22 mul.aa argndxs: -24 -18 -23 outs argndxs: -21 -24 CS6: =.r args: sr 44100 =.r args: kr 44100 =.r args: ksmps 1 =.r args: nchnls 2 =.r args: 0dbfs 1 init.k args: gk_c 0 xin args: i_n ia ic ib != args: #b0 i_n 0 cngoto args: #b0 __synthetic_301: ##sub.ii args: #i0 i_n 1 Hanoi args: ifoo #i0 ia ib ic 0 event args: "i" 2 gk_c 1 i_n ia ic printf args: "Move plate %i from %i to %i at %f\n" 1 i_n ia ic gk_c ##sub.ii args: #i1 i_n 1 Hanoi args: ifoo #i1 ib ic ia 0 goto args: __synthetic_300: ##add.kk args: #k0 gk_c 0.1 =.k args: gk_c #k0 xout args: 1 =.i args: idiscs p4 Hanoi args: ifoo idiscs 1 2 3 0 turnoff args: =.i args: p3 0.1 =.i args: idur p3 =.i args: i_n p4 ##sub.ii args: #i2 p5 1 ##div.ii args: #i3 #i2 2 =.i args: ia #i3 ##sub.ii args: #i4 p6 1 ##div.ii args: #i5 #i4 2 =.i args: ic #i5 ##sub.ii args: #i6 idur 0.02 linseg args: aenv 0 0.01 1 #i6 1 0.01 0 ##mul.ka args: #a0 0.707 aenv ##sub.ii args: #i7 10 i_n ##mul.ii args: #i8 440 #i7 ##mul.ii args: #i9 -1 1 oscil.ak args: a1 #a0 #i8 1 #i9 line args: a2 ia idur ic sqrt.a args: #a1 a2 ##mul.aa args: #a2 a1 #a1 ##sub.ka args: #a3 1 a2 sqrt.a args: #a4 #a3 ##mul.aa args: #a5 a1 #a4 outs args: #a2 #a5 On Sun, Apr 14, 2013 at 10:18 AM, Steven Yi |
Date | 2013-04-14 11:08 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] if-else issue (was Re: Csound 6 Issues) |
OK, with your fixes, this code below works in the same way in Csound 5 and Csound 6, as I would expect. The original code, with its mixed rates is harder to debug, but I think it is nothing to do with memory issues in recursive UDOs, but to do the the control-of-flow behaviour (which is different). Sine Waves of Hanoi Jacob Joaquin June 3, 2010 jacobjoaquin@gmail.com csoundblog.com |
Date | 2013-04-14 14:52 |
From | Steven Yi |
Subject | Re: [Cs-dev] Csound 6 Issues |
Hi Jake and All, I was on IRC with John and Victor a while and we all worked through this bug. We determined the root cause having to do with a change with how the performance functions are iterated through. It caused a bug in the case of recursive UDO's and how goto's would change the next function to call. It was also the root cause of recursive UDO's recursing one extra time, that was patched around previously. The Hanoi Test now works. It is likely that other projects using recursive UDO's might have had issues too, which should all be fixed up now. Thanks! steven On Sun, Apr 14, 2013 at 12:19 AM, Victor Lazzarini |
Date | 2013-04-14 16:15 |
From | Jacob Joaquin |
Subject | Re: [Cs-dev] Csound 6 Issues |
Attachments | None None |
Thanks everyone for looking into and fixing this issue. I have at least a couple other recursive UDO examples I'll test before and after I rebuild C6 when I get a chance. On Sun, Apr 14, 2013 at 6:52 AM, Steven Yi <stevenyi@gmail.com> wrote: Hi Jake and All, codehop.com | #code #art #music |