shithub: leaf

Download patch

ref: bf582dc812263e00fc8db1fb242b9c6d2cc79766
parent: 8ab6a52fdfc58365c123dbab858f2d81f1b737c6
author: Matthew Wang <Matthew@nat-oitwireless-inside-vapornet100-10-9-53-29.princeton.edu>
date: Fri Dec 13 08:02:33 EST 2019

add buffer get record position

--- a/LEAF/Inc/leaf-sampling.h
+++ b/LEAF/Inc/leaf-sampling.h
@@ -55,6 +55,7 @@
     
     void  tBuffer_record (tBuffer* const);
     void  tBuffer_stop (tBuffer* const);
+    int   tBuffer_getRecordPosition(tBuffer* const);
     
     void  tBuffer_setRecordMode (tBuffer* const, RecordMode mode);
     
--- a/LEAF/Src/leaf-sampling.c
+++ b/LEAF/Src/leaf-sampling.c
@@ -99,6 +99,12 @@
     s->active = 0;
 }
 
+int   tBuffer_getRecordPosition(tBuffer* const sb)
+{
+    _tBuffer* s = *sb;
+    return s->idx;
+}
+
 void  tBuffer_setRecordMode (tBuffer* const sb, RecordMode mode)
 {
     _tBuffer* s = *sb;
@@ -224,7 +230,7 @@
                                                alpha);
         
         // num samples to end of loop
-        numsamps = (idx - start) / p->inc;
+        numsamps = (idx - start) * p->iinc;
         //numsamps = (dir > 0) ? (end - idx) : (idx - start);
         //numsamps *= p->iinc;
         
@@ -263,7 +269,7 @@
                                                buff[i4],
                                                1.0f-alpha);
         
-        numsamps = (idx - start) / p->inc;
+        numsamps = (idx - start) * p->iinc;
         
         if (p->mode == PlayLoop)
         {
--- a/LEAF_JUCEPlugin/Source/MyTest.cpp
+++ b/LEAF_JUCEPlugin/Source/MyTest.cpp
@@ -55,7 +55,7 @@
     // Init and set play
     tSampler_init (&samp, &buff); // init, give address of record buffer
     tSampler_setMode (&samp, PlayLoop); //set in Loop Mode
-    tSampler_setRate(&samp, 1.f); // Rate of 1.0
+    tSampler_setRate(&samp, 1.763f); // Rate of 1.0
 }
 
 float   LEAFTest_tick            (float input)
@@ -95,11 +95,13 @@
     
     y = val * 49.0f + 1.0f;
     b = val * 20.0f - 5.0f;
+    b = val * tBuffer_getLength(&buff);
     
     DBG("rate: " + String(b));
     
     tSampler_setStart(&samp, a);
-    tSampler_setRate(&samp, b);
+    tSampler_setEnd(&samp, b);
+//    tSampler_setRate(&samp, b);
     
 //    tFormantShifter_setShiftFactor(&fs, x);
 //    tFormantShifter_setIntensity(&fs, y);