Csound Csound-dev Csound-tekno Search About

[Csnd] new problem with looping

Date2011-05-23 19:19
FromMatti Koskinen
Subject[Csnd] new problem with looping
encountered another problem with looping. Looping pvsbin fsig,kloopindx where kloopindx is incremented by 1
gives same kamp and kfr for  all the bins. e.g. kamp,kfr pvsbin fsig,10 and pvsbin fsig,11 gives different values for kamp and kfr. running the orc from previous posts, changes kamp and kfr after the loops have finished, all the values while in the loop where kbins is incremented by 1 are the same.

??

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"


Date2011-05-23 20:00
Fromjoachim heintz
SubjectRe: [Csnd] new problem with looping
how do you get the values?
if with printks, you will get just one value in a k-cycle (i think
victor mentioned this before, too).
try printf instead.

	joachim

Am 23.05.2011 20:19, schrieb Matti Koskinen:
> encountered another problem with looping. Looping pvsbin fsig,kloopindx where kloopindx is incremented by 1
> gives same kamp and kfr for  all the bins. e.g. kamp,kfr pvsbin fsig,10 and pvsbin fsig,11 gives different values for kamp and kfr. running the orc from previous posts, changes kamp and kfr after the loops have finished, all the values while in the loop where kbins is incremented by 1 are the same.
> 
> ??
> 
> 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 20:02
FromVictor.Lazzarini@nuim.ie
SubjectRe: [Csnd] new problem with looping
AttachmentsNone  None  

Date2011-05-23 20:23
FromVictor.Lazzarini@nuim.ie
SubjectRe: [Csnd] new problem with looping
AttachmentsNone  None  

Date2011-05-23 21:01
FromMatti Koskinen
SubjectRe: [Csnd] new problem with looping
On May 23, 2011, at 10:23 PM, Victor.Lazzarini@nuim.ie wrote:

> I think I know why this does not do what you want. In general, pv opcodes output only
> after a new frame has been produced at the input, so if you loop, you will get the same 
> result. I can change this behaviour to get a new value if the bin is different. I never anticipated
> this use. I will have a look at this tomorrow.
> 
> Victor
> 

sounds reasonable but this csd produces in the output.sco 100 same values, but the printk2's print different values when the bin number is integer

 
 ; Select audio/midi flags here according to platform 
; Audio out	Audio in 
-odac	;;;RT audio I/O ; For Non-realtime ouput leave only the line below:
; -o fprints.wav -W ;;; for file output any platform 
 

;Initialize the global variables. 
sr = 44100 
kr = 4410
ksmps = 10 
nchnls = 1
; Instrument #1 looping pvsbins
instr 1
 
ifftsize = 1024 
iwtype = 1	/* cleaner with hanning window */
kthrs = 20
a1 soundin "hi.aiff" ;select a soundifle
fsig pvsanal	a1, ifftsize, ifftsize/4, ifftsize, iwtype 
kbin = 1
kmaxbin = 100
loop:
	kamp,kfr pvsbin fsig,kbin
	ktr = 0
	if (kamp > kthrs) then
	   ktr = 1
	else
            ktr = 0
	endif
	kbin = kbin + 1
	schedkwhen ktr, 0,100,2,0,0.5,kamp,kfr
	if (kbin < kmaxbin) kgoto loop

kamp2,kfr2 pvsbin fsig,10 ; shouldn't the fsig still be the same?
kamp3,kfr3 pvsbin fsig,11
printk2 kfr2
printk2 kfr3
endin

instr 2
      fprints "output.sco","i1 %f %f %f %f\n",p2,p3,p4,p5
endin
 

i1 0 10





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 21:29
Fromvictor
SubjectRe: [Csnd] new problem with looping
The diagnostic I gave regarding pvsbin is correct, I just looked at the 
code. I'll implement a fix tomorrow.
Meanwhile, you can try recursion as in

opcode fbins,k,ikpp

ih,kt,ibin,icnt xin

if icnt >= ibin goto skip
k1 fbins ih,kt,ibin,icnt+1
skip:
fs1 pvsbufread kt, ih
kamp, kfr pvsbin fs1, icnt
kcnt line 0,100000, 1
printf "amp: %f freq: %f, %f\n",kcnt, kamp, kfr, icnt
xout k1
endop


instr 1
k1 = 0
a1 rand 0dbfs/4
fs1 pvsanal a1, 1024,256,1024,1
iha,kt pvsbuffer fs1,0.1

k1 fbins iha,kt,10

endin


----- Original Message ----- 
From: "Matti Koskinen" 
To: 
Sent: Monday, May 23, 2011 9:01 PM
Subject: Re: [Csnd] new problem with looping



On May 23, 2011, at 10:23 PM, Victor.Lazzarini@nuim.ie wrote:

> I think I know why this does not do what you want. In general, pv opcodes 
> output only
> after a new frame has been produced at the input, so if you loop, you will 
> get the same
> result. I can change this behaviour to get a new value if the bin is 
> different. I never anticipated
> this use. I will have a look at this tomorrow.
>
> Victor
>

sounds reasonable but this csd produces in the output.sco 100 same values, 
but the printk2's print different values when the bin number is integer


 ; Select audio/midi flags here according to platform
; Audio out Audio in
-odac ;;;RT audio I/O ; For Non-realtime ouput leave only the line below:
; -o fprints.wav -W ;;; for file output any platform


;Initialize the global variables.
sr = 44100
kr = 4410
ksmps = 10
nchnls = 1
; Instrument #1 looping pvsbins
instr 1

ifftsize = 1024
iwtype = 1 /* cleaner with hanning window */
kthrs = 20
a1 soundin "hi.aiff" ;select a soundifle
fsig pvsanal a1, ifftsize, ifftsize/4, ifftsize, iwtype
kbin = 1
kmaxbin = 100
loop:
kamp,kfr pvsbin fsig,kbin
ktr = 0
if (kamp > kthrs) then
   ktr = 1
else
            ktr = 0
endif
kbin = kbin + 1
schedkwhen ktr, 0,100,2,0,0.5,kamp,kfr
if (kbin < kmaxbin) kgoto loop

kamp2,kfr2 pvsbin fsig,10 ; shouldn't the fsig still be the same?
kamp3,kfr3 pvsbin fsig,11
printk2 kfr2
printk2 kfr3
endin

instr 2
      fprints "output.sco","i1 %f %f %f %f\n",p2,p3,p4,p5
endin


i1 0 10





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 22:11
FromMatti Koskinen
SubjectRe: [Csnd] new problem with looping
On May 23, 2011, at 11:29 PM, victor wrote:

> The diagnostic I gave regarding pvsbin is correct, I just looked at the code. I'll implement a fix tomorrow.
> Meanwhile, you can try recursion as in
> 
> opcode fbins,k,ikpp
> 
> ih,kt,ibin,icnt xin
> 
> if icnt >= ibin goto skip
> k1 fbins ih,kt,ibin,icnt+1
> skip:
> fs1 pvsbufread kt, ih
> kamp, kfr pvsbin fs1, icnt
> kcnt line 0,100000, 1
> printf "amp: %f freq: %f, %f\n",kcnt, kamp, kfr, icnt
> xout k1
> endop
> 
> 
> instr 1
> k1 = 0
> a1 rand 0dbfs/4
> fs1 pvsanal a1, 1024,256,1024,1
> iha,kt pvsbuffer fs1,0.1
> 
> k1 fbins iha,kt,10
> 
> endin

thanks, I'll try. btw. I hardcoded some bins and the output sounds more interesting :)

-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"