mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-27 12:51:42 +00:00
Implement libvorbis.
This commit is contained in:
parent
5e7e0c026f
commit
b21ddc7bb5
7 changed files with 116 additions and 24 deletions
|
|
@ -222,6 +222,7 @@ find_package(imgui CONFIG REQUIRED)
|
||||||
find_package(magic_enum CONFIG REQUIRED)
|
find_package(magic_enum CONFIG REQUIRED)
|
||||||
find_package(unofficial-tiny-aes-c CONFIG REQUIRED)
|
find_package(unofficial-tiny-aes-c CONFIG REQUIRED)
|
||||||
find_package(nfd CONFIG REQUIRED)
|
find_package(nfd CONFIG REQUIRED)
|
||||||
|
find_package(Vorbis CONFIG REQUIRED)
|
||||||
|
|
||||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/D3D12)
|
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/D3D12)
|
||||||
add_custom_command(TARGET UnleashedRecomp POST_BUILD
|
add_custom_command(TARGET UnleashedRecomp POST_BUILD
|
||||||
|
|
@ -260,6 +261,7 @@ target_link_libraries(UnleashedRecomp PRIVATE
|
||||||
magic_enum::magic_enum
|
magic_enum::magic_enum
|
||||||
unofficial::tiny-aes-c::tiny-aes-c
|
unofficial::tiny-aes-c::tiny-aes-c
|
||||||
nfd::nfd
|
nfd::nfd
|
||||||
|
Vorbis::vorbisfile
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(UnleashedRecomp PRIVATE
|
target_include_directories(UnleashedRecomp PRIVATE
|
||||||
|
|
@ -401,11 +403,11 @@ BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/images/op
|
||||||
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/images/options_menu/thumbnails/xbox_color_correction.dds" DEST_FILE "${RESOURCES_OUTPUT_PATH}/images/options_menu/thumbnails/xbox_color_correction.dds" ARRAY_NAME "g_xbox_color_correction" COMPRESSION_TYPE "zstd")
|
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/images/options_menu/thumbnails/xbox_color_correction.dds" DEST_FILE "${RESOURCES_OUTPUT_PATH}/images/options_menu/thumbnails/xbox_color_correction.dds" ARRAY_NAME "g_xbox_color_correction" COMPRESSION_TYPE "zstd")
|
||||||
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/images/game_icon.bmp" DEST_FILE "${RESOURCES_OUTPUT_PATH}/images/game_icon.bmp" ARRAY_NAME "g_game_icon")
|
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/images/game_icon.bmp" DEST_FILE "${RESOURCES_OUTPUT_PATH}/images/game_icon.bmp" ARRAY_NAME "g_game_icon")
|
||||||
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/images/game_icon_night.bmp" DEST_FILE "${RESOURCES_OUTPUT_PATH}/images/game_icon_night.bmp" ARRAY_NAME "g_game_icon_night")
|
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/images/game_icon_night.bmp" DEST_FILE "${RESOURCES_OUTPUT_PATH}/images/game_icon_night.bmp" ARRAY_NAME "g_game_icon_night")
|
||||||
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/sounds/sys_worldmap_cursor.wav" DEST_FILE "${RESOURCES_OUTPUT_PATH}/sounds/sys_worldmap_cursor.wav" ARRAY_NAME "g_sys_worldmap_cursor")
|
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/sounds/sys_worldmap_cursor.ogg" DEST_FILE "${RESOURCES_OUTPUT_PATH}/sounds/sys_worldmap_cursor.ogg" ARRAY_NAME "g_sys_worldmap_cursor")
|
||||||
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/sounds/sys_worldmap_finaldecide.wav" DEST_FILE "${RESOURCES_OUTPUT_PATH}/sounds/sys_worldmap_finaldecide.wav" ARRAY_NAME "g_sys_worldmap_finaldecide")
|
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/sounds/sys_worldmap_finaldecide.ogg" DEST_FILE "${RESOURCES_OUTPUT_PATH}/sounds/sys_worldmap_finaldecide.ogg" ARRAY_NAME "g_sys_worldmap_finaldecide")
|
||||||
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/sounds/sys_actstg_pausecansel.wav" DEST_FILE "${RESOURCES_OUTPUT_PATH}/sounds/sys_actstg_pausecansel.wav" ARRAY_NAME "g_sys_actstg_pausecansel")
|
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/sounds/sys_actstg_pausecansel.ogg" DEST_FILE "${RESOURCES_OUTPUT_PATH}/sounds/sys_actstg_pausecansel.ogg" ARRAY_NAME "g_sys_actstg_pausecansel")
|
||||||
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/sounds/sys_actstg_pausecursor.wav" DEST_FILE "${RESOURCES_OUTPUT_PATH}/sounds/sys_actstg_pausecursor.wav" ARRAY_NAME "g_sys_actstg_pausecursor")
|
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/sounds/sys_actstg_pausecursor.ogg" DEST_FILE "${RESOURCES_OUTPUT_PATH}/sounds/sys_actstg_pausecursor.ogg" ARRAY_NAME "g_sys_actstg_pausecursor")
|
||||||
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/sounds/sys_actstg_pausedecide.wav" DEST_FILE "${RESOURCES_OUTPUT_PATH}/sounds/sys_actstg_pausedecide.wav" ARRAY_NAME "g_sys_actstg_pausedecide")
|
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/sounds/sys_actstg_pausedecide.ogg" DEST_FILE "${RESOURCES_OUTPUT_PATH}/sounds/sys_actstg_pausedecide.ogg" ARRAY_NAME "g_sys_actstg_pausedecide")
|
||||||
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/sounds/sys_actstg_pausewinclose.wav" DEST_FILE "${RESOURCES_OUTPUT_PATH}/sounds/sys_actstg_pausewinclose.wav" ARRAY_NAME "g_sys_actstg_pausewinclose")
|
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/sounds/sys_actstg_pausewinclose.ogg" DEST_FILE "${RESOURCES_OUTPUT_PATH}/sounds/sys_actstg_pausewinclose.ogg" ARRAY_NAME "g_sys_actstg_pausewinclose")
|
||||||
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/sounds/sys_actstg_pausewinopen.wav" DEST_FILE "${RESOURCES_OUTPUT_PATH}/sounds/sys_actstg_pausewinopen.wav" ARRAY_NAME "g_sys_actstg_pausewinopen")
|
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/sounds/sys_actstg_pausewinopen.ogg" DEST_FILE "${RESOURCES_OUTPUT_PATH}/sounds/sys_actstg_pausewinopen.ogg" ARRAY_NAME "g_sys_actstg_pausewinopen")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,6 @@
|
||||||
#include <cpu/guest_code.h>
|
#include <cpu/guest_code.h>
|
||||||
#include <kernel/heap.h>
|
#include <kernel/heap.h>
|
||||||
|
|
||||||
#define MINIAUDIO_IMPLEMENTATION
|
|
||||||
#include <miniaudio.h>
|
|
||||||
|
|
||||||
static PPCFunc* g_clientCallback{};
|
static PPCFunc* g_clientCallback{};
|
||||||
static DWORD g_clientCallbackParam{}; // pointer in guest memory
|
static DWORD g_clientCallbackParam{}; // pointer in guest memory
|
||||||
static ma_device g_audioDevice{};
|
static ma_device g_audioDevice{};
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,90 @@
|
||||||
#include <miniaudio.h>
|
|
||||||
|
|
||||||
#include <apu/audio.h>
|
#include <apu/audio.h>
|
||||||
#include <apu/embedded_player.h>
|
#include <apu/embedded_player.h>
|
||||||
#include <user/config.h>
|
#include <user/config.h>
|
||||||
|
|
||||||
#include <res/sounds/sys_worldmap_cursor.wav.h>
|
#include <res/sounds/sys_worldmap_cursor.ogg.h>
|
||||||
#include <res/sounds/sys_worldmap_finaldecide.wav.h>
|
#include <res/sounds/sys_worldmap_finaldecide.ogg.h>
|
||||||
#include <res/sounds/sys_actstg_pausecansel.wav.h>
|
#include <res/sounds/sys_actstg_pausecansel.ogg.h>
|
||||||
#include <res/sounds/sys_actstg_pausecursor.wav.h>
|
#include <res/sounds/sys_actstg_pausecursor.ogg.h>
|
||||||
#include <res/sounds/sys_actstg_pausedecide.wav.h>
|
#include <res/sounds/sys_actstg_pausedecide.ogg.h>
|
||||||
#include <res/sounds/sys_actstg_pausewinclose.wav.h>
|
#include <res/sounds/sys_actstg_pausewinclose.ogg.h>
|
||||||
#include <res/sounds/sys_actstg_pausewinopen.wav.h>
|
#include <res/sounds/sys_actstg_pausewinopen.ogg.h>
|
||||||
|
|
||||||
|
#pragma region libvorbis
|
||||||
|
static ma_result ma_decoding_backend_init__libvorbis(void* pUserData, 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_data_source** ppBackend)
|
||||||
|
{
|
||||||
|
ma_result result;
|
||||||
|
ma_libvorbis* pVorbis;
|
||||||
|
|
||||||
|
(void)pUserData;
|
||||||
|
|
||||||
|
pVorbis = (ma_libvorbis*)ma_malloc(sizeof(*pVorbis), pAllocationCallbacks);
|
||||||
|
if (pVorbis == NULL) {
|
||||||
|
return MA_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = ma_libvorbis_init(onRead, onSeek, onTell, pReadSeekTellUserData, pConfig, pAllocationCallbacks, pVorbis);
|
||||||
|
if (result != MA_SUCCESS) {
|
||||||
|
ma_free(pVorbis, pAllocationCallbacks);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ppBackend = pVorbis;
|
||||||
|
|
||||||
|
return MA_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ma_result ma_decoding_backend_init_file__libvorbis(void* pUserData, const char* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_source** ppBackend)
|
||||||
|
{
|
||||||
|
ma_result result;
|
||||||
|
ma_libvorbis* pVorbis;
|
||||||
|
|
||||||
|
(void)pUserData;
|
||||||
|
|
||||||
|
pVorbis = (ma_libvorbis*)ma_malloc(sizeof(*pVorbis), pAllocationCallbacks);
|
||||||
|
if (pVorbis == NULL) {
|
||||||
|
return MA_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = ma_libvorbis_init_file(pFilePath, pConfig, pAllocationCallbacks, pVorbis);
|
||||||
|
if (result != MA_SUCCESS) {
|
||||||
|
ma_free(pVorbis, pAllocationCallbacks);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ppBackend = pVorbis;
|
||||||
|
|
||||||
|
return MA_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ma_decoding_backend_uninit__libvorbis(void* pUserData, ma_data_source* pBackend, const ma_allocation_callbacks* pAllocationCallbacks)
|
||||||
|
{
|
||||||
|
ma_libvorbis* pVorbis = (ma_libvorbis*)pBackend;
|
||||||
|
|
||||||
|
(void)pUserData;
|
||||||
|
|
||||||
|
ma_libvorbis_uninit(pVorbis, pAllocationCallbacks);
|
||||||
|
ma_free(pVorbis, pAllocationCallbacks);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ma_result ma_decoding_backend_get_channel_map__libvorbis(void* pUserData, ma_data_source* pBackend, ma_channel* pChannelMap, size_t channelMapCap)
|
||||||
|
{
|
||||||
|
ma_libvorbis* pVorbis = (ma_libvorbis*)pBackend;
|
||||||
|
|
||||||
|
(void)pUserData;
|
||||||
|
|
||||||
|
return ma_libvorbis_get_data_format(pVorbis, NULL, NULL, NULL, pChannelMap, channelMapCap);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ma_decoding_backend_vtable g_ma_decoding_backend_vtable_libvorbis =
|
||||||
|
{
|
||||||
|
ma_decoding_backend_init__libvorbis,
|
||||||
|
ma_decoding_backend_init_file__libvorbis,
|
||||||
|
NULL, /* onInitFileW() */
|
||||||
|
NULL, /* onInitMemory() */
|
||||||
|
ma_decoding_backend_uninit__libvorbis
|
||||||
|
};
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
enum class EmbeddedSound
|
enum class EmbeddedSound
|
||||||
{
|
{
|
||||||
|
|
@ -34,7 +108,7 @@ struct EmbeddedSoundData
|
||||||
|
|
||||||
static ma_engine g_audioEngine = {};
|
static ma_engine g_audioEngine = {};
|
||||||
static std::array<EmbeddedSoundData, size_t(EmbeddedSound::Count)> g_embeddedSoundData = {};
|
static std::array<EmbeddedSoundData, size_t(EmbeddedSound::Count)> g_embeddedSoundData = {};
|
||||||
static const std::unordered_map<std::string, EmbeddedSound> g_embeddedSoundMap =
|
static const std::unordered_map<std::string_view, EmbeddedSound> g_embeddedSoundMap =
|
||||||
{
|
{
|
||||||
{ "sys_worldmap_cursor", EmbeddedSound::SysWorldMapCursor },
|
{ "sys_worldmap_cursor", EmbeddedSound::SysWorldMapCursor },
|
||||||
{ "sys_worldmap_finaldecide", EmbeddedSound::SysWorldMapFinalDecide },
|
{ "sys_worldmap_finaldecide", EmbeddedSound::SysWorldMapFinalDecide },
|
||||||
|
|
@ -91,9 +165,19 @@ static void PlayEmbeddedSound(EmbeddedSound s)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ma_decoding_backend_vtable* pCustomBackendVTables[] =
|
||||||
|
{
|
||||||
|
&g_ma_decoding_backend_vtable_libvorbis
|
||||||
|
};
|
||||||
|
|
||||||
|
ma_decoder_config decoderConfig = ma_decoder_config_init_default();
|
||||||
|
decoderConfig.pCustomBackendUserData = NULL;
|
||||||
|
decoderConfig.ppCustomBackendVTables = pCustomBackendVTables;
|
||||||
|
decoderConfig.customBackendCount = std::size(pCustomBackendVTables);
|
||||||
|
|
||||||
ma_result res;
|
ma_result res;
|
||||||
data.decoders[i] = std::make_unique<ma_decoder>();
|
data.decoders[i] = std::make_unique<ma_decoder>();
|
||||||
res = ma_decoder_init_memory(soundData, soundDataSize, nullptr, data.decoders[i].get());
|
res = ma_decoder_init_memory(soundData, soundDataSize, &decoderConfig, data.decoders[i].get());
|
||||||
if (res != MA_SUCCESS)
|
if (res != MA_SUCCESS)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "ma_decoder_init_memory failed with error code %d.\n", res);
|
fprintf(stderr, "ma_decoder_init_memory failed with error code %d.\n", res);
|
||||||
|
|
@ -139,7 +223,7 @@ void EmbeddedPlayer::Init()
|
||||||
engineConfig.sampleRate = XAUDIO_SAMPLES_HZ;
|
engineConfig.sampleRate = XAUDIO_SAMPLES_HZ;
|
||||||
|
|
||||||
ma_result res = ma_engine_init(&engineConfig, &g_audioEngine);
|
ma_result res = ma_engine_init(&engineConfig, &g_audioEngine);
|
||||||
if (res == MA_SUCCESS)
|
if (res != MA_SUCCESS)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "ma_engine_init failed with error code %d.\n", res);
|
fprintf(stderr, "ma_engine_init failed with error code %d.\n", res);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,10 @@
|
||||||
#define STB_IMAGE_IMPLEMENTATION
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
#include <stb_image.h>
|
#include <stb_image.h>
|
||||||
|
|
||||||
|
#define MINIAUDIO_IMPLEMENTATION
|
||||||
|
#include <miniaudio.h>
|
||||||
|
|
||||||
|
#define ma_offset_pcm_frames_ptr (char*)ma_offset_pcm_frames_ptr
|
||||||
|
#include <extras/miniaudio_libvorbis.h>
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@
|
||||||
#include <smolv.h>
|
#include <smolv.h>
|
||||||
#include <print>
|
#include <print>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <miniaudio.h>
|
||||||
|
#include <extras/miniaudio_libvorbis.h>
|
||||||
|
|
||||||
using Microsoft::WRL::ComPtr;
|
using Microsoft::WRL::ComPtr;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 86376058708c6b729a451df391617aaabf91018a
|
Subproject commit f499712cb8aa277f20e0488c3940985f253ff907
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
"features": [ "sdl2-binding" ]
|
"features": [ "sdl2-binding" ]
|
||||||
},
|
},
|
||||||
"magic-enum",
|
"magic-enum",
|
||||||
"nativefiledialog-extended"
|
"nativefiledialog-extended",
|
||||||
|
"libvorbis"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue