mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 03:30:13 +01:00
Merge branch 'main' of https://github.com/Yonokid/PyTaiko
This commit is contained in:
@@ -141,12 +141,16 @@ def main():
|
||||
force_dedicated_gpu()
|
||||
global_data.config = get_config()
|
||||
log_level = global_data.config["general"]["log_level"]
|
||||
if sys.platform == 'win32':
|
||||
import io
|
||||
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
|
||||
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace')
|
||||
colored_formatter = ColoredFormatter('[%(levelname)s] %(name)s: %(message)s')
|
||||
plain_formatter = logging.Formatter('[%(levelname)s] %(name)s: %(message)s')
|
||||
console_handler = logging.StreamHandler()
|
||||
console_handler.setFormatter(colored_formatter)
|
||||
|
||||
file_handler = logging.FileHandler("latest.log")
|
||||
file_handler = logging.FileHandler("latest.log", encoding='utf-8')
|
||||
file_handler.setFormatter(plain_formatter)
|
||||
file_handler = DedupHandler(file_handler)
|
||||
logging.basicConfig(
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "portaudio.h"
|
||||
#ifdef _WIN32
|
||||
#include "pa_asio.h"
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
#include <stdbool.h>
|
||||
@@ -647,7 +648,26 @@ wave load_wave(const char* filename) {
|
||||
SF_INFO sf_info;
|
||||
memset(&sf_info, 0, sizeof(sf_info));
|
||||
|
||||
#ifdef _WIN32
|
||||
// Convert UTF-8 filename to wide string for Windows
|
||||
int wlen = MultiByteToWideChar(CP_UTF8, 0, filename, -1, NULL, 0);
|
||||
if (wlen == 0) {
|
||||
TRACELOG(LOG_ERROR, "Failed to convert filename to wide string: '%s'\n", filename);
|
||||
return wave;
|
||||
}
|
||||
|
||||
wchar_t *wfilename = malloc(wlen * sizeof(wchar_t));
|
||||
if (wfilename == NULL) {
|
||||
TRACELOG(LOG_ERROR, "Failed to allocate memory for wide filename");
|
||||
return wave;
|
||||
}
|
||||
|
||||
MultiByteToWideChar(CP_UTF8, 0, filename, -1, wfilename, wlen);
|
||||
snd_file = sf_wchar_open(wfilename, SFM_READ, &sf_info);
|
||||
free(wfilename);
|
||||
#else
|
||||
snd_file = sf_open(filename, SFM_READ, &sf_info);
|
||||
#endif
|
||||
if (snd_file == NULL) {
|
||||
TRACELOG(LOG_ERROR, "Failed to open file '%s'\n", filename);
|
||||
return wave;
|
||||
@@ -921,9 +941,30 @@ void update_audio_stream(audio_stream stream, const void *data, int frame_count)
|
||||
music load_music_stream(const char* filename) {
|
||||
music music = { 0 };
|
||||
bool music_loaded = false;
|
||||
|
||||
SF_INFO sf_info = { 0 };
|
||||
SNDFILE *snd_file = sf_open(filename, SFM_READ, &sf_info);
|
||||
SNDFILE *snd_file;
|
||||
|
||||
#ifdef _WIN32
|
||||
// Convert UTF-8 filename to wide string for Windows
|
||||
int wlen = MultiByteToWideChar(CP_UTF8, 0, filename, -1, NULL, 0);
|
||||
if (wlen == 0) {
|
||||
TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to convert filename to wide string", filename);
|
||||
return music;
|
||||
}
|
||||
|
||||
wchar_t *wfilename = malloc(wlen * sizeof(wchar_t));
|
||||
if (wfilename == NULL) {
|
||||
TRACELOG(LOG_WARNING, "FILEIO: Failed to allocate memory for wide filename");
|
||||
return music;
|
||||
}
|
||||
|
||||
MultiByteToWideChar(CP_UTF8, 0, filename, -1, wfilename, wlen);
|
||||
snd_file = sf_wchar_open(wfilename, SFM_READ, &sf_info);
|
||||
free(wfilename);
|
||||
#else
|
||||
snd_file = sf_open(filename, SFM_READ, &sf_info);
|
||||
#endif
|
||||
|
||||
if (snd_file != NULL) {
|
||||
music_ctx *ctx = calloc(1, sizeof(music_ctx));
|
||||
if (ctx == NULL) {
|
||||
@@ -932,7 +973,6 @@ music load_music_stream(const char* filename) {
|
||||
return music;
|
||||
}
|
||||
ctx->snd_file = snd_file;
|
||||
|
||||
if (sf_info.samplerate != AUDIO.System.sampleRate) {
|
||||
TRACELOG(LOG_INFO, "Resampling music from %d Hz to %f Hz", sf_info.samplerate, AUDIO.System.sampleRate);
|
||||
int error;
|
||||
@@ -948,7 +988,6 @@ music load_music_stream(const char* filename) {
|
||||
ctx->resampler = NULL;
|
||||
ctx->src_ratio = 1.0;
|
||||
}
|
||||
|
||||
music.ctxData = ctx;
|
||||
int sample_size = 32;
|
||||
music.stream = load_audio_stream(AUDIO.System.sampleRate, sample_size, sf_info.channels);
|
||||
|
||||
@@ -378,6 +378,7 @@ class TJAParser:
|
||||
elif item.startswith('WAVE'):
|
||||
data = item.split(':')[1]
|
||||
if not Path(self.file_path.parent / data.strip()).exists():
|
||||
logger.error(f'{data}, {self.file_path}')
|
||||
logger.warning(f"Invalid WAVE value: {data} in TJA file {self.file_path}")
|
||||
self.metadata.wave = Path()
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user