shithub: leaf

Download patch

ref: b1b59893acc33c24f4c72d2531244c76d36b564c
parent: 866c7c185fdce7993d21d05fbc76a09558c5b4d5
author: spiricom <jeff@snyderphonics.com>
date: Sat Jan 11 10:34:06 EST 2020

working on adding location inits to objects to allow alternate mempools. so far only tBuffer

binary files a/.DS_Store b/.DS_Store differ
binary files a/LEAF/.DS_Store b/LEAF/.DS_Store differ
--- a/LEAF/Inc/leaf-sampling.h
+++ b/LEAF/Inc/leaf-sampling.h
@@ -19,6 +19,7 @@
 #include "leaf-global.h"
 #include "leaf-math.h"
 #include "leaf-envelopes.h"
+#include "leaf-mempool.h"
     
     //==============================================================================
     
@@ -45,7 +46,9 @@
     typedef _tBuffer* tBuffer;
     
     void  tBuffer_init (tBuffer* const, uint32_t length);
+    void  tBuffer_init_locate (tBuffer* const sb, uint32_t length, mpool_t* pool);
     void  tBuffer_free (tBuffer* const);
+    void  tBuffer_free_locate (tBuffer* const sb, mpool_t* pool);
     
     void  tBuffer_tick (tBuffer* const, float sample);
     
--- a/LEAF/Src/leaf-sampling.c
+++ b/LEAF/Src/leaf-sampling.c
@@ -38,6 +38,20 @@
     tBuffer_clear(sb);
 }
 
+void  tBuffer_init_locate (tBuffer* const sb, uint32_t length, mpool_t* pool)
+{
+    _tBuffer* s = *sb = (_tBuffer*) mpool_alloc(sizeof(_tBuffer), pool);
+
+    s->buff = (float*) mpool_alloc( sizeof(float) * length, pool);
+
+    s->length = length;
+    s->active = 0;
+    s->idx = 0;
+    s->mode = RecordOneShot;
+
+    tBuffer_clear(sb);
+}
+
 void  tBuffer_free (tBuffer* const sb)
 {
     _tBuffer* s = *sb;
@@ -45,6 +59,15 @@
     leaf_free(s->buff);
     leaf_free(s);
 }
+
+void  tBuffer_free_locate (tBuffer* const sb, mpool_t* pool)
+{
+    _tBuffer* s = *sb;
+
+    mpool_free(s->buff, pool);
+    mpool_free(s, pool);
+}
+
 
 void tBuffer_tick (tBuffer* const sb, float sample)
 {