Csound Csound-dev Csound-tekno Search About

while loop and filter

Date2016-02-29 00:39
FromBeinan Li
Subjectwhile loop and filter
A potential newbie question.
My environment: Csound 6.05  May 13 2015, Mac OS X El Capitan

I use the code at the bottom to let a noise pass a filter bank.
The while loop (METHOD 1) seemed to have blown, while the brute-force way (METHOD 2, commented out) works fine. Unless there is something I don't know about filter inside a while loop, I can't seem to find the semantic difference between the two approaches.

The runtime error I saw:

inactive allocs returned to freespace
end of score.    overall amps:8376828780966801044648502711778270133298631035860828659753408146647852360779829808563618927137961884692901143109118037638663782350071708204472421980196003555302485172590423276679455658277649353228579038265403906871033654101350070211545883655085026468006483720272162045161430387893391435732286790235586560.00000
   overall samples out of range:     9251

What's funnier is that the while loop works if I change the last two elements of ifcs[], so that the array looks like:

ifcs[] array 62.5, 125, 250, 395, 20, 20

This tells me that something is wrong with the filter calls.

I'd appreciate it if someone can share some tips.

The code:

<CsoundSynthesizer>
<CsOptions>
-odac     ;;;realtime audio out
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 10
nchnls = 1
0dbfs = 1

instr 1
amp fractalnoise 0.5, 0

ifcs[] array 62.5, 125, 250, 395, 560, 790
iQs[] array 1, 1, 2, 2, 3, 3

aout = 0

;
; METHOD 1
;
kndx = 0
while kndx<lenarray(ifcs) do
afilt butterbp amp, ifcs[kndx], ifcs[kndx]/iQs[kndx]
aout += afilt
kndx += 1
od
aout += amp*0.2

;
; METHOD 2
;
; afilt1 butterbp amp, ifcs[0], ifcs[0]/iQs[0]
; afilt2 butterbp amp, ifcs[1], ifcs[1]/iQs[1]
; afilt3 butterbp amp, ifcs[2], ifcs[2]/iQs[2]
; afilt4 butterbp amp, ifcs[3], ifcs[3]/iQs[3]
; afilt5 butterbp amp, ifcs[4], ifcs[4]/iQs[4]
; afilt6 butterbp amp, ifcs[5], ifcs[5]/iQs[5]
; aout += afilt1+afilt2+afilt3+afilt4+afilt5+afilt6+amp*0.2

out aout/(lenarray(ifcs)+1)

endin

</CsInstruments>
<CsScore>
f1 0 4096 10 1

i1 0 z 440 0.5

</CsScore>
</CsoundSynthesizer>


Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2016-02-29 09:37
FromJohn ff
SubjectRe: while loop and filter

A loop uses the same filter not like inline where every one has its own state

==John

Sent from TypeApp

On 29 Feb 2016, at 00:40, Beinan Li <li.beinan@GMAIL.COM> wrote:
A potential newbie question.
My environment: Csound 6.05  May 13 2015, Mac OS X El Capitan

I use the code at the bottom to let a noise pass a filter bank.
The while loop (METHOD 1) seemed to have blown, while the brute-force way (METHOD 2, commented out) works fine. Unless there is something I don't know about filter inside a while loop, I can't seem to find the semantic difference between the two approaches.

The runtime error I saw:

i nactive allocs returned to freespace
end of score.    overall amps:8376828780966801044648502711778270133298631035860828659753408146647852360779829808563618927137961884692901143109118037638663782350071708204472421980196003555302485172590423276679455658277649353228579038265403906871033654101350070211545883655085026468006483720272162045161430387893391435732286790235586560.00000
   overall samples out of range:     9251

What's funnier is that the while loop works if I change the last two elements of ifcs[], so that the array looks like:

ifcs[] array 62.5, 125, 250, 395, 20, 20

This tells me that something is wrong with the filter calls.

I'd appreciate it if someone can share some tips.

The code:

<CsoundSynthesizer>
<CsOptions>
-odac     ;;;realtime audio out
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 10
nchnls = 1
0dbfs = 1

instr 1
amp fractalnoise 0.5, 0

ifcs[] array 62.5, 125, 250, 395, 560, 790
iQs[] array 1, 1, 2, 2, 3, 3

aout = 0

