From 0613d0bcb0633d9b2a4b9f041a5849dd9df3f662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <1173718158@qq.com> Date: Sun, 22 Dec 2024 21:11:47 +0800 Subject: [PATCH] . --- cpp/winsharedutils/mp3enc.cpp | 4 ++-- py/LunaTranslator/myutils/audioplayer.py | 2 +- py/LunaTranslator/winsharedutils.py | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cpp/winsharedutils/mp3enc.cpp b/cpp/winsharedutils/mp3enc.cpp index 4ca1d48c..9180e5de 100644 --- a/cpp/winsharedutils/mp3enc.cpp +++ b/cpp/winsharedutils/mp3enc.cpp @@ -12,7 +12,7 @@ int stereo = STEREO; -DECLARE_API void encodemp3(void *ptr, size_t size, void (*cb)(void *ptr, size_t size)) +DECLARE_API void encodemp3(void *ptr, size_t size, void (*cb)(void *ptr, size_t size), int bitrate) { shine_config_t config; shine_t s; @@ -21,7 +21,7 @@ DECLARE_API void encodemp3(void *ptr, size_t size, void (*cb)(void *ptr, size_t /* Set the default MPEG encoding paramters - basically init the struct */ shine_set_config_mpeg_defaults(&config.mpeg); - config.mpeg.bitr = 320; + config.mpeg.bitr = bitrate; // 8-320; uint32_t sampleRate = 0; uint64_t totalSampleCount = 0; diff --git a/py/LunaTranslator/myutils/audioplayer.py b/py/LunaTranslator/myutils/audioplayer.py index 8e10c547..e81150a1 100644 --- a/py/LunaTranslator/myutils/audioplayer.py +++ b/py/LunaTranslator/myutils/audioplayer.py @@ -186,7 +186,7 @@ def bass_decode(bs, ext=None): header.append(bytes(c_int(size))) header.extend(res) data = b"".join(header) - return winsharedutils.encodemp3(data) + return winsharedutils.encodemp3(data, 32) class series_audioplayer: diff --git a/py/LunaTranslator/winsharedutils.py b/py/LunaTranslator/winsharedutils.py index 0f8a5b59..780ba08a 100644 --- a/py/LunaTranslator/winsharedutils.py +++ b/py/LunaTranslator/winsharedutils.py @@ -334,16 +334,16 @@ clipboard_callback_stop.argtypes = (HWND,) clipboard_callback_type = CFUNCTYPE(None, c_wchar_p, c_bool) _encodemp3 = utilsdll.encodemp3 -_encodemp3.argtypes = c_void_p, c_size_t, c_void_p +_encodemp3.argtypes = c_void_p, c_size_t, c_void_p, c_int -def encodemp3(wav): +def encodemp3(wav, bitr=320): ret = [] def cb(ptr, size): ret.append(cast(ptr, POINTER(c_char))[:size]) - _encodemp3(wav, len(wav), CFUNCTYPE(None, c_void_p, c_size_t)(cb)) + _encodemp3(wav, len(wav), CFUNCTYPE(None, c_void_p, c_size_t)(cb), bitr) if len(ret): return ret[0] return None