Unified · Split
| @@ -52,7 +52,8 @@ phasor.o \ · 51 unmodified lines | ||
| 52 | 52 | swell.o \ |
| 53 | 53 | biramp.o \ |
| 54 | 54 | core.o \ |
| 55 | −patchwerk/patchwerk.o | |
| 55 | +patchwerk/patchwerk.o \ | |
| 56 | +scale.o \ | |
| 56 | 57 | |
| 57 | 58 | include nodes/config.mk |
| 58 | 59 | |
| @@ -44,3 +44,5 @@ whose smoothing amount changes based on the direction. · 43 unmodified lines | ||
| 44 | 44 | |
| 45 | 45 | @!(ref "biramp")!@ converts a phasor ramp signal into a ramp |
| 46 | 46 | that goes up and down. |
| 47 | + | |
| 48 | +@!(ref "scale")!@ provides some simple scaling utilities. | |
| @@ -33,6 +33,7 @@ · 32 unmodified lines | ||
| 33 | 33 | (ww-add-link "swell" "swell.org") |
| 34 | 34 | (ww-add-link "biramp" "biramp.org") |
| 35 | 35 | (ww-add-link "core" "core.org") |
| 36 | +(ww-add-link "scale" "scale.org") | |
| 36 | 37 | |
| 37 | 38 | # sync and close |
| 38 | 39 | |
| @@ -0,0 +1,58 @@ | ||
| 1 | +#+TITLE: Scale | |
| 2 | +* Overview | |
| 3 | +=scale= provides some helpful scaling functions. Scaling | |
| 4 | +refers to taking a value in some range, and then protionally | |
| 5 | +refitting it to be in another range. In other words... | |
| 6 | +scaling! | |
| 7 | +* Tangled files | |
| 8 | +=scale.h= and =scale.c= | |
| 9 | + | |
| 10 | +#+NAME: scale.h | |
| 11 | +#+BEGIN_SRC c :tangle scale.h | |
| 12 | +#ifndef SK_SCALE_H | |
| 13 | +#define SK_SCALE_H | |
| 14 | +#ifndef SKFLT | |
| 15 | +#define SKFLT float | |
| 16 | +#endif | |
| 17 | +<<funcdefs>> | |
| 18 | +#endif | |
| 19 | +#+END_SRC | |
| 20 | + | |
| 21 | +#+NAME: scale.c | |
| 22 | +#+BEGIN_SRC c :tangle scale.c | |
| 23 | +#include "scale.h" | |
| 24 | +<<funcs>> | |
| 25 | +#+END_SRC | |
| 26 | +* Scale | |
| 27 | +The function =sk_scale= takes in a value between 0 and 1, | |
| 28 | +an returns a value to be in between =min= and =max=. | |
| 29 | + | |
| 30 | +#+NAME: funcdefs | |
| 31 | +#+BEGIN_SRC c | |
| 32 | +SKFLT sk_scale(SKFLT in, SKFLT min, SKFLT max); | |
| 33 | +#+END_SRC | |
| 34 | + | |
| 35 | +#+NAME: funcs | |
| 36 | +#+BEGIN_SRC c | |
| 37 | +SKFLT sk_scale(SKFLT in, SKFLT min, SKFLT max) | |
| 38 | +{ | |
| 39 | + | |
| 40 | + return in * (max - min) + min; | |
| 41 | +} | |
| 42 | +#+END_SRC | |
| 43 | +* Biscale | |
| 44 | +The function =sk_biscale= takes a value between -1 and | |
| 45 | +1 and returns a value between =min= and =max=. | |
| 46 | + | |
| 47 | +#+NAME: funcdefs | |
| 48 | +#+BEGIN_SRC c | |
| 49 | +SKFLT sk_biscale(SKFLT in, SKFLT min, SKFLT max); | |
| 50 | +#+END_SRC | |
| 51 | + | |
| 52 | +#+NAME: funcs | |
| 53 | +#+BEGIN_SRC c | |
| 54 | +SKFLT sk_biscale(SKFLT in, SKFLT min, SKFLT max) | |
| 55 | +{ | |
| 56 | + return min + (in + 1.0) * 0.5 * (max - min); | |
| 57 | +} | |
| 58 | +#+END_SRC | |