refactor: Make assertsz_asf() resampler aware

> resampling free conversion support (results in sound data errors, game only expects s16le for wavs)
> related to #1
This commit is contained in:
[ ]
2025-05-27 23:11:02 +09:00
parent 5075efc6dc
commit d72f4b780a
+5 -5
View File
@@ -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<size_t>(static_cast<double>(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<size_t>(static_cast<double>(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;