Skip to content

Commit

Permalink
small code reviews (#283)
Browse files Browse the repository at this point in the history
* init

* rabbit code rev

* update version

* code rev
  • Loading branch information
Raffaello authored Nov 14, 2023
1 parent 822e477 commit 18b0a17
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 13 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.17.0 DESCRIPTION "SDL2 based Hyper-Sonic Drivers for emulating old soundcards")
project ("sdl2-hyper-sonic-drivers" VERSION 0.17.1 DESCRIPTION "SDL2 based Hyper-Sonic Drivers for emulating old soundcards")
include (TestBigEndian)
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
if(IS_BIG_ENDIAN)
Expand Down
57 changes: 55 additions & 2 deletions sdl2-hyper-sonic-drivers/sdl2-hyper-sonic-drivers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,58 @@ void pcm_sound_append()
}
}

//void adldune2filestest()
//{
// auto mixer = audio::make_mixer<audio::sdl2::Mixer>(8, 44100, 1024);
// mixer->init();
//
// auto device = devices::make_device<devices::Adlib, devices::Opl>(mixer);
// drivers::westwood::ADLDriver drv(device, audio::mixer::eChannelGroup::Music);
//
// SDL_InitSubSystem(SDL_INIT_EVENTS);
// SDL_InitSubSystem(SDL_INIT_VIDEO);
//
// auto window = SDL_CreateWindow("a", 0, 0, 320, 200, 0);
//
// for (int f = 0; f <= 0; f++)
// {
// const std::string fn = "adl/DUNE" + std::to_string(f) + ".ADL";
// utils::ILogger::instance->info(std::format("opening file: {}", fn), utils::ILogger::eCategory::Application);
// auto adlf = std::make_shared<files::westwood::ADLFile>(fn);
// drv.setADLFile(adlf);
// for (int i = 0; i < adlf->getNumTracks(); i++)
// {
// utils::ILogger::instance->info(std::format("playing track: {}", i), utils::ILogger::eCategory::Application);
// drv.play(i);
// while (drv.isPlaying())
// {
// utils::delayMillis(200);
// SDL_Event e;
// while (SDL_PollEvent(&e))
// switch (e.type)
// {
// case SDL_QUIT:
// goto QUIT;
// case SDL_KEYDOWN:
// //case SDL_KEYUP:
// if (e.key.keysym.sym == SDLK_ESCAPE)
// goto QUIT;
// if (e.key.keysym.sym == SDLK_RETURN)
// drv.stop();
// break;
//
// default:
// std::cout << "event: " << e.type << std::endl;
// }
// }
// drv.stopAllChannels();
// utils::delayMillis(1000);
// }
// }
//QUIT:
// SDL_DestroyWindow(window);
//}

int main(int argc, char* argv[])
{
//newMixerTest();
Expand All @@ -419,8 +471,9 @@ int main(int argc, char* argv[])
//midi_adlib();
//testMT32();

pcm_sound_append();
return 0;
//pcm_sound_append();
//adldune2filestest();
//return 0;
//sdlMixer();
//SDL_Delay(100);
//renderMixer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace HyperSonicDrivers::audio
virtual bool isPaused(const uint8_t id) const noexcept = 0;

virtual bool isActive() const noexcept = 0;
virtual bool isActive(const mixer::eChannelGroup group) = 0;
virtual bool isActive(const mixer::eChannelGroup group) const noexcept = 0;

virtual bool isChannelGroupMuted(const mixer::eChannelGroup group) const noexcept = 0;
virtual void muteChannelGroup(const mixer::eChannelGroup group) noexcept = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ namespace HyperSonicDrivers::audio::sdl2
{ return !ch->isEnded(); });
}

bool Mixer::isActive(const mixer::eChannelGroup group)
bool Mixer::isActive(const mixer::eChannelGroup group) const noexcept
{
std::scoped_lock lck(m_mutex);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ namespace HyperSonicDrivers::audio::sdl2
bool isPaused(const uint8_t id) const noexcept override;

bool isActive() const noexcept override;
bool isActive(const mixer::eChannelGroup group) override;
bool isActive(const mixer::eChannelGroup group) const noexcept override;

bool isChannelGroupMuted(const mixer::eChannelGroup group) const noexcept override;;
bool isChannelGroupMuted(const mixer::eChannelGroup group) const noexcept override;
void muteChannelGroup(const mixer::eChannelGroup group) noexcept override;
void unmuteChannelGroup(const mixer::eChannelGroup group) noexcept override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace HyperSonicDrivers::devices

eDeviceName MT32::getName() const noexcept
{
return eDeviceName::MT32;
return eDeviceName::Mt32;
}

void MT32::lcd_message(const std::string& msg) noexcept
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ namespace HyperSonicDrivers::devices
Adlib,
SbPro,
SbPro2,
MT32
Mt32
};
}
4 changes: 2 additions & 2 deletions sdl2-hyper-sonic-drivers/src/std/IDeviceTypesFormatter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ namespace std
case SbPro2:
str = "SbPro2";
break;
case MT32:
str = "MT32";
case Mt32:
str = "Mt32";
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace HyperSonicDrivers::audio
bool isActive(const uint8_t id) const noexcept override { return true; };
bool isPaused(const uint8_t id) const noexcept override { return false; }
bool isActive() const noexcept override { return true; };
bool isActive(const mixer::eChannelGroup group) override { return true; };
bool isActive(const mixer::eChannelGroup group) const noexcept override { return true; };
bool isChannelGroupMuted(const mixer::eChannelGroup group) const noexcept override { return false; };
void muteChannelGroup(const mixer::eChannelGroup group) noexcept override {};
void unmuteChannelGroup(const mixer::eChannelGroup group) noexcept override {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ namespace std
{
TEST(IDeviceTypesFormatter, Music)
{
ASSERT_STRCASEEQ(std::format("{}", HyperSonicDrivers::devices::eDeviceName::Adlib).c_str(), "Adlib");
EXPECT_STRCASEEQ(std::format("{}", HyperSonicDrivers::devices::eDeviceName::Adlib).c_str(), "Adlib");
EXPECT_STRCASEEQ(std::format("{}", HyperSonicDrivers::devices::eDeviceName::Mt32).c_str(), "Mt32");
EXPECT_STRCASEEQ(std::format("{}", HyperSonicDrivers::devices::eDeviceName::SbPro).c_str(), "SbPro");
EXPECT_STRCASEEQ(std::format("{}", HyperSonicDrivers::devices::eDeviceName::SbPro2).c_str(), "SbPro2");
}
}

Expand Down

0 comments on commit 18b0a17

Please sign in to comment.