Skip to content

Instantly share code, notes, and snippets.

@softpunch
Last active July 10, 2017 23:55
Show Gist options
  • Save softpunch/a2c1a9126d11768397825892f42e1e2c to your computer and use it in GitHub Desktop.
Save softpunch/a2c1a9126d11768397825892f42e1e2c to your computer and use it in GitHub Desktop.
Make Signals Work (Modulation, Range, Translation, Application, Interpolation)
// make a signal do what you want it to do
//
// LFO manipulation
// (assume the signal ranges from -1 to 1)
// make the value range 0-1 (no negative numbers, aka unsigned)
var destination = (signal + 1) / 2;
// adjust another number/value using the LFO signal
var destination = initialVal + (signal);
// same as above, but with +/- 0.5
var destination = initialVal + (signal/2);
// scaling methods
// squash or stretch a source signal to a destination range
var source = signal;
var sourceRange = sourceMax - sourceMin;
var destinationRange = destMax - destMin;
var destination = destMin + (destinationRange)(source - sourceMin) / (sourceRange);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment