shithub: leaf

Download patch

ref: 4cb315f58a570ac0f640c6ea135b70fcbbf1f32f
parent: 5344999c7e5c176f76ec07b954cb876dc5ec09e1
author: spiricom <jeff@snyderphonics.com>
date: Wed May 20 17:20:55 EDT 2020

added fast pow functions

binary files a/.DS_Store b/.DS_Store differ
binary files a/LEAF/.DS_Store b/LEAF/.DS_Store differ
--- a/LEAF/Inc/leaf-math.h
+++ b/LEAF/Inc/leaf-math.h
@@ -142,6 +142,8 @@
     
     float fastexp2f(float f);
     
+    float fastPowf(float a, float b) ;
+    double fastPow(double a, double b);
     
     void LEAF_crossfade(float fade, float* volumes);
 
--- a/LEAF/Src/leaf-math.c
+++ b/LEAF/Src/leaf-math.c
@@ -152,6 +152,29 @@
 }
 
 
+float fastPowf(float a, float b) {
+    union 
+    { 
+        float d; int x; 
+    } 
+    u = { a };
+
+    u.x = (int)(b * (u.x - 1064866805) + 1064866805);
+    return u.d;
+}
+
+
+double fastPow(double a, double b) {
+    union {
+        double d;
+        int x[2];
+    } u = { a };
+
+    u.x[1] = (int)(b * (u.x[1] - 1072632447) + 1072632447);
+    
+    u.x[0] = 0;
+    return u.d;
+}
 /*
  you pass in a float array to get back two indexes representing the volumes of the left (index 0) and right (index 1) channels
  when t is -1, volumes[0] = 0, volumes[1] = 1