fix build error

hopefully
This commit is contained in:
tildearrow 2023-08-12 02:52:50 -05:00
parent 27e454e7aa
commit 94cb733c60
2 changed files with 15 additions and 9 deletions

View file

@ -448,7 +448,7 @@ void DivPlatformC140::renderSamples(int sysID) {
} else { } else {
if (s->depth==DIV_SAMPLE_DEPTH_MULAW) { if (s->depth==DIV_SAMPLE_DEPTH_MULAW) {
for (unsigned int i=0; i<length; i++) { for (unsigned int i=0; i<length; i++) {
sampleMem[i+(memPos/sizeof(short))]=(s->dataMuLaw[i]<<8)^0xff00; sampleMem[i+(memPos/sizeof(short))]=((s->dataMuLaw[i]^0xff)<<8);
} }
} else { } else {
memcpy(sampleMem+(memPos/sizeof(short)),s->data16,length); memcpy(sampleMem+(memPos/sizeof(short)),s->data16,length);

View file

@ -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)) #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) { void DivSample::render(unsigned int formatMask) {
// step 1: convert to 16-bit if needed // step 1: convert to 16-bit if needed
if (depth!=DIV_SAMPLE_DEPTH_16BIT) { if (depth!=DIV_SAMPLE_DEPTH_16BIT) {
@ -1173,9 +1178,10 @@ void DivSample::render(unsigned int formatMask) {
break; break;
case DIV_SAMPLE_DEPTH_MULAW: // 8-bit µ-law PCM case DIV_SAMPLE_DEPTH_MULAW: // 8-bit µ-law PCM
for (unsigned int i=0; i<samples; i++) { for (unsigned int i=0; i<samples; i++) {
unsigned int s=(dataMuLaw[i]^0xff); IntFloat s;
s=0x3f800000+(((s<<24)&0x80000000)|((s&0x7f)<<19)); s.i=(dataMuLaw[i]^0xff);
data16[i]=(short)((*(float*)&s)*128.0f); s.i=0x3f800000+(((s.i<<24)&0x80000000)|((s.i&0x7f)<<19));
data16[i]=(short)(s.f*128.0f);
} }
break; break;
default: default:
@ -1259,11 +1265,11 @@ void DivSample::render(unsigned int formatMask) {
if (NOT_IN_FORMAT(DIV_SAMPLE_DEPTH_MULAW)) { // µ-law if (NOT_IN_FORMAT(DIV_SAMPLE_DEPTH_MULAW)) { // µ-law
if (!initInternal(DIV_SAMPLE_DEPTH_MULAW,samples)) return; if (!initInternal(DIV_SAMPLE_DEPTH_MULAW,samples)) return;
for (unsigned int i=0; i<samples; i++) { for (unsigned int i=0; i<samples; i++) {
float s=(float)-data16[i]; IntFloat s;
s/=32768.0f; s.f=(float)-data16[i];
unsigned int si=*(unsigned int*)&s; s.f/=32768.0f;
si-=0x3f800000; s.i-=0x3f800000;
dataMuLaw[i]=(((si&0x80000000)>>24)|((si&0x03f80000)>>19))^0xff; dataMuLaw[i]=(((s.i&0x80000000)>>24)|((s.i&0x03f80000)>>19))^0xff;
} }
} }
} }