Restoration of Clipped Sound Signals - a Weighted Fourier Series and AR Approach
Total Page:16
File Type:pdf, Size:1020Kb
KTH May 19, 2013 Restoration of clipped sound signals - a weighted Fourier series and AR approach A bachelor thesis on Optimization Anders Gidmark Helena Olofson [email protected] [email protected] Supervisor: Per Enqvist SA104X Degree Project in Engineering Physics, First Level Department of Mathematics, Optimization and Systems Theory Royal Institute of Technology (KTH) Stockholm, Sweden Abstract Sound signals can be distorted in many dierent ways, one of them is called clipping. A clipped sound signal diers from a non-clipped signal in the way that the amplitudes of the sound wave that are higher than a certain amplitude threshold has been partially lowered or completely lowered to the threshold, the latter is called hard clipping. Since data is lost when a signal is clipped, there is an interest in restoring the signal. For a hard clipped signal, it is often impossible to perfectly restore the signal. In this thesis two dierent methods for partially restoring a symmetrically hard clipped signal are suggested. The two methods considered are a weighted Fourier series (WFS) t and an autoregressive (AR) model approach. Both methods attempt to restore the signal by solving optimization problems designed to min- imize the errors of the respective model. Evaluation and comparison of the two methods showed that the AR method typically performed better than the WFS method. The AR method was eec- tive at restoring the signal, while the WFS method stuck close to the clipped signal, which might be due to dierences in their optimization problems. Restoration of clipped sound signals Contents Contents 1 Introduction 1 2 Theory 1 2.1 Clipping in a loudspeaker system . 2 2.2 Optimization . 3 2.3 Quadratic optimization . 3 2.4 Least-squares problem . 4 2.5 Literature . 4 2.6 Fourier series approach . 4 2.7 Autoregressive . 5 3 Method & model 6 3.1 Fourier series approach . 6 3.2 Autoregressive approach . 7 4 Simulation 8 4.1 Simulations using the AR algorithm . 11 4.1.1 Overlapping intervals . 12 4.1.2 Iterations . 13 4.1.3 Sample length . 14 4.1.4 The order of the model . 15 4.1.5 Dierent values for yclip ................... 16 4.1.6 Multiple iterations for a less clipped signal . 17 4.2 Simulations using the Fourier series algorithm . 19 4.2.1 Overlapping intervals . 21 4.2.2 Iterations . 22 4.2.3 Sample length . 23 4.2.4 Order of the model . 24 4.2.5 Dierent values for yclip ................... 25 5 Discussion 25 6 Conclusion 28 7 References 28 A Graphs from the simulations 29 A.1 AR simulations . 30 A.1.1 Multiple iterations for a less clipped signal . 32 A.2 Fourier series simulations . 35 A.2.1 Multiple iterations for a less clipped signal . 38 [email protected] i [email protected] Restoration of clipped sound signals 2 Theory 1 Introduction In this bachelor's thesis we will develop and examine dierent approaches to the audio distortion clipping, which can occur due to hardware limitations when transfering or recording audio. It is in most cases best to prevent clipping in the rst place. However if clipping has occured you might want to nd a way to restore the original signal from the clipped signal. Two dierent methods to partially restore the signal and update the clipped values are suggested. We will consider an autoregressive (AR) model approach and a weighted Fourier series least squares t. Inspiration to these two methods has to some part been taken from articles read, among other the article "Missing Data Recovery Via a Nonparametric Iterative Adaptive Approach" [9]. This article deals with the problem to recover the missing data from the available data. In the report, we will rst introduce the concept of clipping and how it can arise. The theory behind the Fourier series approach and the autoregressive model approach are presented and an insight in the theory of optimization is given. Moving on to the next section, the two approaches are explained in more detail. In the simulation's section the theory of the developed algorithm is explained, as well as the results obtained using the Fourier series approach and the AR approach being presented and later on discussed in the following section. 2 Theory Clipping is a form of distortion of a sound wave and is often caused due to hard- ware limitations, when for example a speaker or microphone has been subjected to overloading. There are dierent types of clipping, for example symmetrical- and asymmetrical clipping. Symmetrical clipping is when the wave is clipped at the same amount for both positive and negative output values, while asymmet- rical clipping is when the wave is clipped at dierent amount for positive and negative output values. There are both hard- and soft clipping. Hard clipping is when the wave has been clipped of at a certain level and stays at the amplitude threshold for a certain time. The clipped output signal can not assume values above the am- plitude threshold for positive output values and below the amplitude threshold for negative output values. In soft clipping the top- and bottom of the output signal is a bit rounded and there is not an evident amplitude threshold as in hard clipping [1]. In Figure 1 an illustration of a signal which has been subject to symmetrical soft- and hard clipping is shown. The hard clipped signal is red and the soft clipped signal green in the Figure. In this report we will restrict ourselves to symmetrical, hard clipping and real-valued signals. [email protected] 1 [email protected] Restoration of clipped sound signals 2 Theory Figure 1: An example of a symmetrical soft clipped, symmetrical hard clipped and an unclipped signal The dierent types of clipping manifests themselves dierently. When a music instrument is played, particles in the air start to vibrate and to build up sound waves. A sound wave can consist of dierent harmonics, depending on how the signal looks like. If the sound wave is a sine wave it has all its energy at the fundamental frequency f, which is the frequency of the fundamental tone (rst harmonic). The rst overtone (second harmonic) has a frequency of 2f and the second overtone (third harmonic) a frequency of 3f. The odd-order harmonics have a frequency equal to an odd number times the fundamental frequency, while the even order harmonics have a frequency of an even number times the fundamental frequency. The high-order harmonics have thus a higher frequency than the low-order harmonics [3]. The sound of the even and odd harmonics, but also the low- and high order harmonics is audible dierent. The even and low order harmonics sound more musical, whereas the odd and high-order harmonics sound more harsh. In sym- metrical clipping the odd order harmonics are more evident, whereas both even and odd harmonics are evident in asymmetrical clipping. The more asymmetri- cal, the more evident are the even order harmonics. In hard clipping the high- order harmonics are more common. In soft clipping on the other hand the low order harmonics are more evident [4]. Clipping is often caused due to hardware limitations which can occur for example in a loudspeaker system. 2.1 Clipping in a loudspeaker system In a loudspeaker system there is a crossover network and a tweeter and a woofer. The tweeter deals with high frequency (HF) signals and the woofer with low frequency (LF) signals. A common problem when dealing with a loudspeaker system is that the tweeter is blown up if you supply too much power [2]. A tweeter is more sensitive than a woofer and can only handle a fraction of the power an amplier, which are rated for use with the loudspeaker, supply. In music LF signals are more common than HF signals and therefore the tweeter is designed with less strong components. The energy of the HF signals have lower amplitude than the LF signals. Therefore it will be the LF signals that are being clipped rst. It has been argued that when the LF signals clip the power limit of the amplier there is established more HF signals which eventually crash the tweeter. Clipping can be frequency dependent, though in this thesis we only study frequency independent clipping. [email protected] 2 [email protected] Restoration of clipped sound signals 2 Theory However in recent years it has been evident that is not the whole thruth. Today many musicians are experimenting with clipping in order to obtain new sounds. The quality of the ampliers in recent years are also better with bigger dynamic range and it is also claimed that the sound becomes better when clipped on these ones. Therefore it is quite common to overdrive the amplier. When this happens the LF signal will clip while the HF signal will continue to increase, because its amplitude is much less. The result is a crashed tweeter. Another reason a loudspeaker system is damaged is that a clipped signal has greater area underneath the curve and therefore more power than an unclipped signal [6]. 2.2 Optimization In optimization you usually want to nd the best solution from a set given a certain condition. Usually this can be reduced to minimizing or maximizing an objective function f subject to some known constraints. "min f(x) # x (1) s:t gi(x) ≤ 0; i = 1; :::; m The solutions to this general form must lie in the feasible set which is given by n . F = fx 2 R : gi(x) ≤ 0; i = 1; :::; mg 2.3 Quadratic optimization As you will see in Section 3 it is very useful to use quadratic optimization when you want to minimize the error in a linear equation or the dierence between two functions.