shithub: soundpipe

Download patch

ref: 29851f9c445d41cd82e422cb4b8c13fd2a13aea5
parent: 79b51e588d41bc7df8c27f1f1aee57832a9d45ad
author: Paul Batchelor <thisispaulbatchelor@gmail.com>
date: Fri Mar 5 11:20:57 EST 2021

updated biscale/scale to use tangled sndkit files

--- a/config.def.mk
+++ b/config.def.mk
@@ -98,6 +98,7 @@
 tangled/modalres.o \
 tangled/phasewarp.o \
 tangled/phasor.o \
+tangled/scale.o \
 
 NO_LIBSNDFILE=1
 CFLAGS += -DNO_LIBSNDFILE
--- a/modules/biscale.c
+++ b/modules/biscale.c
@@ -1,5 +1,8 @@
+/* This code is placed in the public domain. */
+
 #include <stdlib.h>
 #include "soundpipe.h"
+#include "tangled/scale.h"
 
 int sp_biscale_create(sp_biscale **p)
 {
@@ -22,6 +25,6 @@
 
 int sp_biscale_compute(sp_data *sp, sp_biscale *p, SPFLOAT *in, SPFLOAT *out)
 {
-    *out = p->min + (*in + 1.0) * 0.5 * (p->max - p->min);
+    *out = sk_biscale(*in, p->min, p->max);
     return SP_OK;
 }
--- a/modules/scale.c
+++ b/modules/scale.c
@@ -2,6 +2,7 @@
 
 #include <stdlib.h>
 #include "soundpipe.h"
+#include "tangled/scale.h"
 
 int sp_scale_create(sp_scale **p)
 {
@@ -24,6 +25,6 @@
 
 int sp_scale_compute(sp_data *sp, sp_scale *p, SPFLOAT *in, SPFLOAT *out)
 {
-    *out =  *in * (p->max - p->min) + p->min;
+    *out = sk_scale(*in, p->min, p->max);
     return SP_OK;
 }
--- /dev/null
+++ b/tangled/scale.c
@@ -1,0 +1,14 @@
+#line 23 "scale.org"
+#include "scale.h"
+#line 37 "scale.org"
+SKFLT sk_scale(SKFLT in, SKFLT min, SKFLT max)
+{
+
+    return in * (max - min) + min;
+}
+#line 54 "scale.org"
+SKFLT sk_biscale(SKFLT in, SKFLT min, SKFLT max)
+{
+    return min + (in + 1.0) * 0.5 * (max - min);
+}
+#line 23 "scale.org"
--- /dev/null
+++ b/tangled/scale.h
@@ -1,0 +1,12 @@
+#line 12 "scale.org"
+#ifndef SK_SCALE_H
+#define SK_SCALE_H
+#ifndef SKFLT
+#define SKFLT float
+#endif
+#line 32 "scale.org"
+SKFLT sk_scale(SKFLT in, SKFLT min, SKFLT max);
+#line 49 "scale.org"
+SKFLT sk_biscale(SKFLT in, SKFLT min, SKFLT max);
+#line 18 "scale.org"
+#endif