SpeakerAdjust

adjusts levels, arrival times, and optional eqalisation bands for multichannel signals.

Typical use is for multichannel speaker setups.

See also Spectralyzer.help for a related tool.

*ar(ins, specs, vol) // static settings

ins an array of audio channels to be processed/adjusted

specs the adjustment specifications:

one list for each channel consisting of

[ amp, a multiply factor for this channel,

delaytime, (optional) delay time for this channel (in secs)

eqspec1: (optional) spec for one eq band to use, with values for:

[freq, frequency,

db, gain in db,

rq], reciprocal of Q: bandwidth / cutoffFreq.

(1 is wide, 0.1 is narrow).

eqspec2,

...

eqspecN

],

vol master volume for all chans, can be used for muting

// Caution: not working yet, because default values with Control.names are not correct yet.

// for the time being, use ar (fix).

*arDyn ( ins, specs, vol)

same as above, but with adjustable delay times, level and EQ; to be used for tweaking

the setup is final.

This is slightly more efficient than creating control inputs on all parameters.

Recommended use: put a function for speaker adjustment in a MasterFX chain,

where it is guaranteed to run post all other sounds, and wake up after Cmd-period.

s.boot;

// ... full short example here, e.g. 6 chans, amp, delay, 2 bands eq each.

// step by step examples

(

ProxyChain.add(

\testSnd, \mix -> { Dust.ar(20) + PinkNoise.ar([0.1, 0.1]) },

\spkAdj, \filter -> { |in, spkVol=1| SpeakerAdjust.ar(in, [ [0.25], [0.5] ], spkVol) }

);

Spec.add(\spkVol, \amp);

// can be used in a proxy chain

c = ProxyChain(2, [\testSnd, \spkAdj]);

c.gui;

c.play;

)

c.add(\spkAdj, 1); // kick in compensation

c.end;

// make some sound that just plays

{ Dust.ar(20) + PinkNoise.ar([0.1, 0.1]) }.play;

// make a MasterFX - this filters everything on its buses,

// and wakes up after cmd-period.

z = MasterFX(s, 2, [\spkAdj]);

z.gui;

z.pxChain.add(\spkAdj);

(

ProxyChain.add(

\spkAdj, \filter -> { |in, spkVol=1|

SpeakerAdjust.ar(in, [

[1, 0],

[1, 0.02] // right channel slightly late

], spkVol) }

);

z.pxChain.add(\spkAdj, 1);

)

// one eq band on each channel, add gain at different freqs

(

ProxyChain.add(

\spkAdj, \filter -> { |in, spkVol=1|

SpeakerAdjust.ar(in, [

// amp, dt, [freq1, gain1, bw1]

[1, 0, [300, 8, 2]],

[1, 0.02,[2800, 8, 2]]

], spkVol) }

);

z.pxChain.add(\spkAdj, 1);

)

// load test for 24 chans: a MasterFX

(

MasterFX.clear(s.name);

z = MasterFX(s, 24, [\spkAdj]);

z.gui;

)

(

// generate random data for 24 chans, 3 bands each, to test load:

var data = { [

rrand(0.5, 1.0), // amp

0.01.rand ] // dt, max 10msec => 3.4m

++

({ [

exprand(100, 10000), // freq

rrand(12.0, -12.0), // gain in db

rrand(0.2, 1.0) ] // rq

} ! 3);

} ! z.numChannels; // for 24 chans

ProxyChain.add(

\spkAdj, \filter -> { |in, spkVol=1|

SpeakerAdjust.arDyn(in, data, spkVol) }

);

z.pxChain.add(\spkAdj, 1);

)