Csound Csound-dev Csound-tekno Search About

[Csnd] what's wrong with looping?

Date2011-05-23 15:03
FromMatti Koskinen
Subject[Csnd] what's wrong with looping?
this simply doesn't work, nor it prints anything. Tried osx 5.13 and win 5.13

sr = 44100
kr = 44100
ksmps = 1
nchnls = 2

gi1 ftgen 0, 0, 8192, 10, 1
gktrigamp init 0.1
gkbin init 2
gkupbin init 250
gktimeout init 0.5
gklowbin init 2
gkamp init 2
gktimenow init 0
gigrainlen init 0.5
gimaxosc init 400
	instr 1 
ifftsize = 1024 
iwtype = 1	/* cleaner with hanning window */
kbins = ifftsize/2
zakinit 1,ifftsize
loop0:
a1 soundin "hi.aiff" ;select a soundifle 
;a1 inch 1	;Use realtime input

fsig pvsanal	a1, ifftsize, ifftsize/4, ifftsize, iwtype 

kzakpt = 0
knumbins = 0
loop1:
	kamp, kfr pvsbin	fsig, gkbin
	printks "bin ",0,kamp,kfr
	zkw kamp,kzakpt
	kzakpt = kzakpt+1
	zkw kfr,kzakpt
	kzakpt = kzakpt +1
	gkbin =gkbin+1
	knumbins = knumbins+1
	printk 0,kzakpt
cggoto (gkbin= knumbins),reint
ktr = 0
if ka > gktrigamp then
   ktr = 1
else
   ktr = 0
endif
schedkwhen    ktr, 0, gimaxosc, 2, 0, gigrainlen, gkamp*ka, kf
goto loop2a
reint:
	ktim timeinsts
	kdif = ktim-ktimnow
	printk 0,kdif
cggoto (kdif

Date2011-05-23 15:25
FromSteven Yi
SubjectRe: [Csnd] what's wrong with looping?
Hi Matti,

It looks like you have an infinite loop the performace of instr 1, as
you end the instrument with "goto loop0", which will always go back to
the beginning of the instrument. Looks like to me that once csound
goes to performance instr 1, it won't ever get out of performing it.
This may account for the not-seeing the printing, though it may have
to do with the implementation of the printXXX opcodes you are using.
Regardless, the goto loop0 looks like an error to me.

steven

On Mon, May 23, 2011 at 7:03 AM, Matti Koskinen  wrote:
> this simply doesn't work, nor it prints anything. Tried osx 5.13 and win 5.13
>
> sr = 44100
> kr = 44100
> ksmps = 1
> nchnls = 2
>
> gi1 ftgen 0, 0, 8192, 10, 1
> gktrigamp init 0.1
> gkbin init 2
> gkupbin init 250
> gktimeout init 0.5
> gklowbin init 2
> gkamp init 2
> gktimenow init 0
> gigrainlen init 0.5
> gimaxosc init 400
>        instr 1
> ifftsize = 1024
> iwtype = 1      /* cleaner with hanning window */
> kbins = ifftsize/2
> zakinit 1,ifftsize
> loop0:
> a1 soundin "hi.aiff" ;select a soundifle
> ;a1 inch 1      ;Use realtime input
>
> fsig pvsanal    a1, ifftsize, ifftsize/4, ifftsize, iwtype
>
> kzakpt = 0
> knumbins = 0
> loop1:
>        kamp, kfr pvsbin        fsig, gkbin
>        printks "bin ",0,kamp,kfr
>        zkw kamp,kzakpt
>        kzakpt = kzakpt+1
>        zkw kfr,kzakpt
>        kzakpt = kzakpt +1
>        gkbin =gkbin+1
>        knumbins = knumbins+1
>        printk 0,kzakpt
> cggoto (gkbin kzakpt = 0
>
> ktimnow timeinsts
> printf "loop1 finished %f\n",0,ktimnow
> loop2:
>        kzakpt = 0
> loop2a:
>        ka zkr kzakpt
>        kzakpt = kzakpt+1
>        kf zkr kzakpt
>        kzakpt = kzakpt +1
> cggoto (kzakpt >= knumbins),reint
> ktr = 0
> if ka > gktrigamp then
>   ktr = 1
> else
>   ktr = 0
> endif
> schedkwhen    ktr, 0, gimaxosc, 2, 0, gigrainlen, gkamp*ka, kf
> goto loop2a
> reint:
>        ktim timeinsts
>        kdif = ktim-ktimnow
>        printk 0,kdif
> cggoto (kdif goto loop0
> endin
>
> instr 2
>        kenv linseg 0, p3/3, 1, p3/3, 1, p3/3, 0
>        print p2, p3, p4, p5
>        a1 oscil p4, p5, gi1
>        outs a1*kenv, a1*kenv
> endin
>
> sco:
>
> i1 0 30
> e
>
> without looping and not using zak this worked, but not in the way i'd like it
> the global inits are because i made this in osx cecilia 2.5 using csound5.13
> thanks
>
> -matti
>
>
>
> 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"


Date2011-05-23 15:30
FromVictor Lazzarini
SubjectRe: [Csnd] what's wrong with looping?
Notice that printk only prints once per k-cycle (at max). Try printk2  
to print every time the k-var changes.
As for the other things not working, maybe you need to simplify your  
code to see what is going on. Loops
do work, as you can try this:

knumbins init 0
loop1:
knumbins = knumbins+1
printk2 knumbins
if knumbins<10 kgoto loop1

Regards

Victor

On 23 May 2011, at 15:03, Matti Koskinen wrote:

> this simply doesn't work, nor it prints anything. Tried osx 5.13 and  
> win 5.13
>
> sr = 44100
> kr = 44100
> ksmps = 1
> nchnls = 2
>
> gi1 ftgen 0, 0, 8192, 10, 1
> gktrigamp init 0.1
> gkbin init 2
> gkupbin init 250
> gktimeout init 0.5
> gklowbin init 2
> gkamp init 2
> gktimenow init 0
> gigrainlen init 0.5
> gimaxosc init 400
> 	instr 1
> ifftsize = 1024
> iwtype = 1	/* cleaner with hanning window */
> kbins = ifftsize/2
> zakinit 1,ifftsize
> loop0:
> a1 soundin "hi.aiff" ;select a soundifle
> ;a1 inch 1	;Use realtime input
>
> fsig pvsanal	a1, ifftsize, ifftsize/4, ifftsize, iwtype
>
> kzakpt = 0
> knumbins = 0
> loop1:
> 	kamp, kfr pvsbin	fsig, gkbin
> 	printks "bin ",0,kamp,kfr
> 	zkw kamp,kzakpt
> 	kzakpt = kzakpt+1
> 	zkw kfr,kzakpt
> 	kzakpt = kzakpt +1
> 	gkbin =gkbin+1
> 	knumbins = knumbins+1
> 	printk 0,kzakpt
> cggoto (gkbin kzakpt = 0
>
> ktimnow timeinsts
> printf "loop1 finished %f\n",0,ktimnow
> loop2:
> 	kzakpt = 0
> loop2a:
> 	ka zkr kzakpt
> 	kzakpt = kzakpt+1
> 	kf zkr kzakpt
> 	kzakpt = kzakpt +1
> cggoto (kzakpt >= knumbins),reint
> ktr = 0
> if ka > gktrigamp then
>   ktr = 1
> else
>   ktr = 0
> endif
> schedkwhen    ktr, 0, gimaxosc, 2, 0, gigrainlen, gkamp*ka, kf
> goto loop2a
> reint:
> 	ktim timeinsts
> 	kdif = ktim-ktimnow
> 	printk 0,kdif
> cggoto (kdif goto loop0
> endin
> 	
> instr 2
> 	kenv linseg 0, p3/3, 1, p3/3, 1, p3/3, 0
> 	print p2, p3, p4, p5	
> 	a1 oscil p4, p5, gi1
> 	outs a1*kenv, a1*kenv
> endin
>
> sco:
>
> i1 0 30
> e
>
> without looping and not using zak this worked, but not in the way  
> i'd like it
> the global inits are because i made this in osx cecilia 2.5 using  
> csound5.13
> thanks
>
> -matti
>
>
>
> 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"
>

Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie





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"

Date2011-05-23 16:15
FromMatti Koskinen
SubjectRe: [Csnd] what's wrong with looping?

On May 23, 2011, at 5:30 PM, Victor Lazzarini wrote:

this simply doesn't work, nor it prints anything. Tried osx 5.13 and win 5.13

sr = 44100
kr = 44100
ksmps = 1
nchnls = 2

gi1 ftgen 0, 0, 8192, 10, 1
gktrigamp init 0.1
gkbin init 2
gkupbin init 250
gktimeout init 0.5
gklowbin init 2
gkamp init 2
gktimenow init 0
gigrainlen init 0.5
gimaxosc init 400
instr 1
ifftsize = 1024
iwtype = 1 /* cleaner with hanning window */
kbins = ifftsize/2
zakinit 1,ifftsize
loop0:
a1 soundin "hi.aiff" ;select a soundifle
;a1 inch 1 ;Use realtime input

fsig pvsanal a1, ifftsize, ifftsize/4, ifftsize, iwtype

kzakpt = 0
knumbins = 0
loop1:
kamp, kfr pvsbin fsig, gkbin
printks "bin ",0,kamp,kfr
zkw kamp,kzakpt
kzakpt = kzakpt+1
zkw kfr,kzakpt
kzakpt = kzakpt +1
gkbin =gkbin+1
knumbins = knumbins+1
printk 0,kzakpt
cggoto (gkbin<gkupbin),loop1 ; tried if .. kgoto
kzakpt = 0

ktimnow timeinsts
printf "loop1 finished %f\n",0,ktimnow
loop2:
kzakpt = 0
loop2a:
ka zkr kzakpt
kzakpt = kzakpt+1
kf zkr kzakpt
kzakpt = kzakpt +1
cggoto (kzakpt >= knumbins),reint
ktr = 0
if ka > gktrigamp then
 ktr = 1
else
 ktr = 0
endif
schedkwhen    ktr, 0, gimaxosc, 2, 0, gigrainlen, gkamp*ka, kf
goto loop2a
this part went to infinte loop, tried timout ..reinit ..rireturn, but that didn't work as well. Idea was to wait for a defined time, is there any suspend, sleep   or wait opcode?
reint:
ktim timeinsts
kdif = ktim-ktimnow
printk 0,kdif
cggoto (kdif<gktimeout),reint

this was wrong as well. I thought of it being wrong and tried without it, but as the the waiting part didn't work, it was left as it was.
goto loop0
endin

thanks guys, now it works better, still needs some tuning. pvsbin returns in some cases negative frequency?

-matti

Date2011-05-23 16:20
FromVictor Lazzarini
SubjectRe: [Csnd] what's wrong with looping?
which bins return negative frequency?

On 23 May 2011, at 16:15, Matti Koskinen wrote:


On May 23, 2011, at 5:30 PM, Victor Lazzarini wrote:

this simply doesn't work, nor it prints anything. Tried osx 5.13 and win 5.13

sr = 44100
kr = 44100
ksmps = 1
nchnls = 2

gi1 ftgen 0, 0, 8192, 10, 1
gktrigamp init 0.1
gkbin init 2
gkupbin init 250
gktimeout init 0.5
gklowbin init 2
gkamp init 2
gktimenow init 0
gigrainlen init 0.5
gimaxosc init 400
instr 1
ifftsize = 1024
iwtype = 1 /* cleaner with hanning window */
kbins = ifftsize/2
zakinit 1,ifftsize
loop0:
a1 soundin "hi.aiff" ;select a soundifle
;a1 inch 1 ;Use realtime input

fsig pvsanal a1, ifftsize, ifftsize/4, ifftsize, iwtype

kzakpt = 0
knumbins = 0
loop1:
kamp, kfr pvsbin fsig, gkbin
printks "bin ",0,kamp,kfr
zkw kamp,kzakpt
kzakpt = kzakpt+1
zkw kfr,kzakpt
kzakpt = kzakpt +1
gkbin =gkbin+1
knumbins = knumbins+1
printk 0,kzakpt
cggoto (gkbin<gkupbin),loop1 ; tried if .. kgoto
kzakpt = 0

ktimnow timeinsts
printf "loop1 finished %f\n",0,ktimnow
loop2:
kzakpt = 0
loop2a:
ka zkr kzakpt
kzakpt = kzakpt+1
kf zkr kzakpt
kzakpt = kzakpt +1
cggoto (kzakpt >= knumbins),reint
ktr = 0
if ka > gktrigamp then
 ktr = 1
else
 ktr = 0
endif
schedkwhen    ktr, 0, gimaxosc, 2, 0, gigrainlen, gkamp*ka, kf
goto loop2a
this part went to infinte loop, tried timout ..reinit ..rireturn, but that didn't work as well. Idea was to wait for a defined time, is there any suspend, sleep   or wait opcode?
reint:
ktim timeinsts
kdif = ktim-ktimnow
printk 0,kdif
cggoto (kdif<gktimeout),reint

this was wrong as well. I thought of it being wrong and tried without it, but as the the waiting part didn't work, it was left as it was.
goto loop0
endin

thanks guys, now it works better, still needs some tuning. pvsbin returns in some cases negative frequency?

-matti

Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie




Date2011-05-23 16:44
FromMatti Koskinen
SubjectRe: [Csnd] what's wrong with looping?
On May 23, 2011, at 6:20 PM, Victor Lazzarini wrote:

> which bins return negative frequency?
> 
seems to be 1,2,3,4

-matti




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"

Date2011-05-23 16:55
FromVictor Lazzarini
SubjectRe: [Csnd] what's wrong with looping?
yes, I guess that can happen. I would expect the amplitude values to  
be quite low. If significant signals are picked up by the lower bins,
pvsanal should produce positive frequency outputs for those bins.

Victor

On 23 May 2011, at 16:44, Matti Koskinen wrote:

>
> On May 23, 2011, at 6:20 PM, Victor Lazzarini wrote:
>
>> which bins return negative frequency?
>>
> seems to be 1,2,3,4
>
> -matti
>
>
>
>
> 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"
>

Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie





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"

Date2011-05-23 17:57
Fromjoachim heintz
SubjectRe: [Csnd] what's wrong with looping?
Am 23.05.2011 17:15, schrieb Matti Koskinen:
> Idea was to wait for a defined time, is there any suspend, sleep   or
> wait opcode?

not an opcode like this, as far as i know, but several ways to do this,
for instance:
- metro
- delayk
- timeinsts/timeinstk
- simply counting k-cycles

see, for instance,
http://www.csounds.com/udo/displayOpcode.php?opcode_id=130

	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"

Date2011-05-24 16:42
FromRichard Dobson
SubjectRe: [Csnd] what's wrong with looping?
Negative frequencies appear very routinely in the lowest bins. The 
bandwidth even of the lowest bin is symmetrical, like a quasi-bandpass 
filter - so in the first bin it is +- DC. And of course bins "bunch" 
together. If you "rectify" the frequencies, you are imposing a phase 
shift which may or may not matter, YMMV etc.  But there is nothing 
"wrong" with them as such, it is a natural consequence of the pvoc 
conversion.


Richard Dobson





On 23/05/2011 16:55, Victor Lazzarini wrote:
> yes, I guess that can happen. I would expect the amplitude values to be
> quite low. If significant signals are picked up by the lower bins,
> pvsanal should produce positive frequency outputs for those bins.
>
> Victor
>
> On 23 May 2011, at 16:44, Matti Koskinen wrote:
>
>>
>> On May 23, 2011, at 6:20 PM, Victor Lazzarini wrote:
>>
>>> which bins return negative frequency?
>>>
>> seems to be 1,2,3,4
>>
>> -matti
>>




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"