Csound Csound-dev Csound-tekno Search About

[Csnd] Is it possible to have audio-rate loops ?

Date2019-09-12 16:12
FromBernard Geyer
Subject[Csnd] Is it possible to have audio-rate loops ?
I have many lines like this in my code:
	abp[0] reson aSig, givocFreqs[0], kBandWidth, 1
	abp[1] reson aSig, givocFreqs[1], kBandWidth, 1
	abp[2] reson aSig, givocFreqs[2], kBandWidth, 1
	abp[3] reson aSig, givocFreqs[3], kBandWidth, 1

	abp[4] reson aSig, givocFreqs[4], kBandWidth, 1
	abp[5] reson aSig, givocFreqs[5], kBandWidth, 1
	abp[6] reson aSig, givocFreqs[6], kBandWidth, 1
	abp[7] reson aSig, givocFreqs[7], kBandWidth, 1

	abp[8]  reson aSig, givocFreqs[8], kBandWidth, 1
	abp[9] reson aSig, givocFreqs[9], kBandWidth, 1
	abp[10] reson aSig, givocFreqs[10], kBandWidth, 1
	abp[11] reson aSig, givocFreqs[11], kBandWidth, 1

	abp[12] reson aSig, givocFreqs[12], kBandWidth, 1
	abp[13] reson aSig, givocFreqs[13], kBandWidth, 1
	abp[14] reson aSig, givocFreqs[14], kBandWidth, 1
	abp[15] reson aSig, givocFreqs[15], kBandWidth, 1

I would like to do something like that, but of course, it does not work with
arate variables:
	aInd = 0
	abpLoop:
	abp[aInd] reson aSig, givocFreqs[aInd], kBandWidth, 1
loop_lt  aInd, 1, giMaxBuses, abpLoop

Does some solutions exist for this kind of stuff, maybe with an UDO ?

Best,
Bernard



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

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

Date2019-09-12 16:12
Fromjohn
SubjectRe: [Csnd] Is it possible to have audio-rate loops ?
1: you do not need anaudio variable as an aray index but a kvar

2:  The look has only one reson with internal state while our written 
out code has 16 rson filters.

The usual advice is a recursive UDO



On Thu, 12 Sep 2019, Bernard Geyer 
wrote:

> I have many lines like this in my code:
> 	abp[0] reson aSig, givocFreqs[0], kBandWidth, 1
> 	abp[1] reson aSig, givocFreqs[1], kBandWidth, 1
> 	abp[2] reson aSig, givocFreqs[2], kBandWidth, 1
> 	abp[3] reson aSig, givocFreqs[3], kBandWidth, 1
>
> 	abp[4] reson aSig, givocFreqs[4], kBandWidth, 1
> 	abp[5] reson aSig, givocFreqs[5], kBandWidth, 1
> 	abp[6] reson aSig, givocFreqs[6], kBandWidth, 1
> 	abp[7] reson aSig, givocFreqs[7], kBandWidth, 1
>
> 	abp[8]  reson aSig, givocFreqs[8], kBandWidth, 1
> 	abp[9] reson aSig, givocFreqs[9], kBandWidth, 1
> 	abp[10] reson aSig, givocFreqs[10], kBandWidth, 1
> 	abp[11] reson aSig, givocFreqs[11], kBandWidth, 1
>
> 	abp[12] reson aSig, givocFreqs[12], kBandWidth, 1
> 	abp[13] reson aSig, givocFreqs[13], kBandWidth, 1
> 	abp[14] reson aSig, givocFreqs[14], kBandWidth, 1
> 	abp[15] reson aSig, givocFreqs[15], kBandWidth, 1
>
> I would like to do something like that, but of course, it does not work with
> arate variables:
> 	aInd = 0
> 	abpLoop:
> 	abp[aInd] reson aSig, givocFreqs[aInd], kBandWidth, 1
> loop_lt  aInd, 1, giMaxBuses, abpLoop
>
> Does some solutions exist for this kind of stuff, maybe with an UDO ?
>
> Best,
> Bernard
>
>
>
> --
> Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html
>
> 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

Date2019-09-12 16:41
FromBernard Geyer
SubjectRe: [Csnd] Is it possible to have audio-rate loops ?
I tried first using kInd instead of aInd, but i got distortions.




--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

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

Date2019-09-12 17:02
Fromjohn
SubjectRe: [Csnd] Is it possible to have audio-rate loops ?
The distortions probably came from using the single filter 16 times 
rather thar 16 different filters.

Use a recursive UDO and a kvar

On Thu, 12 Sep 2019, Bernard Geyer wrote:

> I tried first using kInd instead of aInd, but i got distortions.
>
>
>
>
> --
> Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html
>
> 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

Date2019-09-12 17:52
FromEduardo Moguillansky
SubjectRe: [Csnd] Is it possible to have audio-rate loops ?
You have an array of frequencies givocFreqs and need a bandpass filter 
for each frequency, storing all these bands in an audio array, right?. 
The "poly" opcode is exactly for this.

https://csound-plugins.github.io/csound-plugins/opcodes/poly.html

inum lenarray givocFreqs
abp[] poly inum, "reson", givocFreqs, kBandWidth, 1
; now you can do anything you want with abp
asum sumarray abp
asum *= 0.1
outs asum, asum


eduardo


On 12.09.19 17:12, Bernard Geyer wrote:

> I have many lines like this in my code:
> 	abp[0] reson aSig, givocFreqs[0], kBandWidth, 1
> 	abp[1] reson aSig, givocFreqs[1], kBandWidth, 1
> 	abp[2] reson aSig, givocFreqs[2], kBandWidth, 1
> 	abp[3] reson aSig, givocFreqs[3], kBandWidth, 1
>
> 	abp[4] reson aSig, givocFreqs[4], kBandWidth, 1
> 	abp[5] reson aSig, givocFreqs[5], kBandWidth, 1
> 	abp[6] reson aSig, givocFreqs[6], kBandWidth, 1
> 	abp[7] reson aSig, givocFreqs[7], kBandWidth, 1
>
> 	abp[8]  reson aSig, givocFreqs[8], kBandWidth, 1
> 	abp[9] reson aSig, givocFreqs[9], kBandWidth, 1
> 	abp[10] reson aSig, givocFreqs[10], kBandWidth, 1
> 	abp[11] reson aSig, givocFreqs[11], kBandWidth, 1
>
> 	abp[12] reson aSig, givocFreqs[12], kBandWidth, 1
> 	abp[13] reson aSig, givocFreqs[13], kBandWidth, 1
> 	abp[14] reson aSig, givocFreqs[14], kBandWidth, 1
> 	abp[15] reson aSig, givocFreqs[15], kBandWidth, 1
>
> I would like to do something like that, but of course, it does not work with
> arate variables:
> 	aInd = 0
> 	abpLoop:
> 	abp[aInd] reson aSig, givocFreqs[aInd], kBandWidth, 1
> loop_lt  aInd, 1, giMaxBuses, abpLoop
>
> Does some solutions exist for this kind of stuff, maybe with an UDO ?
>
> Best,
> Bernard
>
>
>
> --
> Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html
>
> 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

Date2019-09-12 20:18
Fromjoachim heintz
SubjectRe: [Csnd] Is it possible to have audio-rate loops ?
yes this is the nicest way to do the job.  without the poly plugin, you 
can use a recursive udo:





ksmps = 32
nchnls = 2
0dbfs = 1

opcode RecReson, a, ai[]kio
  aSig, iFreqs[], kQ, iMax, iCnt xin
  iCf = iFreqs[iCnt]
  aBp reson aSig, iCf, iCf/kQ, 1
  if iCnt < iMax-1 then
   aAdd RecReson aSig, iFreqs, kQ, iMax, iCnt+1
   aBp += aAdd
  endif
  xout aBp
endop

instr Test

  aSig rand .1, 2, 1
  iFreqs[] fillarray 100, 200, 300, 400, 500, 600, 700
  kQ = 10
  aBp RecReson aSig, iFreqs, kQ, lenarray(iFreqs)
  out aBp, aBp

endin



i "Test" 0 10




	joachim



On 12/09/19 18:52, Eduardo Moguillansky wrote:
> You have an array of frequencies givocFreqs and need a bandpass filter
> for each frequency, storing all these bands in an audio array, right?.
> The "poly" opcode is exactly for this.
>
> https://csound-plugins.github.io/csound-plugins/opcodes/poly.html
>
> inum lenarray givocFreqs
> abp[] poly inum, "reson", givocFreqs, kBandWidth, 1
> ; now you can do anything you want with abp
> asum sumarray abp
> asum *= 0.1
> outs asum, asum
>
>
> eduardo
>
>
> On 12.09.19 17:12, Bernard Geyer wrote:
>
>> I have many lines like this in my code:
>>     abp[0] reson aSig, givocFreqs[0], kBandWidth, 1
>>     abp[1] reson aSig, givocFreqs[1], kBandWidth, 1
>>     abp[2] reson aSig, givocFreqs[2], kBandWidth, 1
>>     abp[3] reson aSig, givocFreqs[3], kBandWidth, 1
>>
>>     abp[4] reson aSig, givocFreqs[4], kBandWidth, 1
>>     abp[5] reson aSig, givocFreqs[5], kBandWidth, 1
>>     abp[6] reson aSig, givocFreqs[6], kBandWidth, 1
>>     abp[7] reson aSig, givocFreqs[7], kBandWidth, 1
>>
>>     abp[8]  reson aSig, givocFreqs[8], kBandWidth, 1
>>     abp[9] reson aSig, givocFreqs[9], kBandWidth, 1
>>     abp[10] reson aSig, givocFreqs[10], kBandWidth, 1
>>     abp[11] reson aSig, givocFreqs[11], kBandWidth, 1
>>
>>     abp[12] reson aSig, givocFreqs[12], kBandWidth, 1
>>     abp[13] reson aSig, givocFreqs[13], kBandWidth, 1
>>     abp[14] reson aSig, givocFreqs[14], kBandWidth, 1
>>     abp[15] reson aSig, givocFreqs[15], kBandWidth, 1
>>
>> I would like to do something like that, but of course, it does not
>> work with
>> arate variables:
>>     aInd = 0
>>     abpLoop:
>>     abp[aInd] reson aSig, givocFreqs[aInd], kBandWidth, 1
>> loop_lt  aInd, 1, giMaxBuses, abpLoop
>>
>> Does some solutions exist for this kind of stuff, maybe with an UDO ?
>>
>> Best,
>> Bernard
>>
>>
>>
>> --
>> Sent from:
>> http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html
>>
>> 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