Csound Csound-dev Csound-tekno Search About

[Csnd] don't understand if-igoto

Date2010-07-20 17:55
Fromjoachim 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:





sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
instr 1
Sfile = "/Joachim/Materialien/SamplesKlangbearbeitung/Kontrabass.aif"
ifilchnls filenchnls Sfile
if ifilchnls == 1 igoto mono; condition if true
igoto stereo; else condition
mono:
aL soundin Sfile
aR = aL
igoto continue
stereo:
aL, aR soundin Sfile
continue:
outs aL, aR
endin


i 1 0 5



this is the output:

SECTION 1:
new alloc for instr 1:
soundin: opened '/Joachim/Materialien/SamplesKlangbearbeitung/ 
Kontrabass.aif':
44100 Hz, 1 channel(s), 202600 sample frames
PERF ERROR in instr 1: soundin: not initialised
aL	aR	soundin	Sfile	0	0	0	0
note aborted
B 0.000 .. 5.000 T 5.000 TT 5.000 M: 0.00000 0.00000
Score finished in csoundPerformKsmps().
inactive allocs returned to freespace
end of score.	 overall amps: 0.00000 0.00000
overall samples out of range: 0 0
1 errors in performance
Elapsed time at end of performance: real: 7.058s, CPU: 1.074s
216 4096-byte soundblks of shorts written to dac

thanks -

	joachim


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-07-20 18:21
FromPeiman 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:
>
> 
> 
> 
> 
> sr = 44100
> ksmps = 32
> nchnls = 2
> 0dbfs = 1
> instr 1
> Sfile = "/Joachim/Materialien/SamplesKlangbearbeitung/Kontrabass.aif"
> ifilchnls filenchnls Sfile
> if ifilchnls == 1 igoto mono; condition if true
> igoto stereo; else condition
> mono:
> aL soundin Sfile
> aR = aL
> igoto continue
> stereo:
> aL, aR soundin Sfile
> continue:
> outs aL, aR
> endin
> 
> 
> i 1 0 5
> 
> 
>
> this is the output:
>
> SECTION 1:
> new alloc for instr 1:
> soundin: opened '/Joachim/Materialien/SamplesKlangbearbeitung/ 
> Kontrabass.aif':
> 44100 Hz, 1 channel(s), 202600 sample frames
> PERF ERROR in instr 1: soundin: not initialised
> aL	aR	soundin	Sfile	0	0	0	0
> note aborted
> B 0.000 .. 5.000 T 5.000 TT 5.000 M: 0.00000 0.00000
> Score finished in csoundPerformKsmps().
> inactive allocs returned to freespace
> end of score.	 overall amps: 0.00000 0.00000
> overall samples out of range: 0 0
> 1 errors in performance
> Elapsed time at end of performance: real: 7.058s, CPU: 1.074s
> 216 4096-byte soundblks of shorts written to dac
>
> thanks -
>
> 	joachim
>
>
> 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"

Date2010-07-20 18:25
FromPeiman 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:

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:

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
instr 1
Sfile = "/Joachim/Materialien/SamplesKlangbearbeitung/Kontrabass.aif"
ifilchnls filenchnls Sfile
if ifilchnls == 1 igoto mono; condition if true
igoto stereo; else condition
mono:
aL soundin Sfile
aR = aL
igoto continue
stereo:
aL, aR soundin Sfile
continue:
outs aL, aR
endin
</CsInstruments>
<CsScore>
i 1 0 5
</CsScore>
</CsoundSynthesizer>

this is the output:

SECTION 1:
new alloc for instr 1:
soundin: opened '/Joachim/Materialien/SamplesKlangbearbeitung/Kontrabass.aif':
44100 Hz, 1 channel(s), 202600 sample frames
PERF ERROR in instr 1: soundin: not initialised
aL aR soundin Sfile 0 0 0 0
note aborted
B 0.000 .. 5.000 T 5.000 TT 5.000 M: 0.00000 0.00000
Score finished in csoundPerformKsmps().
inactive allocs returned to freespace
end of score. overall amps: 0.00000 0.00000
overall samples out of range: 0 0
1 errors in performance
Elapsed time at end of performance: real: 7.058s, CPU: 1.074s
216 4096-byte soundblks of shorts written to dac

thanks -

joachim


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-07-20 18:26
FromSteven 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  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:
>
> 
> 
> 
> 
> sr = 44100
> ksmps = 32
> nchnls = 2
> 0dbfs = 1
> instr 1
> Sfile = "/Joachim/Materialien/SamplesKlangbearbeitung/Kontrabass.aif"
> ifilchnls filenchnls Sfile
> if ifilchnls == 1 igoto mono; condition if true
> igoto stereo; else condition
> mono:
> aL soundin Sfile
> aR = aL
> igoto continue
> stereo:
> aL, aR soundin Sfile
> continue:
> outs aL, aR
> endin
> 
> 
> i 1 0 5
> 
> 
>
> this is the output:
>
> SECTION 1:
> new alloc for instr 1:
> soundin: opened
> '/Joachim/Materialien/SamplesKlangbearbeitung/Kontrabass.aif':
> 44100 Hz, 1 channel(s), 202600 sample frames
> PERF ERROR in instr 1: soundin: not initialised
> aL      aR      soundin Sfile   0       0       0       0
> note aborted
> B 0.000 .. 5.000 T 5.000 TT 5.000 M: 0.00000 0.00000
> Score finished in csoundPerformKsmps().
> inactive allocs returned to freespace
> end of score.    overall amps: 0.00000 0.00000
> overall samples out of range: 0 0
> 1 errors in performance
> Elapsed time at end of performance: real: 7.058s, CPU: 1.074s
> 216 4096-byte soundblks of shorts written to dac
>
> thanks -
>
>        joachim
>
>
> 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"


Date2010-07-20 19:04
Fromjoachim 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  
>  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:
>>
>> 
>> 
>> 
>> 
>> sr = 44100
>> ksmps = 32
>> nchnls = 2
>> 0dbfs = 1
>> instr 1
>> Sfile = "/Joachim/Materialien/SamplesKlangbearbeitung/Kontrabass.aif"
>> ifilchnls filenchnls Sfile
>> if ifilchnls == 1 igoto mono; condition if true
>> igoto stereo; else condition
>> mono:
>> aL soundin Sfile
>> aR = aL
>> igoto continue
>> stereo:
>> aL, aR soundin Sfile
>> continue:
>> outs aL, aR
>> endin
>> 
>> 
>> i 1 0 5
>> 
>> 
>>
>> this is the output:
>>
>> SECTION 1:
>> new alloc for instr 1:
>> soundin: opened
>> '/Joachim/Materialien/SamplesKlangbearbeitung/Kontrabass.aif':
>> 44100 Hz, 1 channel(s), 202600 sample frames
>> PERF ERROR in instr 1: soundin: not initialised
>> aL      aR      soundin Sfile   0       0       0       0
>> note aborted
>> B 0.000 .. 5.000 T 5.000 TT 5.000 M: 0.00000 0.00000
>> Score finished in csoundPerformKsmps().
>> inactive allocs returned to freespace
>> end of score.    overall amps: 0.00000 0.00000
>> overall samples out of range: 0 0
>> 1 errors in performance
>> Elapsed time at end of performance: real: 7.058s, CPU: 1.074s
>> 216 4096-byte soundblks of shorts written to dac
>>
>> thanks -
>>
>>        joachim
>>
>>
>> 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"
>
>



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"