MagnitudeResponseView is a Model View Control (MVC) implementation of a Filter Magnitude Response plotter/control for SuperCollider 3.

// Minimal example
k = SOSKernel.new
v = k.view;

magnitude-response-view
MagnitudeResponseView performs simultaneusly as both a View and a Control.
As a View, it plots the magnitude of frequency bands a Filter will pass or reject.
As a Control, it responds to user adjusts to a Filter’s Cutoff frequency, Gain and Q.

MagnitudeResponseView intefaces with FilterKernels. It can manage any number of FilterKernels and plot the resulting sum of all Filters magnitude responses.

MagnitudeResponseView is highly customizable and can be embedded on almost any kind of parent View/Window.

Controls

MagnitudeResponseView as a control

  • Click on a FilterKernel’s cursor* selects a FilterKernel.
  • Click and drag a FilterKernel’s cursor* to adjust its Cutoff frequency (Hz) [X axis] and/or Gain (dBs) [Y axis] where applicable.

    *In MagnitudeResponseView’s of the shelf configuration, a Filter’s Cursor is the red circle at its Cutoff as shown on the pictures.

  • Mouse Wheel or Two finger vertical swipe on touchpads, adjusts the Filter’s Q value where applicable.
  • Right Mouse Button Click on MagnitudeResponseView and you get a popup menu with all the filters available in your installation for the Selected FilterKernel.

magnitude-response-view+menu

By default, for an SOSKernel for example, the set of installed filters are all of the BEQSuite Filters + an extra Lowshelf example: LowBoost, supplied by this package.


MagnitudeResponseView keyboard controls

  • n - select next kernel
  • p - select previous kernel
  • -/+ - range zoom gain

These operate on the selected FilterKernel:

  • b or d - bypass selected FilterKernel
  • Up Down - adjusts Gain / Q depending on key mods [shift]/[ctr].
  • Left Right - adjusts Cutoff freq.
  • m - Popoup filter select menu.
  • z - Zero Gain

MagnitudeResponseView’s info line updates in real time to reflect user modifications. The info line displays:

  • Active FilterKernel index number in brackets. ie, [0]
  • Filter name. ie, BPeakEQ
  • Cutoff frequency in Hz
  • Q
  • Gain in dBs

Adusting MagnitudeResponseView triggers the View’s instance user installable action function. Just like it would on any other SuperCollider3 View:

MagnitudeResponseView::action_ { arg viewInstance, filterKernel, triggerAction;
  ...
};

Where arguments viewInstance is the View Instance that triggered the action func, filterKernel is the FilterKernel that was modified and triggerAction is a Symbol that states what type of change did just take place:

  • \coefs - Filter Coefficients changed. User adjusts to Cutoff, Gain and/or Q
  • \filterKey - User did select a new Filter Type
  • \bypass - FilterKernel bypass.

Examples

Multiple FilterKernels: An SOS and an FOS FilterKernels.

// Multiple FilterKernels
k = SOSKernel.new;
j = FOSKernel.new;
j.setFrequency(1000);

v = k.view;
v.kernels = [k, j];

SOSKernel examples:

s.boot;

b = Buffer.read(s, "/path/to/your/audio/file)");

(
[1,2].do({ arg chns;
	SynthDef("soskernel-ctrl-"++chns.asString, { |inbus=2, outbus=0, bufnum, rate=1.0, t_trig=1, startPos=0, loop=1, amp=1.0, bypass=0|
		var coefs, coefsctl,fx,dry,z;
		coefs = 0!5;
		coefsctl = \coefs.kr(coefs);
		dry = PlayBuf.ar(2, bufnum, BufRateScale.kr(bufnum) * rate, t_trig, startPos, loop, Done.freeSelf);
		// dry = In.ar(inbus,chns);
		fx = SOS.ar(dry, *coefsctl);
		Out.ar(outbus, ((dry*bypass)+((1-bypass)*fx)) * amp);
	}).add;
});
)

k=SOSKernel.new;
k.coefs;

a=Synth("soskernel-ctrl-2", [\coefs, k.coefs, \bufnum, b.bufnum]);
a.trace;

a.set(\amp, 0.7);
a.set(\amp, 1);

v=k.view;
v.action={|view,kernel| a.set(\coefs, kernel.coefs, \bypass, 1 - kernel.enabled.binaryValue); };

(
v.action={|view,kernel,changed|
	//changed.postln;
	case
	{ changed == \coefs or:{ changed == \filterKey } } {
		a.set(\coefs, kernel.coefs);
	}
	{ changed == \bypass } {
		a.set(\bypass, 1 - kernel.enabled.binaryValue);
	};
};
)

s.dumpOSC(1);
s.dumpOSC(0);

k.filterClass_(BLowPass); a.set(\coefs, k.coefs);
k.setFrequency(2300.0); a.set(\coefs, k.coefs);
k.setFrequency(5200.0); a.set(\coefs, k.coefs);
k.setQ(0.7); a.set(\coefs, k.coefs);
k.setQ(2.5); a.set(\coefs, k.coefs);
k.setQ(1.2); a.set(\coefs, k.coefs);

k.selectFilterType(\BPeakEQ);
k.setFrequency(2300.0);
k.setGain(3.0);
a.set(\coefs, k.coefs);

k.setQ(0.7); a.set(\coefs, k.coefs);
k.setFrequency(5200.0); a.set(\coefs, k.coefs);
k.setGain(3.5); a.set(\coefs, k.coefs);


k.filterClass_(BHiShelf); a.set(\coefs, k.coefs);
k.setFrequency(1000.0); a.set(\coefs, k.coefs);
k.setGain(3.5); a.set(\coefs, k.coefs);
k.setQ(2.4); a.set(\coefs, k.coefs);
k.setQ(0.7); a.set(\coefs, k.coefs);

a.set(\bypass, 1);
a.set(\bypass, 0);

k.frequency_(1000.0);
k.q_(0.7);
k.gain_(0.0);
k.paramsChanged;
k.changed(\freq);
a.set(\coefs, k.coefs);
v.refresh

a.free;
b.free;

Instalation

Clone MagnitudeResponseView repository and move its folder inside the Extensions folder in SuperCollider3 User Support directory or place MagnitudeResponseView repository folder anywhere you want in your file system and add its path to your includes folder in sclang config section in SCIDE prefs.

ie, in the IDE:

Click Edit Menu -> Preferences and click on interpreter.

and recompile Class Library.

If you don’t have GIT available in your system, you can simply download a snapshot of the MagnitudeResponseView repository as a zip file from the Downloads links at the bottom left on that page and install that as a quark:

Quarks.install("~/path/to/MagnitudeResponseView/MagnitudeResponseView.quark")

Recompile Class Library and you are done.

This is a local copy of the latest snapshot.