Commit baf31a81 authored by nanahira's avatar nanahira

Merge branch 'patch-miniaudio' of github.com:mercury233/ygopro into test-miniaudio-another

parents dd1326bc 8818dc40
...@@ -90,6 +90,55 @@ jobs: ...@@ -90,6 +90,55 @@ jobs:
7z x ${{ steps.sqlite.outputs.filepath }} 7z x ${{ steps.sqlite.outputs.filepath }}
move sqlite-amalgamation-3490100 sqlite3 move sqlite-amalgamation-3490100 sqlite3
- name: Download miniaudio
shell: bash
run: |
git clone --depth=1 --branch 0.11.22 https://github.com/mackron/miniaudio
- name: Download ogg
id: ogg
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://github.com/xiph/ogg/releases/download/v1.3.5/libogg-1.3.5.tar.gz
- name: Extract ogg
run: |
tar xf ${{ steps.ogg.outputs.filepath }}
move libogg-1.3.5 miniaudio/external/ogg
- name: Download opus
id: opus
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://github.com/xiph/opus/releases/download/v1.5.2/opus-1.5.2.tar.gz
- name: Extract opus
run: |
tar xf ${{ steps.opus.outputs.filepath }}
move opus-1.5.2 miniaudio/external/opus
- name: Download opusfile
id: opusfile
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://github.com/xiph/opusfile/releases/download/v0.12/opusfile-0.12.tar.gz
- name: Extract opusfile
run: |
tar xf ${{ steps.opusfile.outputs.filepath }}
move opusfile-0.12 miniaudio/external/opusfile
- name: Download vorbis
id: vorbis
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://github.com/xiph/vorbis/releases/download/v1.3.7/libvorbis-1.3.7.tar.gz
- name: Extract vorbis
run: |
tar xf ${{ steps.vorbis.outputs.filepath }}
move libvorbis-1.3.7 miniaudio/external/vorbis
- name: Download irrlicht - name: Download irrlicht
run: | run: |
git clone --depth=1 https://github.com/mercury233/irrlicht git clone --depth=1 https://github.com/mercury233/irrlicht
...@@ -186,7 +235,7 @@ jobs: ...@@ -186,7 +235,7 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install -y libevent-dev libfreetype6-dev libgl1-mesa-dev libglu1-mesa-dev libsqlite3-dev libxxf86vm-dev sudo apt-get install -y libevent-dev libfreetype6-dev libgl1-mesa-dev libglu1-mesa-dev libsqlite3-dev libxxf86vm-dev libopusfile-dev libvorbis-dev
- name: Download premake - name: Download premake
id: premake id: premake
...@@ -211,6 +260,10 @@ jobs: ...@@ -211,6 +260,10 @@ jobs:
tar xf ${{ steps.lua.outputs.filepath }} tar xf ${{ steps.lua.outputs.filepath }}
mv lua-5.4.7 lua mv lua-5.4.7 lua
- name: Download miniaudio
run: |
git clone --depth=1 --branch 0.11.22 https://github.com/mackron/miniaudio
- name: Download irrlicht - name: Download irrlicht
run: | run: |
git clone --depth=1 https://github.com/mercury233/irrlicht git clone --depth=1 https://github.com/mercury233/irrlicht
...@@ -223,7 +276,8 @@ jobs: ...@@ -223,7 +276,8 @@ jobs:
- name: Use premake to generate make files - name: Use premake to generate make files
run: | run: |
./premake5 gmake \ ./premake5 gmake \
--freetype-include-dir="/usr/include/freetype2" --freetype-include-dir="/usr/include/freetype2" \
--opus-include-dir="/usr/include/opus"
- name: Make - name: Make
run: | run: |
...@@ -271,9 +325,9 @@ jobs: ...@@ -271,9 +325,9 @@ jobs:
# git pull origin master # git pull origin master
# cd .. # cd ..
# - name: Install dependencies - name: Install dependencies
# run: | run: |
# brew install freetype libevent libx11 sqlite zlib brew install freetype libevent libx11 sqlite opus opusfile libvorbis
- name: Download premake - name: Download premake
id: premake id: premake
...@@ -298,6 +352,10 @@ jobs: ...@@ -298,6 +352,10 @@ jobs:
tar xf ${{ steps.lua.outputs.filepath }} tar xf ${{ steps.lua.outputs.filepath }}
mv lua-5.4.7 lua mv lua-5.4.7 lua
- name: Download miniaudio
run: |
git clone --depth=1 --branch 0.11.22 https://github.com/mackron/miniaudio
- name: Download irrlicht - name: Download irrlicht
run: | run: |
git clone --depth=1 https://github.com/mercury233/irrlicht git clone --depth=1 https://github.com/mercury233/irrlicht
...@@ -319,6 +377,7 @@ jobs: ...@@ -319,6 +377,7 @@ jobs:
./premake5 gmake \ ./premake5 gmake \
--cc=clang \ --cc=clang \
--freetype-include-dir="/usr/local/include/freetype2" \ --freetype-include-dir="/usr/local/include/freetype2" \
--opus-include-dir="/usr/local/include/opus" \
--irrlicht-include-dir="../irrlicht/include" \ --irrlicht-include-dir="../irrlicht/include" \
--irrlicht-lib-dir="../irrlicht/source/Irrlicht/MacOSX/build/Release" --irrlicht-lib-dir="../irrlicht/source/Irrlicht/MacOSX/build/Release"
...@@ -333,6 +392,12 @@ jobs: ...@@ -333,6 +392,12 @@ jobs:
--freetype-lib-dir="/opt/homebrew/lib" \ --freetype-lib-dir="/opt/homebrew/lib" \
--sqlite-include-dir="/opt/homebrew/opt/sqlite/include" \ --sqlite-include-dir="/opt/homebrew/opt/sqlite/include" \
--sqlite-lib-dir="/opt/homebrew/opt/sqlite/lib" \ --sqlite-lib-dir="/opt/homebrew/opt/sqlite/lib" \
--miniaudio-include-dir="/opt/homebrew/include" \
--miniaudio-lib-dir="/opt/homebrew/lib" \
--opus-include-dir="/opt/homebrew/include/opus" \
--opus-lib-dir="/opt/homebrew/lib" \
--vorbis-include-dir="/opt/homebrew/include" \
--vorbis-lib-dir="/opt/homebrew/lib" \
--irrlicht-include-dir="../irrlicht/include" \ --irrlicht-include-dir="../irrlicht/include" \
--irrlicht-lib-dir="../irrlicht/source/Irrlicht/MacOSX/build/Release" --irrlicht-lib-dir="../irrlicht/source/Irrlicht/MacOSX/build/Release"
......
...@@ -16,6 +16,7 @@ build ...@@ -16,6 +16,7 @@ build
/irrklang /irrklang
/irrlicht* /irrlicht*
/lua /lua
/miniaudio
# gframe additionals # gframe additionals
/gframe/ygopro.ico /gframe/ygopro.ico
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
project "cminiaudio"
kind "StaticLib"
files { "*.c", "*.h" }
filter "system:linux"
links { "dl", "pthread", "m" }
This source diff could not be displayed because it is too large. You can view the blob instead.
include "lzma/." include "lzma/."
include "spmemvfs/." include "spmemvfs/."
if USE_AUDIO then
include "miniaudio/."
end
project "YGOPro" project "YGOPro"
kind "WindowedApp" kind "WindowedApp"
...@@ -43,7 +40,16 @@ project "YGOPro" ...@@ -43,7 +40,16 @@ project "YGOPro"
if USE_AUDIO then if USE_AUDIO then
defines { "YGOPRO_USE_AUDIO" } defines { "YGOPRO_USE_AUDIO" }
links { "cminiaudio" } includedirs { "../miniaudio/extras/miniaudio_split" }
links { "miniaudio" }
if MINIAUDIO_SUPPORT_OPUS_VORBIS then
defines { "YGOPRO_MINIAUDIO_SUPPORT_OPUS_VORBIS" }
includedirs { "../miniaudio/extras/decoders/libopus", "../miniaudio/extras/decoders/libvorbis" }
if not BUILD_OPUS_VORBIS then
links { "opusfile", "vorbisfile" }
libdirs { OPUS_LIB_DIR, VORBIS_LIB_DIR }
end
end
end end
filter "system:windows" filter "system:windows"
......
#include "sound_manager.h" #include "sound_manager.h"
#if defined(YGOPRO_USE_AUDIO) && defined(YGOPRO_MINIAUDIO_SUPPORT_OPUS_VORBIS)
#include <miniaudio_libvorbis.h>
#include <miniaudio_libopus.h>
#endif
#include "myfilesystem.h" #include "myfilesystem.h"
namespace ygo { namespace ygo {
...@@ -12,7 +16,23 @@ bool SoundManager::Init() { ...@@ -12,7 +16,23 @@ bool SoundManager::Init() {
RefreshBGMList(); RefreshBGMList();
bgm_process = false; bgm_process = false;
rnd.reset((unsigned int)std::time(nullptr)); rnd.reset((unsigned int)std::time(nullptr));
if(ma_engine_init(nullptr, &engineSound) || ma_engine_init(nullptr, &engineMusic)) { engineConfig = ma_engine_config_init();
#ifdef YGOPRO_MINIAUDIO_SUPPORT_OPUS_VORBIS
ma_decoding_backend_vtable* pCustomBackendVTables[] =
{
ma_decoding_backend_libvorbis,
ma_decoding_backend_libopus
};
resourceManagerConfig = ma_resource_manager_config_init();
resourceManagerConfig.ppCustomDecodingBackendVTables = pCustomBackendVTables;
resourceManagerConfig.customDecodingBackendCount = sizeof(pCustomBackendVTables) / sizeof(pCustomBackendVTables[0]);
resourceManagerConfig.pCustomDecodingBackendUserData = NULL;
if(ma_resource_manager_init(&resourceManagerConfig, &resourceManager) != MA_SUCCESS) {
return false;
}
engineConfig.pResourceManager = &resourceManager;
#endif
if(ma_engine_init(&engineConfig, &engineSound) != MA_SUCCESS || ma_engine_init(&engineConfig, &engineMusic) != MA_SUCCESS) {
return false; return false;
} else { } else {
return true; return true;
...@@ -36,7 +56,12 @@ void SoundManager::RefreshBGMList() { ...@@ -36,7 +56,12 @@ void SoundManager::RefreshBGMList() {
void SoundManager::RefershBGMDir(std::wstring path, int scene) { void SoundManager::RefershBGMDir(std::wstring path, int scene) {
std::wstring search = L"./sound/BGM/" + path; std::wstring search = L"./sound/BGM/" + path;
FileSystem::TraversalDir(search.c_str(), [this, &path, scene](const wchar_t* name, bool isdir) { FileSystem::TraversalDir(search.c_str(), [this, &path, scene](const wchar_t* name, bool isdir) {
if(!isdir && (IsExtension(name, L".mp3") || IsExtension(name, L".ogg"))) { if(!isdir && (
IsExtension(name, L".mp3")
#ifdef YGOPRO_MINIAUDIO_SUPPORT_OPUS_VORBIS
|| IsExtension(name, L".ogg")
#endif
)) {
std::wstring filename = path + L"/" + name; std::wstring filename = path + L"/" + name;
BGMList[BGM_ALL].push_back(filename); BGMList[BGM_ALL].push_back(filename);
BGMList[scene].push_back(filename); BGMList[scene].push_back(filename);
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "game.h" #include "game.h"
#include "../ocgcore/mtrandom.h" #include "../ocgcore/mtrandom.h"
#ifdef YGOPRO_USE_AUDIO #ifdef YGOPRO_USE_AUDIO
#include "miniaudio/miniaudio.h" #include <miniaudio.h>
#endif #endif
namespace ygo { namespace ygo {
...@@ -17,6 +17,11 @@ private: ...@@ -17,6 +17,11 @@ private:
bool bgm_process; bool bgm_process;
mt19937 rnd; mt19937 rnd;
#ifdef YGOPRO_USE_AUDIO #ifdef YGOPRO_USE_AUDIO
ma_engine_config engineConfig;
#ifdef YGOPRO_MINIAUDIO_SUPPORT_OPUS_VORBIS
ma_resource_manager_config resourceManagerConfig;
ma_resource_manager resourceManager;
#endif
ma_engine engineSound; ma_engine engineSound;
ma_engine engineMusic; ma_engine engineMusic;
ma_sound soundBGM; ma_sound soundBGM;
......
project "miniaudio"
kind "StaticLib"
files { "extras/miniaudio_split/miniaudio.*" }
if MINIAUDIO_SUPPORT_OPUS_VORBIS then
files { "extras/decoders/libopus/*", "extras/decoders/libvorbis/*" }
if BUILD_OPUS_VORBIS then
files { "external/ogg/src/**.c", "external/ogg/src/**.h" }
files { "external/opus/src/**.c", "external/opus/src/**.h" }
files { "external/opus/celt/*.c", "external/opus/celt/*.h" }
files { "external/opus/silk/*.c", "external/opus/silk/*.h" }
files { "external/opus/silk/float/*.c", "external/opus/silk/float/*.h" }
files { "external/opusfile/src/**.c", "external/opusfile/src/**.h" }
files { "external/vorbis/lib/**.c", "external/vorbis/lib/**.h" }
removefiles { "external/opus/src/opus_demo.c", "external/opus/src/tone.c",
"external/opus/src/opus_encoder.c",
"external/vorbis/lib/psy.h", "external/vorbis/lib/psytune.c", "external/vorbis/lib/tone.c",}
defines { "USE_ALLOCA", "OPUS_BUILD" }
includedirs {
"external/ogg/include",
"external/opus/include",
"external/opus/celt",
"external/opus/silk",
"external/opus/silk/float",
"external/opusfile/include",
"external/vorbis/include"
}
else
includedirs { OPUS_INCLUDE_DIR, VORBIS_INCLUDE_DIR }
end
end
filter "system:linux"
links { "dl", "pthread", "m" }
-- default global settings -- default global settings
USE_AUDIO = true
BUILD_LUA = true BUILD_LUA = true
BUILD_EVENT = os.istarget("windows") BUILD_EVENT = os.istarget("windows")
BUILD_FREETYPE = os.istarget("windows") BUILD_FREETYPE = os.istarget("windows")
BUILD_SQLITE = os.istarget("windows") BUILD_SQLITE = os.istarget("windows")
BUILD_IRRLICHT = not os.istarget("macosx") BUILD_IRRLICHT = not os.istarget("macosx")
BUILD_OPUS_VORBIS = true
MINIAUDIO_SUPPORT_OPUS_VORBIS = true
LUA_LIB_NAME = "lua" LUA_LIB_NAME = "lua"
-- read settings from command line or environment variables -- read settings from command line or environment variables
...@@ -35,6 +38,18 @@ newoption { trigger = "build-irrlicht", category = "YGOPro - irrlicht", descript ...@@ -35,6 +38,18 @@ newoption { trigger = "build-irrlicht", category = "YGOPro - irrlicht", descript
newoption { trigger = "no-build-irrlicht", category = "YGOPro - irrlicht", description = "" } newoption { trigger = "no-build-irrlicht", category = "YGOPro - irrlicht", description = "" }
newoption { trigger = "irrlicht-include-dir", category = "YGOPro - irrlicht", description = "", value = "PATH" } newoption { trigger = "irrlicht-include-dir", category = "YGOPro - irrlicht", description = "", value = "PATH" }
newoption { trigger = "irrlicht-lib-dir", category = "YGOPro - irrlicht", description = "", value = "PATH" } newoption { trigger = "irrlicht-lib-dir", category = "YGOPro - irrlicht", description = "", value = "PATH" }
newoption { trigger = "no-audio", category = "YGOPro", description = "" }
newoption { trigger = "miniaudio-include-dir", category = "YGOPro - miniaudio", description = "", value = "PATH" }
newoption { trigger = "miniaudio-lib-dir", category = "YGOPro - miniaudio", description = "", value = "PATH" }
newoption { trigger = "miniaudio-support-opus-vorbis", category = "YGOPro - miniaudio", description = "" }
newoption { trigger = "no-miniaudio-support-opus-vorbis", category = "YGOPro - miniaudio", description = "" }
newoption { trigger = "build-opus-vorbis", category = "YGOPro - miniaudio", description = "" }
newoption { trigger = "no-build-opus-vorbis", category = "YGOPro - miniaudio", description = "" }
newoption { trigger = "opus-include-dir", category = "YGOPro - miniaudio", description = "" }
newoption { trigger = "opus-lib-dir", category = "YGOPro - miniaudio", description = "" }
newoption { trigger = "vorbis-include-dir", category = "YGOPro - miniaudio", description = "" }
newoption { trigger = "vorbis-lib-dir", category = "YGOPro - miniaudio", description = "" }
newoption { trigger = "winxp-support", category = "YGOPro", description = "" } newoption { trigger = "winxp-support", category = "YGOPro", description = "" }
newoption { trigger = "mac-arm", category = "YGOPro", description = "Cross compile for Apple Silicon" } newoption { trigger = "mac-arm", category = "YGOPro", description = "Cross compile for Apple Silicon" }
...@@ -143,7 +158,28 @@ if not BUILD_IRRLICHT then ...@@ -143,7 +158,28 @@ if not BUILD_IRRLICHT then
IRRLICHT_LIB_DIR = GetParam("irrlicht-lib-dir") or os.findlib("irrlicht") IRRLICHT_LIB_DIR = GetParam("irrlicht-lib-dir") or os.findlib("irrlicht")
end end
USE_AUDIO = not GetParam("no-audio") if GetParam("no-audio") then
USE_AUDIO = false
end
if GetParam("miniaudio-support-opus-vorbis") then
MINIAUDIO_SUPPORT_OPUS_VORBIS = true
elseif GetParam("no-miniaudio-support-opus-vorbis") then
MINIAUDIO_SUPPORT_OPUS_VORBIS = false
end
if MINIAUDIO_SUPPORT_OPUS_VORBIS then
if GetParam("build-opus-vorbis") then
BUILD_OPUS_VORBIS = true
elseif GetParam("no-build-opus-vorbis") then
BUILD_OPUS_VORBIS = false
end
if not BUILD_OPUS_VORBIS then
OPUS_INCLUDE_DIR = GetParam("opus-include-dir") or os.findheader("opus")
OPUS_LIB_DIR = GetParam("opus-lib-dir") or os.findlib("opusfile")
VORBIS_INCLUDE_DIR = GetParam("vorbis-include-dir") or os.findheader("vorbis")
VORBIS_LIB_DIR = GetParam("vorbis-lib-dir") or os.findlib("vorbis")
end
end
if GetParam("winxp-support") and os.istarget("windows") then if GetParam("winxp-support") and os.istarget("windows") then
WINXP_SUPPORT = true WINXP_SUPPORT = true
...@@ -254,3 +290,6 @@ workspace "YGOPro" ...@@ -254,3 +290,6 @@ workspace "YGOPro"
if BUILD_SQLITE then if BUILD_SQLITE then
include "sqlite3" include "sqlite3"
end end
if USE_AUDIO then
include "miniaudio"
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment