Using Bass/Treble Equalizer

I am using the Bass/Treble equalizer code in my own project, but for some reason, when I use the bass/treble code, especially, the most recent
update, I am getting a lot of noise in the resulting audio. It is not just clipping, but severe noise. I think I am using the code properly.

I am trying to use the code and adapting it to C#.

Any suggestions.


Ensure that your track is 32 bit float format.
The track sample format can be changed if necessary in the track drop down menu:

my audio samples running through the Bass/treble code is 32-bit float, so not sure what else I can do…


What settings are you using in “Bass and Treble”?
Could you post a short sample (just a few seconds, in WAV format, without “Bass and Treble” applied) of the audio that you are trying to process.
See here for how to attach an audio sample:

Here is an example audio file…you can see the difference. I used 0 as Treble. The odd thing is, when I don’t include the PI calculation in calculating wTreble, I get no noise.


please note I don’t use audacity directly, but the code from audacity for bass/treble and use it in a C# project, and use the C# equivalent for all the math libraries.

The problem is not with the Bass and Treble effect.
If you zoom in close on the audio sample processed by you C# code you will see that there are discontinuities in the waveform.
My guess is that your code is processing in blocks of 160 samples but not correctly preserving the old sample value from one block to the next.
I don’t know C# so I’ll be no help with your code, but hopefully that gives you a clue.

I finally got a chance to revisit this issue within our code-base and figured out the problem. However, it only occurs in our scenario
since we are playing back audio as we are changing the the bass/treble gains.

Within the bass/treble code, there is a call to compute the coefficients for bass/treble which is done in the NewTrackPass1 method.

I realized that this call is done before processing the audio, and in audacity, you perform the bass/treble effect in the entire wave file
as oppose to being able to adjust it on the fly. So, this is done once.

In my case, NAudio processes playback (in my case), in 320 byte chucks. So, every time NAudio performs a read of the audio, I would
be initializing the coefficients and performing bass/treble effect whenever NAudio performs a “read”. I have since changed the logic
to only initialize the coefficients whenever there is a change. There is only slight static when I am in the process of changing the audio,
but when there are no dB changes, the audio playback doesn’t exhibit the static in the sample WAVE file I have provided.

This is a huge improvement over what was previously in the code.

If there is anyone that needs some clarification, please let me know.

I have actually been able to refine it even further and eliminate any distortion altogether during the actual db change of bass/treble.