| @@ -1271,16 +1271,16 @@ float tMinBLEP_tick (tMinBLEP* const minblep, float input) · 1270 unmodified lines |
| 1271 | 1271 | float adjusted_Freq = m->overSamplingRatio*m->proportionalBlepFreq;//m->freqMultiple[i]; |
| 1272 | 1272 | float exactPosition = m->offset[i]; |
| 1273 | 1273 | |
| 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); |
| 1277 | 1277 | |
| 1278 | 1278 | // LIMIT the scaling on the derivative array |
| 1279 | 1279 | // 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); |
| 1284 | 1284 | |
| 1285 | 1285 | |
| 1286 | 1286 | // DONE ... we reached the end ... |
| @@ -1371,7 +1371,7 @@ void tMBTriangle_initToPool (tMBTriangle* const osc, tMempool* const mp) · 84 unmodified lines |
| 1371 | 1371 | c->lastOut = 0.0f; |
| 1372 | 1372 | |
| 1373 | 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 | |
| 1377 | 1377 | void tMBTriangle_freeFromPool (tMBTriangle* const cy, tMempool* const mp) |
| @@ -1390,7 +1390,7 @@ float tMBTriangle_tick (tMBTriangle* const osc) · 12 unmodified lines |
| 1390 | 1390 | _tMBTriangle* c = *osc; |
| 1391 | 1391 | |
| 1392 | 1392 | float out; |
| 1393 | | − |
| 1393 | + |
| 1394 | 1394 | c->phase += c->inc; |
| 1395 | 1395 | if (c->phase >= 1.0f) |
| 1396 | 1396 | { |
| @@ -1403,7 +1403,7 @@ float tMBTriangle_tick (tMBTriangle* const osc) · 6 unmodified lines |
| 1403 | 1403 | float offset = 1.0f - ((c->inc - c->phase + c->skew) / c->inc); |
| 1404 | 1404 | tMinBLEP_addBLEP(&c->minBlep, offset, 2, 0.0f); |
| 1405 | 1405 | } |
| 1406 | | − |
| 1406 | + |
| 1407 | 1407 | if (c->phase < c->skew) |
| 1408 | 1408 | { |
| 1409 | 1409 | out = (1.0f - c->skew) * 2.0f; |
| @@ -1412,15 +1412,37 @@ float tMBTriangle_tick (tMBTriangle* const osc) · 2 unmodified lines |
| 1412 | 1412 | { |
| 1413 | 1413 | out = -c->skew * 2.0f; |
| 1414 | 1414 | } |
| 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; |
| 1419 | 1417 | |
| 1420 | 1418 | out = (c->inc * out) + ((1 - c->inc) * c->lastOut); |
| 1421 | 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 | |
| 1426 | 1448 | void tMBTriangle_setFreq (tMBTriangle* const osc, float freq) |
| @@ -1442,22 +1464,27 @@ void tMBTriangle_setSkew (tMBTriangle* const osc, float skew) · 15 unmodified lines |
| 1442 | 1464 | void tMBTriangle_sync (tMBTriangle* const osc, float phase) |
| 1443 | 1465 | { |
| 1444 | 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; |
| 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; |
| 1451 | 1477 | |
| 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; |
| 1454 | 1480 | |
| 1455 | 1481 | c->phase = phase; |
| 1456 | 1482 | |
| 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); |
| 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 | 1536 | c->phase -= 1.0f; |
| 1510 | 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 | 1540 | if (c->width <= c->phase && c->phase < c->width + c->inc) |
| 1514 | 1541 | { |
| 1515 | 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 | 1546 | float out; |
| 1520 | 1547 | if (c->phase < c->width) out = 1.0f; |
| 1521 | 1548 | else out = -1.0f; |
| 1522 | 1549 | |
| 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)); |
| 1528 | 1551 | } |
| 1529 | 1552 | |
| 1530 | 1553 | void tMBPulse_setFreq (tMBPulse* const osc, float freq) |
| @@ -1544,20 +1567,21 @@ void tMBPulse_setWidth (tMBPulse* const osc, float width) · 13 unmodified lines |
| 1544 | 1567 | void tMBPulse_sync (tMBPulse* const osc, float phase) |
| 1545 | 1568 | { |
| 1546 | 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; |
| 1552 | | − else last = -1.0f; |
| 1575 | + if (c->phase < c->width) before = 1.0f; |
| 1576 | + else before = -1.0f; |
| 1553 | 1577 | |
| 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; |
| 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); |
| 1560 | | − tMinBLEP_addBLEP(&c->minBlep, offset, last - next, 0.0f); |
| 1584 | + c->phase = phase; |
| 1561 | 1585 | } |
| 1562 | 1586 | |
| 1563 | 1587 | |
| @@ -1606,14 +1630,12 @@ float tMBSaw_tick (tMBSaw* const osc) · 42 unmodified lines |
| 1606 | 1630 | { |
| 1607 | 1631 | c->phase -= 1.0f; |
| 1608 | 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 | 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; |
| 1615 | | − |
| 1616 | | −// return tMinBLEP_tick(&c->minBlep, out) - c->inc * 2.0f; |
| 1638 | + return tHighpass_tick(&c->dcBlock, tMinBLEP_tick(&c->minBlep, out)); |
| 1617 | 1639 | } |
| 1618 | 1640 | |
| 1619 | 1641 | void tMBSaw_setFreq (tMBSaw* const osc, float freq) |
| @@ -1628,10 +1650,11 @@ void tMBSaw_setFreq (tMBSaw* const osc, float freq) · 8 unmodified lines |
| 1628 | 1650 | void tMBSaw_sync (tMBSaw* const osc, float phase) |
| 1629 | 1651 | { |
| 1630 | 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); |
| 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); |
| 1635 | 1658 | |
| 1636 | 1659 | c->phase = phase; |
| 1637 | 1660 | } |