extract one channel out of a stereo bus

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

extract one channel out of a stereo bus

Peter P.-2
Hi list,

excuse the simple question, but I can't really find a direct answer to
this in the docs and tutorials:

I have a private stereo audio bus and want to access only one of its
channels.

        ~someBus = Bus.audio(s, 2);

        In.ar(~someBus, 2)

Will give me both channels. I guess I have to extract individual
elements of arrays, or try to use the XFade2 UGen, but was just curious
if there is a better way to do it, or a shortcut even?

Thank you!
P

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Reply | Threaded
Open this post in threaded view
|

Re: extract one channel out of a stereo bus

Alessandro Fogar
Hi,

In.ar(~someBu, 1); 

Best

AF

2017-03-10 10:53 GMT+01:00 Peter P. <[hidden email]>:
Hi list,

excuse the simple question, but I can't really find a direct answer to
this in the docs and tutorials:

I have a private stereo audio bus and want to access only one of its
channels.

        ~someBus = Bus.audio(s, 2);

        In.ar(~someBus, 2)

Will give me both channels. I guess I have to extract individual
elements of arrays, or try to use the XFade2 UGen, but was just curious
if there is a better way to do it, or a shortcut even?

Thank you!
P

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/



--
Alessandro Fogar

http://www.fogar.it
Reply | Threaded
Open this post in threaded view
|

Re: extract one channel out of a stereo bus

daniel-mayer
In reply to this post by Peter P.-2

Am 10.03.2017 um 10:53 schrieb Peter P. <[hidden email]>:

> Hi list,
>
> excuse the simple question, but I can't really find a direct answer to
> this in the docs and tutorials:
>
> I have a private stereo audio bus and want to access only one of its
> channels.
>
> ~someBus = Bus.audio(s, 2);
>
> In.ar(~someBus, 2)
>
> Will give me both channels. I guess I have to extract individual
> elements of arrays, or try to use the XFade2 UGen, but was just curious
> if there is a better way to do it, or a shortcut even?


~someBus.subBus(offset, numChannels)


Regards

Daniel

-----------------------------
www.daniel-mayer.at
-----------------------------


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Reply | Threaded
Open this post in threaded view
|

Re: extract one channel out of a stereo bus

Peter P.-2
In reply to this post by Alessandro Fogar
* Alessandro Fogar <[hidden email]> [2017-03-10 12:01]:
> Hi,
>
> In.ar(~someBu, 1);
Thank you Alessandro, but I fear this would always only give me the
first of the two signals. I think Daniel has already posted a solution.
Thank you again,
P

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Reply | Threaded
Open this post in threaded view
|

Re: extract one channel out of a stereo bus

Peter P.-2
In reply to this post by daniel-mayer
* Daniel Mayer <[hidden email]> [2017-03-10 12:31]:

>
> Am 10.03.2017 um 10:53 schrieb Peter P. <[hidden email]>:
>
> > Hi list,
> >
> > excuse the simple question, but I can't really find a direct answer to
> > this in the docs and tutorials:
> >
> > I have a private stereo audio bus and want to access only one of its
> > channels.
> >
> > ~someBus = Bus.audio(s, 2);
> >
> > In.ar(~someBus, 2)
> >
> > Will give me both channels. I guess I have to extract individual
> > elements of arrays, or try to use the XFade2 UGen, but was just curious
> > if there is a better way to do it, or a shortcut even?
>
>
> ~someBus.subBus(offset, numChannels)

Sweet, thank you!
P

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Reply | Threaded
Open this post in threaded view
|

Re: extract one channel out of a stereo bus

ddw_music
In reply to this post by Peter P.-2
Peter P.-2 wrote
> In.ar(~someBu, 1);
Thank you Alessandro, but I fear this would always only give me the
first of the two signals. I think Daniel has already posted a solution.
Actually you can still do it Alessandro's way. The key point there is that the server doesn't understand stereo buses at all -- there is no such thing. The server has only a flat array of mono buses.

As a convenience, sclang lets you ask for a bus number where /n/ consecutive buses are available. This is a language-side convenience only -- Bus.audio(s, 2) does exactly nothing in the server to bind the buses together. It only guarantees you'll get two adjacent buses.

That means, you don't have to do anything special to get only the right channel -- just take the left channel bus index and add one. That's it. Nothing more complicated than that. The subBus method that Daniel mentioned does this for you, but for In.ar, you don't actually need it.

Left: In.ar(~someBus, 1);

Right: In.ar(~someBus.index + 1, 1);

(Assuming ~someBus is a Bus object. If you pass the bus number as a synth argument, you would drop the ".index" call.)

hjh
Reply | Threaded
Open this post in threaded view
|

Re: extract one channel out of a stereo bus

Peter P.-2
* ddw_music <[hidden email]> [2017-03-10 14:44]:

> Peter P.-2 wrote
> >> In.ar(~someBu, 1);
> > Thank you Alessandro, but I fear this would always only give me the
> > first of the two signals. I think Daniel has already posted a solution.
>
> Actually you can still do it Alessandro's way. The key point there is that
> the server doesn't understand stereo buses at all -- there is no such thing.
> The server has only a flat array of mono buses.
>
> As a convenience, sclang lets you ask for a bus number where /n/ consecutive
> buses are available. This is a language-side convenience only --
> Bus.audio(s, 2) does exactly nothing in the server to bind the buses
> together. It only guarantees you'll get two adjacent buses.
>
> That means, you don't have to do anything special to get only the right
> channel -- just take the left channel bus index and add one. That's it.
> Nothing more complicated than that. The subBus method that Daniel mentioned
> does this for you, but for In.ar, you don't actually need it.
>
> Left: In.ar(~someBus, 1);
>
> Right: In.ar(~someBus.index + 1, 1);
You are right! This is another way, even more concise (unless you would
want to extract a number of channels larger than 1 in which case .subBus
would be the solution).
Thanks hjh!

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Reply | Threaded
Open this post in threaded view
|

Re: extract one channel out of a stereo bus

ddw_music
Peter P.-2 wrote
> Left: In.ar(~someBus, 1);
>
> Right: In.ar(~someBus.index + 1, 1);

You are right! This is another way, even more concise (unless you would
want to extract a number of channels larger than 1 in which case .subBus
would be the solution).
Then again, nothing in this technique requires the In.ar number of channels to be 1. If you have a 4-channel bus, you could get the third and fourth channels by:

In.ar(~bus.index + 2, 2)

(Meta-discussion: The problem with documenting by example is the chance of inferring the wrong principle from the examples. That is, here, all the In.ar sub-bus examples had numChannels = 1, from which it was inferred that the technique is valid only for individual buses. Not so!)

hjh
Reply | Threaded
Open this post in threaded view
|

Re: extract one channel out of a stereo bus

Peter P.-2
* ddw_music <[hidden email]> [2017-03-11 03:05]:

> Peter P.-2 wrote
> >> Left: In.ar(~someBus, 1);
> >>
> >> Right: In.ar(~someBus.index + 1, 1);
> >
> > You are right! This is another way, even more concise (unless you would
> > want to extract a number of channels larger than 1 in which case .subBus
> > would be the solution).
>
> Then again, nothing in this technique requires the In.ar number of channels
> to be 1. If you have a 4-channel bus, you could get the third and fourth
> channels by:
>
> In.ar(~bus.index + 2, 2)
Indeed!
(Meta-question: I wonder why or for which cases .subBus exists then)
Thanks

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/