UnitShapers - A collection of stateless window functions

hey, i have just released the UnitShaper library as SuperCollider Plugins. You can grab the latest release here.

EDIT: they are merged with the GrainUtils now, which you can find here

I have implemented the kink and triangle helper functions, the grain window functions and a versatile S-Curve with a quintic easing core and morphable shapes (between S and J shapes).

// ===== HELPER FUNCTIONS =====

(
{
	var phase = Phasor.ar(DC.ar(0), 50 * SampleDur.ir);
	UnitKink.ar(phase, \skew.kr(0.25));
}.plot(0.02);
)

(
{
	var phase = Phasor.ar(DC.ar(0), 50 * SampleDur.ir);
	UnitTriangle.ar(phase, \skew.kr(0.5));
}.plot(0.02);
)


// ===== WINDOW FUNCTIONS =====

(
{
	var phase = Phasor.ar(DC.ar(0), 50 * SampleDur.ir);
	HanningWindow.ar(phase, \skew.kr(0.5));
}.plot(0.02);
)

(
{
	var phase = Phasor.ar(DC.ar(0), 50 * SampleDur.ir);
	GaussianWindow.ar(phase, \skew.kr(0.5), \index.kr(5));
}.plot(0.02);
)

(
{
	var phase = Phasor.ar(DC.ar(0), 50 * SampleDur.ir);
	TrapezoidalWindow.ar(phase, \skew.kr(0.5), \width.kr(0.5), \duty.kr(1));
}.plot(0.02);
)

(
{
	var phase = Phasor.ar(DC.ar(0), 50 * SampleDur.ir);
	TukeyWindow.ar(phase, \skew.kr(0.5), \width.kr(0.5));
}.plot(0.02);
)

(
{
	var phase = Phasor.ar(DC.ar(0), 50 * SampleDur.ir);
	ExponentialWindow.ar(phase, \skew.kr(0.5), \shape.kr(0));
}.plot(0.02);
)

// ===== INTERP FUNCTIONS =====

(
{
	var phase = Phasor.ar(DC.ar(0), 50 * SampleDur.ir);
	SCurve.ar(phase, \shape.kr(1), \inflection.kr(0.5));
}.plot(0.02);
)

The kink and triangle helper functions are useful utilities for either phaseshaping (kink) or phase increment distortion (triangle) and used internally to derive the window functions from the unit shapers.

Here is how you can implement phase shaping for classic PD using UnitKink:

(
{
	var skew = \skew.kr(0.125);
	var phase = Phasor.ar(DC.ar(0), 50 * SampleDur.ir);
	var warpedPhase = UnitKink.ar(phase, skew);
	cos(warpedPhase * 2pi).neg;
}.plot(0.02);
)

Here is how you can implement phase increment distortion for classic PD using UnitTriangle:

(
{
	var skew = \skew.kr(0.125);
	var phase = Phasor.ar(DC.ar(0), 50 * SampleDur.ir);
	var warpedPhase = UnitTriangle.ar(phase, skew);
	cos(phase + (warpedPhase * (0.5 - skew)) * 2pi).neg;
}.plot(0.02);
)
7 Likes

I have included the UnitShapers in my GrainUtils repository. I will therefore delete the UnitShapers repository. You can grab the latest release of GrainUtils here including the UnitShapers.