commit 2e7bfbda73d923e35b533193c0b3fee8c90bd5e0
parent 9bbd17fed5701c6ef6264b1fa84c1098d7918ffa
Author: Olav Sørensen <olav.sorensen@live.no>
Date: Sat, 5 Dec 2020 16:36:16 +0100
Some minor cleanup
Diffstat:
5 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/src/ft2_audio.c b/src/ft2_audio.c
@@ -141,7 +141,7 @@ void setNewAudioFreq(uint32_t freq) // for song-to-WAV rendering
const bool mustRecalcTables = audio.freq != oldAudioFreq;
if (mustRecalcTables)
{
- calcReplayRate(audio.freq);
+ calcReplayerVars(audio.freq);
calcRevMixDeltaTable();
}
}
@@ -154,7 +154,7 @@ void setBackOldAudioFreq(void) // for song-to-WAV rendering
if (mustRecalcTables)
{
- calcReplayRate(audio.freq);
+ calcReplayerVars(audio.freq);
calcRevMixDeltaTable();
}
}
@@ -1182,7 +1182,7 @@ bool setupAudio(bool showErrorMsg)
audio.dTickSampleCounter = 0.0; // zero tick sample counter so that it will instantly initiate a tick
- calcReplayRate(audio.freq);
+ calcReplayerVars(audio.freq);
if (song.speed == 0)
song.speed = 125;
diff --git a/src/ft2_module_loader.c b/src/ft2_module_loader.c
@@ -2283,7 +2283,6 @@ static bool loadInstrSample(FILE *f, uint16_t i, bool externalThreadFlag)
void unpackPatt(uint8_t *dst, uint8_t *src, uint16_t len, int32_t antChn)
{
- uint8_t note, data;
int32_t j;
if (dst == NULL)
@@ -2304,14 +2303,14 @@ void unpackPatt(uint8_t *dst, uint8_t *src, uint16_t len, int32_t antChn)
if (srcIdx >= srcEnd)
return; // error!
- note = *src++;
+ const uint8_t note = *src++;
if (note & 0x80)
{
- data = 0; if (note & 0x01) data = *src++; *dst++ = data;
- data = 0; if (note & 0x02) data = *src++; *dst++ = data;
- data = 0; if (note & 0x04) data = *src++; *dst++ = data;
- data = 0; if (note & 0x08) data = *src++; *dst++ = data;
- data = 0; if (note & 0x10) data = *src++; *dst++ = data;
+ *dst++ = (note & 0x01) ? *src++ : 0;
+ *dst++ = (note & 0x02) ? *src++ : 0;
+ *dst++ = (note & 0x04) ? *src++ : 0;
+ *dst++ = (note & 0x08) ? *src++ : 0;
+ *dst++ = (note & 0x10) ? *src++ : 0;
}
else
{
@@ -2342,7 +2341,7 @@ void unpackPatt(uint8_t *dst, uint8_t *src, uint16_t len, int32_t antChn)
if (srcIdx >= srcEnd)
return; // error!
- note = *src++;
+ const uint8_t note = *src++;
if (note & 0x80)
{
if (note & 0x01) src++;
diff --git a/src/ft2_module_loader.h b/src/ft2_module_loader.h
@@ -10,5 +10,4 @@ bool handleModuleLoadFromArg(int argc, char **argv);
void loadDroppedFile(char *fullPathUTF8, bool songModifiedCheck);
void handleLoadMusicEvents(void);
void clearUnusedChannels(tonTyp *p, int16_t pattLen, int32_t antChn);
-//void unpackPatt(uint8_t *dst, uint16_t inn, uint16_t len, int32_t antChn);
void checkSampleRepeat(sampleTyp *s);
diff --git a/src/ft2_replayer.c b/src/ft2_replayer.c
@@ -360,9 +360,10 @@ void calcReplayerLogTab(void)
dLogTab[i] = exp2(i / 768.0) * (8363.0 * 256.0);
}
-void calcReplayRate(int32_t audioFreq)
+void calcReplayerVars(int32_t audioFreq)
{
- if (audioFreq == 0)
+ assert(audioFreq > 0);
+ if (audioFreq <= 0)
return;
dHz2MixDeltaMul = (double)MIXER_FRAC_SCALE / audioFreq;
@@ -2749,7 +2750,12 @@ bool setupReplayer(void)
audio.linearFreqTable = true;
note2Period = linearPeriods;
- calcWindowedSincTables();
+ if (!calcWindowedSincTables())
+ {
+ showErrorMsgBox("Not enough memory!");
+ return false;
+ }
+
calcPeriod2HzTable();
calcRevMixDeltaTable();
calcPanningTable();
diff --git a/src/ft2_replayer.h b/src/ft2_replayer.h
@@ -252,7 +252,7 @@ void resetReplayerState(void);
void fixSongName(void); // removes spaces from right side of song name
void fixSampleName(int16_t nr); // removes spaces from right side of ins/smp names
-void calcReplayRate(int32_t rate);
+void calcReplayerVars(int32_t rate);
void tuneSample(sampleTyp *s, int32_t midCFreq);
void calcRevMixDeltaTable(void);