Elimination of unwanted signals in audio materials by using wavelet transform Zoran Brajević, Croatian Radio, Prisavlje 3 Zagreb, Croatia zbrajevic@hrt.hr Abstract - As a sound engineer, employed at Croatian Radio, I realized that the tools for the reconstruction and restoration of old recordings (or damaged recordings) are insufficient and at least they have deficient analyzing method. Orthogonal frequency-based systems, such as the DFT do not offer a good insight into the temporal localization of unwanted parts of the audio material such as pulse-formed signal (e.g., clicks). In this search for such a tool, I reached for the discrete wavelet transformation (DWT) which is realized by double decomposition in order to obtain wavelet coefficients and a graphic depiction of the coefficients. Distortion is measured with according mean square error (MSE) and it is compared with the number of discarded wavelet coefficients. It is also done the comparison between DWT and the results obtained with frequency based systems based on discrete Fourier transform (DFT). After being performed on an arbitrary mathematical function, the wavelet transform is applied on a sound example. (Wave 22.05 kHz, 8 bit). It is shown that DWT is dealing very well with both, noise and discrete disturbance which are the most common problems in the daily work with audio material. Keywords – noise distrubances, audio material, Discrete Fourier Transform, Wavelet transform, I. INTRODUCTION Clicks are short impulsive disturbances typical for old records [1]. Beside clicks and crackles, historically, there are broadband noise and wow & flutter, as typical unwanted signal disturbance. Crackles are small clicks while wow and flutter are disturbances that cause pitch changes. Hence the need for developing tools which can operate in the time domain and, modeled on the DFT-based tools, had a graphic representation of unwanted events in audio. Wavelet transform has found a wide application in the field of elimination of interference and noise in audio signals. One simple and effective method for improving of the useful signal is suppression of those wavelet coefficients which have small amplitude. Graphic presentation (graphic depiction) will show us which wavelet coefficients are redundant, and we expect them fading away in places where observed function has a derivation [2]. X(k) s(n)+w(n) DWT Ẋ(k) ŝ(n) IDWT Figure 1. Nonlinear processing of wavelet coefficients obtained by discrete wavelet transformation. II. FAST WAVELET TRANSFORM AND FILTER BANKS The recursive calculation of wavelet coefficients is used in realization of analytic branches. At the same time is noted that every subset of lower-level coefficients is incorporated in a set of higher-level (or ranking) coefficients. This means that the higher-level coefficients can be expressed with lower-level (or ranked) coefficients by a simple recursive operation. Figure 2. Fast wavelet-transform In this way we are coming to the analytical part of the fast wavelet transform (Fig. 2). The starting point for calculating the coefficients are the symmetric formulae: um + 1 = um , 2n + vm , 2n + 1 (2.1) 2 um - 1 = um , n - vm , n (2.2) 2 Formulas 2.1 and 2.1 are translated into the language of digital signal processing. First of all, the coefficients: um + 1 = (um , n )n Î Z and vm + 1 = (vm , n )n Î Z should be understood as a series of discrete signals. The next two operations are introduced: um + 1 = (¯ 2)A (um ) vm + 1 = (¯ 2)D (vm ) (2.3) (2.4) The function (↓) is called downsampling and in this case we are performing the downsampling by factor 2. This means that every second (consecutive) sample, within the given series, is omitted. A(xm) and D(xm) are representing the moving Average operation and the moving Difference operation [1]. Moving average and moving difference are a type of digital filter used to analyze a set of data points by creating a series of averages of different subsets of the full data set. The mentioned operations are applied to get wavelet coefficients by using a recursive method described before. Discrete signal x = (xm )m Î Z will be transformed according to formulae (2.5) and (2.6) æ ö A çççèx ø÷÷÷÷n = xn + xn æ ö D çççèx ø÷÷÷÷n = + 1 , while the synthesis is shown in Figure 4; (2.5) 2 xn - xn + 1 (2.6) 2 The procedure can be reversed and from the higher-level coefficients (um and vm) get the lower-level (or ranked) coefficients (um-1 and vm-1) and by that is the right branch of dwt-coder (right branch on the Fig.1). um - 1 = Ă (­ 2)(um ) + Ď (­ 2)(vm ) (2.7) Where are Ă (x ) m and Ď (x ) m given as follows: æ ö Ă ççèçx ø÷÷÷÷n = æ çç çè Ďx ö ÷ ÷ ÷n ÷ ø xn - xn - 1 (2.8) xn + xn - = 1 (2.9) 2 opposite operation than A (xm) and D (xm) ([1], [2]). It comes from the conditions obtained by the z-transform: æ ö This double branch of filter is called the Perfect Reconstruction Filterbank. (PR-Filterbank). Coefficients um,n are approximate coefficients and vm,n are details coefficients ([1], [2]) and these coefficients are used in detection of clicks in audio signal sample. 2 Operation (↑2) means upsampling by factor 2 and performs inserting zero between two adjacent (consecutive) members of a given input. At this point we have all elements (formulae (2.1) - (2.9)) necessary for the definition of fast wavelet transform (FWT). As we can see, æ ö æ ö the functions Ă çççèx ø÷÷÷÷ and Ď çççèx ø÷÷÷÷ are calculating the exact æ ö Figure 4. Filter series for signal synthesis æ ö æ ö ö ÷ ÷ ÷ ÷ ø Multiresolution analysis is a theory which puts development of wavelet coefficients and digital signal processing under common denominator. After the analysis in the z-domain, the math shows us that is, basically, enough to satisfy the following two equations which connect the coefficients with the conditions of orthogonality: ψ := å kÎ Z Ă ççèçz ø÷÷÷÷ Ă ççèççz - 1 ø÷÷÷÷ + Ă èççç- z ø÷÷÷÷ Ă èçççç- z - 1 ø÷÷÷÷ = 2 æ çç çè III. MULTIRESOLUTION ANALYSIS (MRA) AND CONSTRUCTION OF WAVELET WITH MRA gk ×φ - 1, k with gk := (- 1)k hl - k (2.10) æ çç çè Where the relation between A z and Ă z ö÷ ÷ ÷ ø÷ is given (3.1) 2å ψ(t) = with: k (- 1) h l - k φ (2t - k) kÎ Z æ æ ö ö A çççèz ÷÷÷÷ø = Ă çççèçz - 1 ÷÷÷÷ø (2.11) One more request which has to be fulfilled, considering æ ö Ă çççèz ø÷÷÷÷ filter, is symmetry; æ ö Ă çççèz ÷÷÷÷ø = 1 2 (1 + z ) -l (2.12) æ ö , where l is odd. Namely, realization of Ă çççèz ø÷÷÷÷ in practice will be low pass FIR (Finite Impulse Response) filter. Block-scheme of the analytical series of filters is shown in Figure 3: Formulae (3.1) showing us the mother-wavelet. We also see that the moved copy (wavelet again) ψ0,n helps φ0,n to became an orthonormal basis on V-1. If we look briefly at 1 Haar case, we notice that the coefficients h 0 = h 1 = 2 are also the coefficients of mother-wavelet of the Haar function. All other coefficients are zero. (hk=0). If we choose l=1, we get, from (3.1) : ψ(t ) = φ (2t ) - φ (2t - 1) . And before the end of this brief mathematical analysis, let us summarize: Arbitrary mathematical function will be approximated with the wavelet coefficients as follows: The difference should approximations ([3], [6]): A mf = å be noticed, u m , n φm , n , where, um, n = φm,n,f between (3.2) mÎ Z , and the details: Figure 3. Filter series for signal analysis Dm f = å nÎ Z vm , n ψm , n , where, vm, n = ψm,n,f (3.3) m1 å A m 0 f = A m 1f + Dm 0 f (3.4) m = m 0+ 1 The function D m f is detail which appears on interval with length 2m and stretch and shift along that interval. In the similar way we can observe the details on A1, A2, A3 …, i.e., D 1 f , D 2 f , D 3 f …. Precisely this characteristic of wavelet transform we will use later (in the next chapter) at the concrete application of the noise elimination applied on the audio signal. (Wave, 22.05 kHz, 8 bit) ([3],[6]). IV. ANALYSIS AND RESULTS First of all, we will apply the wavelet analysis and Fourier transformation (DFT), (i.e. frequency based system t analysis), on two functions: f 1(t ) = sin(t ) ×rect ( ) , p t ( rect ( ) is rectangle function of width π), with p discontinuities at –π/2 and π/2, and f 2(t ) = u(t - 1) , ( u(t - 1) ) is unit step function shifted by 1), with discontinuity at 1. Those functions are chosen because they have obvious discontinuities and exactly these kinds of discontinuities are very good approximation of discrete disturbances in audio material. The distortion of resulting function will be measured with MSE (Mean Square Error) ([4], [5]): MSE := 1 N N- 1 å ~2 fi - fi Figure 9. Wavelet coefficients at discontinuities at f1(t) Matlab function ‘kizo_skalendiagram’ is searching for discontinuities on a test functions (Fig. 9 and 10) and on the sound signal (Fig. 15). Values of coefficients are represented with the level of grey (white is 0 and black is 255). Matlab function kizo_rad_1_ uses wavelet coefficients to reconstruct the original test function (Figure 13.) and considered audio signal (Figure 16) to detect impulse signals while Matlab function ‘kizoanafurCTFT’ is used for DFT synthesis of test function (Fig. 14). All programs use mathematical principles described in chapters’ I-III. (4.1) i= 0 , and, in the last example, SNR (Signal to Noise Ratio): SNR = 10 log 10 1 N æ f 2i ö ÷ çç ÷ ççMSE ÷ ÷ ø i= 0 è N- 1 å (4.2) Where f is input function with N samples and f ~ is output function also with N samples. Figure 10. Wavelet coefficients at discontinuities at f2(t) Figure 8. Test functions t f 1(t ) = sin(t ) ×rect ( ) and f 2(t ) = u(t - 1) (4.3) p Figure 11. DFT analysis of f1(t) Figure 12. DFT analysis on f2(t) Samplitude is high-definition digital audio workstation (DAWs), specializing in recording, editing, mixing and mastering and it is used only for graphic depiction of audio signal (Fig. 15 and 16). Figure 15. Wave ‘Klarinet.wav’ 22.050 Hz, 8 bit with click on 1. and 2. sec Figure 16. Wave ‘Klarinet.wav’ 22.050 Hz, 8 bit with 75% reduced click on 1. and 2. sec (MSE=0.0877, improvement of aprox. SNR=3.2dB) V. CONCLUSION Wavelet transform is giving us quick and visible analysis of the discrete disturbance of audio material, while DFT analysis is not able to do. Furthermore, MSE of wavelet reconstruction is approximately 3 times better with 25% less coefficients then DFT analysis. However, the best solution would be cooperation between the DFT and DWT analysis, where discrete disturbance would be solved with DWT processing and noise with DFT processing. REFERENCES [1] Figure 13. Reconstruction of f1(t) with 75 wavelet-coefficients (MSE=0.0155) [2] [3] [4] [5] Figure 14. Reconstruction of f1(t) with 100 Fourier-coefficients (MSE=0.0454) Christoph Musialik and Urlich Hatje “Frequency-domain processors for efficient removal of noise and unwanted audio events”, Algoritmix GmbH, AES 26th conference 2005 M. J. Roberts, ˝Signals and Systems“, McGraw-Hill, New York, 2004. Gerhard Doblinger, “Programierung in der digitalen Signalverarbeitung”, Schlembach Fachverlag. 2001. Yves Meyer, “Precursors and Development in Mathematics”, Princeton University Press 2006. Stephane G. Mallat, “Multiresolution Signal Decomposition” IEEE Transactions on pattern analysis Vol. II 1989.