ref: 4c40a1ff45a4e04f64f7692c2d3a3523ee51a453
parent: c9ae42fb875909d02f78940f31114499b8cb8798
author: Jeffrey Snyder <jeffsnyder@jeffreys-mbp.mynetworksettings.com>
date: Wed Aug 24 13:01:58 EDT 2022
changed triLFO to do integer bitmask math
--- a/leaf/Inc/leaf-oscillators.h
+++ b/leaf/Inc/leaf-oscillators.h
@@ -1470,11 +1470,10 @@
{
tMempool mempool;
- uint32_t phase;
- uint32_t inc;
- uint32_t prevPhase;
+ int32_t phase;
+ int32_t inc;
+ int32_t prevPhase;
float freq;
- int32_t mask;
uint8_t phaseDidReset;
uint32_t invSampleRate;
float invSampleRateTimesTwoTo32;
--- a/leaf/Src/leaf-oscillators.c
+++ b/leaf/Src/leaf-oscillators.c
@@ -3024,7 +3024,7 @@
c->phase = 0;
c->invSampleRate = leaf->invSampleRate;
c->invSampleRateTimesTwoTo32 = (c->invSampleRate * TWO_TO_32);
- c->mask = TRI_TABLE_SIZE - 1;
+ //c->mask = TRI_TABLE_SIZE - 1;
tTriLFO_setFreq(cy, 220);
}
@@ -3039,10 +3039,20 @@
float tTriLFO_tick(tTriLFO* const cy)
{
_tTriLFO* c = *cy;
- uint32_t idx;
- float frac, samp0, samp1;
+ //uint32_t idx;
+ //float frac, samp0, samp1;
// Phasor increment
c->phase += c->inc;
+
+ //bitmask fun
+ //
+ uint32_t mask = c->phase >> 31;
+ int32_t val2 = c->phase + mask;
+ int32_t test = val2 ^ mask;
+ float output =( ((float)test * INV_TWO_TO_31)-0.5f) * 2.0f;
+ return output;
+
+ /*
// Wavetable synthesis
idx = c->phase >> 21;
uint32_t idx2 = (idx + 1) & c->mask;
@@ -3054,7 +3064,9 @@
float oct0 = (samp0 + (samp1 - samp0) * frac);
- return oct0;
+ return oct0;
+ */
+
}
void tTriLFO_setFreq(tTriLFO* const cy, float freq)
@@ -3112,7 +3124,7 @@
_tSineTriLFO* c = *cy;
float a = tCycle_tick(&c->sine);
float b = tTriLFO_tick(&c->tri);
- return (1 - c->shape) * a + c->shape * b;
+ return (1 - c->shape) * a + c->shape * -1.0f * b;
}
void tSineTriLFO_setFreq (tSineTriLFO* const cy, float freq)
{