Csound Csound-dev Csound-tekno Search About

[Csnd] flexible routing with audio arrays

Date2025-08-19 14:05
Fromjoachim heintz
Subject[Csnd] flexible routing with audio arrays
i like the possibility to put an audio array in out, like

	audio_sigs:a[] = [poscil:a(.2,500),poscil:a(.2,400)]
	out(audio_sigs)

however, sometimes i want to route it to higher channel numbers, or to 
irregular numbers, for instance, sending four audio signals in an array 
to the outputs 1,2,5,6.

i would like to do something like this:

	hw_out_chnls:i[] = [3,4]
	audio_sigs:a[] = [poscil:a(.2,500),poscil:a(.2,400)]
	for h,i in hw_out_chnls do
    	  outch(h,audio_sigs[i])
	od

this obviously cannot work because only the last array element is sent 
via outch.

i could solve it with a recursive UDO, but i am wondering:
is there any more elegant solution now in CS7?

thanks -
	joachim

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

Date2025-08-19 17:03
FromEduardo Moguillansky
SubjectRe: [Csnd] flexible routing with audio arrays
outch is not stateful so you can iterate the array using it


On Tue, Aug 19, 2025 at 3:05 PM joachim heintz <jh@joachimheintz.de> wrote:
i like the possibility to put an audio array in out, like

        audio_sigs:a[] = [poscil:a(.2,500),poscil:a(.2,400)]
        out(audio_sigs)

however, sometimes i want to route it to higher channel numbers, or to
irregular numbers, for instance, sending four audio signals in an array
to the outputs 1,2,5,6.

i would like to do something like this:

        hw_out_chnls:i[] = [3,4]
        audio_sigs:a[] = [poscil:a(.2,500),poscil:a(.2,400)]
        for h,i in hw_out_chnls do
          outch(h,audio_sigs[i])
        od

this obviously cannot work because only the last array element is sent
via outch.

i could solve it with a recursive UDO, but i am wondering:
is there any more elegant solution now in CS7?

thanks -
        joachim

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

Date2025-08-19 17:30
Fromjoachim heintz
SubjectRe: [Csnd] flexible routing with audio arrays
you mean "cannot" rather than "can"?
do you mean the same what i described as "this obviously cannot work 
because only the last array element is sent via outch"?
otherwise i don't get what you mean.

On 19/08/2025 18:03, Eduardo Moguillansky wrote:
> outch is not stateful so you can iterate the array using it
> 
> 
> On Tue, Aug 19, 2025 at 3:05 PM joachim heintz  > wrote:
> 
>     i like the possibility to put an audio array in out, like
> 
>              audio_sigs:a[] = [poscil:a(.2,500),poscil:a(.2,400)]
>              out(audio_sigs)
> 
>     however, sometimes i want to route it to higher channel numbers, or to
>     irregular numbers, for instance, sending four audio signals in an array
>     to the outputs 1,2,5,6.
> 
>     i would like to do something like this:
> 
>              hw_out_chnls:i[] = [3,4]
>              audio_sigs:a[] = [poscil:a(.2,500),poscil:a(.2,400)]
>              for h,i in hw_out_chnls do
>                outch(h,audio_sigs[i])
>              od
> 
>     this obviously cannot work because only the last array element is sent
>     via outch.
> 
>     i could solve it with a recursive UDO, but i am wondering:
>     is there any more elegant solution now in CS7?
> 
>     thanks -
>              joachim
> 
>     Csound mailing list
>     Csound@listserv.heanet.ie 
>     https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND      listserv.heanet.ie/cgi-bin/wa?A0=CSOUND>
>     Send bugs reports to
>     https://github.com/csound/csound/issues      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  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

Date2025-08-19 17:37
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] [EXTERNAL] Re: [Csnd] flexible routing with audio arrays
He means outch() can be used in a loop without any problems - it doesn't hold state from one call to another.

Prof. Victor Lazzarini
Maynooth University
Ireland

> On 19 Aug 2025, at 17:30, joachim heintz  wrote:
>
> *Warning*
>
> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
>
> you mean "cannot" rather than "can"?
> do you mean the same what i described as "this obviously cannot work
> because only the last array element is sent via outch"?
> otherwise i don't get what you mean.
>
>> On 19/08/2025 18:03, Eduardo Moguillansky wrote:
>> outch is not stateful so you can iterate the array using it
>>
>>
>> On Tue, Aug 19, 2025 at 3:05 PM joachim heintz > > wrote:
>>
>>    i like the possibility to put an audio array in out, like
>>
>>             audio_sigs:a[] = [poscil:a(.2,500),poscil:a(.2,400)]
>>             out(audio_sigs)
>>
>>    however, sometimes i want to route it to higher channel numbers, or to
>>    irregular numbers, for instance, sending four audio signals in an array
>>    to the outputs 1,2,5,6.
>>
>>    i would like to do something like this:
>>
>>             hw_out_chnls:i[] = [3,4]
>>             audio_sigs:a[] = [poscil:a(.2,500),poscil:a(.2,400)]
>>             for h,i in hw_out_chnls do
>>               outch(h,audio_sigs[i])
>>             od
>>
>>    this obviously cannot work because only the last array element is sent
>>    via outch.
>>
>>    i could solve it with a recursive UDO, but i am wondering:
>>    is there any more elegant solution now in CS7?
>>
>>    thanks -
>>             joachim
>>
>>    Csound mailing list
>>    Csound@listserv.heanet.ie 
>>    https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND >    listserv.heanet.ie/cgi-bin/wa?A0=CSOUND>
>>    Send bugs reports to
>>    https://github.com/csound/csound/issues >    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 > 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

Date2025-08-19 18:03
Fromjoachim heintz
SubjectRe: [Csnd] [EXTERNAL] Re: [Csnd] flexible routing with audio arrays
but i only hear the last array element (and the output shows the same).
here is the full code:

instr 1
   // array of hardware output channels (starting at 1)
   hw_out_chnls:i[] = [3,4]

   // array of audio signals
   audio_sigs:a[] = [poscil:a(.2,500),poscil:a(.2,400)]

   for h,i in hw_out_chnls do
     outch(h,audio_sigs[i])
   od
endin

anything i overlooked?

On 19/08/2025 18:37, Victor Lazzarini wrote:
> He means outch() can be used in a loop without any problems - it doesn't hold state from one call to another.
> 
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
> 
>> On 19 Aug 2025, at 17:30, joachim heintz  wrote:
>>
>> *Warning*
>>
>> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
>>
>> you mean "cannot" rather than "can"?
>> do you mean the same what i described as "this obviously cannot work
>> because only the last array element is sent via outch"?
>> otherwise i don't get what you mean.
>>
>>> On 19/08/2025 18:03, Eduardo Moguillansky wrote:
>>> outch is not stateful so you can iterate the array using it
>>>
>>>
>>> On Tue, Aug 19, 2025 at 3:05 PM joachim heintz >> > wrote:
>>>
>>>     i like the possibility to put an audio array in out, like
>>>
>>>              audio_sigs:a[] = [poscil:a(.2,500),poscil:a(.2,400)]
>>>              out(audio_sigs)
>>>
>>>     however, sometimes i want to route it to higher channel numbers, or to
>>>     irregular numbers, for instance, sending four audio signals in an array
>>>     to the outputs 1,2,5,6.
>>>
>>>     i would like to do something like this:
>>>
>>>              hw_out_chnls:i[] = [3,4]
>>>              audio_sigs:a[] = [poscil:a(.2,500),poscil:a(.2,400)]
>>>              for h,i in hw_out_chnls do
>>>                outch(h,audio_sigs[i])
>>>              od
>>>
>>>     this obviously cannot work because only the last array element is sent
>>>     via outch.
>>>
>>>     i could solve it with a recursive UDO, but i am wondering:
>>>     is there any more elegant solution now in CS7?
>>>
>>>     thanks -
>>>              joachim
>>>
>>>     Csound mailing list
>>>     Csound@listserv.heanet.ie 
>>>     https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND >>     listserv.heanet.ie/cgi-bin/wa?A0=CSOUND>
>>>     Send bugs reports to
>>>     https://github.com/csound/csound/issues >>     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 >> 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

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

Date2025-08-19 18:16
Fromvlz
SubjectRe: [Csnd] [EXTERNAL] Re: [Csnd] flexible routing with audio arrays
you are using an i-time loop as your array is i not k. Use a k array instead.

Prof. Victor Lazzarini
Maynooth University
Ireland

