These operate on the channel dimension itself: indexing, rearranging, and reducing.
Remember that channel counts round to powers of two, and indexing is cyclic
(index & (chans-1)).
| Function | Description |
|---|---|
at(a, i) | Select channel i (a signal or constant; cyclic). 1-channel result per index channel. |
put(a, i, v) | Replace channel i of a with v. |
take(a, n) | First n channels (widened to a power of two, cyclic fill). |
drop(a, n) | Drop the first n channels. |
stride(a, n) | Every nth channel: channels 0, n, 2n, … |
stutter(a, n) | Repeat each channel n times: [a b] stutter(2) → [a a b b]. |
ncyc(a, n) | Cycle the whole channel array n times: [a b] ncyc(2) → [a b a b]. |
rotate(a, k) | Rotate channels by k (a signal or constant). |
reverse(a) | Reverse channel order. |
transpose(a, n) | Treat the channels as an n-column matrix and transpose it — converts between interleaved and grouped channel layouts. |
join([a, b, ...]) | Concatenate an array of signals along the channel dimension. |
reduce(a, op, chans = 1) | Fold the channels down to chans with a BinaryOp; channel i of the result combines input channels i, i+chans, i+2·chans, … |
sum(a, chans = 1) | reduce with add — the standard mixdown. sum(2) mixes an even/odd split to stereo. |
product(a, chans = 1) | reduce with multiply. |
minOf(a, chans = 1) / maxOf(a, chans = 1) | reduce with min / max. |
-- 16 random-frequency sines, mixed to stereo
fn shimmer() S {
let freqs = exprand(200, 2000, 16, Rate.init);
freqs sinosc sum(2) * 0.05 |> outlet
}
-- 16 random sine plinks, each randomly panned, mixed to stereo.
-- pandust(density, 16) emits 32 chans grouped by side [L0..L15, R0..R15];
-- transpose(16) interleaves them to [L0 R0 L1 R1 ...], so sum(2) mixes
-- even channels to the left output and odd channels to the right.
fn dustCloud() S {
let freqs = exprand(100, 5000, 16, Rate.init);
let ticks = pandust(3/16, 16) decay2(0.004, 0.2);
ticks * freqs sinosc |> transpose(16) sum(2) outlet
}
↑ Back to top