;
; METHOD 1
;
kndx = 0
while kndx<lenarray(ifcs) do
afilt butterbp amp, ifcs[kndx], ifcs[kndx]/iQs[kndx]
aout += afilt
kndx += 1
od
aout += amp*0.2

;
blockquote>
; METHOD 2
;
; afilt1 butterbp amp, ifcs[0], ifcs[0]/iQs[0]
; afilt2 butterbp amp, ifcs[1], ifcs[1]/iQs[1]
; afilt3 butterbp amp, ifcs[2], ifcs[2]/iQs[2]
; afilt4 butterbp amp, ifcs[3], ifcs[3]/iQs[3]
; afilt5 butterbp amp, ifcs[4], ifcs[4]/iQs[4]
; afilt6 butterbp amp, ifcs[5], ifcs[5]/iQs[5]
; aout += afilt1+afilt2+afilt3+afilt4+afilt5+afilt6+amp*0.2

out aout/(lenarray(ifcs)+1)

endin

</CsInstruments>
<CsScore>
f1 0 4096 10 1
< div>

i1 0 z 440 0.5

</CsScore>
</CsoundSynthesizer>


Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2016-02-29 15:01
FromBeinan Li
SubjectRe: while loop and filter
Thanks a lot, John!

Other than the source code, where can I find info like this? 
I checked the "loop" and "filters" sections in the FLOSS manual and also the canonical reference, to no avail.
If possible, I'd like to know more about special opcode behaviours in a loop.

Thanks,
Beinan


On Mon, Feb 29, 2016 at 4:37 AM, John ff <jpff@codemist.co.uk> wrote:

A loop uses the same filter not like inline where every one has its own state

==John

Sent from TypeApp

On 29 Feb 2016, at 00:40, Beinan Li <li.beinan@GMAIL.COM> wrote:
A potential newbie question.
My environment: Csound 6.05  May 13 2015, Mac OS X El Capitan

I use the code at the bottom to let a noise pass a filter bank.
The while loop (METHOD 1) seemed to have blown, while the brute-force way (METHOD 2, commented out) works fine. Unless there is something I don't know about filter inside a while loop, I can't seem to find the semantic difference between the two approaches.

The runtime error I saw:

inactive allocs returned to freespace
end of score.    overall amps:8376828780966801044648502711778270133298631035860828659753408146647852360779829808563618927137961884692901143109118037638663782350071708204472421980196003555302485172590423276679455658277649353228579038265403906871033654101350070211545883655085026468006483720272162045161430387893391435732286790235586560.00000
   overall samples out of range:     9251

What's funnier is that the while loop works if I change the last two elements of ifcs[], so that the array looks like:

ifcs[] array 62.5, 125, 250, 395, 20, 20

This tells me that something is wrong with the filter calls.

I'd appreciate it if someone can share some tips.

The code:

<CsoundSynthesizer>
<CsOptions>
-odac     ;;;realtime audio out
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 10
nchnls = 1
0dbfs = 1

instr 1
amp fractalnoise 0.5, 0

ifcs[] array 62.5, 125, 250, 395, 560, 790
iQs[] array 1, 1, 2, 2, 3, 3

aout = 0

;
; METHOD 1
;
kndx = 0
while kndx<lenarray(ifcs) do
afilt butterbp amp, ifcs[kndx], ifcs[kndx]/iQs[kndx]
aout += afilt
kndx += 1
od
aout += amp*0.2

;
; METHOD 2
;
; afilt1 butterbp amp, ifcs[0], ifcs[0]/iQs[0]
; afilt2 butterbp amp, ifcs[1], ifcs[1]/iQs[1]
; afilt3 butterbp amp, ifcs[2], ifcs[2]/iQs[2]
; afilt4 butterbp amp, ifcs[3], ifcs[3]/iQs[3]
; afilt5 butterbp amp, ifcs[4], ifcs[4]/iQs[4]
; afilt6 butterbp amp, ifcs[5], ifcs[5]/iQs[5]
; aout += afilt1+afilt2+afilt3+afilt4+afilt5+afilt6+amp*0.2

out aout/(lenarray(ifcs)+1)

endin

</CsInstruments>
<CsScore>
f1 0 4096 10 1

i1 0 z 440 0.5

</CsScore>
</CsoundSynthesizer>


Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here