Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Equalizer #1

Open
Ghostkeeper opened this issue Feb 28, 2023 · 1 comment
Open

Equalizer #1

Ghostkeeper opened this issue Feb 28, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@Ghostkeeper
Copy link
Owner

Problem statement

With some of the tracks I'm playing, the beat is hard to hear. For instance, the beat could be prominently played by the hi-hat of the drum kit, but the recording is so old that the high frequencies are hard to hear in the room. But then with other tracks the trumpets are so loud that I'm afraid it's causing loss of hearing for people dancing near the speakers.

I could solve this by applying an equalizer to the music. My mixing panel has a built-in hardware equalizer that works well to turn down the highs against loud trumpets, or turn up the lows in order to make the beat on the double bass more audible, etc. However this requires me to be on the nose and on time with adjusting the volumes.

I could also solve this by baking in effects into the audio files. However this makes me too late to change the music while it's playing. I couldn't adjust the trumpets on the evening that I'm hearing the problem. Moreover it's cumbersome and changes the audio files resulting in quality loss.

Requested solution

I'd like LynDJ to feature an equalizer of sorts. These are the requirements of what I'd like to see:

  • The equalizer needs to feature at least 3 channels: Lows, mids and highs.
  • Preferably this equalizer is adjusted via the main interface similar to the main volume.
  • The changes to the equalizer need to be remembered in time, similar to the volume, and played back the next time the track plays.
@Ghostkeeper Ghostkeeper added the enhancement New feature or request label Feb 28, 2023
@Ghostkeeper
Copy link
Owner Author

I've attempted this feature before, but ran into some implementation issues.

The equalizer can be applied to the audio in the playback module. I have attempted this with PyDub's built-in filter effects when this project still used PyDub to play music. At least with that library, performance was not an issue. However there was a big problem that I didn't yet overcome:

The lowpass/highpass effects can be applied to individual pieces of audio only. It needs some length of audio to work on. If we apply the effect to the song as a whole, it takes a few seconds to apply to any ordinary song (processing power). This is infeasible, because we'd like to hear the feedback of adjusting the EQ pretty much immediately. However if we apply the effect to pieces of the song, the waveforms of these pieces don't match up at their borders any more. A lowpass filter doesn't ensure that the waveform at the border is still the same sample as before. So if we e.g. apply the effect to 0.1s pieces of music, we get a click 10 times per second in the music. This is abhorrent to listen to.

There are actually two problems here folded into one:

  • To get quick feedback of the EQ's effect, we want to apply the filter to short pieces of music and gluing these short pieces together gives regular clicks.
  • Even if we were to have infinite processing power and could smartly join up pieces of music while the EQ is not changed, changing the EQ smoothly doesn't guarantee that the waveform is also changed smoothly. Thus any change to the EQ is going to result in clicks while it is changing. If we store the EQ changes with waypoints similar to volume, this is going to result in 20 clicks per second as the EQ animates the change.

To solve this issue I need to do some research on how other audio players implement this. They must've encountered the same problem.

One idea that I've had is to remove the clicks by fading the audio samples together. This involves adding e.g. 0.1s to the start and end of every processed audio fragment and then blending those together with the previous segment with a fade. This would certainly remove the clicks for EQ changes (problem 2). But it doesn't solve the first problem. To solve the first problem we could temporarily process short fragments and in the background process the whole track. Once the whole track is also processed we could switch to that one (again with a fade to prevent a click). That way we will only have this problem temporarily while processing. But it's not really a proper solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant