Skip to content

Commit

Permalink
dosbox generateSamples improvements (#280)
Browse files Browse the repository at this point in the history
* dosbox generateSamples improvements

* update version
  • Loading branch information
Raffaello authored Nov 12, 2023
1 parent a133242 commit 1ceb2a6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
endif()


project ("sdl2-hyper-sonic-drivers" VERSION 0.15.3 DESCRIPTION "SDL2 based Hyper-Sonic Drivers for emulating old soundcards")
project ("sdl2-hyper-sonic-drivers" VERSION 0.15.4 DESCRIPTION "SDL2 based Hyper-Sonic Drivers for emulating old soundcards")
include (TestBigEndian)
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
if(IS_BIG_ENDIAN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,37 +214,42 @@ namespace HyperSonicDrivers::hardware::opl::scummvm::dosbox

if(isStereo())
{
while (length_ > 0)
if (m_emulator->opl3Active) // DUAL_OPL2 or OPL3 in OPL3 mode
{
const unsigned int readSamples = std::min<unsigned int>(length_, bufferLength);
const unsigned int readSamples2 = (readSamples << 1);
if (m_emulator->opl3Active)
while (length_ > 0)
{
const unsigned int readSamples = std::min<unsigned int>(length_, bufferLength);
const unsigned int readSamples2 = (readSamples << 1);
m_emulator->GenerateBlock3(readSamples, tempBuffer.data());
for (unsigned int i = 0; i < readSamples2; ++i)
buffer[i] = static_cast<int16_t>(tempBuffer[i]);

buffer += static_cast<int16_t>(readSamples2);
length_ -= readSamples;
}
else
}
else // OPL3 in OPL2 compatibility mode
{
while (length_ > 0)
{
const unsigned int readSamples = std::min<unsigned int>(length_, bufferLength);
const unsigned int readSamples2 = (readSamples << 1);
m_emulator->GenerateBlock2(readSamples, tempBuffer.data());
for (unsigned int i = 0, j =0; i < readSamples; ++i, j+=2)
{
buffer[j] = buffer[j+1] = static_cast<int16_t>(tempBuffer[i]);
}
}
for (unsigned int i = 0, j = 0; i < readSamples; ++i, j += 2)
buffer[j] = buffer[j + 1] = static_cast<int16_t>(tempBuffer[i]);

buffer += static_cast<int16_t>(readSamples2);
length_ -= readSamples;

buffer += static_cast<int16_t>(readSamples2);
length_ -= readSamples;
}
}
}
else
else // OPL2
{
while (length_ > 0)
{
const unsigned int readSamples = std::min<unsigned int>(length_, bufferLength << 1);

m_emulator->GenerateBlock2(readSamples, tempBuffer.data());

for (unsigned int i = 0; i < readSamples; ++i)
buffer[i] = static_cast<int16_t>(tempBuffer[i]);

Expand Down

0 comments on commit 1ceb2a6

Please sign in to comment.