back
▲ 3 points

Ask HN: Does this algorithm for increasing audio quality exist?

by E-Reverance·5y ago·13 comments·view on hn ↗
I've been having this weird thought lately about how to increase the 'definition' of audio using convolutions. The idea is as follows

1. Convolve a rectangular function of a certain width against the audio

2. The local maxima's of the convolved function show where there is the highest average amplitude, so increase the amplitude of those regions a bit

3. Repeat with smaller rectangular functions to capture finer details

Does this already exist, and if it doesn't, does this idea even work

13 comments
You're going to have to define "definition" a bit because it's unclear what your goals are.

In general what it sounds like you're talking about is a class of nonlinear processes called "dynamics processing" (common examples are automatic gain correction (AGC), compression, expansion, the compressor-expander (compander)). All have been in production use since the least the 1940s. It's built into your cellphone and also those default sound effects they put in crappy TVs.

Your algorithm as described (convolution with a rect in time == multiplication by sinc in frequency) would be a pretty terrible sounding filter, and would cause some gnarly phasing sound effects to the signal. A linear filter will not solve this problem directly.

What you want to do is extract the envelope of the signal, which can be done using the Hilbert Transform (1), which is an example of a class of algorithms called envelope followers (2).

After extracting the envelope from the signal you can use it to compute a gain to apply to the signal (this is how dynamics processing works). It's not a magic bullet, and dynamics processing is undesirable in high fidelity reproduction. Its used in telephones to compensate for the godawful dynamic range, as an effect in recording or production to add balance within a mix, in conferencing applications to make up for poor mic'ing conditions, and in protection circuitry. You do not want to add more than necesssary, as a general rule.

(1) https://en.wikipedia.org/wiki/Hilbert_transform

(2) https://www.dsprelated.com/showarticle/938.php

Dynamics processing is exactly what I was looking for. I wouldn’t have any idea where to look without these replies, so thank you.
You may be looking for "dynamic range compression":

https://en.wikipedia.org/wiki/Dynamic_range_compression

Thank you! The expander section looks interesting, I'll definitely look into it more.
I don't believe you'll capture finer details. What you'll end up with is a softer sound. It will make overly-digital sounding clips sound better, but it won't make previously unheard stuff come out.

Where I get this from, is many moons ago I experimented with turning audio into a very wide image. Visually it looks rather like a frequency analyzer. It was easy to shift pitches around, but the digitization left artifacts at the wrong (unexpected) pitches which changed the sound of vowels quite considerably.

Before I figured out why that is (and that alone was an amazingly interesting lightbulb over my head), I tried smoothing them out so those artifacts wouldn't be so odd. What I ended up with instead was something akin to talking through cotton, and guitar lines totally didn't sound like guitar anymore - more like a synth, which I thought sounded cool, but was effectively a failed experiment.

I don't want to discourage you from doing this using math, and I'd love to see your progress in it, but my prediction is that you'll find something similar occurs.

Having said that, I later discovered this device that I think contains the secret to making my experiments actually succeed: https://www.behringer.com/product.html?modelCode=P0CD0 because it literally compensates for the problems inherent to what my smoothing experiments were doing.

PS: I actually got the idea from an old television set I used to have that had a function that supposedly made it look higher definition. But even that showed some interesting artifacts (blur) if you looked at it up really close. But in motion, the videos indeed looked higher def, which is why I tried it on sound.

Do you know what the effect on the old TV set is called?
There are features like "Edge Enhancement" and "Motion Smoothing" that supposedly work hand-in-hand to improve the image, but I'm not particularly convinced that they succeed all that well, except on the roughest images.

Edge Enhancement is pretty much what you are talking about with audio.

The way I applied it to audio, was to treat the spectral analyzer output as an image. Where the weird artifacts showed up most was when the overtones weren't precisely edited the same way. It was especially obvious in stereo, where weird glitches were really obvious hard-left or hard-right because of differences in the smoothing. Even if you couldn't identify what happened, it would catch your attention one side or the other. And it took away a lot of the "alive-ness" which I described as making guitar sound more synthy.

Here's the type of image I was working with: http://www.music-software-reviews.com/image-files/adobe_audi...

This was back in the latter 90's / early Y2K, so there might be significantly better methods available for keeping it consistent now.

It would be nice if something similar to DLSS was mainstream for motion smoothing because a lot of the newer ML based interpolation methods look a lot better (but are too slow).
The ideal response function for a visual field is a point, so deconvolution works to "sharpen" an image.

The experience of an audio recording is both the experience of the sound source plus the experience of the space that the sound source is in. This is particularly important for multichannel sound in movies and video games but it is important for music.

Good sound recordings (say a David Bowie album from the 1970s) carefully record the instruments with a "dry" recording with limited echo and reverb. Then they put in the echo and reverb they want with a convolutional filter or physical realization thereof.

If you see that as the artistic vision and want to reproduce it accurately you don't want to undo that convolution.

Undoing convolution is an iffy thing to do anyway because it involves a lot of subtracting two big numbers to get two little numbers and is apt to amplify high frequency noise.

It is different for voice applications: a speech recognition system needs some kind of deconvolution to not be confused by the audio environment.

Convolution is multiplication in the frequency domain. By convolving with a rectangle, you are multiplying by the Fourier transform of a rectangle in the frequency domain. In EE terminology, this is a sinc (sin(x)/x) low pass filter: it emphasizes low frequencies and attenuated high frequencies.
The question is with regards to convolution in the time domain, I'm pretty sure the convolution operation is not limited to the frequency domain.
Anyway, here are my thoughts.

1) This is simply a low pass filter. It essentially computes the average values (plus a multiplicative constant). So this value would be high for audio signal segments with lots of bass.

2) This is incorrect. The value in 1) is the amplitude of low frequency signals. Increasing the amplitude of this would probably result in emphasizing the bass.

3) Smaller rectangular functions are low pass filters with different cutoffs, so effect would be similar as 1).

My guess is that the audio will end up having its bass region boosted, depending on the size of the rectangular windowing functions.

this is a white noise machine.