Skip to content

Commit

Permalink
Renderer OPL through device test
Browse files Browse the repository at this point in the history
  • Loading branch information
Raffaello committed Oct 31, 2023
1 parent 2b0b9ae commit 5941636
Showing 1 changed file with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace HyperSonicDrivers::audio::sdl2
using devices::Adlib;
using hardware::opl::OplEmulator;

TEST(Renderer, test_adlib_mame2)
TEST(Renderer, adlib_mame2)
{
constexpr const char* exp_renderer = "../fixtures/test_renderer_adlib_mame2.wav";
constexpr const char* rfile = "test_renderer_adlib_mame2_out.wav";
Expand Down Expand Up @@ -52,6 +52,46 @@ namespace HyperSonicDrivers::audio::sdl2
EXPECT_EQ(sound->data[i], exp_sound->data[i]);
}
}

TEST(Renderer, adlib_mame2_device)
{
constexpr const char* exp_renderer = "../fixtures/test_renderer_adlib_mame2.wav";
constexpr const char* rfile = "test_renderer_adlib_mame2_out.wav";

if (std::filesystem::exists(rfile))
std::filesystem::remove(rfile);

ASSERT_FALSE(std::filesystem::exists(rfile));

audio::sdl2::Renderer r(44100, 1024);
r.setOutputFile(rfile);

auto mixer = r.getMixer();

auto adlib = devices::make_device<devices::Adlib, devices::Opl>(mixer, OplEmulator::MAME);
auto drv1 = drivers::westwood::ADLDriver(adlib, eChannelGroup::Music);
auto af = std::make_shared<files::westwood::ADLFile>("../fixtures/DUNE0.ADL");
drv1.setADLFile(af);

drv1.play(4);
while (drv1.isPlaying())
r.renderBuffer(adlib);

r.releaseOutputFile();

files::WAVFile w(rfile);
auto sound = w.getSound();
files::WAVFile wexp(exp_renderer);
auto exp_sound = wexp.getSound();

ASSERT_EQ(sound->dataSize, exp_sound->dataSize);
ASSERT_EQ(sound->freq, exp_sound->freq);
ASSERT_EQ(sound->stereo, exp_sound->stereo);
for (uint32_t i = 0; i < sound->dataSize; i++)
{
EXPECT_EQ(sound->data[i], exp_sound->data[i]);
}
}
}

int main(int argc, char** argv)
Expand Down

0 comments on commit 5941636

Please sign in to comment.