History

hard syncing

Matthew Wang committed 6 years ago

Commit 1bea5d71 parent 482f07c2 files · +78 −51Browse files

Unified · Split

2 files
  1. LEAF/Src/leaf-oscillators.c +70 −47
  2. LEAF_JUCEPlugin/Source/MyTest.cpp +8 −4
LEAF/Src/leaf-oscillators.c+70−47
@@ -1271,16 +1271,16 @@ float tMinBLEP_tick (tMinBLEP* const minblep, float input) · 1270 unmodified lines
12711271 float adjusted_Freq = m->overSamplingRatio*m->proportionalBlepFreq;//m->freqMultiple[i];
12721272 float exactPosition = m->offset[i];
12731273
1274− double blepPosExact = adjusted_Freq*(exactPosition + 1); // +1 because this needs to trigger on the LOW SAMPLE
1275− double blepPosSample = 0;
1276− double fraction = modf(blepPosExact, &blepPosSample);
1274+ float blepPosExact = adjusted_Freq*(exactPosition + 1); // +1 because this needs to trigger on the LOW SAMPLE
1275+ float blepPosSample = 0;
1276+ float fraction = modff(blepPosExact, &blepPosSample);
12771277
12781278 // LIMIT the scaling on the derivative array
12791279 // otherwise, it can get TOO large
1280− double depthLimited = m->proportionalBlepFreq; //jlimit<double>(.1, 1, proportionalBlepFreq);
1281− double blepDeriv_PosExact = depthLimited*m->overSamplingRatio*(exactPosition + 1);
1282− double blepDeriv_Sample = 0;
1283− double fraction_Deriv = modf(blepDeriv_PosExact, &blepDeriv_Sample);
1280+ float depthLimited = m->proportionalBlepFreq; //jlimit<double>(.1, 1, proportionalBlepFreq);
1281+ float blepDeriv_PosExact = depthLimited*m->overSamplingRatio*(exactPosition + 1);
1282+ float blepDeriv_Sample = 0;
1283+ float fraction_Deriv = modff(blepDeriv_PosExact, &blepDeriv_Sample);
12841284
12851285
12861286 // DONE ... we reached the end ...
@@ -1371,7 +1371,7 @@ void tMBTriangle_initToPool (tMBTriangle* const osc, tMempool* const mp) · 84 unmodified lines
13711371 c->lastOut = 0.0f;
13721372
13731373 tMinBLEP_initToPool(&c->minBlep, 16, 32, mp);
1374− tHighpass_initToPool(&c->dcBlock, 10.0f, mp);
1374+ tHighpass_initToPool(&c->dcBlock, 5.0f, mp);
13751375 }
13761376
13771377 void tMBTriangle_freeFromPool (tMBTriangle* const cy, tMempool* const mp)
@@ -1390,7 +1390,7 @@ float tMBTriangle_tick (tMBTriangle* const osc) · 12 unmodified lines
13901390 _tMBTriangle* c = *osc;
13911391
13921392 float out;
1393−
1393+
13941394 c->phase += c->inc;
13951395 if (c->phase >= 1.0f)
13961396 {
@@ -1403,7 +1403,7 @@ float tMBTriangle_tick (tMBTriangle* const osc) · 6 unmodified lines
14031403 float offset = 1.0f - ((c->inc - c->phase + c->skew) / c->inc);
14041404 tMinBLEP_addBLEP(&c->minBlep, offset, 2, 0.0f);
14051405 }
1406−
1406+
14071407 if (c->phase < c->skew)
14081408 {
14091409 out = (1.0f - c->skew) * 2.0f;
@@ -1412,15 +1412,37 @@ float tMBTriangle_tick (tMBTriangle* const osc) · 2 unmodified lines
14121412 {
14131413 out = -c->skew * 2.0f;
14141414 }
1415−
1416− out = tHighpass_tick(&c->dcBlock, tMinBLEP_tick(&c->minBlep, out));// - phasor->inc * 2.0f;
1417−
1418−// out = tMinBLEP_tick(&c->minBlep, out) - c->inc * 2.0f;
1415+
1416+ out = tMinBLEP_tick(&c->minBlep, out);// - phasor->inc * 2.0f;
14191417
14201418 out = (c->inc * out) + ((1 - c->inc) * c->lastOut);
14211419 c->lastOut = out;
14221420
1423− return out;
1421+ return tHighpass_tick(&c->dcBlock, out * 4.0f);
1422+
1423+// float offset;
1424+// float vel = 2;
1425+// c->phase += c->inc;
1426+// if (c->phase >= 1.0f)
1427+// {
1428+// c->phase -= 1.0f;
1429+// offset = 1.0f - ((c->inc - c->phase) / c->inc);
1430+// tMinBLEP_addBLEP(&c->minBlep, offset, 0.0f, -vel);
1431+// }
1432+// if (c->skew <= c->phase && c->phase < c->skew + c->inc)
1433+// {
1434+// offset = 1.0f - ((c->inc - c->phase + c->skew) / c->inc);
1435+// tMinBLEP_addBLEP(&c->minBlep, offset, 0.0f, vel);
1436+// }
1437+//
1438+// float out;
1439+// if (c->phase < c->skew) out = 1.0f - (c->phase / c->skew);
1440+// else out = (c->phase - c->skew) / (1 - c->skew);
1441+//
1442+// out = (out - 0.5f) * 2.0f;
1443+//
1444+//// return tHighpass_tick(&c->dcBlock, tMinBLEP_tick(&c->minBlep, out));
1445+// return tMinBLEP_tick(&c->minBlep, out);
14241446 }
14251447
14261448 void tMBTriangle_setFreq (tMBTriangle* const osc, float freq)
@@ -1442,22 +1464,27 @@ void tMBTriangle_setSkew (tMBTriangle* const osc, float skew) · 15 unmodified lines
14421464 void tMBTriangle_sync (tMBTriangle* const osc, float phase)
14431465 {
14441466 _tMBTriangle* c = *osc;
1445− LEAF_clip(0.0f, phase, 1.0f);
14461467
1447− float last, next;
1468+ phase += 0.5f;
1469+
1470+ int intPart = (int) phase;
1471+ phase = phase - (float) intPart;
1472+
1473+ float before, after;
14481474
1449− if (c->phase < c->skew) last = (1.0f - c->skew - c->phase) * 2.0f;
1450− else last = -(c->phase - c->skew) * 2.0f;
1475+ if (c->phase < c->skew) before = (1.0f - c->skew - c->phase) * 2.0f;
1476+ else before = -(c->skew - c->phase) * 2.0f;
14511477
1452− if (phase < c->skew) next = (1.0f - c->skew - phase) * 2.0f;
1453− else next = -(phase - c->skew) * 2.0f;
1478+ if (phase < c->skew) after = (1.0f - c->skew - c->phase) * 2.0f;
1479+ else after = -(c->skew - c->phase) * 2.0f;
14541480
14551481 c->phase = phase;
14561482
1457− float offset = 1.0f - ((c->inc - c->phase) / c->inc);
1458− tMinBLEP_addBLEP(&c->minBlep, offset, last - next, 0.0f);
1483+ float offset = 0.0f;//1.0f - ((c->inc - c->phase) / c->inc);
1484+ tMinBLEP_addBLEP(&c->minBlep, offset, before - after, 0.0f);
14591485
1460−// c->lastOut = 0.0f;
1486+ if (c->phase < c->skew) c->lastOut = 1.0f - (c->phase / c->skew);
1487+ else c->lastOut = (c->phase - c->skew) / (1.0f - c->skew);
14611488 }
14621489
14631490 //==============================================================================
@@ -1508,23 +1535,19 @@ float tMBPulse_tick (tMBPulse* const osc) · 44 unmodified lines
15081535 {
15091536 c->phase -= 1.0f;
15101537 float offset = 1.0f - ((c->inc - c->phase) / c->inc);
1511− tMinBLEP_addBLEP(&c->minBlep, offset, -2, 0.0f);
1538+ tMinBLEP_addBLEP(&c->minBlep, offset, -2.0f, 0.0f);
15121539 }
15131540 if (c->width <= c->phase && c->phase < c->width + c->inc)
15141541 {
15151542 float offset = 1.0f - ((c->inc - c->phase + c->width) / c->inc);
1516− tMinBLEP_addBLEP(&c->minBlep, offset, 2, 0.0f);
1543+ tMinBLEP_addBLEP(&c->minBlep, offset, 2.0f, 0.0f);
15171544 }
15181545
15191546 float out;
15201547 if (c->phase < c->width) out = 1.0f;
15211548 else out = -1.0f;
15221549
1523− return tHighpass_tick(&c->dcBlock, tMinBLEP_tick(&c->minBlep, out));// - phasor->inc * 2.0f;
1524−
1525−
1526−
1527− return out;
1550+ return tHighpass_tick(&c->dcBlock, tMinBLEP_tick(&c->minBlep, out));
15281551 }
15291552
15301553 void tMBPulse_setFreq (tMBPulse* const osc, float freq)
@@ -1544,20 +1567,21 @@ void tMBPulse_setWidth (tMBPulse* const osc, float width) · 13 unmodified lines
15441567 void tMBPulse_sync (tMBPulse* const osc, float phase)
15451568 {
15461569 _tMBPulse* c = *osc;
1547− LEAF_clip(0.0f, phase, 1.0f);
1570+ int intPart = (int) phase;
1571+ phase = phase - (float) intPart;
15481572
1549− float last, next;
1573+ float before, after;
15501574
1551− if (c->phase < c->width) last = 1.0f;
1552− else last = -1.0f;
1575+ if (c->phase < c->width) before = 1.0f;
1576+ else before = -1.0f;
15531577
1554− if (phase < c->width) next = 1.0;
1555− else next = -1.0f;
1578+ if (phase < c->width) after = 1.0;
1579+ else after = -1.0f;
15561580
1557− c->phase = phase;
1581+ float offset = 0.0f;//1.0f - ((c->inc - c->phase) / c->inc);
1582+ tMinBLEP_addBLEP(&c->minBlep, offset, before - after, 0.0f);
15581583
1559− float offset = 1.0f - ((c->inc - c->phase) / c->inc);
1560− tMinBLEP_addBLEP(&c->minBlep, offset, last - next, 0.0f);
1584+ c->phase = phase;
15611585 }
15621586
15631587
@@ -1606,14 +1630,12 @@ float tMBSaw_tick (tMBSaw* const osc) · 42 unmodified lines
16061630 {
16071631 c->phase -= 1.0f;
16081632 float offset = 1.0f - ((c->inc - c->phase) / c->inc);
1609− tMinBLEP_addBLEP(&c->minBlep, offset, 2, 0.0f);
1633+ tMinBLEP_addBLEP(&c->minBlep, offset, 2.0f, 0.0f);
16101634 }
16111635
16121636 float out = (c->phase * 2.0f) - 1.0f;
16131637
1614− return tHighpass_tick(&c->dcBlock, tMinBLEP_tick(&c->minBlep, out));// - phasor->inc * 2.0f;
1615−
1616−// return tMinBLEP_tick(&c->minBlep, out) - c->inc * 2.0f;
1638+ return tHighpass_tick(&c->dcBlock, tMinBLEP_tick(&c->minBlep, out));
16171639 }
16181640
16191641 void tMBSaw_setFreq (tMBSaw* const osc, float freq)
@@ -1628,10 +1650,11 @@ void tMBSaw_setFreq (tMBSaw* const osc, float freq) · 8 unmodified lines
16281650 void tMBSaw_sync (tMBSaw* const osc, float phase)
16291651 {
16301652 _tMBSaw* c = *osc;
1631− LEAF_clip(0.0f, phase, 1.0f);
1653+ int intPart = (int) phase;
1654+ phase = phase - (float) intPart;
16321655
1633− float offset = 1.0f - ((c->inc - phase) / c->inc);
1634− tMinBLEP_addBLEP(&c->minBlep, offset, c->phase * 2.0f, 0.0f);
1656+ float offset = 0.0f;//1.0f - ((c->inc - phase +) / c->inc);
1657+ tMinBLEP_addBLEP(&c->minBlep, offset, (c->phase - phase) * 2.0f, 0.0f);
16351658
16361659 c->phase = phase;
16371660 }
LEAF_JUCEPlugin/Source/MyTest.cpp+8−4
@@ -60,7 +60,7 @@ void LEAFTest_init (float sampleRate, int blockSize) · 59 unmodified lines
6060
6161 tPhasor_init(&phasor);
6262
63− tPhasor_setFreq(&phasor, 2000);
63+ tPhasor_setFreq(&phasor, 200);
6464 }
6565
6666 inline double getSawFall(double angle) {
@@ -78,14 +78,18 @@ float LEAFTest_tick (float input) · 11 unmodified lines
7878 tMBSaw_setFreq(&saw, y);
7979 tMBPulse_setWidth(&pulse, x);
8080 tMBPulse_setFreq(&pulse, y);
81− tMBTriangle_setSkew(&tri, x*2.0f - 1.0f);
81+ tMBTriangle_setSkew(&tri, 0.0);//x*2.0f - 1.0f);
8282 tMBTriangle_setFreq(&tri, y);
8383
8484 tPhasor_tick(&phasor);
8585
8686 // if (phasor->phaseDidReset) tMBSaw_sync(&saw, 0.0f);
87+// if (phasor->phaseDidReset) tMBPulse_sync(&pulse, 0.0f);
88+ if (phasor->phaseDidReset) tMBTriangle_sync(&tri, 0.0f);
8789
88− return tMBSaw_tick(&saw);// - phasor->inc * 2.0f;
90+// return tMBSaw_tick(&saw);
91+// return tMBPulse_tick(&pulse);
92+ return tMBTriangle_tick(&tri);
8993 }
9094
9195 int firstFrame = 1;
@@ -109,7 +113,7 @@ void LEAFTest_block (void) · 17 unmodified lines
109113
110114 val = getSliderValue("mod depth");
111115
112− y = val * 20000.0f + 20.0f;
116+ y = val * 5000.0f + 20.0f;
113117
114118 DBG(String(y));
115119 // b = val * tBuffer_getBufferLength(&buff);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t