ref: 2e7bfbda73d923e35b533193c0b3fee8c90bd5e0
parent: 9bbd17fed5701c6ef6264b1fa84c1098d7918ffa
author: Olav Sørensen <olav.sorensen@live.no>
date: Sat Dec 5 11:36:43 EST 2020
Some minor cleanup
--- a/src/ft2_audio.c
+++ b/src/ft2_audio.c
@@ -141,7 +141,7 @@
const bool mustRecalcTables = audio.freq != oldAudioFreq;
if (mustRecalcTables)
{
- calcReplayRate(audio.freq);
+ calcReplayerVars(audio.freq);
calcRevMixDeltaTable();
}
}
@@ -154,7 +154,7 @@
if (mustRecalcTables)
{
- calcReplayRate(audio.freq);
+ calcReplayerVars(audio.freq);
calcRevMixDeltaTable();
}
}
@@ -1182,7 +1182,7 @@
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;
--- a/src/ft2_module_loader.c
+++ b/src/ft2_module_loader.c
@@ -2283,7 +2283,6 @@
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 @@
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 @@
if (srcIdx >= srcEnd)
return; // error!
- note = *src++;
+ const uint8_t note = *src++;
if (note & 0x80)
{
if (note & 0x01) src++;
--- a/src/ft2_module_loader.h
+++ b/src/ft2_module_loader.h
@@ -10,5 +10,4 @@
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);
--- a/src/ft2_replayer.c
+++ b/src/ft2_replayer.c
@@ -360,9 +360,10 @@
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 @@
audio.linearFreqTable = true;
note2Period = linearPeriods;
- calcWindowedSincTables();
+ if (!calcWindowedSincTables())
+ {
+ showErrorMsgBox("Not enough memory!");
+ return false;
+ }
+
calcPeriod2HzTable();
calcRevMixDeltaTable();
calcPanningTable();
--- a/src/ft2_replayer.h
+++ b/src/ft2_replayer.h
@@ -252,7 +252,7 @@
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);