History

trying out some ways to improve and optimize pitch detection

Matthew Wang committed 6 years ago

Commit f253eaf1 parent a8e41584 files · +118 −58Browse files

Unified · Split

4 files
  1. leaf/Inc/leaf-analysis.h +1 −0
  2. leaf/Inc/leaf-effects.h +18 −11
  3. leaf/Src/leaf-analysis.c +41 −22
  4. leaf/Src/leaf-effects.c +58 −25
leaf/Inc/leaf-analysis.h+1−0
@@ -909,6 +909,7 @@ extern "C" { · 908 unmodified lines
909 float _mean;909 float _mean;
910 float _predicted_frequency;910 float _predicted_frequency;
911 int _first;911 int _first;
912 int sub;
912 913
913 } _tDualPitchDetector;914 } _tDualPitchDetector;
914 915
leaf/Inc/leaf-effects.h+18−11
@@ -430,11 +430,11 @@ extern "C" { · 429 unmodified lines
430 430
431 @} */431 @} */
432 432
433#define LOOPSIZE (2048*2) // (4096*2) // loop size must be power of two433//#define LOOPSIZE (2048*2) // (4096*2) // loop size must be power of two
434#define LOOPMASK (LOOPSIZE - 1)434//#define LOOPMASK (LOOPSIZE - 1)
435#define PITCHFACTORDEFAULT 1.0f435#define PITCHFACTORDEFAULT 1.0f
436#define INITPERIOD 64.0f436#define INITPERIOD 64.0f
437#define MAXPERIOD (float)((LOOPSIZE - w->blocksize) * 0.8f)437//#define MAXPERIOD (float)((LOOPSIZE - w->blocksize) * 0.8f)
438#define MINPERIOD 8.0f438#define MINPERIOD 8.0f
439 439
440 typedef struct _tSOLAD440 typedef struct _tSOLAD
@@ -444,6 +444,7 @@ extern "C" { · 3 unmodified lines
444 tAttackDetection ad;444 tAttackDetection ad;
445 tHighpass hp;445 tHighpass hp;
446 446
447 int loopSize;
447 uint16_t timeindex; // current reference time, write index448 uint16_t timeindex; // current reference time, write index
448 uint16_t blocksize; // signal input / output block size449 uint16_t blocksize; // signal input / output block size
449 float pitchfactor; // pitch factor between 0.25 and 4450 float pitchfactor; // pitch factor between 0.25 and 4
@@ -459,8 +460,8 @@ extern "C" { · 9 unmodified lines
459 460
460 typedef _tSOLAD* tSOLAD;461 typedef _tSOLAD* tSOLAD;
461 462
462 void tSOLAD_init (tSOLAD* const, LEAF* const leaf);463 void tSOLAD_init (tSOLAD* const, int loopSize, LEAF* const leaf);
463 void tSOLAD_initToPool (tSOLAD* const, tMempool* const);464 void tSOLAD_initToPool (tSOLAD* const, int loopSize, tMempool* const);
464 void tSOLAD_free (tSOLAD* const);465 void tSOLAD_free (tSOLAD* const);
465 466
466 // send one block of input samples, receive one block of output samples467 // send one block of input samples, receive one block of output samples
@@ -521,16 +522,20 @@ extern "C" { · 54 unmodified lines
521 float* inBuffer;522 float* inBuffer;
522 int bufSize;523 int bufSize;
523 int index;524 int index;
525
526 float pickiness;
524 } _tPitchShift;527 } _tPitchShift;
525 528
526 typedef _tPitchShift* tPitchShift;529 typedef _tPitchShift* tPitchShift;
527 530
528 void tPitchShift_init (tPitchShift* const, tDualPitchDetector* const, LEAF* const leaf);531 void tPitchShift_init (tPitchShift* const, tDualPitchDetector* const, int bufSize, LEAF* const leaf);
529 void tPitchShift_initToPool (tPitchShift* const, tDualPitchDetector* const, tMempool* const);532 void tPitchShift_initToPool (tPitchShift* const, tDualPitchDetector* const, int bufSize, tMempool* const);
530 void tPitchShift_free (tPitchShift* const);533 void tPitchShift_free (tPitchShift* const);
531 534
532 void tPitchShift_shiftBy (tPitchShift* const, float factor, float* in, float* out, int bufSize);535 void tPitchShift_shiftBy (tPitchShift* const, float factor, float* in, float* out);
533 void tPitchShift_shiftTo (tPitchShift* const, float freq, float* in, float* out, int bufSize);536 void tPitchShift_shiftTo (tPitchShift* const, float freq, float* in, float* out);
537
538 void tPitchShift_setPickiness (tPitchShift* const, float p);
534 539
535 /*!540 /*!
536 @defgroup tsimpleretune tSimpleRetune541 @defgroup tsimpleretune tSimpleRetune
@@ -582,7 +587,7 @@ extern "C" { · 45 unmodified lines
582 int bufSize;587 int bufSize;
583 int index;588 int index;
584 589
585 void (*shiftFunction)(tPitchShift* const, float, float*, float*, int);590 void (*shiftFunction)(tPitchShift* const, float, float*, float*);
586 591
587 float* shiftValues;592 float* shiftValues;
588 int numVoices;593 int numVoices;
@@ -597,6 +602,7 @@ extern "C" { · 8 unmodified lines
597 float tSimpleRetune_tick (tSimpleRetune* const, float sample);602 float tSimpleRetune_tick (tSimpleRetune* const, float sample);
598 void tSimpleRetune_setMode (tSimpleRetune* const, int mode);603 void tSimpleRetune_setMode (tSimpleRetune* const, int mode);
599 void tSimpleRetune_setNumVoices (tSimpleRetune* const, int numVoices);604 void tSimpleRetune_setNumVoices (tSimpleRetune* const, int numVoices);
605 void tSimpleRetune_setPickiness (tSimpleRetune* const, float p);
600 void tSimpleRetune_tuneVoices (tSimpleRetune* const, float* t);606 void tSimpleRetune_tuneVoices (tSimpleRetune* const, float* t);
601 void tSimpleRetune_tuneVoice (tSimpleRetune* const, int voice, float t);607 void tSimpleRetune_tuneVoice (tSimpleRetune* const, int voice, float t);
602 float tSimpleRetune_getInputFrequency (tSimpleRetune* const);608 float tSimpleRetune_getInputFrequency (tSimpleRetune* const);
@@ -653,7 +659,7 @@ extern "C" { · 50 unmodified lines
653 659
654 float* output;660 float* output;
655 661
656 void (*shiftFunction)(tPitchShift* const, float, float*, float*, int);662 void (*shiftFunction)(tPitchShift* const, float, float*, float*);
657 663
658 float* shiftValues;664 float* shiftValues;
659 int numVoices;665 int numVoices;
@@ -668,6 +674,7 @@ extern "C" { · 8 unmodified lines
668 float* tRetune_tick (tRetune* const, float sample);674 float* tRetune_tick (tRetune* const, float sample);
669 void tRetune_setMode (tRetune* const, int mode);675 void tRetune_setMode (tRetune* const, int mode);
670 void tRetune_setNumVoices (tRetune* const, int numVoices);676 void tRetune_setNumVoices (tRetune* const, int numVoices);
677 void tRetune_setPickiness (tRetune* const, float p);
671 void tRetune_tuneVoices (tRetune* const, float* t);678 void tRetune_tuneVoices (tRetune* const, float* t);
672 void tRetune_tuneVoice (tRetune* const, int voice, float t);679 void tRetune_tuneVoice (tRetune* const, int voice, float t);
673 float tRetune_getInputFrequency (tRetune* const);680 float tRetune_getInputFrequency (tRetune* const);
leaf/Src/leaf-analysis.c+41−22
@@ -1889,7 +1889,7 @@ void tPitchDetector_initToPool (tPitchDetector* const detector, float lowes · 1888 unmodified lines
1889 _tPitchDetector* p = *detector = (_tPitchDetector*) mpool_alloc(sizeof(_tPitchDetector), m);1889 _tPitchDetector* p = *detector = (_tPitchDetector*) mpool_alloc(sizeof(_tPitchDetector), m);
1890 p->mempool = m;1890 p->mempool = m;
1891 1891
1892 tPeriodDetector_initToPool(&p->_pd, lowestFreq, highestFreq, DEFAULT_HYSTERESIS, mempool);1892 tPeriodDetector_initToPool(&p->_pd, lowestFreq, highestFreq, -120.0f, mempool);
1893 p->_current.frequency = 0.0f;1893 p->_current.frequency = 0.0f;
1894 p->_current.periodicity = 0.0f;1894 p->_current.periodicity = 0.0f;
1895 p->_frames_after_shift = 0;1895 p->_frames_after_shift = 0;
@@ -2119,13 +2119,14 @@ void tDualPitchDetector_initToPool (tDualPitchDetector* const detector, flo · 223 unmodified lines
2119 _tDualPitchDetector* p = *detector = (_tDualPitchDetector*) mpool_alloc(sizeof(_tDualPitchDetector), m);2119 _tDualPitchDetector* p = *detector = (_tDualPitchDetector*) mpool_alloc(sizeof(_tDualPitchDetector), m);
2120 p->mempool = m;2120 p->mempool = m;
2121 2121
2122 tPitchDetector_initToPool(&p->_pd1, lowestFreq, highestFreq, mempool);2122 tPitchDetector_initToPool(&p->_pd1, lowestFreq*2.0f, highestFreq*2.0f, mempool);
2123 tPitchDetector_initToPool(&p->_pd2, lowestFreq, highestFreq, mempool);2123 tPitchDetector_initToPool(&p->_pd2, lowestFreq*2.0f, highestFreq*2.0f, mempool);
2124 p->_current.frequency = 0.0f;2124 p->_current.frequency = 0.0f;
2125 p->_current.periodicity = 0.0f;2125 p->_current.periodicity = 0.0f;
2126 p->_mean = lowestFreq + ((highestFreq - lowestFreq) / 2.0f);2126 p->_mean = lowestFreq + ((highestFreq - lowestFreq) / 2.0f);
2127 p->_predicted_frequency = 0.0f;2127 p->_predicted_frequency = 0.0f;
2128 p->_first = 1;2128 p->_first = 1;
2129 p->sub = 0;
2129}2130}
2130 2131
2131void tDualPitchDetector_free (tDualPitchDetector* const detector)2132void tDualPitchDetector_free (tDualPitchDetector* const detector)
@@ -2142,34 +2143,52 @@ int tDualPitchDetector_tick (tDualPitchDetector* const detector, float sa · 10 unmodified lines
2142{2143{
2143 _tDualPitchDetector* p = *detector;2144 _tDualPitchDetector* p = *detector;
2144 2145
2145 int pd1_ready = tPitchDetector_tick(&p->_pd1, sample);2146 int pd1_ready;
2146 int pd2_ready = tPitchDetector_tick(&p->_pd2, -sample);2147 if (!(p->sub % 2))
2148 {
2149 pd1_ready = tPitchDetector_tick(&p->_pd2, sample);
2150 p->sub = 0;
2151 }
2152 else
2153 {
2154 pd1_ready = tPitchDetector_tick(&p->_pd1, sample);
2155 }
2156 p->sub++;
2147 2157
2148 if (pd1_ready || pd2_ready)2158 if (pd1_ready)
2149 {2159 {
2150 int pd1_indeterminate = tPitchDetector_indeterminate(&p->_pd1);2160 int pd1_indeterminate = tPitchDetector_indeterminate(&p->_pd1);
2151 int pd2_indeterminate = tPitchDetector_indeterminate(&p->_pd2);2161 int pd2_indeterminate = tPitchDetector_indeterminate(&p->_pd2);
2162 int disagreement = 0;
2152 if (!pd1_indeterminate && !pd2_indeterminate)2163 if (!pd1_indeterminate && !pd2_indeterminate)
2153 {2164 {
2154 _pitch_info _i1 = p->_pd1->_current;2165 _pitch_info _i1 = p->_pd1->_current;
2155 _pitch_info _i2 = p->_pd2->_current;2166 _pitch_info _i2 = p->_pd2->_current;
2156 2167
2157 float pd1_diff = fabsf(_i1.frequency - p->_mean);2168 float pd1_diff = fabsf(_i1.frequency*0.5f - p->_mean);
2158 float pd2_diff = fabsf(_i2.frequency - p->_mean);2169 float pd2_diff = fabsf(_i2.frequency*0.5f - p->_mean);
2159 _pitch_info i = (pd1_diff < pd2_diff) ? _i1 : _i2;2170 _pitch_info i1 = _i1;
2171 i1.frequency = i1.frequency*0.5f;
2172 _pitch_info i2 = _i2;
2173 i2.frequency = i2.frequency*0.5f;
2174
2175 _pitch_info i = (pd1_diff < pd2_diff) ? i1 : i2;
2176 disagreement = fabsf(pd1_diff - pd2_diff) > 2.0f;
2160 2177
2161 if (p->_first)2178 if (!disagreement) {
2162 {2179 if (p->_first)
2163 p->_current = i;2180 {
2164 p->_mean = p->_current.frequency;2181 p->_current = i;
2165 p->_first = 0;2182 p->_mean = p->_current.frequency;
2166 p->_predicted_frequency = 0.0f;2183 p->_first = 0;
2167 }2184 p->_predicted_frequency = 0.0f;
2168 else2185 }
2169 {2186 else
2170 p->_current = i;2187 {
2171 p->_mean = (0.222222f * p->_current.frequency) + (0.777778f * p->_mean);2188 p->_current = i;
2172 p->_predicted_frequency = 0.0f;2189 p->_mean = (0.2222222 * p->_current.frequency) + (0.7777778 * p->_mean);
2190 p->_predicted_frequency = 0.0f;
2191 }
2173 }2192 }
2174 }2193 }
2175 2194
@@ -2181,7 +2200,7 @@ int tDualPitchDetector_tick (tDualPitchDetector* const detector, float sa · 5 unmodified lines
2181 }2200 }
2182 }2201 }
2183 2202
2184 return pd1_ready || pd2_ready;2203 return pd1_ready;
2185}2204}
2186 2205
2187float tDualPitchDetector_getFrequency (tDualPitchDetector* const detector)2206float tDualPitchDetector_getFrequency (tDualPitchDetector* const detector)
leaf/Src/leaf-effects.c+58−25
@@ -1019,19 +1019,20 @@ static void pitchup(_tSOLAD *w, float *out); · 1018 unmodified lines
1019/******************************************************************************/1019/******************************************************************************/
1020 1020
1021// init1021// init
1022void tSOLAD_init (tSOLAD* const wp, LEAF* const leaf)1022void tSOLAD_init (tSOLAD* const wp, int loopSize, LEAF* const leaf)
1023{1023{
1024 tSOLAD_initToPool(wp, &leaf->mempool);1024 tSOLAD_initToPool(wp, loopSize, &leaf->mempool);
1025}1025}
1026 1026
1027void tSOLAD_initToPool (tSOLAD* const wp, tMempool* const mp)1027void tSOLAD_initToPool (tSOLAD* const wp, int loopSize, tMempool* const mp)
1028{1028{
1029 _tMempool* m = *mp;1029 _tMempool* m = *mp;
1030 _tSOLAD* w = *wp = (_tSOLAD*) mpool_calloc(sizeof(_tSOLAD), m);1030 _tSOLAD* w = *wp = (_tSOLAD*) mpool_calloc(sizeof(_tSOLAD), m);
1031 w->mempool = m;1031 w->mempool = m;
1032 1032
1033 w->loopSize = loopSize;
1033 w->pitchfactor = 1.;1034 w->pitchfactor = 1.;
1034 w->delaybuf = (float*) mpool_calloc(sizeof(float) * LOOPSIZE, m);1035 w->delaybuf = (float*) mpool_calloc(sizeof(float) * w->loopSize, m);
1035 1036
1036 w->timeindex = 0;1037 w->timeindex = 0;
1037 w->xfadevalue = -1;1038 w->xfadevalue = -1;
@@ -1065,7 +1066,7 @@ void tSOLAD_ioSamples(tSOLAD* const wp, float* in, float* out, int blocksize) · 27 unmodified lines
1065 {1066 {
1066 float sample = tHighpass_tick(&w->hp, in[0]);1067 float sample = tHighpass_tick(&w->hp, in[0]);
1067 w->delaybuf[0] = sample;1068 w->delaybuf[0] = sample;
1068 w->delaybuf[LOOPSIZE] = sample; // copy one sample for interpolation1069 w->delaybuf[w->loopSize] = sample; // copy one sample for interpolation
1069 n--;1070 n--;
1070 i++;1071 i++;
1071 in++;1072 in++;
@@ -1082,7 +1083,7 @@ void tSOLAD_ioSamples(tSOLAD* const wp, float* in, float* out, int blocksize) · 10 unmodified lines
1082 else pitchdown(w, out);1083 else pitchdown(w, out);
1083 1084
1084 w->timeindex += blocksize;1085 w->timeindex += blocksize;
1085 w->timeindex &= LOOPMASK;1086 w->timeindex &= (w->loopSize - 1);
1086}1087}
1087 1088
1088// set periodicity analysis data1089// set periodicity analysis data
@@ -1090,7 +1091,8 @@ void tSOLAD_setPeriod(tSOLAD* const wp, float period) · 1 unmodified line
1090{1091{
1091 _tSOLAD* w = *wp;1092 _tSOLAD* w = *wp;
1092 1093
1093 if(period > MAXPERIOD) period = MAXPERIOD;1094 float maxPeriod = (float)((w->loopSize - w->blocksize) * 0.8f);
1095 if(period > maxPeriod) period = maxPeriod;
1094 if(period > MINPERIOD) w->period = period; // ignore period when too small1096 if(period > MINPERIOD) w->period = period; // ignore period when too small
1095}1097}
1096 1098
@@ -1126,7 +1128,7 @@ void tSOLAD_resetState(tSOLAD* const wp) · 29 unmodified lines
1126{1128{
1127 _tSOLAD* w = *wp;1129 _tSOLAD* w = *wp;
1128 1130
1129 int n = LOOPSIZE;1131 int n = w->loopSize;
1130 float *buf = w->delaybuf;1132 float *buf = w->delaybuf;
1131 1133
1132 while(n--) *buf++ = 0;1134 while(n--) *buf++ = 0;
@@ -1173,7 +1175,7 @@ void tSOLAD_resetState(tSOLAD* const wp) · 40 unmodified lines
1173static void pitchdown(_tSOLAD* const w, float *out)1175static void pitchdown(_tSOLAD* const w, float *out)
1174{1176{
1175 int n = w->blocksize;1177 int n = w->blocksize;
1176 float refindex = (float)(w->timeindex + LOOPSIZE); // no negative values!1178 float refindex = (float)(w->timeindex + w->loopSize); // no negative values!
1177 float pitchfactor = w->pitchfactor;1179 float pitchfactor = w->pitchfactor;
1178 float period = w->period;1180 float period = w->period;
1179 float readlag = w->readlag;1181 float readlag = w->readlag;
@@ -1291,7 +1293,7 @@ static void pitchdown(_tSOLAD* const w, float *out) · 111 unmodified lines
1291static void pitchup(_tSOLAD* const w, float *out)1293static void pitchup(_tSOLAD* const w, float *out)
1292{1294{
1293 int n = w->blocksize;1295 int n = w->blocksize;
1294 float refindex = (float)(w->timeindex + LOOPSIZE); // no negative values1296 float refindex = (float)(w->timeindex + w->loopSize); // no negative values
1295 float pitchfactor = w->pitchfactor;1297 float pitchfactor = w->pitchfactor;
1296 float period = w->period;1298 float period = w->period;
1297 float readlag = w->readlag;1299 float readlag = w->readlag;
@@ -1359,7 +1361,7 @@ static inline float read_sample(_tSOLAD* const w, float floatindex) · 61 unmodified lines
1359 int index = (int)floatindex;1361 int index = (int)floatindex;
1360 float fraction = floatindex - (float)index;1362 float fraction = floatindex - (float)index;
1361 float *buf = w->delaybuf;1363 float *buf = w->delaybuf;
1362 index &= LOOPMASK;1364 index &= (w->loopSize - 1);
1363 1365
1364 return (buf[index] + (fraction * (buf[index+1] - buf[index])));1366 return (buf[index] + (fraction * (buf[index+1] - buf[index])));
1365}1367}
@@ -1368,20 +1370,22 @@ static inline float read_sample(_tSOLAD* const w, float floatindex) · 2 unmodified lines
1368// PITCHSHIFT1370// PITCHSHIFT
1369//============================================================================================================1371//============================================================================================================
1370 1372
1371void tPitchShift_init (tPitchShift* const psr, tDualPitchDetector* const dpd, LEAF* const leaf)1373void tPitchShift_init (tPitchShift* const psr, tDualPitchDetector* const dpd, int bufSize, LEAF* const leaf)
1372{1374{
1373 tPitchShift_initToPool(psr, dpd, &leaf->mempool);1375 tPitchShift_initToPool(psr, dpd, bufSize, &leaf->mempool);
1374}1376}
1375 1377
1376void tPitchShift_initToPool (tPitchShift* const psr, tDualPitchDetector* const dpd, tMempool* const mp)1378void tPitchShift_initToPool (tPitchShift* const psr, tDualPitchDetector* const dpd, int bufSize, tMempool* const mp)
1377{1379{
1378 _tMempool* m = *mp;1380 _tMempool* m = *mp;
1379 _tPitchShift* ps = *psr = (_tPitchShift*) mpool_alloc(sizeof(_tPitchShift), m);1381 _tPitchShift* ps = *psr = (_tPitchShift*) mpool_alloc(sizeof(_tPitchShift), m);
1380 ps->mempool = m;1382 ps->mempool = m;
1381 1383
1382 ps->pd = *dpd;1384 ps->pd = *dpd;
1385 ps->bufSize = bufSize;
1386 ps->pickiness = 0.95f;
1383 1387
1384 tSOLAD_initToPool(&ps->sola, mp);1388 tSOLAD_initToPool(&ps->sola, pow(2.0, ceil(log2(ps->bufSize * 2.0))), mp);
1385 tSOLAD_setPitchFactor(&ps->sola, DEFPITCHRATIO);1389 tSOLAD_setPitchFactor(&ps->sola, DEFPITCHRATIO);
1386}1390}
1387 1391
@@ -1393,29 +1397,31 @@ void tPitchShift_free (tPitchShift* const psr) · 5 unmodified lines
1393 mpool_free((char*)ps, ps->mempool);1397 mpool_free((char*)ps, ps->mempool);
1394}1398}
1395 1399
1396void tPitchShift_shiftBy (tPitchShift* const psr, float factor, float* in, float* out, int bufSize)1400void tPitchShift_shiftBy (tPitchShift* const psr, float factor, float* in, float* out)
1397{1401{
1398 _tPitchShift* ps = *psr;1402 _tPitchShift* ps = *psr;
1399 LEAF* leaf = ps->mempool->leaf;1403 LEAF* leaf = ps->mempool->leaf;
1400 1404
1401 float detected = tDualPitchDetector_getFrequency(&ps->pd);1405 float detected = tDualPitchDetector_getFrequency(&ps->pd);
1402 if (detected > 0.0f)1406 float periodicity = tDualPitchDetector_getPeriodicity(&ps->pd);
1407 if (detected > 0.0f && periodicity > ps->pickiness)
1403 {1408 {
1404 float period = leaf->sampleRate / detected;1409 float period = leaf->sampleRate / detected;
1405 tSOLAD_setPeriod(&ps->sola, period);1410 tSOLAD_setPeriod(&ps->sola, period);
1406 tSOLAD_setPitchFactor(&ps->sola, factor);1411 tSOLAD_setPitchFactor(&ps->sola, factor);
1407 }1412 }
1408 1413
1409 tSOLAD_ioSamples(&ps->sola, in, out, bufSize);1414 tSOLAD_ioSamples(&ps->sola, in, out, ps->bufSize);
1410}1415}
1411 1416
1412void tPitchShift_shiftTo (tPitchShift* const psr, float freq, float* in, float* out, int bufSize)1417void tPitchShift_shiftTo (tPitchShift* const psr, float freq, float* in, float* out)
1413{1418{
1414 _tPitchShift* ps = *psr;1419 _tPitchShift* ps = *psr;
1415 LEAF* leaf = ps->mempool->leaf;1420 LEAF* leaf = ps->mempool->leaf;
1416 1421
1417 float detected = tDualPitchDetector_getFrequency(&ps->pd);1422 float detected = tDualPitchDetector_getFrequency(&ps->pd);
1418 if (detected > 0.0f)1423 float periodicity = tDualPitchDetector_getPeriodicity(&ps->pd);
1424 if (detected > 0.0f && periodicity > ps->pickiness)
1419 {1425 {
1420 float period = 1.0f / detected;1426 float period = 1.0f / detected;
1421 float factor = freq * period;1427 float factor = freq * period;
@@ -1423,7 +1429,14 @@ void tPitchShift_shiftTo (tPitchShift* const psr, float freq, float* in, floa · 1 unmodified line
1423 tSOLAD_setPitchFactor(&ps->sola, factor);1429 tSOLAD_setPitchFactor(&ps->sola, factor);
1424 }1430 }
1425 1431
1426 tSOLAD_ioSamples(&ps->sola, in, out, bufSize);1432 tSOLAD_ioSamples(&ps->sola, in, out, ps->bufSize);
1433}
1434
1435void tPitchShift_setPickiness (tPitchShift* const psr, float p)
1436{
1437 _tPitchShift* ps = *psr;
1438
1439 ps->pickiness = p;
1427}1440}
1428 1441
1429 1442
@@ -1459,7 +1472,7 @@ void tSimpleRetune_initToPool (tSimpleRetune* const rt, int numVoices, float min · 29 unmodified lines
1459 1472
1460 for (int i = 0; i < r->numVoices; ++i)1473 for (int i = 0; i < r->numVoices; ++i)
1461 {1474 {
1462 tPitchShift_initToPool(&r->ps[i], &r->dp, mp);1475 tPitchShift_initToPool(&r->ps[i], &r->dp, r->bufSize, mp);
1463 }1476 }
1464 1477
1465 r->shiftFunction = &tPitchShift_shiftBy;1478 r->shiftFunction = &tPitchShift_shiftBy;
@@ -1495,7 +1508,7 @@ float tSimpleRetune_tick(tSimpleRetune* const rt, float sample) · 29 unmodified lines
1495 {1508 {
1496 for (int i = 0; i < r->numVoices; ++i)1509 for (int i = 0; i < r->numVoices; ++i)
1497 {1510 {
1498 r->shiftFunction(&r->ps[i], r->shiftValues[i], r->inBuffer, r->outBuffer, r->bufSize);1511 r->shiftFunction(&r->ps[i], r->shiftValues[i], r->inBuffer, r->outBuffer);
1499 }1512 }
1500 r->index = 0;1513 r->index = 0;
1501 }1514 }
@@ -1524,6 +1537,16 @@ void tSimpleRetune_setNumVoices(tSimpleRetune* const rt, int numVoices) · 22 unmodified lines
1524 tSimpleRetune_initToPool(rt, minInputFreq, maxInputFreq, numVoices, bufSize, &mempool);1537 tSimpleRetune_initToPool(rt, minInputFreq, maxInputFreq, numVoices, bufSize, &mempool);
1525}1538}
1526 1539
1540void tSimpleRetune_setPickiness (tSimpleRetune* const rt, float p)
1541{
1542 _tSimpleRetune* r = *rt;
1543
1544 for (int i = 0; i < r->numVoices; ++i)
1545 {
1546 tPitchShift_setPickiness(&r->ps[i], p);
1547 }
1548}
1549
1527void tSimpleRetune_tuneVoices(tSimpleRetune* const rt, float* t)1550void tSimpleRetune_tuneVoices(tSimpleRetune* const rt, float* t)
1528{1551{
1529 _tSimpleRetune* r = *rt;1552 _tSimpleRetune* r = *rt;
@@ -1581,7 +1604,7 @@ void tRetune_initToPool (tRetune* const rt, int numVoices, float minInputFreq, f · 51 unmodified lines
1581 1604
1582 for (int i = 0; i < r->numVoices; ++i)1605 for (int i = 0; i < r->numVoices; ++i)
1583 {1606 {
1584 tPitchShift_initToPool(&r->ps[i], &r->dp, mp);1607 tPitchShift_initToPool(&r->ps[i], &r->dp, r->bufSize, mp);
1585 r->outBuffers[i] = (float*) mpool_calloc(sizeof(float) * r->bufSize, m);1608 r->outBuffers[i] = (float*) mpool_calloc(sizeof(float) * r->bufSize, m);
1586 }1609 }
1587 1610
@@ -1623,7 +1646,7 @@ float* tRetune_tick(tRetune* const rt, float sample) · 35 unmodified lines
1623 {1646 {
1624 for (int i = 0; i < r->numVoices; ++i)1647 for (int i = 0; i < r->numVoices; ++i)
1625 {1648 {
1626 r->shiftFunction(&r->ps[i], r->shiftValues[i], r->inBuffer, r->outBuffers[i], r->bufSize);1649 r->shiftFunction(&r->ps[i], r->shiftValues[i], r->inBuffer, r->outBuffers[i]);
1627 }1650 }
1628 r->index = 0;1651 r->index = 0;
1629 }1652 }
@@ -1639,6 +1662,16 @@ void tRetune_setMode (tRetune* const rt, int mode) · 9 unmodified lines
1639 else r->shiftFunction = &tPitchShift_shiftBy;1662 else r->shiftFunction = &tPitchShift_shiftBy;
1640}1663}
1641 1664
1665void tRetune_setPickiness (tRetune* const rt, float p)
1666{
1667 _tRetune* r = *rt;
1668
1669 for (int i = 0; i < r->numVoices; ++i)
1670 {
1671 tPitchShift_setPickiness(&r->ps[i], p);
1672 }
1673}
1674
1642void tRetune_setNumVoices(tRetune* const rt, int numVoices)1675void tRetune_setNumVoices(tRetune* const rt, int numVoices)
1643{1676{
1644 _tRetune* r = *rt;1677 _tRetune* r = *rt;

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