M pmp_mix.c => pmp_mix.c +2 -2
@@ 305,7 305,7 @@ void mix_UpdateBuffer(int16_t *buffer, int32_t numSamples)
** Instead we change the amplitude here.
*/
- if (masterVol == 256) // 8bb: max master volume, no need to change amp
+ if (ctx->masterVol == 256) // 8bb: max master volume, no need to change amp
{
for (int32_t i = 0; i < numSamples; i++)
{
@@ 320,7 320,7 @@ void mix_UpdateBuffer(int16_t *buffer, int32_t numSamples)
{
int32_t out32 = CDA_MixBuffer[i] >> 8;
CLAMP16(out32);
- out32 = (out32 * masterVol) >> 8;
+ out32 = (out32 * ctx->masterVol) >> 8;
buffer[i] = (int16_t)out32;
}
}
M pmplay.c => pmplay.c +9 -3
@@ 132,7 132,7 @@ patternHeaderTyp;
static int32_t soundBufferSize;
// globalized
-int32_t masterVol = DEFAULT_MASTER_VOL, PMPLeft = 0;
+int32_t PMPLeft = 0;
int32_t realReplayRate, quickVolSizeVal, speedVal;
uint32_t frequenceDivFactor, frequenceMulFactor, CDA_Amp = 8*DEFAULT_AMP;
tonTyp *patt[256];
@@ 1161,7 1161,10 @@ void setVolumeRamping(bool on)
void setMasterVol(int32_t v) // 0..256
{
- masterVol = CLAMP(v, 0, 256);
+ pmplay_ctx *ctx;
+ ctx = &PMPlayContext;
+
+ ctx->masterVol = CLAMP(v, 0, 256);
stmTyp *ch = stm;
for (int32_t i = 0; i < 32; i++, ch++)
@@ 1178,7 1181,9 @@ void setAmp(int32_t level) // 1..32
int32_t getMasterVol(void) // 8bb: added this
{
- return masterVol;
+ pmplay_ctx *ctx;
+ ctx = &PMPlayContext;
+ return ctx->masterVol;
}
int32_t getAmp(void) // 8bb: added this
@@ 1467,4 1472,5 @@ void pmplay_init(void)
ctx->interpolationFlag = true;
ctx->boostLevel = DEFAULT_AMP;
+ ctx->masterVol = DEFAULT_MASTER_VOL;
}
M pmplay.h => pmplay.h +2 -1
@@ 130,10 130,11 @@ typedef struct {
const uint16_t *note2Period;
uint16_t pattLens[256];
int16_t PMPTmpActiveChannel, boostLevel;
+ int32_t masterVol; //, PMPLeft;
} pmplay_ctx;
// globalized
-extern int32_t masterVol, PMPLeft;
+extern int32_t PMPLeft;
extern int32_t realReplayRate, quickVolSizeVal, speedVal;
extern uint32_t frequenceDivFactor, frequenceMulFactor;
extern uint32_t CDA_Amp;