Skip to content

Commit 1ceb2a6

Browse files
authored
dosbox generateSamples improvements (#280)
* dosbox generateSamples improvements * update version
1 parent a133242 commit 1ceb2a6

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
55
endif()
66

77

8-
project ("sdl2-hyper-sonic-drivers" VERSION 0.15.3 DESCRIPTION "SDL2 based Hyper-Sonic Drivers for emulating old soundcards")
8+
project ("sdl2-hyper-sonic-drivers" VERSION 0.15.4 DESCRIPTION "SDL2 based Hyper-Sonic Drivers for emulating old soundcards")
99
include (TestBigEndian)
1010
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
1111
if(IS_BIG_ENDIAN)

sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/hardware/opl/scummvm/dosbox/DosBoxOPL.cpp

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -214,37 +214,42 @@ namespace HyperSonicDrivers::hardware::opl::scummvm::dosbox
214214

215215
if(isStereo())
216216
{
217-
while (length_ > 0)
217+
if (m_emulator->opl3Active) // DUAL_OPL2 or OPL3 in OPL3 mode
218218
{
219-
const unsigned int readSamples = std::min<unsigned int>(length_, bufferLength);
220-
const unsigned int readSamples2 = (readSamples << 1);
221-
if (m_emulator->opl3Active)
219+
while (length_ > 0)
222220
{
221+
const unsigned int readSamples = std::min<unsigned int>(length_, bufferLength);
222+
const unsigned int readSamples2 = (readSamples << 1);
223223
m_emulator->GenerateBlock3(readSamples, tempBuffer.data());
224224
for (unsigned int i = 0; i < readSamples2; ++i)
225225
buffer[i] = static_cast<int16_t>(tempBuffer[i]);
226+
227+
buffer += static_cast<int16_t>(readSamples2);
228+
length_ -= readSamples;
226229
}
227-
else
230+
}
231+
else // OPL3 in OPL2 compatibility mode
232+
{
233+
while (length_ > 0)
228234
{
235+
const unsigned int readSamples = std::min<unsigned int>(length_, bufferLength);
236+
const unsigned int readSamples2 = (readSamples << 1);
229237
m_emulator->GenerateBlock2(readSamples, tempBuffer.data());
230-
for (unsigned int i = 0, j =0; i < readSamples; ++i, j+=2)
231-
{
232-
buffer[j] = buffer[j+1] = static_cast<int16_t>(tempBuffer[i]);
233-
}
234-
}
238+
for (unsigned int i = 0, j = 0; i < readSamples; ++i, j += 2)
239+
buffer[j] = buffer[j + 1] = static_cast<int16_t>(tempBuffer[i]);
235240

236-
buffer += static_cast<int16_t>(readSamples2);
237-
length_ -= readSamples;
241+
242+
buffer += static_cast<int16_t>(readSamples2);
243+
length_ -= readSamples;
244+
}
238245
}
239246
}
240-
else
247+
else // OPL2
241248
{
242249
while (length_ > 0)
243250
{
244251
const unsigned int readSamples = std::min<unsigned int>(length_, bufferLength << 1);
245-
246252
m_emulator->GenerateBlock2(readSamples, tempBuffer.data());
247-
248253
for (unsigned int i = 0; i < readSamples; ++i)
249254
buffer[i] = static_cast<int16_t>(tempBuffer[i]);
250255

0 commit comments

Comments
 (0)