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
1271 float adjusted_Freq = m->overSamplingRatio*m->proportionalBlepFreq;//m->freqMultiple[i];1271 float adjusted_Freq = m->overSamplingRatio*m->proportionalBlepFreq;//m->freqMultiple[i];
1272 float exactPosition = m->offset[i];1272 float exactPosition = m->offset[i];
1273 1273
1274 double blepPosExact = adjusted_Freq*(exactPosition + 1); // +1 because this needs to trigger on the LOW SAMPLE1274 float blepPosExact = adjusted_Freq*(exactPosition + 1); // +1 because this needs to trigger on the LOW SAMPLE
1275 double blepPosSample = 0;1275 float blepPosSample = 0;
1276 double fraction = modf(blepPosExact, &blepPosSample);1276 float fraction = modff(blepPosExact, &blepPosSample);
1277 1277
1278 // LIMIT the scaling on the derivative array1278 // LIMIT the scaling on the derivative array
1279 // otherwise, it can get TOO large1279 // otherwise, it can get TOO large
1280 double depthLimited = m->proportionalBlepFreq; //jlimit<double>(.1, 1, proportionalBlepFreq);1280 float depthLimited = m->proportionalBlepFreq; //jlimit<double>(.1, 1, proportionalBlepFreq);
1281 double blepDeriv_PosExact = depthLimited*m->overSamplingRatio*(exactPosition + 1);1281 float blepDeriv_PosExact = depthLimited*m->overSamplingRatio*(exactPosition + 1);
1282 double blepDeriv_Sample = 0;1282 float blepDeriv_Sample = 0;
1283 double fraction_Deriv = modf(blepDeriv_PosExact, &blepDeriv_Sample);1283 float fraction_Deriv = modff(blepDeriv_PosExact, &blepDeriv_Sample);
1284 1284
1285 1285
1286 // DONE ... we reached the end ...1286 // DONE ... we reached the end ...
@@ -1371,7 +1371,7 @@ void tMBTriangle_initToPool (tMBTriangle* const osc, tMempool* const mp) · 84 unmodified lines
1371 c->lastOut = 0.0f;1371 c->lastOut = 0.0f;
1372 1372
1373 tMinBLEP_initToPool(&c->minBlep, 16, 32, mp);1373 tMinBLEP_initToPool(&c->minBlep, 16, 32, mp);
1374 tHighpass_initToPool(&c->dcBlock, 10.0f, mp);1374 tHighpass_initToPool(&c->dcBlock, 5.0f, mp);
1375}1375}
1376 1376
1377void tMBTriangle_freeFromPool (tMBTriangle* const cy, tMempool* const mp)1377void tMBTriangle_freeFromPool (tMBTriangle* const cy, tMempool* const mp)
@@ -1390,7 +1390,7 @@ float tMBTriangle_tick (tMBTriangle* const osc) · 12 unmodified lines
1390 _tMBTriangle* c = *osc;1390 _tMBTriangle* c = *osc;
1391 1391
1392 float out;1392 float out;
1393 1393
1394 c->phase += c->inc;1394 c->phase += c->inc;
1395 if (c->phase >= 1.0f)1395 if (c->phase >= 1.0f)
1396 {1396 {
@@ -1403,7 +1403,7 @@ float tMBTriangle_tick (tMBTriangle* const osc) · 6 unmodified lines
1403 float offset = 1.0f - ((c->inc - c->phase + c->skew) / c->inc);1403 float offset = 1.0f - ((c->inc - c->phase + c->skew) / c->inc);
1404 tMinBLEP_addBLEP(&c->minBlep, offset, 2, 0.0f);1404 tMinBLEP_addBLEP(&c->minBlep, offset, 2, 0.0f);
1405 }1405 }
1406 1406
1407 if (c->phase < c->skew)1407 if (c->phase < c->skew)
1408 {1408 {
1409 out = (1.0f - c->skew) * 2.0f;1409 out = (1.0f - c->skew) * 2.0f;
@@ -1412,15 +1412,37 @@ float tMBTriangle_tick (tMBTriangle* const osc) · 2 unmodified lines
1412 {1412 {
1413 out = -c->skew * 2.0f;1413 out = -c->skew * 2.0f;
1414 }1414 }
1415 1415
1416 out = tHighpass_tick(&c->dcBlock, tMinBLEP_tick(&c->minBlep, out));// - phasor->inc * 2.0f;1416 out = tMinBLEP_tick(&c->minBlep, out);// - phasor->inc * 2.0f;
1417
1418// out = tMinBLEP_tick(&c->minBlep, out) - c->inc * 2.0f;
1419 1417
1420 out = (c->inc * out) + ((1 - c->inc) * c->lastOut);1418 out = (c->inc * out) + ((1 - c->inc) * c->lastOut);
1421 c->lastOut = out;1419 c->lastOut = out;
1422 1420
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);
1424}1446}
1425 1447
1426void tMBTriangle_setFreq (tMBTriangle* const osc, float freq)1448void tMBTriangle_setFreq (tMBTriangle* const osc, float freq)
@@ -1442,22 +1464,27 @@ void tMBTriangle_setSkew (tMBTriangle* const osc, float skew) · 15 unmodified lines
1442void tMBTriangle_sync (tMBTriangle* const osc, float phase)1464void tMBTriangle_sync (tMBTriangle* const osc, float phase)
1443{1465{
1444 _tMBTriangle* c = *osc;1466 _tMBTriangle* c = *osc;
1445 LEAF_clip(0.0f, phase, 1.0f);
1446 1467
1447 float last, next;1468 phase += 0.5f;
1469
1470 int intPart = (int) phase;
1471 phase = phase - (float) intPart;
1472
1473 float before, after;
1448 1474
1449 if (c->phase < c->skew) last = (1.0f - c->skew - c->phase) * 2.0f;1475 if (c->phase < c->skew) before = (1.0f - c->skew - c->phase) * 2.0f;
1450 else last = -(c->phase - c->skew) * 2.0f;1476 else before = -(c->skew - c->phase) * 2.0f;
1451 1477
1452 if (phase < c->skew) next = (1.0f - c->skew - phase) * 2.0f;1478 if (phase < c->skew) after = (1.0f - c->skew - c->phase) * 2.0f;
1453 else next = -(phase - c->skew) * 2.0f;1479 else after = -(c->skew - c->phase) * 2.0f;
1454 1480
1455 c->phase = phase;1481 c->phase = phase;
1456 1482
1457 float offset = 1.0f - ((c->inc - c->phase) / c->inc);1483 float offset = 0.0f;//1.0f - ((c->inc - c->phase) / c->inc);
1458 tMinBLEP_addBLEP(&c->minBlep, offset, last - next, 0.0f);1484 tMinBLEP_addBLEP(&c->minBlep, offset, before - after, 0.0f);
1459 1485
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);
1461}1488}
1462 1489
1463//==============================================================================1490//==============================================================================
@@ -1508,23 +1535,19 @@ float tMBPulse_tick (tMBPulse* const osc) · 44 unmodified lines
1508 {1535 {
1509 c->phase -= 1.0f;1536 c->phase -= 1.0f;
1510 float offset = 1.0f - ((c->inc - c->phase) / c->inc);1537 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);
1512 }1539 }
1513 if (c->width <= c->phase && c->phase < c->width + c->inc)1540 if (c->width <= c->phase && c->phase < c->width + c->inc)
1514 {1541 {
1515 float offset = 1.0f - ((c->inc - c->phase + c->width) / c->inc);1542 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);
1517 }1544 }
1518 1545
1519 float out;1546 float out;
1520 if (c->phase < c->width) out = 1.0f;1547 if (c->phase < c->width) out = 1.0f;
1521 else out = -1.0f;1548 else out = -1.0f;
1522 1549
1523 return tHighpass_tick(&c->dcBlock, tMinBLEP_tick(&c->minBlep, out));// - phasor->inc * 2.0f;1550 return tHighpass_tick(&c->dcBlock, tMinBLEP_tick(&c->minBlep, out));
1524
1525
1526
1527 return out;
1528}1551}
1529 1552
1530void tMBPulse_setFreq (tMBPulse* const osc, float freq)1553void tMBPulse_setFreq (tMBPulse* const osc, float freq)
@@ -1544,20 +1567,21 @@ void tMBPulse_setWidth (tMBPulse* const osc, float width) · 13 unmodified lines
1544void tMBPulse_sync (tMBPulse* const osc, float phase)1567void tMBPulse_sync (tMBPulse* const osc, float phase)
1545{1568{
1546 _tMBPulse* c = *osc;1569 _tMBPulse* c = *osc;
1547 LEAF_clip(0.0f, phase, 1.0f);1570 int intPart = (int) phase;
1571 phase = phase - (float) intPart;
1548 1572
1549 float last, next;1573 float before, after;
1550 1574
1551 if (c->phase < c->width) last = 1.0f;1575 if (c->phase < c->width) before = 1.0f;
1552 else last = -1.0f;1576 else before = -1.0f;
1553 1577
1554 if (phase < c->width) next = 1.0;1578 if (phase < c->width) after = 1.0;
1555 else next = -1.0f;1579 else after = -1.0f;
1556 1580
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);
1558 1583
1559 float offset = 1.0f - ((c->inc - c->phase) / c->inc);1584 c->phase = phase;
1560 tMinBLEP_addBLEP(&c->minBlep, offset, last - next, 0.0f);
1561}1585}
1562 1586
1563 1587
@@ -1606,14 +1630,12 @@ float tMBSaw_tick (tMBSaw* const osc) · 42 unmodified lines
1606 {1630 {
1607 c->phase -= 1.0f;1631 c->phase -= 1.0f;
1608 float offset = 1.0f - ((c->inc - c->phase) / c->inc);1632 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);
1610 }1634 }
1611 1635
1612 float out = (c->phase * 2.0f) - 1.0f;1636 float out = (c->phase * 2.0f) - 1.0f;
1613 1637
1614 return tHighpass_tick(&c->dcBlock, tMinBLEP_tick(&c->minBlep, out));// - phasor->inc * 2.0f;1638 return tHighpass_tick(&c->dcBlock, tMinBLEP_tick(&c->minBlep, out));
1615
1616// return tMinBLEP_tick(&c->minBlep, out) - c->inc * 2.0f;
1617}1639}
1618 1640
1619void tMBSaw_setFreq (tMBSaw* const osc, float freq)1641void tMBSaw_setFreq (tMBSaw* const osc, float freq)
@@ -1628,10 +1650,11 @@ void tMBSaw_setFreq (tMBSaw* const osc, float freq) · 8 unmodified lines
1628void tMBSaw_sync (tMBSaw* const osc, float phase)1650void tMBSaw_sync (tMBSaw* const osc, float phase)
1629{1651{
1630 _tMBSaw* c = *osc;1652 _tMBSaw* c = *osc;
1631 LEAF_clip(0.0f, phase, 1.0f);1653 int intPart = (int) phase;
1654 phase = phase - (float) intPart;
1632 1655
1633 float offset = 1.0f - ((c->inc - phase) / c->inc);1656 float offset = 0.0f;//1.0f - ((c->inc - phase +) / c->inc);
1634 tMinBLEP_addBLEP(&c->minBlep, offset, c->phase * 2.0f, 0.0f);1657 tMinBLEP_addBLEP(&c->minBlep, offset, (c->phase - phase) * 2.0f, 0.0f);
1635 1658
1636 c->phase = phase;1659 c->phase = phase;
1637}1660}
LEAF_JUCEPlugin/Source/MyTest.cpp+8−4
@@ -60,7 +60,7 @@ void LEAFTest_init (float sampleRate, int blockSize) · 59 unmodified lines
60 60
61 tPhasor_init(&phasor);61 tPhasor_init(&phasor);
62 62
63 tPhasor_setFreq(&phasor, 2000);63 tPhasor_setFreq(&phasor, 200);
64}64}
65 65
66inline double getSawFall(double angle) {66inline double getSawFall(double angle) {
@@ -78,14 +78,18 @@ float LEAFTest_tick (float input) · 11 unmodified lines
78 tMBSaw_setFreq(&saw, y);78 tMBSaw_setFreq(&saw, y);
79 tMBPulse_setWidth(&pulse, x);79 tMBPulse_setWidth(&pulse, x);
80 tMBPulse_setFreq(&pulse, y);80 tMBPulse_setFreq(&pulse, y);
81 tMBTriangle_setSkew(&tri, x*2.0f - 1.0f);81 tMBTriangle_setSkew(&tri, 0.0);//x*2.0f - 1.0f);
82 tMBTriangle_setFreq(&tri, y);82 tMBTriangle_setFreq(&tri, y);
83 83
84 tPhasor_tick(&phasor);84 tPhasor_tick(&phasor);
85 85
86// if (phasor->phaseDidReset) tMBSaw_sync(&saw, 0.0f);86// 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);
87 89
88 return tMBSaw_tick(&saw);// - phasor->inc * 2.0f;90// return tMBSaw_tick(&saw);
91// return tMBPulse_tick(&pulse);
92 return tMBTriangle_tick(&tri);
89}93}
90 94
91int firstFrame = 1;95int firstFrame = 1;
@@ -109,7 +113,7 @@ void LEAFTest_block (void) · 17 unmodified lines
109 113
110 val = getSliderValue("mod depth");114 val = getSliderValue("mod depth");
111 115
112 y = val * 20000.0f + 20.0f;116 y = val * 5000.0f + 20.0f;
113 117
114 DBG(String(y));118 DBG(String(y));
115 // b = val * tBuffer_getBufferLength(&buff);119 // 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