From d72f4b780a0f69c284cd5bd6779b3bda092038bd Mon Sep 17 00:00:00 2001 From: "[ ]" <[ ]> Date: Tue, 27 May 2025 23:11:02 +0900 Subject: [PATCH] refactor: Make `assertsz_asf()` resampler aware > resampling free conversion support (results in sound data errors, game only expects s16le for wavs) > related to #1 --- hooks/bmsbhook.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hooks/bmsbhook.cpp b/hooks/bmsbhook.cpp index b67baf7..973d106 100644 --- a/hooks/bmsbhook.cpp +++ b/hooks/bmsbhook.cpp @@ -317,10 +317,10 @@ public: } }; - [[nodiscard]] static constexpr size_t assertsz_asf(size_t sz) noexcept + [[nodiscard]] static constexpr size_t assertsz_asf(size_t sz, int8_t resampler = 1) noexcept { - //_TODO: second argument data type (float/int) - return static_cast(static_cast(sz) * 14.8) + WAVHDRSIZE; // 0.wma is consistent 180 therefore VBR Q90, sometimes 160 though, but samples are all over the place + resampler = (resampler > 1 || resampler == -1) ? 2 : 1; // resampler ratio multiplier (see pcm_resampler enum, original data is float) + return static_cast(static_cast(sz) * 14.8) * resampler + WAVHDRSIZE; // 0.wma is consistent 180 therefore VBR Q90, sometimes 160 though, but samples are all over the place } [[nodiscard]] constexpr const decltype(bank::header) *header() const noexcept @@ -826,8 +826,8 @@ void run_tests() wavsz = 0; // AV codec (1:1 unmodified PCM data, other than resampling if enabled) - wav = (BYTE *) malloc(snd_2dx::assertsz_asf(snds3p->voice(0)->sz)); - avcodec::BmswTranscoderAsfToWav(snds3p->voice(0)->asf(), snds3p->voice(0)->sz, &wav, &wavsz, avcodec::bmswac_resampler_s16); + wav = (BYTE *) malloc(snd_2dx::assertsz_asf(snds3p->voice(0)->sz, avcodec::bmswac_resampler_f32)); + avcodec::BmswTranscoderAsfToWav(snds3p->voice(0)->asf(), snds3p->voice(0)->sz, &wav, &wavsz, avcodec::bmswac_resampler_f32); dump_("ac_wav.wav", wav, wavsz); free(wav); wav = nullptr;