[Csnd] don't understand if-igoto
Date | 2010-07-20 17:55 |
From | joachim heintz |
Subject | [Csnd] don't understand if-igoto |
hi - i am trying to make an example for if-igoto. i test whether a file is mono or stereo, and call a certain label in the one and in the other case. but although my file is mono, i get an perf error saying "soundin not initialized". but this affects the "stereo" section, so i don't understand what happens. can anyone help? this is the .csd: |
Date | 2010-07-20 18:21 |
From | Peiman Khosravi |
Subject | [Csnd] Re: don't understand if-igoto |
I think the problem is that "igoto continue" should be "goto continue". Otherwise it is ignored and so the stereo block is initiated leading to the error (because your soundfile is mono). P On 20 Jul 2010, at 17:55, joachim heintz wrote: > hi - > > i am trying to make an example for if-igoto. > i test whether a file is mono or stereo, and call a certain label in > the one and in the other case. > but although my file is mono, i get an perf error saying "soundin > not initialized". > but this affects the "stereo" section, so i don't understand what > happens. > can anyone help? > > this is the .csd: > > |
Date | 2010-07-20 18:25 |
From | Peiman Khosravi |
Subject | [Csnd] Re: don't understand if-igoto |
Having said that I don't know why Csound is ignoring igoto. According to the manual If goto or then is used instead of kgoto or igoto, the behavior is determined by the type being compared. If the comparison used k-type variables, kgoto is used and viceversa. This suggests that in this case goto should be interpreted as igoto anyway because the type you are comparing is i-rate. I am sure there is a simple explanation? P On 20 Jul 2010, at 17:55, joachim heintz wrote:
|
Date | 2010-07-20 18:26 |
From | Steven Yi |
Subject | [Csnd] Re: don't understand if-igoto |
Hi Joachim, Using if's can be tricky due to rates. You're using specifically an igoto here, but it seems you want to use either a goto or a kgoto. If it's just igoto, that whole expression is only evaluated as an i-time if. That means at perf-time, it doesn't evaluate and drops through to the mono case that was skipped at i-time. I wrote some notes about this in this article: http://www.csounds.com/journal/2006spring/controlFlow.html " Notice the use of kgoto, as the code within each labelled group needs to operate at k-rate. Making sure rates match can be tricky and is dependent on the code within the code branches. As a general rule, you'll want to make sure that the code in the different labelled code branches run at the same rate, and that the type goto you use after the if(test) matches." Since you're dealing with a-rate opcodes in the code you are skipping over, you should match them with perf-time conditionals (kgoto, etc.). Hope that helps! steven On Tue, Jul 20, 2010 at 12:55 PM, joachim heintz |
Date | 2010-07-20 19:04 |
From | joachim heintz |
Subject | [Csnd] Re: Re: don't understand if-igoto |
peiman, steven - thanks for the quick replies. i understand now that i must use in this case both, the if-igoto and the if-kgoto statement. so the solution with the if-then-else statement is really much easier in this case. best - joachim Am 20.07.2010 um 19:26 schrieb Steven Yi: > Hi Joachim, > > Using if's can be tricky due to rates. You're using specifically an > igoto here, but it seems you want to use either a goto or a kgoto. If > it's just igoto, that whole expression is only evaluated as an i-time > if. That means at perf-time, it doesn't evaluate and drops through to > the mono case that was skipped at i-time. > > I wrote some notes about this in this article: > > http://www.csounds.com/journal/2006spring/controlFlow.html > > " Notice the use of kgoto, as the code within each labelled group > needs to operate at k-rate. Making sure rates match can be tricky and > is dependent on the code within the code branches. As a general rule, > you'll want to make sure that the code in the different labelled code > branches run at the same rate, and that the type goto you use after > the if(test) matches." > > Since you're dealing with a-rate opcodes in the code you are skipping > over, you should match them with perf-time conditionals (kgoto, etc.). > > Hope that helps! > steven > > On Tue, Jul 20, 2010 at 12:55 PM, joachim heintz > |