# Selecting one output from a multichannel ndef?

Hi,

I’ve been trying to model some basic logic chips (flip-flops, counters, etc.) in SC to make a kind of virtual lunetta synth. And I’ve been drawn to JITLib and Ndefs as a way of playing with them in a modular-like way. I’m new to JIT and have never used Ndefs before…so I’m sure I’m missing something…but here’s my question.

Say I have a Ndef that outputs different things on multiple channels. For instance, on one channel it outputs a square wave, and on the other it outputs the inverse of the square wave (ie. when one is high, the other is low, etc – kind of like Q and barQ on an old logic chip). Or say I have an Ndef that is acting like a counter: for each trigger it receives, it will output a pulse, first on channel zero, the next on channel one, the next on channel two, etc. until it reaches, say ten, then it starts over.

Here’s the question: how can I grab only one of an Ndef’s multiple outs and route it into another Ndef? I’d like to be able to do something like this piece of fantasy code…

Ndef(\someOscillator).set(\theOscillatorGate, Ndef(\counter).out(3));



It is the Ndef(\counter).out(3) part that I’m curious about. How can I grab, say, only channel 3 of that Ndef’s output, so I can plug it into another Ndef?

I’m sure there is some simple solution, but I haven’t been able to find it. Any help from the collective hive mind would be appreciated.

–Brian

Dr K,

Have you tried using an array index like mya:

Ndef(\a, { [SinOsc.ar(300, 0, 1), LFTri.ar(400, 0, 0.2), LFPulse.ar(450, 0, 0.1)] }).mold(3);

Ndef(\b, { SinOsc.ar(375+(Ndef.ar(\a)[0]*400), 0, 0.1) });

Ndef(\b).play;


Sorry if the code is ugly. Ndef is not my native tongue.

Sam

The output bus of an Ndef is available via Ndef(\foo).bus. And, you can use the subBus method on a bus to extract one channel of a multichannel bus. So, in combination, you should be able to do Ndef(\foo).bus.subBus(0) to get the 0th channel of the multichannel bus. An example:

(

Ndef(\stereo, {
Impulse.ar([1.3333, 1.2])
});

Ndef(\delay, {
var in = \in.ar;
in + CombC.ar(in, 1, 1/3, 4)
}).play;

Ndef(\delay).map(
\in, Ndef(\stereo).bus.subBus(1).asMap
);

)

1 Like

Scott and Sam,

Thanks to both of you for your help! All hail collective hive mind!

The Ndef(\foo).bus.subBus(n).asMap did the trick.

All best,
Brian