| @@ -419,14 +419,20 @@ void tRetune_init(tRetune* const r, int numVoices, int bufSize, int frameSize) · 418 unmodified lines |
| 419 | 419 | r->fba = FBA; |
| 420 | 420 | tRetune_setTimeConstant(r, DEFTIMECONSTANT); |
| 421 | 421 | |
| 422 | | − tPeriodDetection_init(&r->pd, r->inBuffer, r->outBuffers[0], r->bufSize, r->frameSize); |
| 423 | | − |
| 424 | 422 | r->inputPeriod = 0.0f; |
| 425 | 423 | |
| 426 | 424 | r->ps = (tPitchShift*) leaf_alloc(sizeof(tPitchShift) * r->numVoices); |
| 425 | + r->pitchFactor = (float*) leaf_alloc(sizeof(float) * r->numVoices); |
| 426 | + r->tickOutput = (float*) leaf_alloc(sizeof(float) * r->numVoices); |
| 427 | 427 | for (int i = 0; i < r->numVoices; ++i) |
| 428 | 428 | { |
| 429 | 429 | r->outBuffers[i] = (float*) leaf_alloc(sizeof(float) * r->bufSize); |
| 430 | + } |
| 431 | + |
| 432 | + tPeriodDetection_init(&r->pd, r->inBuffer, r->outBuffers[0], r->bufSize, r->frameSize); |
| 433 | + |
| 434 | + for (int i = 0; i < r->numVoices; ++i) |
| 435 | + { |
| 430 | 436 | tPitchShift_init(&r->ps[i], &r->pd, r->outBuffers[i], r->bufSize); |
| 431 | 437 | } |
| 432 | 438 | } |
| @@ -439,6 +445,8 @@ void tRetune_free(tRetune* const r) · 6 unmodified lines |
| 439 | 445 | tPitchShift_free(&r->ps[i]); |
| 440 | 446 | leaf_free(r->outBuffers[i]); |
| 441 | 447 | } |
| 448 | + leaf_free(r->tickOutput); |
| 449 | + leaf_free(r->pitchFactor); |
| 442 | 450 | leaf_free(r->ps); |
| 443 | 451 | leaf_free(r->inBuffer); |
| 444 | 452 | leaf_free(r->outBuffers); |
| @@ -463,6 +471,8 @@ void tRetune_setNumVoices(tRetune* const r, int numVoices) · 18 unmodified lines |
| 463 | 471 | tPitchShift_free(&r->ps[i]); |
| 464 | 472 | leaf_free(r->outBuffers[i]); |
| 465 | 473 | } |
| 474 | + leaf_free(r->tickOutput); |
| 475 | + leaf_free(r->pitchFactor); |
| 466 | 476 | leaf_free(r->ps); |
| 467 | 477 | leaf_free(r->outBuffers); |
| 468 | 478 | |
| @@ -470,6 +480,8 @@ void tRetune_setNumVoices(tRetune* const r, int numVoices) · 1 unmodified line |
| 470 | 480 | |
| 471 | 481 | r->outBuffers = (float**) leaf_alloc(sizeof(float*) * r->numVoices); |
| 472 | 482 | r->ps = (tPitchShift*) leaf_alloc(sizeof(tPitchShift) * r->numVoices); |
| 483 | + r->pitchFactor = (float*) leaf_alloc(sizeof(float) * r->numVoices); |
| 484 | + r->tickOutput = (float*) leaf_alloc(sizeof(float) * r->numVoices); |
| 473 | 485 | for (int i = 0; i < r->numVoices; ++i) |
| 474 | 486 | { |
| 475 | 487 | r->outBuffers[i] = (float*) leaf_alloc(sizeof(float) * r->bufSize); |
| @@ -540,12 +552,20 @@ void tAutotune_init(tAutotune* const r, int numVoices, int bufSize, int frameSiz · 64 unmodified lines |
| 540 | 552 | r->fba = FBA; |
| 541 | 553 | tAutotune_setTimeConstant(r, DEFTIMECONSTANT); |
| 542 | 554 | |
| 543 | | − tPeriodDetection_init(&r->pd, r->inBuffer, r->outBuffers[0], r->bufSize, r->frameSize); |
| 555 | + |
| 544 | 556 | |
| 545 | 557 | r->ps = (tPitchShift*) leaf_alloc(sizeof(tPitchShift) * r->numVoices); |
| 558 | + r->freq = (float*) leaf_alloc(sizeof(float) * r->numVoices); |
| 559 | + r->tickOutput = (float*) leaf_alloc(sizeof(float) * r->numVoices); |
| 546 | 560 | for (int i = 0; i < r->numVoices; ++i) |
| 547 | 561 | { |
| 548 | 562 | r->outBuffers[i] = (float*) leaf_alloc(sizeof(float) * r->bufSize); |
| 563 | + } |
| 564 | + |
| 565 | + tPeriodDetection_init(&r->pd, r->inBuffer, r->outBuffers[0], r->bufSize, r->frameSize); |
| 566 | + |
| 567 | + for (int i = 0; i < r->numVoices; ++i) |
| 568 | + { |
| 549 | 569 | tPitchShift_init(&r->ps[i], &r->pd, r->outBuffers[i], r->bufSize); |
| 550 | 570 | } |
| 551 | 571 | |
| @@ -560,6 +580,8 @@ void tAutotune_free(tAutotune* const r) · 8 unmodified lines |
| 560 | 580 | tPitchShift_free(&r->ps[i]); |
| 561 | 581 | leaf_free(r->outBuffers[i]); |
| 562 | 582 | } |
| 583 | + leaf_free(r->tickOutput); |
| 584 | + leaf_free(r->freq); |
| 563 | 585 | leaf_free(r->ps); |
| 564 | 586 | leaf_free(r->inBuffer); |
| 565 | 587 | leaf_free(r->outBuffers); |
| @@ -584,6 +606,8 @@ void tAutotune_setNumVoices(tAutotune* const r, int numVoices) · 18 unmodified lines |
| 584 | 606 | tPitchShift_free(&r->ps[i]); |
| 585 | 607 | leaf_free(r->outBuffers[i]); |
| 586 | 608 | } |
| 609 | + leaf_free(r->tickOutput); |
| 610 | + leaf_free(r->freq); |
| 587 | 611 | leaf_free(r->ps); |
| 588 | 612 | leaf_free(r->outBuffers); |
| 589 | 613 | |
| @@ -591,6 +615,8 @@ void tAutotune_setNumVoices(tAutotune* const r, int numVoices) · 1 unmodified line |
| 591 | 615 | |
| 592 | 616 | r->outBuffers = (float**) leaf_alloc(sizeof(float*) * r->numVoices); |
| 593 | 617 | r->ps = (tPitchShift*) leaf_alloc(sizeof(tPitchShift) * r->numVoices); |
| 618 | + r->freq = (float*) leaf_alloc(sizeof(float) * r->numVoices); |
| 619 | + r->tickOutput = (float*) leaf_alloc(sizeof(float) * r->numVoices); |
| 594 | 620 | for (int i = 0; i < r->numVoices; ++i) |
| 595 | 621 | { |
| 596 | 622 | r->outBuffers[i] = (float*) leaf_alloc(sizeof(float) * r->bufSize); |
| @@ -600,7 +626,7 @@ void tAutotune_setNumVoices(tAutotune* const r, int numVoices) · 3 unmodified lines |
| 600 | 626 | |
| 601 | 627 | } |
| 602 | 628 | |
| 603 | | −void tAutotune_setFreq(tAutotune* const r, float f, int voice) |
| 629 | +void tAutotune_setFreqs(tAutotune* const r, float f) |
| 604 | 630 | { |
| 605 | 631 | for (int i = 0; i < r->numVoices; ++i) |
| 606 | 632 | { |
| @@ -608,6 +634,11 @@ void tAutotune_setFreq(tAutotune* const r, float f, int voice) · 1 unmodified line |
| 608 | 634 | } |
| 609 | 635 | } |
| 610 | 636 | |
| 637 | +void tAutotune_setFreq(tAutotune* const r, float f, int voice) |
| 638 | +{ |
| 639 | + r->freq[voice] = f; |
| 640 | +} |
| 641 | + |
| 611 | 642 | void tAutotune_setTimeConstant(tAutotune* const r, float tc) |
| 612 | 643 | { |
| 613 | 644 | r->timeConstant = tc; |
| @@ -644,7 +675,7 @@ static int pitchshift_attackdetect(tPitchShift* ps) · 30 unmodified lines |
| 644 | 675 | { |
| 645 | 676 | float envout; |
| 646 | 677 | |
| 647 | | − envout = tEnv_tick(&ps->p->env); |
| 678 | + envout = tEnvPD_tick(&ps->p->env); |
| 648 | 679 | |
| 649 | 680 | if (envout >= 1.0f) |
| 650 | 681 | { |
| @@ -846,8 +877,7 @@ void tSOLAD_setPeriod(tSOLAD* const w, float period) · 195 unmodified lines |
| 846 | 877 | // set pitch factor between 0.25 and 4 |
| 847 | 878 | void tSOLAD_setPitchFactor(tSOLAD* const w, float pitchfactor) |
| 848 | 879 | { |
| 849 | | − if(pitchfactor < 0.25) pitchfactor = 0.25; |
| 850 | | − else if(pitchfactor > 4.) pitchfactor = 4.; |
| 880 | + if (pitchfactor <= 0.0f) return; |
| 851 | 881 | w->pitchfactor = pitchfactor; |
| 852 | 882 | } |
| 853 | 883 | |