ref: 1bea5d76d5b4ad8ec19112d07008fc5f0e46509c
parent: 482f07c8138ec548f0d371bedebc560dd5f9b5d3
author: Matthew Wang <mjw7@princeton.edu>
date: Wed May 20 11:59:10 EDT 2020
hard syncing
--- a/LEAF/Src/leaf-oscillators.c
+++ b/LEAF/Src/leaf-oscillators.c
@@ -1271,16 +1271,16 @@
float adjusted_Freq = m->overSamplingRatio*m->proportionalBlepFreq;//m->freqMultiple[i];
float exactPosition = m->offset[i];
- double blepPosExact = adjusted_Freq*(exactPosition + 1); // +1 because this needs to trigger on the LOW SAMPLE
- double blepPosSample = 0;
- double fraction = modf(blepPosExact, &blepPosSample);
+ float blepPosExact = adjusted_Freq*(exactPosition + 1); // +1 because this needs to trigger on the LOW SAMPLE
+ float blepPosSample = 0;
+ float fraction = modff(blepPosExact, &blepPosSample);
// LIMIT the scaling on the derivative array
// otherwise, it can get TOO large
- double depthLimited = m->proportionalBlepFreq; //jlimit<double>(.1, 1, proportionalBlepFreq);
- double blepDeriv_PosExact = depthLimited*m->overSamplingRatio*(exactPosition + 1);
- double blepDeriv_Sample = 0;
- double fraction_Deriv = modf(blepDeriv_PosExact, &blepDeriv_Sample);
+ float depthLimited = m->proportionalBlepFreq; //jlimit<double>(.1, 1, proportionalBlepFreq);
+ float blepDeriv_PosExact = depthLimited*m->overSamplingRatio*(exactPosition + 1);
+ float blepDeriv_Sample = 0;
+ float fraction_Deriv = modff(blepDeriv_PosExact, &blepDeriv_Sample);
// DONE ... we reached the end ...
@@ -1371,7 +1371,7 @@
c->lastOut = 0.0f;
tMinBLEP_initToPool(&c->minBlep, 16, 32, mp);
- tHighpass_initToPool(&c->dcBlock, 10.0f, mp);
+ tHighpass_initToPool(&c->dcBlock, 5.0f, mp);
}
void tMBTriangle_freeFromPool (tMBTriangle* const cy, tMempool* const mp)
@@ -1390,7 +1390,7 @@
_tMBTriangle* c = *osc;
float out;
-
+
c->phase += c->inc;
if (c->phase >= 1.0f)
{
@@ -1403,7 +1403,7 @@
float offset = 1.0f - ((c->inc - c->phase + c->skew) / c->inc);
tMinBLEP_addBLEP(&c->minBlep, offset, 2, 0.0f);
}
-
+
if (c->phase < c->skew)
{
out = (1.0f - c->skew) * 2.0f;
@@ -1412,15 +1412,37 @@
{
out = -c->skew * 2.0f;
}
+
+ out = tMinBLEP_tick(&c->minBlep, out);// - phasor->inc * 2.0f;
- out = tHighpass_tick(&c->dcBlock, tMinBLEP_tick(&c->minBlep, out));// - phasor->inc * 2.0f;
-
-// out = tMinBLEP_tick(&c->minBlep, out) - c->inc * 2.0f;
-
out = (c->inc * out) + ((1 - c->inc) * c->lastOut);
c->lastOut = out;
- return out;
+ return tHighpass_tick(&c->dcBlock, out * 4.0f);
+
+// float offset;
+// float vel = 2;
+// c->phase += c->inc;
+// if (c->phase >= 1.0f)
+// {
+// c->phase -= 1.0f;
+// offset = 1.0f - ((c->inc - c->phase) / c->inc);
+// tMinBLEP_addBLEP(&c->minBlep, offset, 0.0f, -vel);
+// }
+// if (c->skew <= c->phase && c->phase < c->skew + c->inc)
+// {
+// offset = 1.0f - ((c->inc - c->phase + c->skew) / c->inc);
+// tMinBLEP_addBLEP(&c->minBlep, offset, 0.0f, vel);
+// }
+//
+// float out;
+// if (c->phase < c->skew) out = 1.0f - (c->phase / c->skew);
+// else out = (c->phase - c->skew) / (1 - c->skew);
+//
+// out = (out - 0.5f) * 2.0f;
+//
+//// return tHighpass_tick(&c->dcBlock, tMinBLEP_tick(&c->minBlep, out));
+// return tMinBLEP_tick(&c->minBlep, out);
}
void tMBTriangle_setFreq (tMBTriangle* const osc, float freq)
@@ -1442,22 +1464,27 @@
void tMBTriangle_sync (tMBTriangle* const osc, float phase)
{
_tMBTriangle* c = *osc;
- LEAF_clip(0.0f, phase, 1.0f);
- float last, next;
+ phase += 0.5f;
- if (c->phase < c->skew) last = (1.0f - c->skew - c->phase) * 2.0f;
- else last = -(c->phase - c->skew) * 2.0f;
+ int intPart = (int) phase;
+ phase = phase - (float) intPart;
+
+ float before, after;
+
+ if (c->phase < c->skew) before = (1.0f - c->skew - c->phase) * 2.0f;
+ else before = -(c->skew - c->phase) * 2.0f;
- if (phase < c->skew) next = (1.0f - c->skew - phase) * 2.0f;
- else next = -(phase - c->skew) * 2.0f;
+ if (phase < c->skew) after = (1.0f - c->skew - c->phase) * 2.0f;
+ else after = -(c->skew - c->phase) * 2.0f;
c->phase = phase;
- float offset = 1.0f - ((c->inc - c->phase) / c->inc);
- tMinBLEP_addBLEP(&c->minBlep, offset, last - next, 0.0f);
+ float offset = 0.0f;//1.0f - ((c->inc - c->phase) / c->inc);
+ tMinBLEP_addBLEP(&c->minBlep, offset, before - after, 0.0f);
-// c->lastOut = 0.0f;
+ if (c->phase < c->skew) c->lastOut = 1.0f - (c->phase / c->skew);
+ else c->lastOut = (c->phase - c->skew) / (1.0f - c->skew);
}
//==============================================================================
@@ -1508,12 +1535,12 @@
{
c->phase -= 1.0f;
float offset = 1.0f - ((c->inc - c->phase) / c->inc);
- tMinBLEP_addBLEP(&c->minBlep, offset, -2, 0.0f);
+ tMinBLEP_addBLEP(&c->minBlep, offset, -2.0f, 0.0f);
}
if (c->width <= c->phase && c->phase < c->width + c->inc)
{
float offset = 1.0f - ((c->inc - c->phase + c->width) / c->inc);
- tMinBLEP_addBLEP(&c->minBlep, offset, 2, 0.0f);
+ tMinBLEP_addBLEP(&c->minBlep, offset, 2.0f, 0.0f);
}
float out;
@@ -1520,11 +1547,7 @@
if (c->phase < c->width) out = 1.0f;
else out = -1.0f;
- return tHighpass_tick(&c->dcBlock, tMinBLEP_tick(&c->minBlep, out));// - phasor->inc * 2.0f;
-
-
-
- return out;
+ return tHighpass_tick(&c->dcBlock, tMinBLEP_tick(&c->minBlep, out));
}
void tMBPulse_setFreq (tMBPulse* const osc, float freq)
@@ -1544,20 +1567,21 @@
void tMBPulse_sync (tMBPulse* const osc, float phase)
{
_tMBPulse* c = *osc;
- LEAF_clip(0.0f, phase, 1.0f);
+ int intPart = (int) phase;
+ phase = phase - (float) intPart;
- float last, next;
+ float before, after;
- if (c->phase < c->width) last = 1.0f;
- else last = -1.0f;
+ if (c->phase < c->width) before = 1.0f;
+ else before = -1.0f;
- if (phase < c->width) next = 1.0;
- else next = -1.0f;
+ if (phase < c->width) after = 1.0;
+ else after = -1.0f;
- c->phase = phase;
+ float offset = 0.0f;//1.0f - ((c->inc - c->phase) / c->inc);
+ tMinBLEP_addBLEP(&c->minBlep, offset, before - after, 0.0f);
- float offset = 1.0f - ((c->inc - c->phase) / c->inc);
- tMinBLEP_addBLEP(&c->minBlep, offset, last - next, 0.0f);
+ c->phase = phase;
}
@@ -1606,14 +1630,12 @@
{
c->phase -= 1.0f;
float offset = 1.0f - ((c->inc - c->phase) / c->inc);
- tMinBLEP_addBLEP(&c->minBlep, offset, 2, 0.0f);
+ tMinBLEP_addBLEP(&c->minBlep, offset, 2.0f, 0.0f);
}
float out = (c->phase * 2.0f) - 1.0f;
- return tHighpass_tick(&c->dcBlock, tMinBLEP_tick(&c->minBlep, out));// - phasor->inc * 2.0f;
-
-// return tMinBLEP_tick(&c->minBlep, out) - c->inc * 2.0f;
+ return tHighpass_tick(&c->dcBlock, tMinBLEP_tick(&c->minBlep, out));
}
void tMBSaw_setFreq (tMBSaw* const osc, float freq)
@@ -1628,10 +1650,11 @@
void tMBSaw_sync (tMBSaw* const osc, float phase)
{
_tMBSaw* c = *osc;
- LEAF_clip(0.0f, phase, 1.0f);
+ int intPart = (int) phase;
+ phase = phase - (float) intPart;
- float offset = 1.0f - ((c->inc - phase) / c->inc);
- tMinBLEP_addBLEP(&c->minBlep, offset, c->phase * 2.0f, 0.0f);
+ float offset = 0.0f;//1.0f - ((c->inc - phase +) / c->inc);
+ tMinBLEP_addBLEP(&c->minBlep, offset, (c->phase - phase) * 2.0f, 0.0f);
c->phase = phase;
}
--- a/LEAF_JUCEPlugin/Source/MyTest.cpp
+++ b/LEAF_JUCEPlugin/Source/MyTest.cpp
@@ -60,7 +60,7 @@
tPhasor_init(&phasor);
- tPhasor_setFreq(&phasor, 2000);
+ tPhasor_setFreq(&phasor, 200);
}
inline double getSawFall(double angle) {
@@ -78,14 +78,18 @@
tMBSaw_setFreq(&saw, y);
tMBPulse_setWidth(&pulse, x);
tMBPulse_setFreq(&pulse, y);
- tMBTriangle_setSkew(&tri, x*2.0f - 1.0f);
+ tMBTriangle_setSkew(&tri, 0.0);//x*2.0f - 1.0f);
tMBTriangle_setFreq(&tri, y);
tPhasor_tick(&phasor);
// if (phasor->phaseDidReset) tMBSaw_sync(&saw, 0.0f);
+// if (phasor->phaseDidReset) tMBPulse_sync(&pulse, 0.0f);
+ if (phasor->phaseDidReset) tMBTriangle_sync(&tri, 0.0f);
- return tMBSaw_tick(&saw);// - phasor->inc * 2.0f;
+// return tMBSaw_tick(&saw);
+// return tMBPulse_tick(&pulse);
+ return tMBTriangle_tick(&tri);
}
int firstFrame = 1;
@@ -109,7 +113,7 @@
val = getSliderValue("mod depth");
- y = val * 20000.0f + 20.0f;
+ y = val * 5000.0f + 20.0f;
DBG(String(y));
// b = val * tBuffer_getBufferLength(&buff);