History

getting new pitch detection working in retune and autotune

Matthew Wang committed 6 years ago

Commit 11c878e1 parent 17430886 files · +157 −531Browse files

Unified · Split

6 files
  1. TestPlugin/Source/LEAFLink.cpp +3 −3
  2. TestPlugin/Source/MyTest.cpp +14 −86
  3. leaf/Inc/leaf-analysis.h +1 −2
  4. leaf/Inc/leaf-effects.h +22 −91
  5. leaf/Inc/leaf-math.h +2 −0
  6. leaf/Src/leaf-effects.c +115 −349
TestPlugin/Source/LEAFLink.cpp+3−3
@@ -20,9 +20,9 @@ std::vector<juce::String> cButtonNames = std::vector<juce::String> · 19 unmodified lines
20 20
21std::vector<juce::String> cSliderNames = std::vector<juce::String>21std::vector<juce::String> cSliderNames = std::vector<juce::String>
22{22{
23 "on/off",23 "slider1",
24 "mod freq",24 "slider2",
25 "mod depth"25 "slider3"
26};26};
27 27
28std::vector<juce::String> cComboBoxNames = std::vector<juce::String>28std::vector<juce::String> cComboBoxNames = std::vector<juce::String>
TestPlugin/Source/MyTest.cpp+14−86
@@ -18,7 +18,8 @@ tMBSaw bsaw; · 17 unmodified lines
18tMBTriangle btri;18tMBTriangle btri;
19tMBPulse bpulse;19tMBPulse bpulse;
20 20
21tDualPitchDetector detector;21tRetune retune;
22tAutotune autotune;
22 23
23tCompressor compressor;24tCompressor compressor;
24 25
@@ -54,33 +55,8 @@ void LEAFTest_init (float sampleRate, int blockSize) · 29 unmodified lines
54{55{
55 LEAF_init(&leaf, sampleRate, blockSize, memory, MSIZE, &getRandomFloat);56 LEAF_init(&leaf, sampleRate, blockSize, memory, MSIZE, &getRandomFloat);
56 57
57 tMBSaw_init(&bsaw, &leaf);58 tRetune_init(&retune, 1, 1024, &leaf);
58 tMBTriangle_init(&btri, &leaf);59 tAutotune_init(&autotune, 1, 1024, &leaf);
59 tMBPulse_init(&bpulse, &leaf);
60
61 bufIn = (float*) leaf_alloc(&leaf, sizeof(float) * 4096);
62 bufOut = (float*) leaf_alloc(&leaf, sizeof(float) * 4096);
63
64 tDualPitchDetector_init(&detector, mtof(48), mtof(84), &leaf);
65
66 tCompressor_init(&compressor, &leaf);
67
68 tSVF_init(&lp, SVFTypeLowpass, mtof(84) * 2.0f, 1.0f, &leaf);
69 tSVF_init(&hp, SVFTypeHighpass, mtof(48) * 0.5f, 1.0f, &leaf);
70
71 tPeriodDetection_init(&pd, bufIn, bufOut, 4096, 1024, &leaf);
72
73 tZeroCrossingCounter_init(&zc, 128, &leaf);
74 tEnvelopeFollower_init(&ef, 0.02f, 0.9999f, &leaf);
75
76 tTriangle_init(&tri, &leaf);
77 tTriangle_setFreq(&tri, 100);
78
79 tBuffer_init(&samp, 5.0f * leaf.sampleRate, &leaf);
80 tMBSampler_init(&sampler, &samp, &leaf);
81
82 tMBSampler_setMode(&sampler, PlayLoop);
83 tMBSampler_setEnd(&sampler, samp->bufferLength);
84}60}
85 61
86inline double getSawFall(double angle) {62inline double getSawFall(double angle) {
@@ -94,72 +70,24 @@ inline double getSawFall(double angle) { · 7 unmodified lines
94 70
95float LEAFTest_tick (float input)71float LEAFTest_tick (float input)
96{72{
97 tBuffer_tick(&samp, input);73// return tRetune_tick(&retune, input);
98 74 return tAutotune_tick(&autotune, input);
99 return tMBSampler_tick(&sampler);
100
101
102// tMBSaw_setFreq(&bsaw, x);
103// tMBTriangle_setFreq(&btri, x);
104// tMBPulse_setFreq(&bpulse, x);
105//
106// tMBTriangle_setWidth(&btri, y);
107// tMBPulse_setWidth(&bpulse, y);
108//
109//// return tMBSaw_tick(&bsaw);
110//// return tMBTriangle_tick(&btri);
111// return tMBPulse_tick(&bpulse);
112
113// input = tSVF_tick(&hp, tSVF_tick(&lp, tCompressor_tick(&compressor, input)));
114//
115//// float freq = 1.0f/tPeriodDetection_tick(&pd, input) * leaf.sampleRate;
116// tDualPitchDetector_tick(&detector, input);
117// float altFreq = tDualPitchDetector_getFrequency(&detector);
118//
119//// if (fabsf(1.0f - (freq / altFreq)) < 0.05f)
120//// if (tZeroCrossingCounter_tick(&zc, input) < 0.05 && freq > 0.0f)
121// if (altFreq > 0.0f)
122// {
123// tTriangle_setFreq(&tri, altFreq);
124// }
125//
126// float g = tEnvelopeFollower_tick(&ef, input);
127//
128// return tTriangle_tick(&tri) * g;
129}75}
130 76
131int firstFrame = 1;77int firstFrame = 1;
132bool lastState = false, lastPlayState = false;78bool lastState = false, lastPlayState = false;
133void LEAFTest_block (void)79void LEAFTest_block (void)
134{80{
135 float periodicity = tDualPitchDetector_getPeriodicity(&detector);81 float val = getSliderValue("slider1");
136 if (periodicity > 0.99f)82// tRetune_setPitchFactor(&retune, val * 3.0f + 0.5f, 0);
137 {83 tAutotune_setFreq(&autotune, 300, 0);
138 DBG(tDualPitchDetector_getFrequency(&detector));
139 DBG(tDualPitchDetector_getPeriodicity(&detector));
140 }
141
142 float val = getSliderValue("on/off");
143
144 if (val > 0.5f && !sampler->active)
145 {
146 tBuffer_record(&samp);
147 tMBSampler_play(&sampler);
148 }
149 else if (val < 0.5f && sampler->active)
150 {
151 tMBSampler_stop(&sampler);
152 }
153
154 val = getSliderValue("mod freq");
155
156 tMBSampler_setStart(&sampler, val * 5.0f * leaf.sampleRate);
157 84
85 val = getSliderValue("slider2");
86// tRetune_setPitchFactor(&retune, val * 3.0f + 0.5f, 1);
158 87
159 val = getSliderValue("mod depth");88 val = getSliderValue("slider3");
160 89// tRetune_setPitchFactor(&retune, val * 3.0f + 0.5f, 2);
161 tMBSampler_setRate(&sampler, val * 8.0f - 4.0f);90
162
163}91}
164 92
165void LEAFTest_controllerInput (int cnum, float cval)93void LEAFTest_controllerInput (int cnum, float cval)
leaf/Inc/leaf-analysis.h+1−2
@@ -497,7 +497,7 @@ extern "C" { · 496 unmodified lines
497#define DEFHOPSIZE 64497#define DEFHOPSIZE 64
498#define DEFWINDOWSIZE 64498#define DEFWINDOWSIZE 64
499#define FBA 20499#define FBA 20
500#define HPFREQ 40.0f500#define HPFREQ 20.0f
501 501
502 typedef struct _tPeriodDetection502 typedef struct _tPeriodDetection
503 {503 {
@@ -769,7 +769,6 @@ extern "C" { · 265 unmodified lines
769 769
770 typedef struct _tPeriodDetector770 typedef struct _tPeriodDetector
771 {771 {
772
773 tMempool mempool;772 tMempool mempool;
774 773
775 tZeroCrossingCollector _zc;774 tZeroCrossingCollector _zc;
leaf/Inc/leaf-effects.h+22−91
@@ -510,38 +510,27 @@ extern "C" { · 509 unmodified lines
510 510
511 typedef struct _tPitchShift511 typedef struct _tPitchShift
512 {512 {
513
514 tMempool mempool;513 tMempool mempool;
515 514
515 _tDualPitchDetector* pd;
516
516 tSOLAD sola;517 tSOLAD sola;
517 tHighpass hp;518 tHighpass hp;
518 tPeriodDetection* p;
519 tDualPitchDetector dp;
520 519
521 float* outBuffer;520 float* outBuffer;
522 int frameSize;521 float* inBuffer;
523 int bufSize;522 int bufSize;
524
525 int framesPerBuffer;
526 int curBlock;
527 int lastBlock;
528 int index;523 int index;
529
530 float pitchFactor;
531 float timeConstant;
532 float radius;
533 } _tPitchShift;524 } _tPitchShift;
534 525
535 typedef _tPitchShift* tPitchShift;526 typedef _tPitchShift* tPitchShift;
536 527
537 void tPitchShift_init (tPitchShift* const, tPeriodDetection* const, tDualPitchDetector* const, float* out, int bufSize, LEAF* const leaf);528 void tPitchShift_init (tPitchShift* const, tDualPitchDetector* const, LEAF* const leaf);
538 void tPitchShift_initToPool (tPitchShift* const, tPeriodDetection* const, tDualPitchDetector* const, float* out, int bufSize, tMempool* const);529 void tPitchShift_initToPool (tPitchShift* const, tDualPitchDetector* const, tMempool* const);
539 void tPitchShift_free (tPitchShift* const);530 void tPitchShift_free (tPitchShift* const);
540 531
541 float tPitchShift_shift (tPitchShift* const);532 void tPitchShift_shiftBy (tPitchShift* const, float factor, float* in, float* out, int bufSize);
542 float tPitchShift_shiftToFunc (tPitchShift* const, float (*fun)(float));533 void tPitchShift_shiftTo (tPitchShift* const, float freq, float* in, float* out, int bufSize);
543 float tPitchShift_shiftToFreq (tPitchShift* const, float freq);
544 void tPitchShift_setPitchFactor (tPitchShift* const, float pf);
545 534
546 /*!535 /*!
547 @defgroup tretune tRetune536 @defgroup tretune tRetune
@@ -577,35 +566,10 @@ extern "C" { · 29 unmodified lines
577 @brief566 @brief
578 @param567 @param
579 568
580 @fn void tRetune_setTimeConstant (tRetune* const, float tc)
581 @brief
582 @param
583
584 @fn void tRetune_setHopSize (tRetune* const, int hs)
585 @brief
586 @param
587
588 @fn void tRetune_setWindowSize (tRetune* const, int ws)
589 @brief
590 @param
591
592 @fn void tRetune_setFidelityThreshold(tRetune* const, float threshold)
593 @brief
594 @param
595
596 @fn float tRetune_getInputPeriod (tRetune* const)
597 @brief
598 @param
599
600 @fn float tRetune_getInputFreq (tRetune* const)
601 @brief
602 @param
603
604 @} */569 @} */
605 570
606 typedef struct _tRetune571 typedef struct _tRetune
607 {572 {
608
609 tMempool mempool;573 tMempool mempool;
610 574
611 tDualPitchDetector dp;575 tDualPitchDetector dp;
@@ -613,40 +577,25 @@ extern "C" { · 1 unmodified line
613 tPitchShift* ps;577 tPitchShift* ps;
614 578
615 float* inBuffer;579 float* inBuffer;
616 float** outBuffers;580 float* outBuffer;
617 float* tickOutput;581 float* lastOutBuffer;
618 int frameSize;
619 int bufSize;582 int bufSize;
583 int index;
620 584
621 uint16_t hopSize;585 float* pitchFactors;
622 uint16_t windowSize;
623 uint8_t fba;
624
625 float* pitchFactor;
626 float timeConstant;
627 float radius;
628
629 float inputPeriod;
630
631 int numVoices;586 int numVoices;
632 } _tRetune;587 } _tRetune;
633 588
634 typedef _tRetune* tRetune;589 typedef _tRetune* tRetune;
635 590
636 void tRetune_init (tRetune* const, int numVoices, int bufSize, int frameSize, LEAF* const leaf);591 void tRetune_init (tRetune* const, int numVoices, int bufSize, LEAF* const leaf);
637 void tRetune_initToPool (tRetune* const, int numVoices, int bufSize, int frameSize, tMempool* const);592 void tRetune_initToPool (tRetune* const, int numVoices, int bufSize, tMempool* const);
638 void tRetune_free (tRetune* const);593 void tRetune_free (tRetune* const);
639 594
640 float* tRetune_tick (tRetune* const, float sample);595 float tRetune_tick (tRetune* const, float sample);
641 void tRetune_setNumVoices (tRetune* const, int numVoices);596 void tRetune_setNumVoices (tRetune* const, int numVoices);
642 void tRetune_setPitchFactors (tRetune* const, float pf);597 void tRetune_setPitchFactors (tRetune* const, float pf);
643 void tRetune_setPitchFactor (tRetune* const, float pf, int voice);598 void tRetune_setPitchFactor (tRetune* const, float pf, int voice);
644 void tRetune_setTimeConstant (tRetune* const, float tc);
645 void tRetune_setHopSize (tRetune* const, int hs);
646 void tRetune_setWindowSize (tRetune* const, int ws);
647 void tRetune_setFidelityThreshold(tRetune* const, float threshold);
648 float tRetune_getInputPeriod (tRetune* const);
649 float tRetune_getInputFreq (tRetune* const);
650 599
651 /*!600 /*!
652 @defgroup tautotune tAutotune601 @defgroup tautotune tAutotune
@@ -718,7 +667,6 @@ extern "C" { · 65 unmodified lines
718 667
719 typedef struct _tAutotune668 typedef struct _tAutotune
720 {669 {
721
722 tMempool mempool;670 tMempool mempool;
723 671
724 tDualPitchDetector dp;672 tDualPitchDetector dp;
@@ -726,42 +674,25 @@ extern "C" { · 1 unmodified line
726 tPitchShift* ps;674 tPitchShift* ps;
727 675
728 float* inBuffer;676 float* inBuffer;
729 float** outBuffers;677 float* outBuffer;
730 float* tickOutput;678 float* lastOutBuffer;
731 int frameSize;
732 int bufSize;679 int bufSize;
680 int index;
733 681
734 uint16_t hopSize;682 float* freqs;
735 uint16_t windowSize;
736 uint8_t fba;
737
738 float* freq;
739 float timeConstant;
740 float radius;
741
742 float inputPeriod;
743 int shiftOn;
744 int numVoices;683 int numVoices;
745 } _tAutotune;684 } _tAutotune;
746 685
747 typedef _tAutotune* tAutotune;686 typedef _tAutotune* tAutotune;
748 687
749 void tAutotune_init (tAutotune* const, int numVoices, int bufSize, int frameSize, LEAF* const leaf);688 void tAutotune_init (tAutotune* const, int numVoices, int bufSize, LEAF* const leaf);
750 void tAutotune_initToPool (tAutotune* const, int numVoices, int bufSize, int frameSize, tMempool* const);689 void tAutotune_initToPool (tAutotune* const, int numVoices, int bufSize, tMempool* const);
751 void tAutotune_free (tAutotune* const);690 void tAutotune_free (tAutotune* const);
752 691
753 float* tAutotune_tick (tAutotune* const, float sample);692 float tAutotune_tick (tAutotune* const, float sample);
754 void tAutotune_setNumVoices (tAutotune* const, int numVoices);693 void tAutotune_setNumVoices (tAutotune* const, int numVoices);
755 void tAutotune_setFreqs (tAutotune* const, float f);694 void tAutotune_setFreqs (tAutotune* const, float f);
756 void tAutotune_setFreq (tAutotune* const, float f, int voice);695 void tAutotune_setFreq (tAutotune* const, float f, int voice);
757 void tAutotune_setTimeConstant (tAutotune* const, float tc);
758 void tAutotune_setHopSize (tAutotune* const, int hs);
759 void tAutotune_setWindowSize (tAutotune* const, int ws);
760 void tAutotune_setFidelityThreshold (tAutotune* const, float threshold);
761 void tAutotune_setAlpha (tAutotune* const, float alpha);
762 void tAutotune_setTolerance (tAutotune* const, float tolerance);
763 float tAutotune_getInputPeriod (tAutotune* const);
764 float tAutotune_getInputFreq (tAutotune* const);
765 696
766 //==============================================================================697 //==============================================================================
767 698
leaf/Inc/leaf-math.h+2−0
@@ -190,6 +190,8 @@ extern "C" { · 189 unmodified lines
190 double fasterexp(double x);190 double fasterexp(double x);
191 191
192 float fasterexpf(float x);192 float fasterexpf(float x);
193
194 float fastsqrtf(float x);
193 195
194 float mtof(float f);196 float mtof(float f);
195 197
leaf/Src/leaf-effects.c+115−349
@@ -1010,7 +1010,6 @@ void tRosenbergGlottalPulse_setOpenLengthAndPulseLength (tRosenbergG · 1009 unmodified lines
1010/***************** static function declarations *******************************/1010/***************** static function declarations *******************************/
1011/******************************************************************************/1011/******************************************************************************/
1012 1012
1013static void solad_init(_tSOLAD *w);
1014static inline float read_sample(_tSOLAD *w, float floatindex);1013static inline float read_sample(_tSOLAD *w, float floatindex);
1015static void pitchdown(_tSOLAD *w, float *out);1014static void pitchdown(_tSOLAD *w, float *out);
1016static void pitchup(_tSOLAD *w, float *out);1015static void pitchup(_tSOLAD *w, float *out);
@@ -1032,9 +1031,13 @@ void tSOLAD_initToPool (tSOLAD* const wp, tMempool* const mp) · 15 unmodified lines
1032 w->mempool = m;1031 w->mempool = m;
1033 1032
1034 w->pitchfactor = 1.;1033 w->pitchfactor = 1.;
1035 w->delaybuf = (float*) mpool_calloc(sizeof(float) * (LOOPSIZE+16), m);1034 w->delaybuf = (float*) mpool_calloc(sizeof(float) * LOOPSIZE, m);
1036 1035
1037 solad_init(w);1036 w->timeindex = 0;
1037 w->xfadevalue = -1;
1038 w->period = INITPERIOD;
1039 w->readlag = INITPERIOD;
1040 w->blocksize = INITPERIOD;
1038}1041}
1039 1042
1040void tSOLAD_free (tSOLAD* const wp)1043void tSOLAD_free (tSOLAD* const wp)
@@ -1077,7 +1080,10 @@ void tSOLAD_setPitchFactor(tSOLAD* const wp, float pitchfactor) · 36 unmodified lines
1077{1080{
1078 _tSOLAD* w = *wp;1081 _tSOLAD* w = *wp;
1079 1082
1080 if (pitchfactor <= 0.0f) return;1083 if (pitchfactor <= 0.0f || pitchfactor > 1000.0f)
1084 {
1085 return;
1086 }
1081 w->pitchfactor = pitchfactor;1087 w->pitchfactor = pitchfactor;
1082}1088}
1083 1089
@@ -1101,11 +1107,16 @@ void tSOLAD_resetState(tSOLAD* const wp) · 17 unmodified lines
1101{1107{
1102 _tSOLAD* w = *wp;1108 _tSOLAD* w = *wp;
1103 1109
1104 int n = LOOPSIZE + 1;1110 int n = LOOPSIZE;
1105 float *buf = w->delaybuf;1111 float *buf = w->delaybuf;
1106 1112
1107 while(n--) *buf++ = 0;1113 while(n--) *buf++ = 0;
1108 solad_init(w);1114
1115 w->timeindex = 0;
1116 w->xfadevalue = -1;
1117 w->period = INITPERIOD;
1118 w->readlag = INITPERIOD;
1119 w->blocksize = INITPERIOD;
1109}1120}
1110 1121
1111/******************************************************************************/1122/******************************************************************************/
@@ -1182,7 +1193,7 @@ static void pitchdown(_tSOLAD* const w, float *out) · 70 unmodified lines
1182 xfadevalue -= xfadestep;1193 xfadevalue -= xfadestep;
1183 }1194 }
1184 1195
1185 *out++ = outputsample;1196 *out++ += outputsample;
1186 refindex += 1;1197 refindex += 1;
1187 readlag += readlagstep;1198 readlag += readlagstep;
1188 }1199 }
@@ -1312,7 +1323,7 @@ static void pitchup(_tSOLAD* const w, float *out) · 123 unmodified lines
1312 xfadevalue -= xfadestep;1323 xfadevalue -= xfadestep;
1313 }1324 }
1314 1325
1315 *out++ = outputsample;1326 *out++ += outputsample;
1316 refindex += 1;1327 refindex += 1;
1317 readlag -= readlagstep;1328 readlag -= readlagstep;
1318 }1329 }
@@ -1334,77 +1345,55 @@ static inline float read_sample(_tSOLAD* const w, float floatindex) · 15 unmodified lines
1334 return (buf[index] + (fraction * (buf[index+1] - buf[index])));1345 return (buf[index] + (fraction * (buf[index+1] - buf[index])));
1335}1346}
1336 1347
1337static void solad_init(_tSOLAD* const w)
1338{
1339 w->timeindex = 0;
1340 w->xfadevalue = -1;
1341 w->period = INITPERIOD;
1342 w->readlag = INITPERIOD;
1343 w->blocksize = INITPERIOD;
1344}
1345
1346//============================================================================================================1348//============================================================================================================
1347// PITCHSHIFT1349// PITCHSHIFT
1348//============================================================================================================1350//============================================================================================================
1349 1351
1350static int pitchshift_attackdetect(_tPitchShift* ps)1352static int pitchshift_attackdetect(_tPitchShift* ps)
1351{1353{
1352 float envout;1354// float envout;
1353 1355//
1354 _tPeriodDetection* p = *ps->p;1356// _tPeriodDetection* p = *ps->p;
1355 1357//
1356 envout = tEnvPD_tick(&p->env);1358// envout = tEnvPD_tick(&p->env);
1357 1359//
1358 if (envout >= 1.0f)1360// if (envout >= 1.0f)
1359 {1361// {
1360 p->lastmax = p->max;1362// p->lastmax = p->max;
1361 if (envout > p->max)1363// if (envout > p->max)
1362 {1364// {
1363 p->max = envout;1365// p->max = envout;
1364 }1366// }
1365 else1367// else
1366 {1368// {
1367 p->deltamax = envout - p->max;1369// p->deltamax = envout - p->max;
1368 p->max = p->max * ps->radius;1370// p->max = p->max * ps->radius;
1369 }1371// }
1370 p->deltamax = p->max - p->lastmax;1372// p->deltamax = p->max - p->lastmax;
1371 }1373// }
1372 1374//
1373 p->fba = p->fba ? (p->fba - 1) : 0;1375// p->fba = p->fba ? (p->fba - 1) : 0;
1374 1376//
1375 return (p->fba == 0 && (p->max > 60 && p->deltamax > 6)) ? 1 : 0;1377// return (p->fba == 0 && (p->max > 60 && p->deltamax > 6)) ? 1 : 0;
1376}1378}
1377 1379
1378void tPitchShift_init (tPitchShift* const psr, tPeriodDetection* const pd, tDualPitchDetector* const dp, float* out, int bufSize, LEAF* const leaf)1380void tPitchShift_init (tPitchShift* const psr, tDualPitchDetector* const dpd, LEAF* const leaf)
1379{1381{
1380 tPitchShift_initToPool(psr, pd, dp, out, bufSize, &leaf->mempool);1382 tPitchShift_initToPool(psr, dpd, &leaf->mempool);
1381}1383}
1382 1384
1383void tPitchShift_initToPool (tPitchShift* const psr, tPeriodDetection* const pd, tDualPitchDetector* const dp, float* out, int bufSize, tMempool* const mp)1385void tPitchShift_initToPool (tPitchShift* const psr, tDualPitchDetector* const dpd, tMempool* const mp)
1384{1386{
1385 _tMempool* m = *mp;1387 _tMempool* m = *mp;
1386 _tPitchShift* ps = *psr = (_tPitchShift*) mpool_calloc(sizeof(_tPitchShift), m);1388 _tPitchShift* ps = *psr = (_tPitchShift*) mpool_calloc(sizeof(_tPitchShift), m);
1387 ps->mempool = m;1389 ps->mempool = m;
1388 1390
1389 _tPeriodDetection* p = *pd;1391 ps->pd = *dpd;
1390
1391 ps->p = pd;
1392
1393 ps->outBuffer = out;
1394 ps->bufSize = bufSize;
1395 ps->frameSize = p->frameSize;
1396 ps->framesPerBuffer = ps->bufSize / ps->frameSize;
1397 ps->curBlock = 1;
1398 ps->lastBlock = 0;
1399 ps->index = 0;
1400 ps->pitchFactor = 1.0f;
1401 ps->dp = *dp;
1402 1392
1403 tSOLAD_initToPool(&ps->sola, mp);1393 tSOLAD_initToPool(&ps->sola, mp);
1394 tSOLAD_setPitchFactor(&ps->sola, DEFPITCHRATIO);
1404 1395
1405 tHighpass_initToPool(&ps->hp, HPFREQ, mp);1396 tHighpass_initToPool(&ps->hp, HPFREQ, mp);
1406
1407 tSOLAD_setPitchFactor(&ps->sola, DEFPITCHRATIO);
1408}1397}
1409 1398
1410void tPitchShift_free (tPitchShift* const psr)1399void tPitchShift_free (tPitchShift* const psr)
@@ -1416,168 +1405,63 @@ void tPitchShift_free (tPitchShift* const psr) · 5 unmodified lines
1416 mpool_free((char*)ps, ps->mempool);1405 mpool_free((char*)ps, ps->mempool);
1417}1406}
1418 1407
1419void tPitchShift_setPitchFactor(tPitchShift* psr, float pf)1408void tPitchShift_shiftBy (tPitchShift* const psr, float factor, float* in, float* out, int bufSize)
1420{1409{
1421 _tPitchShift* ps = *psr;1410 _tPitchShift* ps = *psr;
1422
1423 ps->pitchFactor = pf;
1424}
1425
1426float tPitchShift_shift (tPitchShift* psr)
1427{
1428 _tPitchShift* ps = *psr;
1429 _tPeriodDetection* p = *ps->p;
1430
1431 float period, out;
1432 int i, iLast;
1433
1434 i = p->i;
1435 iLast = p->iLast;
1436
1437 out = tHighpass_tick(&ps->hp, ps->outBuffer[iLast]);
1438
1439 if (p->indexstore >= ps->frameSize)
1440 {
1441// period = tPeriodDetection_getPeriod(&p);
1442 period = 1.0f / tDualPitchDetector_getFrequency(&ps->dp);
1443
1444 if(pitchshift_attackdetect(ps) == 1)
1445 {
1446 p->fba = 5;
1447 tSOLAD_setReadLag(&ps->sola, p->windowSize);
1448 }
1449
1450 tSOLAD_setPeriod(&ps->sola, period);
1451 tSOLAD_setPitchFactor(&ps->sola, ps->pitchFactor);
1452
1453 tSOLAD_ioSamples(&ps->sola, &(p->inBuffer[i]), &(ps->outBuffer[i]), ps->frameSize);
1454 }
1455
1456 return out;
1457}
1458
1459float tPitchShift_shiftToFreq (tPitchShift* psr, float freq)
1460{
1461 _tPitchShift* ps = *psr;
1462 _tPeriodDetection* p = *ps->p;
1463 LEAF* leaf = ps->mempool->leaf;1411 LEAF* leaf = ps->mempool->leaf;
1464 1412
1465 float period = 0;1413 float period = leaf->sampleRate / tDualPitchDetector_getFrequency(&ps->pd);
1466 float out;1414 tSOLAD_setPeriod(&ps->sola, period);
1467 int i, iLast;1415 tSOLAD_setPitchFactor(&ps->sola, factor);
1468 1416
1469 i = p->i;1417 tSOLAD_ioSamples(&ps->sola, in, out, bufSize);
1470 iLast = p->iLast;
1471
1472 out = tHighpass_tick(&ps->hp, ps->outBuffer[iLast]);
1473
1474 if (p->indexstore >= ps->frameSize)
1475 {
1476// period = tPeriodDetection_getPeriod(&p);
1477 float f = tDualPitchDetector_getFrequency(&ps->dp);
1478 if (f > 0) period = 1.0f / f;
1479
1480 if(pitchshift_attackdetect(ps) == 1)
1481 {
1482 p->fba = 5;
1483 tSOLAD_setReadLag(&ps->sola, p->windowSize);
1484 }
1485
1486 tSOLAD_setPeriod(&ps->sola, period * leaf->sampleRate);
1487
1488 if (period != 0) ps->pitchFactor = freq * period;
1489 else ps->pitchFactor = 1.0f;
1490
1491 tSOLAD_setPitchFactor(&ps->sola, ps->pitchFactor);
1492
1493 tSOLAD_ioSamples(&ps->sola, &(p->inBuffer[i]), &(ps->outBuffer[i]), ps->frameSize);
1494 }
1495 return out;
1496}1418}
1497 1419
1498float tPitchShift_shiftToFunc (tPitchShift* psr, float (*fun)(float))1420void tPitchShift_shiftTo (tPitchShift* const psr, float freq, float* in, float* out, int bufSize)
1499{1421{
1500 _tPitchShift* ps = *psr;1422 _tPitchShift* ps = *psr;
1501 _tPeriodDetection* p = *ps->p;1423 LEAF* leaf = ps->mempool->leaf;
1502
1503 float period, out;
1504 int i, iLast;
1505
1506 i = p->i;
1507 iLast = p->iLast;
1508
1509 out = tHighpass_tick(&ps->hp, ps->outBuffer[iLast]);
1510 1424
1511 if (p->indexstore >= ps->frameSize)1425 float period = 1.0f / tDualPitchDetector_getFrequency(&ps->pd);
1512 {1426 float factor = freq * period;
1513// period = tPeriodDetection_getPeriod(&p);1427 tSOLAD_setPeriod(&ps->sola, leaf->sampleRate * period);
1514 period = 1.0f / tDualPitchDetector_getFrequency(&ps->dp);1428 tSOLAD_setPitchFactor(&ps->sola, factor);
1515
1516 if(pitchshift_attackdetect(ps) == 1)
1517 {
1518 p->fba = 5;
1519 tSOLAD_setReadLag(&ps->sola, p->windowSize);
1520 }
1521
1522 tSOLAD_setPeriod(&ps->sola, period);
1523
1524 ps->pitchFactor = period/fun(period);
1525 tSOLAD_setPitchFactor(&ps->sola, ps->pitchFactor);
1526
1527 tSOLAD_ioSamples(&ps->sola, &(p->inBuffer[i]), &(ps->outBuffer[i]), ps->frameSize);
1528
1529 ps->curBlock++;
1530 if (ps->curBlock >= p->framesPerBuffer) ps->curBlock = 0;
1531 ps->lastBlock++;
1532 if (ps->lastBlock >= ps->framesPerBuffer) ps->lastBlock = 0;
1533 }
1534 1429
1535 return out;1430 tSOLAD_ioSamples(&ps->sola, in, out, bufSize);
1536}1431}
1537 1432
1538//============================================================================================================1433//============================================================================================================
1539// RETUNE1434// RETUNE
1540//============================================================================================================1435//============================================================================================================
1541 1436
1542void tRetune_init(tRetune* const rt, int numVoices, int bufSize, int frameSize, LEAF* const leaf)1437void tRetune_init(tRetune* const rt, int numVoices, int bufSize, LEAF* const leaf)
1543{1438{
1544 tRetune_initToPool(rt, numVoices, bufSize, frameSize, &leaf->mempool);1439 tRetune_initToPool(rt, numVoices, bufSize, &leaf->mempool);
1545}1440}
1546 1441
1547void tRetune_initToPool (tRetune* const rt, int numVoices, int bufSize, int frameSize, tMempool* const mp)1442void tRetune_initToPool (tRetune* const rt, int numVoices, int bufSize, tMempool* const mp)
1548{1443{
1549 _tMempool* m = *mp;1444 _tMempool* m = *mp;
1550 _tRetune* r = *rt = (_tRetune*) mpool_alloc(sizeof(_tRetune), m);1445 _tRetune* r = *rt = (_tRetune*) mpool_alloc(sizeof(_tRetune), m);
1551 r->mempool = *mp;1446 r->mempool = *mp;
1552 1447
1553 r->bufSize = bufSize;1448 r->bufSize = bufSize;
1554 r->frameSize = frameSize;
1555 r->numVoices = numVoices;1449 r->numVoices = numVoices;
1556 1450
1557 r->inBuffer = (float*) mpool_calloc(sizeof(float) * r->bufSize, m);1451 r->inBuffer = (float*) mpool_calloc(sizeof(float) * r->bufSize, m);
1558 r->outBuffers = (float**) mpool_calloc(sizeof(float*) * r->numVoices, m);1452 r->outBuffer = (float*) mpool_calloc(sizeof(float) * r->bufSize, m);
1559 1453 r->lastOutBuffer = (float*) mpool_calloc(sizeof(float) * r->bufSize, m);
1560 r->hopSize = DEFHOPSIZE;
1561 r->windowSize = DEFWINDOWSIZE;
1562 r->fba = FBA;
1563 tRetune_setTimeConstant(rt, DEFTIMECONSTANT);
1564 1454
1565 r->inputPeriod = 0.0f;1455 r->index = 0;
1566 1456
1567 r->ps = (tPitchShift*) mpool_calloc(sizeof(tPitchShift) * r->numVoices, m);1457 r->ps = (tPitchShift*) mpool_calloc(sizeof(tPitchShift) * r->numVoices, m);
1568 r->pitchFactor = (float*) mpool_calloc(sizeof(float) * r->numVoices, m);1458 r->pitchFactors = (float*) mpool_calloc(sizeof(float) * r->numVoices, m);
1569 r->tickOutput = (float*) mpool_calloc(sizeof(float) * r->numVoices, m);
1570 for (int i = 0; i < r->numVoices; ++i)
1571 {
1572 r->outBuffers[i] = (float*) mpool_calloc(sizeof(float) * r->bufSize, m);
1573 }
1574 1459
1575 tDualPitchDetector_initToPool(&r->dp, mtof(48), mtof(72), mp);1460 tDualPitchDetector_initToPool(&r->dp, mtof(48), mtof(72), mp);
1576 tPeriodDetection_initToPool(&r->pd, r->inBuffer, r->outBuffers[0], r->bufSize, r->frameSize, mp);
1577 1461
1578 for (int i = 0; i < r->numVoices; ++i)1462 for (int i = 0; i < r->numVoices; ++i)
1579 {1463 {
1580 tPitchShift_initToPool(&r->ps[i], &r->pd, &r->dp, r->outBuffers[i], r->bufSize, mp);1464 tPitchShift_initToPool(&r->ps[i], &r->dp, mp);
1581 }1465 }
1582}1466}
1583 1467
@@ -1590,30 +1474,34 @@ void tRetune_free (tRetune* const rt) · 6 unmodified lines
1590 for (int i = 0; i < r->numVoices; ++i)1474 for (int i = 0; i < r->numVoices; ++i)
1591 {1475 {
1592 tPitchShift_free(&r->ps[i]);1476 tPitchShift_free(&r->ps[i]);
1593 mpool_free((char*)r->outBuffers[i], r->mempool);
1594 }1477 }
1595 mpool_free((char*)r->tickOutput, r->mempool);1478 mpool_free((char*)r->pitchFactors, r->mempool);
1596 mpool_free((char*)r->pitchFactor, r->mempool);
1597 mpool_free((char*)r->ps, r->mempool);1479 mpool_free((char*)r->ps, r->mempool);
1598 mpool_free((char*)r->inBuffer, r->mempool);1480 mpool_free((char*)r->inBuffer, r->mempool);
1599 mpool_free((char*)r->outBuffers, r->mempool);1481 mpool_free((char*)r->outBuffer, r->mempool);
1600 mpool_free((char*)r, r->mempool);1482 mpool_free((char*)r, r->mempool);
1601}1483}
1602 1484
1603float* tRetune_tick(tRetune* const rt, float sample)1485float tRetune_tick(tRetune* const rt, float sample)
1604{1486{
1605 _tRetune* r = *rt;1487 _tRetune* r = *rt;
1606 1488
1607 tPeriodDetection_tick(&r->pd, sample);
1608 tDualPitchDetector_tick(&r->dp, sample);1489 tDualPitchDetector_tick(&r->dp, sample);
1609 r->inputPeriod = 1.0f / tDualPitchDetector_getFrequency(&r->dp);
1610 1490
1611 for (int v = 0; v < r->numVoices; ++v)1491 r->inBuffer[r->index] = sample;
1492 float out = r->outBuffer[r->index];
1493 r->outBuffer[r->index++] = 0.0f;
1494
1495 if (r->index >= r->bufSize)
1612 {1496 {
1613 r->tickOutput[v] = tPitchShift_shift(&r->ps[v]);1497 for (int i = 0; i < r->numVoices; ++i)
1498 {
1499 tPitchShift_shiftBy(&r->ps[i], r->pitchFactors[i], r->inBuffer, r->outBuffer, r->bufSize);
1500 }
1501 r->index = 0;
1614 }1502 }
1615 1503
1616 return r->tickOutput;1504 return out;
1617}1505}
1618 1506
1619void tRetune_setNumVoices(tRetune* const rt, int numVoices)1507void tRetune_setNumVoices(tRetune* const rt, int numVoices)
@@ -1621,11 +1509,10 @@ void tRetune_setNumVoices(tRetune* const rt, int numVoices) · 1 unmodified line
1621 _tRetune* r = *rt;1509 _tRetune* r = *rt;
1622 1510
1623 int bufSize = r->bufSize;1511 int bufSize = r->bufSize;
1624 int frameSize = r->frameSize;
1625 tMempool mempool = r->mempool;1512 tMempool mempool = r->mempool;
1626 1513
1627 tRetune_free(rt);1514 tRetune_free(rt);
1628 tRetune_initToPool(rt, numVoices, bufSize, frameSize, &mempool);1515 tRetune_initToPool(rt, numVoices, bufSize, &mempool);
1629}1516}
1630 1517
1631void tRetune_setPitchFactors(tRetune* const rt, float pf)1518void tRetune_setPitchFactors(tRetune* const rt, float pf)
@@ -1634,8 +1521,7 @@ void tRetune_setPitchFactors(tRetune* const rt, float pf) · 2 unmodified lines
1634 1521
1635 for (int i = 0; i < r->numVoices; ++i)1522 for (int i = 0; i < r->numVoices; ++i)
1636 {1523 {
1637 r->pitchFactor[i] = pf;1524 r->pitchFactors[i] = pf;
1638 tPitchShift_setPitchFactor(&r->ps[i], r->pitchFactor[i]);
1639 }1525 }
1640}1526}
1641 1527
@@ -1643,142 +1529,81 @@ void tRetune_setPitchFactor(tRetune* const rt, float pf, int voice) · 1 unmodified line
1643{1529{
1644 _tRetune* r = *rt;1530 _tRetune* r = *rt;
1645 1531
1646 r->pitchFactor[voice] = pf;1532 r->pitchFactors[voice] = pf;
1647 tPitchShift_setPitchFactor(&r->ps[voice], r->pitchFactor[voice]);
1648}
1649
1650void tRetune_setTimeConstant(tRetune* const rt, float tc)
1651{
1652 _tRetune* r = *rt;
1653 LEAF* leaf = r->mempool->leaf;
1654
1655 r->timeConstant = tc;
1656 r->radius = expf(-1000.0f * r->hopSize * leaf->invSampleRate / r->timeConstant);
1657}
1658
1659void tRetune_setHopSize(tRetune* const rt, int hs)
1660{
1661 _tRetune* r = *rt;
1662
1663 r->hopSize = hs;
1664 tPeriodDetection_setHopSize(&r->pd, r->hopSize);
1665}
1666
1667void tRetune_setWindowSize(tRetune* const rt, int ws)
1668{
1669 _tRetune* r = *rt;
1670
1671 r->windowSize = ws;
1672 tPeriodDetection_setWindowSize(&r->pd, r->windowSize);
1673}
1674
1675void tRetune_setFidelityThreshold(tRetune* const rt, float threshold)
1676{
1677 _tRetune* r = *rt;
1678
1679 tPeriodDetection_setFidelityThreshold(&r->pd, threshold);
1680}
1681
1682float tRetune_getInputPeriod(tRetune* const rt)
1683{
1684 _tRetune* r = *rt;
1685 LEAF* leaf = r->mempool->leaf;
1686
1687 return (r->inputPeriod * leaf->invSampleRate);
1688}
1689
1690float tRetune_getInputFreq(tRetune* const rt)
1691{
1692 _tRetune* r = *rt;
1693 LEAF* leaf = r->mempool->leaf;
1694
1695 return 1.0f/(r->inputPeriod * leaf->invSampleRate);
1696}1533}
1697 1534
1698//============================================================================================================1535//============================================================================================================
1699// AUTOTUNE1536// AUTOTUNE
1700//============================================================================================================1537//============================================================================================================
1701 1538
1702void tAutotune_init (tAutotune* const rt, int numVoices, int bufSize, int frameSize, LEAF* const leaf)1539void tAutotune_init (tAutotune* const rt, int numVoices, int bufSize, LEAF* const leaf)
1703{1540{
1704 tAutotune_initToPool(rt, numVoices, bufSize, frameSize, &leaf->mempool);1541 tAutotune_initToPool(rt, numVoices, bufSize, &leaf->mempool);
1705}1542}
1706 1543
1707void tAutotune_initToPool (tAutotune* const rt, int numVoices, int bufSize, int frameSize, tMempool* const mp)1544void tAutotune_initToPool (tAutotune* const rt, int numVoices, int bufSize, tMempool* const mp)
1708{1545{
1709 _tMempool* m = *mp;1546 _tMempool* m = *mp;
1710 _tAutotune* r = *rt = (_tAutotune*) mpool_alloc(sizeof(_tAutotune), m);1547 _tAutotune* r = *rt = (_tAutotune*) mpool_alloc(sizeof(_tAutotune), m);
1711 r->mempool = *mp;1548 r->mempool = *mp;
1712 1549
1713 r->bufSize = bufSize;1550 r->bufSize = bufSize;
1714 r->frameSize = frameSize;
1715 r->numVoices = numVoices;1551 r->numVoices = numVoices;
1716 1552
1717 r->inBuffer = (float*) mpool_alloc(sizeof(float) * r->bufSize, m);1553 r->inBuffer = (float*) mpool_calloc(sizeof(float) * r->bufSize, m);
1718 r->outBuffers = (float**) mpool_alloc(sizeof(float*) * r->numVoices, m);1554 r->outBuffer = (float*) mpool_calloc(sizeof(float) * r->bufSize, m);
1555 r->lastOutBuffer = (float*) mpool_calloc(sizeof(float) * r->bufSize, m);
1719 1556
1720 r->hopSize = DEFHOPSIZE;1557 r->index = 0;
1721 r->windowSize = DEFWINDOWSIZE;
1722 r->fba = FBA;
1723 tAutotune_setTimeConstant(rt, DEFTIMECONSTANT);
1724 1558
1725 r->ps = (tPitchShift*) mpool_alloc(sizeof(tPitchShift) * r->numVoices, m);1559 r->ps = (tPitchShift*) mpool_calloc(sizeof(tPitchShift) * r->numVoices, m);
1726 r->freq = (float*) mpool_alloc(sizeof(float) * r->numVoices, m);1560 r->freqs = (float*) mpool_calloc(sizeof(float) * r->numVoices, m);
1727 r->tickOutput = (float*) mpool_alloc(sizeof(float) * r->numVoices, m);
1728 for (int i = 0; i < r->numVoices; ++i)
1729 {
1730 r->outBuffers[i] = (float*) mpool_alloc(sizeof(float) * r->bufSize, m);
1731 }
1732 1561
1733 tDualPitchDetector_initToPool(&r->dp, mtof(48), mtof(72), mp);1562 tDualPitchDetector_initToPool(&r->dp, mtof(48), mtof(72), mp);
1734 tPeriodDetection_initToPool(&r->pd, r->inBuffer, r->outBuffers[0], r->bufSize, r->frameSize, mp);1563
1735
1736 for (int i = 0; i < r->numVoices; ++i)1564 for (int i = 0; i < r->numVoices; ++i)
1737 {1565 {
1738 tPitchShift_initToPool(&r->ps[i], &r->pd, &r->dp, r->outBuffers[i], r->bufSize, mp);1566 tPitchShift_initToPool(&r->ps[i], &r->dp, mp);
1739 }1567 }
1740
1741 r->inputPeriod = 0.0f;
1742 r->shiftOn = 0;
1743}1568}
1744 1569
1745void tAutotune_free (tAutotune* const rt)1570void tAutotune_free (tAutotune* const rt)
1746{1571{
1747 _tAutotune* r = *rt;1572 _tAutotune* r = *rt;
1748 1573
1574 tDualPitchDetector_free(&r->dp);
1749 tPeriodDetection_free(&r->pd);1575 tPeriodDetection_free(&r->pd);
1750 for (int i = 0; i < r->numVoices; ++i)1576 for (int i = 0; i < r->numVoices; ++i)
1751 {1577 {
1752 tPitchShift_free(&r->ps[i]);1578 tPitchShift_free(&r->ps[i]);
1753 mpool_free((char*)r->outBuffers[i], r->mempool);
1754 }1579 }
1755 mpool_free((char*)r->tickOutput, r->mempool);1580 mpool_free((char*)r->freqs, r->mempool);
1756 mpool_free((char*)r->freq, r->mempool);
1757 mpool_free((char*)r->ps, r->mempool);1581 mpool_free((char*)r->ps, r->mempool);
1758 mpool_free((char*)r->inBuffer, r->mempool);1582 mpool_free((char*)r->inBuffer, r->mempool);
1759 mpool_free((char*)r->outBuffers, r->mempool);1583 mpool_free((char*)r->outBuffer, r->mempool);
1760 mpool_free((char*)r, r->mempool);1584 mpool_free((char*)r, r->mempool);
1761}1585}
1762 1586
1763float* tAutotune_tick(tAutotune* const rt, float sample)1587float tAutotune_tick(tAutotune* const rt, float sample)
1764{1588{
1765 _tAutotune* r = *rt;1589 _tAutotune* r = *rt;
1766 1590
1767 tPeriodDetection_tick(&r->pd, sample);
1768 tDualPitchDetector_tick(&r->dp, sample);1591 tDualPitchDetector_tick(&r->dp, sample);
1769 r->inputPeriod = 1.0f / tDualPitchDetector_getFrequency(&r->dp);
1770 1592
1771// if (tempPeriod < 1000.0f) //to avoid trying to follow consonants JS1593 r->inBuffer[r->index] = sample;
1772// {1594 float out = r->outBuffer[r->index];
1773// r->inputPeriod = tempPeriod;1595 r->outBuffer[r->index++] = 0.0f;
1774// }1596
1775 1597 if (r->index >= r->bufSize)
1776 for (int v = 0; v < r->numVoices; ++v)
1777 {1598 {
1778 r->tickOutput[v] = tPitchShift_shiftToFreq(&r->ps[v], r->freq[v]);1599 for (int i = 0; i < r->numVoices; ++i)
1600 {
1601 tPitchShift_shiftTo(&r->ps[i], r->freqs[i], r->inBuffer, r->outBuffer, r->bufSize);
1602 }
1603 r->index = 0;
1779 }1604 }
1780 1605
1781 return r->tickOutput;1606 return out;
1782}1607}
1783 1608
1784void tAutotune_setNumVoices(tAutotune* const rt, int numVoices)1609void tAutotune_setNumVoices(tAutotune* const rt, int numVoices)
@@ -1786,11 +1611,10 @@ void tAutotune_setNumVoices(tAutotune* const rt, int numVoices) · 1 unmodified line
1786 _tAutotune* r = *rt;1611 _tAutotune* r = *rt;
1787 1612
1788 int bufSize = r->bufSize;1613 int bufSize = r->bufSize;
1789 int frameSize = r->frameSize;
1790 tMempool mempool = r->mempool;1614 tMempool mempool = r->mempool;
1791 1615
1792 tAutotune_free(rt);1616 tAutotune_free(rt);
1793 tAutotune_initToPool(rt, numVoices, bufSize, frameSize, &mempool);1617 tAutotune_initToPool(rt, numVoices, bufSize, &mempool);
1794}1618}
1795 1619
1796void tAutotune_setFreqs(tAutotune* const rt, float f)1620void tAutotune_setFreqs(tAutotune* const rt, float f)
@@ -1799,7 +1623,7 @@ void tAutotune_setFreqs(tAutotune* const rt, float f) · 2 unmodified lines
1799 1623
1800 for (int i = 0; i < r->numVoices; ++i)1624 for (int i = 0; i < r->numVoices; ++i)
1801 {1625 {
1802 r->freq[i] = f;1626 r->freqs[i] = f;
1803 }1627 }
1804}1628}
1805 1629
@@ -1807,65 +1631,7 @@ void tAutotune_setFreq(tAutotune* const rt, float f, int voice) · 1 unmodified line
1807{1631{
1808 _tAutotune* r = *rt;1632 _tAutotune* r = *rt;
1809 1633
1810 r->freq[voice] = f;1634 r->freqs[voice] = f;
1811}
1812
1813void tAutotune_setTimeConstant(tAutotune* const rt, float tc)
1814{
1815 _tAutotune* r = *rt;
1816 LEAF* leaf = r->mempool->leaf;
1817
1818 r->timeConstant = tc;
1819 r->radius = expf(-1000.0f * r->hopSize * leaf->invSampleRate / r->timeConstant);
1820}
1821
1822void tAutotune_setHopSize(tAutotune* const rt, int hs)
1823{
1824 _tAutotune* r = *rt;
1825
1826 r->hopSize = hs;
1827 tPeriodDetection_setHopSize(&r->pd, r->hopSize);
1828}
1829
1830void tAutotune_setWindowSize(tAutotune* const rt, int ws)
1831{
1832 _tAutotune* r = *rt;
1833
1834 r->windowSize = ws;
1835 tPeriodDetection_setWindowSize(&r->pd, r->windowSize);
1836}
1837
1838void tAutotune_setFidelityThreshold(tAutotune* const rt, float threshold)
1839{
1840 _tAutotune* r = *rt;
1841
1842 tPeriodDetection_setFidelityThreshold(&r->pd, threshold);
1843}
1844
1845void tAutotune_setAlpha (tAutotune* rt, float alpha)
1846{
1847 _tAutotune* r = *rt;
1848 tPeriodDetection_setAlpha(&r->pd, alpha);
1849}
1850
1851void tAutotune_setTolerance (tAutotune* rt, float tolerance)
1852{
1853 _tAutotune* r = *rt;
1854 tPeriodDetection_setTolerance(&r->pd, tolerance);
1855}
1856
1857float tAutotune_getInputPeriod(tAutotune* const rt)
1858{
1859 _tAutotune* r = *rt;
1860
1861 return r->inputPeriod;
1862}
1863
1864float tAutotune_getInputFreq(tAutotune* const rt)
1865{
1866 _tAutotune* r = *rt;
1867
1868 return 1.0f/r->inputPeriod;
1869}1635}
1870 1636
1871//============================================================================================================1637//============================================================================================================

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