Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加新的音频引擎 miniaudio #2679

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

yybbwc
Copy link
Contributor

@yybbwc yybbwc commented Feb 16, 2025

https://miniaud.io/docs/manual/

有点疑虑

if (scene != bgm_scene or ! ma_sound_is_playing(&soundBGM)) {

这里好像未经初始化就使用变量了,而我自己编译时往往带了-ftrivial-auto-var-init=zero,用于把变量自动初始化为0。

premake未测试……
大概没问题……

@purerosefallen
Copy link
Collaborator

purerosefallen commented Feb 16, 2025

Can it run on Mac or Linux?
btw you may wipe off irrklang completely because that lib actually does not comply with YGOPro's open source license GPLv2.
Go ahead!

auto name = BGMList[scene][bgm].c_str();
wchar_t fname[1024];
myswprintf(fname, L"./sound/BGM/%ls", name);
PlayMusic(reinterpret_cast<char*>(fname), false);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use EncodeUTF8 rather than reinterpret_cast

return;
ma_sound_uninit(&soundBGM);
#ifdef _WIN32
ma_sound_init_from_file_w(&engineMusic, reinterpret_cast<wchar_t*>(song), MA_SOUND_FLAG_ASYNC | MA_SOUND_FLAG_STREAM, nullptr, nullptr, &soundBGM);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also DecodeUTF8 here.

@@ -177,6 +188,139 @@ void SoundManager::PlaySoundEffect(int sound) {
break;
}
#endif
#ifdef YGOPRO_USE_MINIAUDIO
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use #elif

@@ -25,6 +25,17 @@ bool SoundManager::Init() {
}
#endif // YGOPRO_USE_IRRKLANG
// TODO: Implement other sound engines
#ifdef YGOPRO_USE_MINIAUDIO
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use #elif

break;
}
case SOUND_COMMON_FEEDBACK: {
ma_engine_play_sound(&engineSound, "./sound/common_feedback.wav", nullptr);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used in YGOPro. Please remove it for now.

BUILD_MINIAUDIO = false
end
if not BUILD_miniaudio then
MINIAUDIO_INCLUDE_DIR = GetParam("miniaudio-include-dir") or "/usr/local/include"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

miniaudio being a single header library, everything in premake5.lua is not needed.
You may toss the miniaudio.h file to gframe directory directly. But remember to add some conditional checks in gframe/premake5.lua

@yybbwc
Copy link
Contributor Author

yybbwc commented Feb 16, 2025

哦,我晚点改,现在在写xmake。

@purerosefallen
Copy link
Collaborator

哦,我晚点改,现在在写xmake。

#2681

I'm planning to use this one. Thanks for your work anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants