# Arbitrary Custom Interpolation Curves

Probably another stupid one, but:

Is it possible to design arbitrary interpolation curves, a bit like the builtin LinLin UGen, but with arbitrary number of points and curves?

I’ve worked out how to create envelope shapes like this, but is it possible to design an interpolation curve for, say, a control parameter in a similar way?

I know this kind of thing can be done with lookup-tables, but wondered if SuperCollider provided an easier way of doing it.

IEnvGen, I believe.

hjh

I was also thinking about Envs, in particular Env.xyc, which allows you to create an Env by providing xy coordinates and curve for each point.
You can read it on the server with IEnvGen, or use it on the client as a Spec:

// actually the last point's curve is ignored
~env = Env.xyc([[0, 0, \sin], [0.5, 0.1, \sin],  [1, 1, \lin]]);
~env.plot();
// map: get y for x
~env.asSpec.map(0); // -> 0
~env.asSpec.map(0.5); // -> 0.1
// unmap: get x for y
~env.asSpec.unmap(0.1); // -> 0.5
~env.asSpec.unmap(0.5); // -> 0.73227952719877
// EDIT: I had a typo here, wrote map instead of unmap, now it is correct


Thank you both!

I will try that.

Would that be

~env.asSpec.unmap(0.1); // -> 0.5
~env.asSpec.unmap(0.5); // -> 0.73227952719877


Oh yes my friend, sorry for the typo!

That’s OK. Had me scratching my head for a while, there, though… Have this working nicely, now.

(

// Filter morph delta curve envelope
~fMorphCurve = Env(
levels:[0, 0.49, 0.51, 1],
times: [0.4, 0.2, 0.4],
curve: [-2, 0, 2]
);
// Plot envelope
~fMorphCurve.plot;

// Generate morph position using curve defined in envelope
~fMorph = IEnvGen.kr(~fMorphCurve, MouseY.kr(0, ~fMorphCurve.times.sum));

)


Thanks guys!