2
0
Fork 0

Fix noise issue in Reaper (and possibly other VST hosts) caused by calls with buffer lengths > 512 bytes.

This commit is contained in:
bsutherland 2016-05-14 13:37:38 +09:00
parent a1b70cebc4
commit d1824927f5
2 changed files with 11 additions and 1 deletions

View file

@ -1498,6 +1498,8 @@ void Handler::WriteReg( Bit32u addr, Bit8u val ) {
}
void Handler::Generate( Bitu samples, Bit32s* buffer ) {
// Not sure why this is here, possibly limited length of LUT etc?
// Limiting calls to 512 bytes at a time in HiOPL.
if ( GCC_UNLIKELY(samples > 512) )
samples = 512;
if ( !chip.opl3Active ) {

View file

@ -50,7 +50,15 @@ void Hiopl::SetEmulator(Emulator emulator) {
void Hiopl::Generate(int length, float* buffer) {
intermediateBufIdx = (intermediateBufIdx + 1) % INTERMEDIATE_BUF_N;
Bit32s *iBuf = intermediateBuf[intermediateBufIdx];
adlib->Generate(length, iBuf);
int fullCalls = length / 512; // the emulator is limited to 512 bytes per call
int c = 0;
for (; c < fullCalls; c++) {
adlib->Generate(512, iBuf + (c * 512));
}
// final (or only) call
if (length % 512 > 0) {
adlib->Generate(length % 512, iBuf + (c * 512));
}
for (int i = 0; i < length; i++) {
// Magic divisor taken from ZDoom wrapper for DOSBox emulator, line 892
// https://github.com/rheit/zdoom/blob/master/src/oplsynth/dosbox/opl.cpp