# De-Noising Process in Room Impulse Response with Generalized Spectral Subtraction
## 2 Principle of Spectral Subtraction  
### Basic Spectral Subtraction  
The spectral subtraction algorithm is one of the earliest and longest-used techniques for background noise reduction and has been mainly applied to improve the quality of speech [21]. The basic principle is to subtract the magnitude spectrum of noise from the noisy signals where the signal and noise are considered uncorrelated. The method assumes that speech and noise are uncorrelated, and noise is added in the time domain, which is why the SS algorithm is applied to de-noise the RIRs, because the background noise presented in the RIRs is assumed to be additive noise. The discrete-time noisy RIR \(y(n)\) is composed of a clean signal, \(x(n)\), and the noise \(d(n)\) is expressed as,  
\[y(n)\ =\ x(n)+d(n). \tag{1}\]  
In the application of the SS, the discrete Fourier transform (DFT) of both sides is taken, where the general form of the enhanced signal spectrum can be described in terms of its magnitude spectrum of one frame, as follows,  
\[\big{|}\hat{X}(\omega)\big{|}^{b}\ =\ \big{|}Y(\omega)\big{|}^{b}-\big{|}\hat{D}( \omega)\big{|}^{b}, \tag{2}\]  
where \(\big{|}\hat{D}(\omega)\big{|}\) is the estimated noise spectrum and the updated during periods of silence and, \(\big{|}\hat{X}(\omega)\big{|}\) is the enhanced signal spectrum calculated using the inverse Fourier transform with the information of phase of the original signal \(|Y(\omega)|\). When reconstructing the enhanced signal, its phase is approximated by the phase of the original signal, owing to the estimated phase of the noise spectrum, causing a sharp increase in the complexity of the algorithm, and when the SNR is comparatively high, leading to an imperceptible phase difference [29; 30]. The value \(b\) is the exponent determining the transition sharpness, \(b=2\) represents the power spectral subtraction, while \(b=1\) represents the magnitude spectral subtraction. In this paper, the \(b=2\) is applied. Although the spectral subtraction algorithm can easily reduce noise, the enhanced spectrum may contain some negative values because of the inaccurate estimation and nonlinear compensation processing of the noise, leading to spectral peaks that do not belong to the original signal. When converting in the time domain, these peaks sound like tones and generate the perceptually annoying residual noise named musical noise [28]. Therefore, special attention should be paid to musical noise when applying the spectral subtraction algorithm to de-noise the RIR without affecting the reverberation decay. The basic approach proposed by [PERSON] [21] to reduce the musical noise effects was to set the spectral magnitude negative rather than set them to zero and is expressed as follows,  
\[\big{|}\hat{X}(\omega)\big{|}^{2}\ =\ \begin{cases}\big{|}Y(\omega)\big{|}^{2}- \big{|}\hat{D}(\omega)\big{|}^{2},&\text{if }|Y(\omega)|^{2}-\big{|}\hat{D}(\omega)\big{|}^{2}> \text{max}\Big{(}\big{|}\hat{D}(\omega)\big{|}^{2}\Big{)}\\ \min_{j=i-1,d,i+1}\big{|}\hat{X}_{j}(\omega)\big{|}^{2}&\text{else}\end{cases}  \tag{3}\]  
where \(\big{|}\hat{X}(\omega)\big{|}^{2}\) is the enhanced spectrum of the RIR in frame and \(\big{|}\hat{D}(\omega)\big{|}^{2}\) is the estimated spectrum of the noise, which is estimated at the beginning or the end of the RIR. The common and most straightforward method to estimate and update the noise during silence (the pause) in speech uses the voice activity detector (VAD) because silence exists not only at the beginning or the end of a sentence, it also exists in the middle of a sentence [31]. However, the VAD algorithms have less effect on the RIRs because the background noises exist at the beginning and end of the RIRs. Applying the SS for the RIRs with stable background noises, the mean amplitude differences between the dynamic ranges of the EDCs and the reduced noise levels with and without VAD algorithms were around 1 dB. Hence, the VAD algorithm will no longer be applied for the RIR.