SuperCollider Forum
May 23, 2013, 08:49:42 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: The SuperCollider forum is currently experiencing a rash of spambot registrations. New user requests may not be approved quickly as a result -- and if your email address looks like spam, it might not be approved at all. We are working to improve the security of the registration process, and to provide alternate means to contact the administrators to get a new account. Thanks for your patience.
 
   Home   Help Search Calendar Login Register  
Pages: [1]
  Print  
Author Topic: possible to refer to an individual channel within a multichannel bus object?  (Read 3211 times)
0 Members and 1 Guest are viewing this topic.
Charles
Newbie
*

Karma: 0
Posts: 2


View Profile
« on: August 31, 2008, 11:10:15 AM »

Hi, I'm yet another user New to SC.
Could anyone help me with this very simple question?

if I have a bus object, say
a = Bus.audio(s, 6);

how can I refer to just individual channels within the six channels of object 'a'

For example...
Code:
//Load a simple sine SynthDef to default server
(
var outFunc;

outFunc = {arg outBus = 0, freq = 220;
var outSignal;
outSignal = SinOsc.ar(freq, 0, 0.02);
Out.ar(outBus, outSignal);
};

SynthDef.new("simpleSynth", outFunc).load(s);
)

// Fill an array with 6 synths each outputting 
// to a seperate channel within bus06
(
var bus06, synthArr;

bus06 = Bus.audio(s, 6);
synthArr = Array.new(0);

6.do({arg i;
synthArr = synthArr.add(Synth.new("simpleSynth", ["outBus", 0/*What Goes Here?*/,"freq", (i * 100)]));
};);
)

is it possible to use the 'Do' loop to fill the array with 6 overtones of 100hz, each going to a separate channel?
Logged
joshp
AdminGroup
Full Member
*

Karma: 5
Posts: 121



View Profile WWW
« Reply #1 on: August 31, 2008, 09:43:45 PM »

To the first part... that is a little tricky. Does this work?

Code:
a  = Bus.audio(s, 6);

a.index + 0
a.index + 1

Which would make this work (I added 1 to i in the 'freq' parameter... otherwise the first partial is '0'):
Code:
//Load a simple sine SynthDef to default server
(
var outFunc;

outFunc = {arg outBus = 0, freq = 220;
var outSignal;
outSignal = SinOsc.ar(freq, 0, 0.02);
Out.ar(outBus, outSignal);
};

SynthDef.new("simpleSynth", outFunc).load(s);
)

// Fill an array with 6 synths each outputting 
// to a seperate channel within bus06
(
var bus06, synthArr;

bus06 = Bus.audio(s, 6);
synthArr = Array.new(0);

bus06.numChannels.do({arg i;
synthArr = synthArr.add(
Synth.new("simpleSynth", ["outBus", bus06.index + i, "freq", (i + 1 * 100)]));
};);
)

Hope that helps.

Josh
Logged
Charles
Newbie
*

Karma: 0
Posts: 2


View Profile
« Reply #2 on: September 01, 2008, 02:32:34 PM »

Thanks! that makes thing easy! I was thinking that creating a Bus Object would allocate busses with non sequential indexes if it were so inclined, but it looks as if this is not the case.

when using .control and .audio messages to crate multi channel bus objects, are the indexes that are used always sequential? I did some testing and it looks like they are.  for example....
Code:
(
a = Bus.control(s, 2);
b = Bus.control(s, 2);

a.free;
a = Bus.control(s, 4);
)

..will output this line:

Bus(control, 4, 4, localhost)

...implying that control buses with indexes '0' and '1' were not used because there was not four sequential indexes available.

is there a situation were this would work otherwise?
Logged
joshp
AdminGroup
Full Member
*

Karma: 5
Posts: 121



View Profile WWW
« Reply #3 on: September 01, 2008, 02:39:12 PM »

Yes... they are always a contiguous block and sequential. Out inside UGens relies on this.

Josh
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!