Commit 9a36ca40 authored by mercury233's avatar mercury233

test opus & vorbis

parent 5ebd8aef
......@@ -30,6 +30,7 @@
/irrklang
/ikpmp3
/lua
/miniaudio
/sqlite3
/gframe/*.ico
/gframe/ygopro.rc
......
project "cminiaudio"
kind "StaticLib"
files { "*.c", "*.h" }
filter "system:linux"
links { "dl", "pthread", "m" }
This diff is collapsed.
include "lzma/."
include "spmemvfs/."
if USE_AUDIO then
include "miniaudio/."
end
project "YGOPro"
kind "WindowedApp"
......@@ -43,7 +40,8 @@ project "YGOPro"
if USE_AUDIO then
defines { "YGOPRO_USE_AUDIO" }
links { "cminiaudio" }
includedirs { "../miniaudio" }
links { "miniaudio" }
end
filter "system:windows"
......
#include "sound_manager.h"
#ifdef YGOPRO_USE_AUDIO
#include "../miniaudio/miniaudio_libvorbis.h"
#include "../miniaudio/miniaudio_libopus.h"
#endif
#include "myfilesystem.h"
namespace ygo {
......@@ -10,7 +14,21 @@ bool SoundManager::Init() {
bgm_scene = -1;
RefreshBGMList();
rnd.reset((unsigned int)std::time(nullptr));
if(ma_engine_init(nullptr, &engineSound) || ma_engine_init(nullptr, &engineMusic)) {
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 = ma_engine_config_init();
engineConfig.pResourceManager = &resourceManager;
if(ma_engine_init(&engineConfig, &engineSound) != MA_SUCCESS || ma_engine_init(&engineConfig, &engineMusic) != MA_SUCCESS) {
return false;
} else {
return true;
......
......@@ -4,7 +4,7 @@
#include "game.h"
#include "../ocgcore/mtrandom.h"
#ifdef YGOPRO_USE_AUDIO
#include "miniaudio/miniaudio.h"
#include "../miniaudio/miniaudio.h"
#endif
namespace ygo {
......@@ -15,6 +15,9 @@ private:
int bgm_scene;
mt19937 rnd;
#ifdef YGOPRO_USE_AUDIO
ma_resource_manager_config resourceManagerConfig;
ma_resource_manager resourceManager;
ma_engine_config engineConfig;
ma_engine engineSound;
ma_engine engineMusic;
ma_sound soundBGM;
......
......@@ -52081,8 +52081,6 @@ static ma_result ma_decoder_init_mp3_from_memory__internal(const void* pData, si
#endif /* ma_dr_mp3_h */
/* Vorbis */
// This is the line added by YGOPro
#include "stb_vorbis.c"
#ifdef STB_VORBIS_INCLUDE_STB_VORBIS_H
#define MA_HAS_VORBIS
This diff is collapsed.
/*
This implements a data source that decodes Opus streams via libopus + libopusfile
This object can be plugged into any `ma_data_source_*()` API and can also be used as a custom
decoding backend. See the custom_decoder example.
*/
#ifndef miniaudio_libopus_h
#define miniaudio_libopus_h
#ifdef __cplusplus
extern "C" {
#endif
#include <miniaudio.h>
typedef struct
{
ma_data_source_base ds; /* The libopus decoder can be used independently as a data source. */
ma_read_proc onRead;
ma_seek_proc onSeek;
ma_tell_proc onTell;
void* pReadSeekTellUserData;
ma_format format; /* Will be either f32 or s16. */
/*OggOpusFile**/ void* of; /* Typed as void* so we can avoid a dependency on opusfile in the header section. */
} ma_libopus;
MA_API ma_result ma_libopus_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_proc onTell, void* pReadSeekTellUserData, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_libopus* pOpus);
MA_API ma_result ma_libopus_init_file(const char* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_libopus* pOpus);
MA_API void ma_libopus_uninit(ma_libopus* pOpus, const ma_allocation_callbacks* pAllocationCallbacks);
MA_API ma_result ma_libopus_read_pcm_frames(ma_libopus* pOpus, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead);
MA_API ma_result ma_libopus_seek_to_pcm_frame(ma_libopus* pOpus, ma_uint64 frameIndex);
MA_API ma_result ma_libopus_get_data_format(ma_libopus* pOpus, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap);
MA_API ma_result ma_libopus_get_cursor_in_pcm_frames(ma_libopus* pOpus, ma_uint64* pCursor);
MA_API ma_result ma_libopus_get_length_in_pcm_frames(ma_libopus* pOpus, ma_uint64* pLength);
/* Decoding backend vtable. This is what you'll plug into ma_decoder_config.pBackendVTables. No user data required. */
extern ma_decoding_backend_vtable* ma_decoding_backend_libopus;
#ifdef __cplusplus
}
#endif
#endif /* miniaudio_libopus_h */
This diff is collapsed.
/*
This implements a data source that decodes Vorbis streams via libvorbis + libvorbisfile
This object can be plugged into any `ma_data_source_*()` API and can also be used as a custom
decoding backend. See the custom_decoder example.
*/
#ifndef miniaudio_libvorbis_h
#define miniaudio_libvorbis_h
#ifdef __cplusplus
extern "C" {
#endif
#include <miniaudio.h>
typedef struct
{
ma_data_source_base ds; /* The libvorbis decoder can be used independently as a data source. */
ma_read_proc onRead;
ma_seek_proc onSeek;
ma_tell_proc onTell;
void* pReadSeekTellUserData;
ma_format format; /* Will be either f32 or s16. */
/*OggVorbis_File**/ void* vf; /* Typed as void* so we can avoid a dependency on opusfile in the header section. */
} ma_libvorbis;
MA_API ma_result ma_libvorbis_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_proc onTell, void* pReadSeekTellUserData, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_libvorbis* pVorbis);
MA_API ma_result ma_libvorbis_init_file(const char* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_libvorbis* pVorbis);
MA_API void ma_libvorbis_uninit(ma_libvorbis* pVorbis, const ma_allocation_callbacks* pAllocationCallbacks);
MA_API ma_result ma_libvorbis_read_pcm_frames(ma_libvorbis* pVorbis, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead);
MA_API ma_result ma_libvorbis_seek_to_pcm_frame(ma_libvorbis* pVorbis, ma_uint64 frameIndex);
MA_API ma_result ma_libvorbis_get_data_format(ma_libvorbis* pVorbis, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap);
MA_API ma_result ma_libvorbis_get_cursor_in_pcm_frames(ma_libvorbis* pVorbis, ma_uint64* pCursor);
MA_API ma_result ma_libvorbis_get_length_in_pcm_frames(ma_libvorbis* pVorbis, ma_uint64* pLength);
/* Decoding backend vtable. This is what you'll plug into ma_decoder_config.pBackendVTables. No user data required. */
extern ma_decoding_backend_vtable* ma_decoding_backend_libvorbis;
#ifdef __cplusplus
}
#endif
#endif /* miniaudio_libvorbis_h */
Subproject commit fe48b4fbbf9c84c459eca432de494a5bcef1c276
Subproject commit d2c754121645fb021de5dc7d7f13f0a4210f5d9e
project "miniaudio"
kind "StaticLib"
files { "*.c", "*.h" }
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" }
filter "system:linux"
links { "dl", "pthread", "m" }
......@@ -199,6 +199,6 @@ workspace "YGOPro"
if BUILD_SQLITE then
include "sqlite3"
end
--if BUILD_IKPMP3 then
-- include "ikpmp3"
--end
if USE_AUDIO then
include "miniaudio"
end
Subproject commit 5d9d3779b34df5937ea9db039b68e6e440d461ec
Subproject commit f10071b5d60b728dda89d2d9dffb8d345d3efba1
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