SourMesen / Mesen

Mesen is a cross-platform (Windows & Linux) NES/Famicom emulator built in C++ and C#
https://www.mesen.ca
GNU General Public License v3.0
1.26k stars 319 forks source link

Audio Effect Addition: Soft Clipper / De-Spiker / De-Popper #442

Open torridgristle opened 6 years ago

torridgristle commented 6 years ago

There's a few games on the NES that you can't safely or comfortably turn up because of obnoxious popping, like Batman with its drums, and there's a simple fix for it: clip them out. It doesn't have to be a hard clipping digital distortion, a soft clipper would still let things pass the threshold while forcing down extreme samples more than others. Unlike something that'd need to analyze an envelope and duck the audio, like a limiter, it has zero latency. Plus if a limiter was fed a signal that had one sample that popped too loud, even if the rest was fine, it'd end up lowering the volume of the audio for the parts that were fine.

I'd place this before the EQ so that spikes don't get stretched over several samples from filtering and can be caught when they're just one or so samples long, as opposed to having it miss a spike due to the bass or treble being altered resulting in the spike no longer being clearly louder than its surroundings.

Cibomatto2002 commented 6 years ago

This helps with the popping in games. capture7-31-2018-9 48 33 am

torridgristle commented 6 years ago

I've tried that and, at least in Batman, it very effectively removes the popping, but it also loses the transient smack of the drums when I A/B recordings of the intro cinematic music. (Also it apparently alters the volume of the triangle bass sounds in the music but I didn't really notice that while listening to it normally, I only recognized it when I aligned and differenced the outputs to check out how the depopper works.) The current depopper sounds dampened, which isn't necessarily bad and certain sounds and certain games would sound better with this than something else, but with a soft clipper you still get the smacky / smack-like quality in the Batman drums while also ensuring that you can bring up the volume of the game without worrying about transient spikes that reach about 3x the amplitude of everything else blowing something in your physical hardware, or simply tiring your ears.

Plus, and this is a separate purpose entirely, it may just be nice as an aesthetic choice like those available with video filters. Just a generic low-cost phattening effect if dialed in too far for simple transient trimming. Honestly it's weird that audio effects aren't more common in emulators when shaders are so widespread. Makes me really appreciate Mesen.

SourMesen commented 6 years ago

Thanks for the request(s)!

Normally I'd happily implement this sort of thing, but the reality is that my knowledge of DSP is extremely limited (and by limited, I mean almost nonexistent). I spent a couple of hours looking for info and attempting to implement the stereo comb filter using the existing equalizer code, but haven't had much luck in implementing anything that seems useful so far. It's a bit frustrating since I'm sure they are not actually all that hard to implement - I imagine someone who knew what they were doing would likely be able to write the code for all this in a few hours' time.

At the moment, I'm a bit busy trying to finish up the next release version of Mesen, so I probably won't have time to look more into these until after 0.9.6 is released.

torridgristle commented 6 years ago

I had a moment of clarity and realized something about the stereo comb filter effect, all this time I thought it was way more complicated than it was until I thought about how comb filtering is done and that mdaStereo will mono out to the original signal. The video I linked in the other issue wasn't exactly wrong per say, it's just a different approach that might sound a bit smoother as the cuts and boosts are far apart etc. I'll get into it in the other issue about the stereo enhancing comb filtering so it's all grouped together but I promise that mdaStereo's approach is incredibly and beautifully and forehead-slappingly simple.