# Method for Resonant Frequency Attenuation in Dynamic Audio Equalizer
## 2 Materials and Methods
### Representative Values  
The determination of the bands is based upon a frequency scale selected according to a criterion defined by the Spectral Flatness measure as shown in Equation (1). The Spectral Flatness coefficient is a metric employed to characterise an audio spectrum. It provides a quantitative means to ascertain the extent to which a sound resembles a pure tone, as opposed to being noise-like. In order to obtain a representative value per band, it is necessary to define the frequency band distribution. These parameters determine the center frequency and the bandwidth for signal analysis and filtering. Thirty frequency bands are considered and two types of frequency band distributions are proposed. Figure 3: Time-domain analysis buffer, magnitude spectrum at positive and negative frequencies, and magnitude spectrum at positive frequencies. Figure 2: Representation of the analysis buffer with respect to the input buffer with a sample size of 1024 samples. \[SFM=20\log(\frac{\sqrt{\prod_{n=0}^{N-1}a[n]}}{\frac{\sum_{n=0}^{N-1}a[n]}{N}}). \tag{1}\]  
The discrete function \(a[n]\) is the amplitude in frequency band number \(n\) and \(N\) is the total number of spectrum samples. The first distribution is in one-third octave bands, using 100 Hz as the reference. From there, the frequencies from 25 Hz to 20,000 Hz are calculated using Equation (2), where \(f_{n}\) is the reference frequency and \(f_{n+1}\) is the next frequency on the scale. Bandwidths are defined by the standard in [16], which defines the distribution of the auditory spectrum by fractions of an octave using a reference center frequency. \[f_{n+1}=f_{n}2^{\frac{1}{3}}. \tag{2}\]  
The second proposed distribution is the Equivalent Rectangular Bandwidth (ERB) psychoacoustic scale. Each band of such a scale is based on auditory critical bands [17]. For the distribution, it is necessary to calculate the band spacing overlap factor \(v\), which is defined by the extreme frequencies and the number of bands given by Equation (3) [17]: \(f_{L}\) is the lowest frequency of the auditory spectrum corresponding to 20 Hz, \(f_{H}\) is the highest frequency of the auditory spectrum corresponding to 20,000 Hz, and \(N\) is the number of bands corresponding to 30. \[v=\frac{9.26}{N}\ln(\frac{f_{H}+228.7}{f_{L}+228.7}). \tag{3}\]  
The superposition factor \(v\) is used to calculate the center frequencies for each band using Equation (4), where \(f_{c}\) is the center frequency and \(n=1\), \(\ldots\), 30 to obtain the center frequencies. \[f_{c}[n]=-228.7+(f_{L}+228.7)e^{\frac{\pi n}{28}}. \tag{4}\]  
Finally, Equation (5) is used to calculate the bandwidths \(BW\) for each center frequency. \[BW(f_{c})=24.7+0.18f_{c}. \tag{5}\]  
It is known that the bandwidth is given by the difference between the upper frequency \(f_{u}\) and the lower frequency of the band \(f_{l}\) as \(BW=f_{u}-f_{l}\) and the center frequency is given by the geometric mean between the two extremes of the band--\(f_{c}=\sqrt{f_{u}f_{l}}\). With these equations, the expressions for each frequency are given by Equations (6) and (7). \[f_{u}=\frac{BW+\sqrt{BW^{2}+4f_{c}^{2}}}{2}, \tag{6}\]  
\[f_{l}=\frac{f_{c}^{2}}{f_{s}}. \tag{7}\]  
The Spectral Flatness measure in decibels as shown in Equation (1) is employed to select a scale. The coefficient serves to quantify the degree of resonance exhibited by the signal spectrum. A high coefficient (approaching 0 dB) indicates that the spectrum exhibits a similar power distribution to white noise. In the opposite case, the power is concentrated in certain bands, similar in characteristics to a pure tone [18]. A threshold was determined for the choice between the third octave distribution and the ERB scale. The threshold was calculated by dividing all the audio files in the dataset into blocks of 4096 samples and obtaining the spectral flatness coefficient for each block. Finally, the average of all blocks was calculated, and the threshold was determined.