NukedOPL no longer converts generated samples to 16-bit before resampling.

This commit is contained in:
OBattler
2020-07-17 05:15:21 +02:00
parent 8b169648c8
commit 7b8c03c139
2 changed files with 6 additions and 19 deletions

View File

@@ -131,8 +131,8 @@ struct opl3_chip {
//OPL3L //OPL3L
Bit32s rateratio; Bit32s rateratio;
Bit32s samplecnt; Bit32s samplecnt;
Bit16s oldsamples[2]; Bit32s oldsamples[2];
Bit16s samples[2]; Bit32s samples[2];
Bit64u writebuf_samplecnt; Bit64u writebuf_samplecnt;
Bit32u writebuf_cur; Bit32u writebuf_cur;
@@ -141,7 +141,7 @@ struct opl3_chip {
struct opl3_writebuf writebuf[OPL_WRITEBUF_SIZE]; struct opl3_writebuf writebuf[OPL_WRITEBUF_SIZE];
}; };
void OPL3_Generate(struct opl3_chip *chip, Bit16s *buf); void OPL3_Generate(struct opl3_chip *chip, Bit32s *buf);
void OPL3_GenerateResampled(struct opl3_chip *chip, Bit32s *buf); void OPL3_GenerateResampled(struct opl3_chip *chip, Bit32s *buf);
void OPL3_Reset(struct opl3_chip *chip, Bit32u samplerate); void OPL3_Reset(struct opl3_chip *chip, Bit32u samplerate);
Bit32u OPL3_WriteAddr(struct opl3_chip *chip, Bit32u port, Bit8u val); Bit32u OPL3_WriteAddr(struct opl3_chip *chip, Bit32u port, Bit8u val);

View File

@@ -1030,27 +1030,14 @@ static void OPL3_ChannelSet4Op(struct opl3_chip *chip, Bit8u data)
} }
} }
static Bit16s OPL3_ClipSample(Bit32s sample) void OPL3_Generate(struct opl3_chip *chip, Bit32s *buf)
{
if (sample > 32767)
{
sample = 32767;
}
else if (sample < -32768)
{
sample = -32768;
}
return (Bit16s)sample;
}
void OPL3_Generate(struct opl3_chip *chip, Bit16s *buf)
{ {
Bit8u ii; Bit8u ii;
Bit8u jj; Bit8u jj;
Bit16s accm; Bit16s accm;
Bit8u shift = 0; Bit8u shift = 0;
buf[1] = OPL3_ClipSample(chip->mixbuff[1]); buf[1] = chip->mixbuff[1];
for (ii = 0; ii < 15; ii++) for (ii = 0; ii < 15; ii++)
{ {
@@ -1079,7 +1066,7 @@ void OPL3_Generate(struct opl3_chip *chip, Bit16s *buf)
OPL3_SlotGenerate(&chip->slot[ii]); OPL3_SlotGenerate(&chip->slot[ii]);
} }
buf[0] = OPL3_ClipSample(chip->mixbuff[0]); buf[0] = chip->mixbuff[0];
for (ii = 18; ii < 33; ii++) for (ii = 18; ii < 33; ii++)
{ {