arescentral / antares

A tactical space combat game
http://arescentral.org/antares/
GNU Lesser General Public License v3.0
101 stars 18 forks source link

Music quality lower than original #400

Closed elasota closed 2 years ago

elasota commented 2 years ago

Compared to the original game, the music quality is noticeably lower, as if the sample rate was reduced. This isn't a playback issue, the problem occurs when playing the S3M data in other programs like VLC. It's possible that the instrument sample rate was reduced during conversion or something.

Anecdotally, I believe S3M was a lower-quality format than FastTracker (XM) and Impulse Tracker at the time, and PlayerPro's MAD format was relatively high-quality, although I don't know if it can be losslessly exported to any other format. Needs investigation.

sfiera commented 2 years ago

That’s possible. I’ll admit to usually playing with the music off, since I tend to jump in, test for a few seconds, and quit.

I believe that I exported the MADH music with the open-source PlayerPro app itself, though I’m hazy on how I got the music into it.

I think XM support is already enabled in Antares; I don’t remember the background of why I chose S3M over XM.

elasota commented 2 years ago

Figured out the "problem," I think.

MAD is PlayerPro's native format, but I extracted the MADH resources and opened them with PlayerPro 5.9 and they were having the same problem, and didn't sound like they did in the original game. But, I opened them in PlayerPro 4.5 and they did, so it's actually due to playback inconsistencies.

Going off the oscillo view, my guess is that 4.5 isn't using sample interpolation but 5.9 is, and the Ares code disabled sample interpolation in the driver config.

Might need to check what libmodplug has for resampling. Filtering off tends to be "noisier" but adds high-frequency overtones that make certain things (like the snare instrument) sound crisper, and linear interpolation tends to wipe out high frequencies. (Or could make it configurable per-track?)

sfiera commented 2 years ago

Sorry, I’m not sure I have the background to understand properly what’s going on. When you talk about sample interpolation, are you talking about turning e.g. 8-bit instrument samples into 16-bit? 22kHz into 44kHz? Or something that happens later on in the process?

If it’s some sort of sample-to-sample translation, I would wonder if we could export the original samples, upscale them in the “correct” way (I’m more familiar with image scaling so I’m imagining the audio equivalent of “nearest neighbor”), then stick the upscaled samples back into the S3M/XM.

sfiera commented 2 years ago

Well, though changing this is a possible easy fix: https://github.com/arescentral/antares/blob/eaa4de4d6e8efa41e0462dd70f438a5de9d13631/src/data/audio.cpp#L156 https://github.com/Konstanty/libmodplug/blob/master/src/modplug.h#L87-L90

elasota commented 2 years ago

Yeah, changing that to NEAREST makes it sound much closer to the original.

Sample interpolation = How it handles "resizing" the waveform to account for the output rate and pitch change. With interpolation disabled, it's using nearest neighbor sampling, which adds overtones due to the waveform not being smooth. It's kinda weird that the worst interpolation mode can sound better, but with synths and cymbals, it winds up working out.

I think there's something weird going on with the panning too. PlayerPro 4 has a "True Stereo" option and I'm not sure what it does exactly but it seems like it exaggerates the channel panning. Opening the music in 5.9, it assigned 50% panning to each channel but playing it back in-game really sounds more like 100%.

I've been looking through 4 to see if the channel panning is adjustable and I'm not sure if it actually is or if they hard-coded it to alternating L/R panning (???). That might be fixable by just changing the panning and re-exporting.

sfiera commented 2 years ago

I think there's something weird going on with the panning too. PlayerPro 4 has a "True Stereo" option and I'm not sure what it does exactly but it seems like it exaggerates the channel panning. Opening the music in 5.9, it assigned 50% panning to each channel but playing it back in-game really sounds more like 100%.

I've been looking through 4 to see if the channel panning is adjustable and I'm not sure if it actually is or if they hard-coded it to alternating L/R panning (???). That might be fixable by just changing the panning and re-exporting.

This rings a bell. I think this is something I’ve adjusted before, or at least gotten a ticket about.

sfiera commented 2 years ago

Ah, yeah: #216

elasota commented 2 years ago

Maybe per-song rendering properties and just change it to nearest for all of the stock tracks?

sfiera commented 2 years ago

I'd be fine just changing it to nearest globally for now. I'm not aware of anyone using non-stock tracks in Ares or Antares plugins.