> On 19 Aug 2025, at 18:03, joachim heintz  wrote:
> 
> but i only hear the last array element (and the output shows the same).
> here is the full code:
> 
> instr 1
>  // array of hardware output channels (starting at 1)
>  hw_out_chnls:i[] = [3,4]
> 
>  // array of audio signals
>  audio_sigs:a[] = [poscil:a(.2,500),poscil:a(.2,400)]
> 
>  for h,i in hw_out_chnls do
>    outch(h,audio_sigs[i])
>  od
> endin
> 
> anything i overlooked?
> 
>> On 19/08/2025 18:37, Victor Lazzarini wrote:
>> He means outch() can be used in a loop without any problems - it doesn't hold state from one call to another.
>> Prof. Victor Lazzarini
>> Maynooth University
>> Ireland
>>>> On 19 Aug 2025, at 17:30, joachim heintz  wrote:
>>> 
>>> *Warning*
>>> 
>>> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
>>> 
>>> you mean "cannot" rather than "can"?
>>> do you mean the same what i described as "this obviously cannot work
>>> because only the last array element is sent via outch"?
>>> otherwise i don't get what you mean.
>>> 
>>>> On 19/08/2025 18:03, Eduardo Moguillansky wrote:
>>>> outch is not stateful so you can iterate the array using it
>>>> 
>>>> 
>>>> On Tue, Aug 19, 2025 at 3:05 PM joachim heintz >>> > wrote:
>>>> 
>>>>    i like the possibility to put an audio array in out, like
>>>> 
>>>>             audio_sigs:a[] = [poscil:a(.2,500),poscil:a(.2,400)]
>>>>             out(audio_sigs)
>>>> 
>>>>    however, sometimes i want to route it to higher channel numbers, or to
>>>>    irregular numbers, for instance, sending four audio signals in an array
>>>>    to the outputs 1,2,5,6.
>>>> 
>>>>    i would like to do something like this:
>>>> 
>>>>             hw_out_chnls:i[] = [3,4]
>>>>             audio_sigs:a[] = [poscil:a(.2,500),poscil:a(.2,400)]
>>>>             for h,i in hw_out_chnls do
>>>>               outch(h,audio_sigs[i])
>>>>             od
>>>> 
>>>>    this obviously cannot work because only the last array element is sent
>>>>    via outch.
>>>> 
>>>>    i could solve it with a recursive UDO, but i am wondering:
>>>>    is there any more elegant solution now in CS7?
>>>> 
>>>>    thanks -
>>>>             joachim
>>>> 
>>>>    Csound mailing list
>>>>    Csound@listserv.heanet.ie 
>>>>    https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND >>>    listserv.heanet.ie/cgi-bin/wa?A0=CSOUND>
>>>>    Send bugs reports to
>>>>    https://github.com/csound/csound/issues >>>    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 >>> 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
> 
> 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

Date2025-08-19 19:10
Fromjoachim heintz
SubjectRe: [Csnd] [EXTERNAL] Re: [Csnd] flexible routing with audio arrays
makes sense and works =)
perhaps i should read the chapter about i-rate and k-rate in the floss 
manual ...


On 19/08/2025 19:16, vlz wrote:
> you are using an i-time loop as your array is i not k. Use a k array instead.
> 
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
> 
>> On 19 Aug 2025, at 18:03, joachim heintz  wrote:
>>
>> but i only hear the last array element (and the output shows the same).
>> here is the full code:
>>
>> instr 1
>>   // array of hardware output channels (starting at 1)
>>   hw_out_chnls:i[] = [3,4]
>>
>>   // array of audio signals
>>   audio_sigs:a[] = [poscil:a(.2,500),poscil:a(.2,400)]
>>
>>   for h,i in hw_out_chnls do
>>     outch(h,audio_sigs[i])
>>   od
>> endin
>>
>> anything i overlooked?
>>
>>> On 19/08/2025 18:37, Victor Lazzarini wrote:
>>> He means outch() can be used in a loop without any problems - it doesn't hold state from one call to another.
>>> Prof. Victor Lazzarini
>>> Maynooth University
>>> Ireland
>>>>> On 19 Aug 2025, at 17:30, joachim heintz  wrote:
>>>>
>>>> *Warning*
>>>>
>>>> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
>>>>
>>>> you mean "cannot" rather than "can"?
>>>> do you mean the same what i described as "this obviously cannot work
>>>> because only the last array element is sent via outch"?
>>>> otherwise i don't get what you mean.
>>>>
>>>>> On 19/08/2025 18:03, Eduardo Moguillansky wrote:
>>>>> outch is not stateful so you can iterate the array using it
>>>>>
>>>>>
>>>>> On Tue, Aug 19, 2025 at 3:05 PM joachim heintz >>>> > wrote:
>>>>>
>>>>>     i like the possibility to put an audio array in out, like
>>>>>
>>>>>              audio_sigs:a[] = [poscil:a(.2,500),poscil:a(.2,400)]
>>>>>              out(audio_sigs)
>>>>>
>>>>>     however, sometimes i want to route it to higher channel numbers, or to
>>>>>     irregular numbers, for instance, sending four audio signals in an array
>>>>>     to the outputs 1,2,5,6.
>>>>>
>>>>>     i would like to do something like this:
>>>>>
>>>>>              hw_out_chnls:i[] = [3,4]
>>>>>              audio_sigs:a[] = [poscil:a(.2,500),poscil:a(.2,400)]
>>>>>              for h,i in hw_out_chnls do
>>>>>                outch(h,audio_sigs[i])
>>>>>              od
>>>>>
>>>>>     this obviously cannot work because only the last array element is sent
>>>>>     via outch.
>>>>>
>>>>>     i could solve it with a recursive UDO, but i am wondering:
>>>>>     is there any more elegant solution now in CS7?
>>>>>
>>>>>     thanks -
>>>>>              joachim
>>>>>
>>>>>     Csound mailing list
>>>>>     Csound@listserv.heanet.ie 
>>>>>     https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND >>>>     listserv.heanet.ie/cgi-bin/wa?A0=CSOUND>
>>>>>     Send bugs reports to
>>>>>     https://github.com/csound/csound/issues >>>>     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 >>>> 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
>>
>> 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