From 772d4f180ba70855b0071a031982e47adcea2bd5 Mon Sep 17 00:00:00 2001 From: Paul Batchelor Date: Wed, 21 Jun 2023 14:02:30 -0400 Subject: [PATCH] PMPLeft --- pmp_mix.c | 16 ++++++++++------ pmplay.c | 1 - pmplay.h | 3 +-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/pmp_mix.c b/pmp_mix.c index 9c3d3aa..db18438 100644 --- a/pmp_mix.c +++ b/pmp_mix.c @@ -52,11 +52,15 @@ void P_StartTone(sampleTyp *s, int32_t smpStartPos) // 8bb: added these two bool mix_Init(int32_t audioBufferSize) { + pmplay_ctx *ctx; + + ctx = &PMPlayContext; + CDA_MixBuffer = (int32_t *)malloc(audioBufferSize * 2 * sizeof (int32_t)); if (CDA_MixBuffer == NULL) return false; - PMPLeft = 0; + ctx->PMPLeft = 0; return true; } @@ -277,17 +281,17 @@ void mix_UpdateBuffer(int16_t *buffer, int32_t numSamples) while (a > 0) { - if (PMPLeft == 0) + if (ctx->PMPLeft == 0) { mix_SaveIPVolumes(); mainPlayer(); mix_UpdateChannelVolPanFrq(); - PMPLeft = speedVal; + ctx->PMPLeft = speedVal; } int32_t b = a; - if (b > PMPLeft) - b = PMPLeft; + if (b > ctx->PMPLeft) + b = ctx->PMPLeft; CIType *v = CI; for (int32_t i = 0; i < song.antChn*2; i++, v++) @@ -295,7 +299,7 @@ void mix_UpdateBuffer(int16_t *buffer, int32_t numSamples) c += b; a -= b; - PMPLeft -= b; + ctx->PMPLeft -= b; } numSamples *= 2; // 8bb: stereo diff --git a/pmplay.c b/pmplay.c index a325f1b..9282c8d 100644 --- a/pmplay.c +++ b/pmplay.c @@ -132,7 +132,6 @@ patternHeaderTyp; static int32_t soundBufferSize; // globalized -int32_t PMPLeft = 0; int32_t realReplayRate, quickVolSizeVal, speedVal; uint32_t frequenceDivFactor, frequenceMulFactor, CDA_Amp = 8*DEFAULT_AMP; tonTyp *patt[256]; diff --git a/pmplay.h b/pmplay.h index 009d3cd..21840f4 100644 --- a/pmplay.h +++ b/pmplay.h @@ -130,11 +130,10 @@ typedef struct { const uint16_t *note2Period; uint16_t pattLens[256]; int16_t PMPTmpActiveChannel, boostLevel; - int32_t masterVol; //, PMPLeft; + int32_t masterVol, PMPLeft; } pmplay_ctx; // globalized -extern int32_t PMPLeft; extern int32_t realReplayRate, quickVolSizeVal, speedVal; extern uint32_t frequenceDivFactor, frequenceMulFactor; extern uint32_t CDA_Amp; -- 2.45.2