vampirefrog / mdxtools

A bunch of tools for handling the MDX music format (music for the Sharp x68000)
GNU General Public License v3.0
68 stars 14 forks source link

pdx2wav + pdx2sfx distorted and wrong length #9

Open torridgristle opened 6 years ago

torridgristle commented 6 years ago

Seems that every PDX I converted ended up cut early (which I wasn't sure about until I got to some voices that abruptly stopped mid-sentence) and distorted / clipping.

"bd b heavy Loader 32k.wav" is a recording of a PCM drum sample from Namachuukei 68 taken from a pack made by Alianger on the Deflemask forum.

"nama.pdx-0.wav" is the same PCM drum sample converted with pdx2wav from nama.pdx, which is also included the zip.

namachuukei68issue.zip

torridgristle commented 6 years ago

I tried using another program, PDX2PCM, which dumps the OKI-ADPCM files, but seemingly only when you also provide a PDL since it doesn't just dump everything in there with incrementing filenames (I'll include the generic PDL I made). This one pulls out the whole sound.

Also, there's an interesting quirk with the files that I'm not sure you're aware of. When imported with Audacity or converted with sox as OKI-ADPCM (I can only get sox to do it right if I rename the files to .vox) they come out off-center and slightly warped, but if sox converts it with the option -N which reads "Specifies that the nibble ordering (i.e. the 2 halves of a byte) of the samples should be reversed" then the resulting WAV looks accurate to the recording.

Also, in order to make this correct appearing output look like / be virtually the same as pdx2wav's output all that has to be done is multiply the amplitude by 4, such as "return s * 4" with Nyquist in Audacity which I specify so show that I'm being literal with regard to sample values.

namachuukei68issue-update1.zip

Also you don't need to set your computer to use Japanese localization to see the text, if you want to read the output just redirecting the output to a txt with > seems to work fine, provided you open it with something that supports Shift-JIS like Notepad++. Though sometimes it doesn't catch all the text for some reason so for that copying and pasting the output into this decoding website set to Expert: Source Encoding: SJIS Output Encoding: CP850 will clear it up.

vampirefrog commented 6 years ago

Thanks for reporting, I've taken a look and fixed it. Please try it out. I cannot currently test pdx2sf2 or make an .exe release so you'll have to compile.

torridgristle commented 6 years ago

Sorry for taking so long, I haven't compiled anything before and I just recently found out it wasn't working because the -l and -L go after the .cpp in the command line and also that I didn't need to bother with libiconv at all, which was such a pain to set up that I didn't even set it up at all.

A lot of them sound better, and now more problems are visible. Mainly DC offsets, either all of it being in the wrong place, the offset drifting around, or the offset shifting suddenly. There's also an issue with what ought to be pure silence being filled with nyquist-frequency buzzing due to the presence of samples that alternate in volume every other sample. It seems to be happening all the time but only has a noticeable effect when sounds are quiet or when there's no noise at all, not even ambient noise. Also it handles some data in Namachuukei 68 strangely, pdx2pcm output a different noise but it didn't get it right either except for the last part which had some game SFX.

Also you should just normalize the sounds rather than multiplying the amplitude and flooring it, some games have very quiet sounds and I reckon folks what rip WAVs out of PDX files would find normalized files better to work with. Or just an option that can be used like -n just in case there's some reason not to.

I selected several PDXs that previously had problems and run them through the new one and listed observations in a TXT. Everything, including the converted WAVs in case it's an issue only on my end and also the compiled EXE and BAT, are in the ZIP.

pdx2wav-new-test.zip