History

added scale

Paul Batchelor committed 5 years ago

Commit 14f4c7a1 parent f8a34974 files · +63 −1Browse files

Unified · Split

4 files
  1. Makefile +2 −1
  2. algos.org +2 −0
  3. mkdb.janet +1 −0
  4. scale.org +58 −0
Makefile+2−1
@@ -52,7 +52,8 @@ phasor.o \ · 51 unmodified lines
5252 swell.o \
5353 biramp.o \
5454 core.o \
55−patchwerk/patchwerk.o
55+patchwerk/patchwerk.o \
56+scale.o \
5657
5758 include nodes/config.mk
5859
algos.org+2−0
@@ -44,3 +44,5 @@ whose smoothing amount changes based on the direction. · 43 unmodified lines
4444
4545 @!(ref "biramp")!@ converts a phasor ramp signal into a ramp
4646 that goes up and down.
47+
48+@!(ref "scale")!@ provides some simple scaling utilities.
mkdb.janet+1−0
@@ -33,6 +33,7 @@ · 32 unmodified lines
3333 (ww-add-link "swell" "swell.org")
3434 (ww-add-link "biramp" "biramp.org")
3535 (ww-add-link "core" "core.org")
36+(ww-add-link "scale" "scale.org")
3637
3738 # sync and close
3839
scale.org+58−0
@@ -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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t