Just resample rather than reset

This commit is contained in:
cam900 2023-05-13 18:54:05 +09:00
parent 967cc86ec9
commit 0c5a6d9760
4 changed files with 13 additions and 2 deletions

View File

@ -1,4 +1,4 @@
# modification disclaimer
this is a modified version of Nuked-OPL3 which implements channel muting in the core.
this is a modified version of Nuked-OPL3 which implements channel muting in the core, and resampling function.
see [this issue](https://github.com/tildearrow/furnace/issues/414) for more information.

5
extern/opl/opl3.c vendored
View File

@ -1362,6 +1362,11 @@ void OPL3_Reset(opl3_chip *chip, uint32_t samplerate)
#endif
}
void OPL3_Resample(opl3_chip *chip, uint32_t samplerate)
{
chip->rateratio = (samplerate << RSM_FRAC) / 49716;
}
void OPL3_WriteReg(opl3_chip *chip, uint16_t reg, uint8_t v)
{
uint8_t high = (reg >> 8) & 0x01;

1
extern/opl/opl3.h vendored
View File

@ -158,6 +158,7 @@ struct _opl3_chip {
void OPL3_Generate(opl3_chip *chip, int16_t *buf);
void OPL3_GenerateResampled(opl3_chip *chip, int16_t *buf);
void OPL3_Reset(opl3_chip *chip, uint32_t samplerate);
void OPL3_Resample(opl3_chip *chip, uint32_t samplerate);
void OPL3_WriteReg(opl3_chip *chip, uint16_t reg, uint8_t v);
void OPL3_WriteRegBuffered(opl3_chip *chip, uint16_t reg, uint8_t v);
void OPL3_GenerateStream(opl3_chip *chip, int16_t *sndptr, uint32_t numsamples);

View File

@ -1866,7 +1866,12 @@ void DivPlatformOPL::setFlags(const DivConfig& flags) {
totalOutputs=4;
break;
}
reset();
if (downsample) {
const unsigned int downsampledRate=(unsigned int)((double)rate*49716.0/(double)chipRateBase);
OPL3_Resample(&fm,downsampledRate);
} else {
OPL3_Resample(&fm,rate);
}
break;
case 4:
switch (flags.getInt("clockSel",0)) {