ref: dfe835e434d1d6f5ad84e5462aa9b132a6c4fb18
parent: 2d2ef2908d0008ff66352dc97d7ceb59f715d5bf
author: Olav Sørensen <[email protected]>
date: Wed Jan 27 14:27:59 EST 2021
Small cleanup of the tuneSample() function
--- a/src/ft2_replayer.c
+++ b/src/ft2_replayer.c
@@ -135,7 +135,7 @@
return;
}
- // handle frequency boundaries
+ // handle frequency boundaries first...
if (midCFreq <= (int32_t)dPeriod2HzTab[note2Period[MIN_PERIOD]])
{
@@ -151,8 +151,7 @@
return;
}
- // check if midCFreq is matching any of the clean note frequencies (C-0..B-9)
-
+ // check if midCFreq is matching any of the non-finetuned note frequencies (C-0..B-9)
for (int8_t i = 0; i < 10*12; i++)
{
if (midCFreq == (int32_t)dPeriod2HzTab[note2Period[16 + (i<<4)]])
@@ -168,7 +167,7 @@
int32_t period = MAX_PERIOD;
for (; period >= MIN_PERIOD; period--)
{
- const int32_t curr = (int32_t)dPeriod2HzTab[note2Period[period+0]];
+ const int32_t curr = (int32_t)dPeriod2HzTab[note2Period[period]];
if (midCFreq == curr)
break;
@@ -184,12 +183,6 @@
period++;
break; // current+1 is the closest
}
- }
-
- if (period == -1) // frequency was too for period table
- {
- s->fine = s->relTon = 0;
- return;
}
s->fine = ((period & 31) - 16) << 3;