#include #include #include #include #include #include #include #include #include #include #include #include #include // inlining zip #include "res/erik_gun_fx_1.zip.h" using namespace entt::literals; extern char* argv0; TEST(soloud_fs_loader, wav) { MM::Engine engine; // setup auto& sound = engine.addService(); ASSERT_TRUE(engine.enableService()); engine.addService(argv0, "soloud_filesystem_loader_test"); ASSERT_TRUE(engine.enableService()); auto& rm = MM::ResourceManager::ref(); ASSERT_TRUE(PHYSFS_mountMemory(erik_gun_fx_1_zip, erik_gun_fx_1_zip_len, NULL, "", NULL, 0)); sound.engine.setGlobalVolume(0.4f); ASSERT_FALSE(rm.contains("test"_hs)); rm.load("test", "does_not_exist.wav", engine); ASSERT_FALSE(rm.contains("test"_hs)); rm.load("test", "erik_gun_fx_1.flac", engine); ASSERT_TRUE(rm.contains("test"_hs)); auto wh = rm.get("test"_hs); std::cout << "wav length: " << wh->getLength() << "s" << std::endl; sound.engine.play(*wh); while (sound.engine.getActiveVoiceCount()) { using namespace std::chrono_literals; std::this_thread::sleep_for(5ms); } rm.clear(); } TEST(soloud_fs_loader, sfxr) { MM::Engine engine; // setup auto& sound = engine.addService(); ASSERT_TRUE(engine.enableService()); engine.addService(argv0, "soloud_filesystem_loader_test"); ASSERT_TRUE(engine.enableService()); auto& rm = MM::ResourceManager::ref(); sound.engine.setGlobalVolume(0.4f); ASSERT_FALSE(rm.contains("test_preset"_hs)); rm.load("test_preset", ::SoLoud::Sfxr::SFXR_PRESETS::EXPLOSION, 0); ASSERT_TRUE(rm.contains("test_preset"_hs)); // TODO: add load from json // TODO: add load from json from file { auto sh = rm.get("test_preset"_hs); sound.engine.play(*sh); while (sound.engine.getActiveVoiceCount()) { using namespace std::chrono_literals; std::this_thread::sleep_for(5ms); } } rm.clear(); }