From 94cb733c60737b297acc8dc8f46fad5d9ab7eee3 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sat, 12 Aug 2023 02:52:50 -0500 Subject: [PATCH] fix build error hopefully --- src/engine/platform/c140.cpp | 2 +- src/engine/sample.cpp | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/engine/platform/c140.cpp b/src/engine/platform/c140.cpp index 55f4983ad..f2ee8dfef 100644 --- a/src/engine/platform/c140.cpp +++ b/src/engine/platform/c140.cpp @@ -448,7 +448,7 @@ void DivPlatformC140::renderSamples(int sysID) { } else { if (s->depth==DIV_SAMPLE_DEPTH_MULAW) { for (unsigned int i=0; idataMuLaw[i]<<8)^0xff00; + sampleMem[i+(memPos/sizeof(short))]=((s->dataMuLaw[i]^0xff)<<8); } } else { memcpy(sampleMem+(memPos/sizeof(short)),s->data16,length); diff --git a/src/engine/sample.cpp b/src/engine/sample.cpp index 127f3eff6..8ddcf2297 100644 --- a/src/engine/sample.cpp +++ b/src/engine/sample.cpp @@ -1128,6 +1128,11 @@ bool DivSample::resample(double sRate, double tRate, int filter) { #define NOT_IN_FORMAT(x) (depth!=x && formatMask&(1U<<(unsigned int)x)) +union IntFloat { + unsigned int i; + float f; +}; + void DivSample::render(unsigned int formatMask) { // step 1: convert to 16-bit if needed if (depth!=DIV_SAMPLE_DEPTH_16BIT) { @@ -1173,9 +1178,10 @@ void DivSample::render(unsigned int formatMask) { break; case DIV_SAMPLE_DEPTH_MULAW: // 8-bit µ-law PCM for (unsigned int i=0; i>24)|((si&0x03f80000)>>19))^0xff; + IntFloat s; + s.f=(float)-data16[i]; + s.f/=32768.0f; + s.i-=0x3f800000; + dataMuLaw[i]=(((s.i&0x80000000)>>24)|((s.i&0x03f80000)>>19))^0xff; } } }