DEV Community

孤高游侠
孤高游侠

Posted on

2

Algorithm for Normalizing Current Data Using Historical Data to Eliminate Sound Noise

When developing a music playback software, I chose to use an IIR filter to implement the audio equalizer functionality, as it is simpler for me to develop compared to other options. However, when adjusting the sound effects to extreme settings—such as having a very high gain for one frequency while keeping others low—it often produces noise. Even when testing other similar software (like Winamp), I found that this problem cannot be completely avoided.

After researching, I discovered two common handling methods. The first is to clip any data exceeding an absolute value of 1 to 1, but this only partially reduces noise and does not eliminate it entirely. The second method is to normalize based on the absolute maximum value of the current data group, but this can cause sudden changes in volume during playback, impacting user experience.

Therefore, I propose an improved solution: introduce a global absolute maximum value (denoted as α), with an initial value set to 1. Each time I process a group of audio data, I will first obtain the absolute maximum value of that group (denoted as β), and then assign the larger value between α and β to α, using this α value to normalize the audio data. If the user switches songs or readjusts the equalizer, α will be reset to 1. This approach can avoid the drawbacks of the previous methods, but the side effect is that the overall volume of the song may be slightly reduced, while switching to other songs may result in the volume returning to normal (with a very low probability). Nevertheless, from a user experience perspective, I think this remains the best solution available.

Billboard image

Monitoring as code

With Checkly, you can use Playwright tests and Javascript to monitor end-to-end scenarios in your NextJS, Astro, Remix, or other application.

Get started now!

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay