Audio Compression using Wavelets in MATLAB

Audio frequencies range from 20Hz to 20kHz but these frequencies are not heard in the same way. Frequencies below 20Hz and above 20kHz are very difficult to hear, while those not much more than 20Hz, or not much less than 20kHz, cannot be heard by most people. We often need to process these audio signals for various applications. MATLAB is one of the best signal analysis and signal processing tools.

Audio compression is a very good example of speech and signal processing. We use the Internet for various purposes including entertainment. Audio is common in all entertainment applications. If an audio file size is large, it takes more space to store.

Audio/video compression frees up space substantially, which can then be utilised for other purposes. This article describes some important audio compression techniques.

An audio signal sample is taken and analysed using MATLAB for frequency and amplitude. Haar and Daubenches algorithms are applied on the speech signal and the audio is compressed. Audio sizes before and after compression are compared.

The following parameters are compared by the program: Peak signal-to-noise ratio (PSNR), normalised root-mean-square error (NRMSE) and compression ratios.

Haar wavelet algorithm performs the following functions:
1. Selects audio and finds actual signal size
2. Finds amplitude and frequency
3. Creates frame
4. Decomposes the signal spectrum into wavelet
5. Creates psychoacoustic model
6. Inspects the spectrum and finds tones maskers
7. Applies mu-law of compression
8. Finds and corrects offset
9. Rewrites wave
10. Finds the size of compressed signal

Daubenches wavelet transform performs the following functions:
1. Selects audio and finds the actual signal size
2. Finds amplitude and frequency
3. Chooses a block size
4. Changes compression percentages
5. Initialises compressed matrix
6. Does compression using inverse discrete cosine transform (IDCT)
7. Rewrites signal
8. Finds the size of compressed signal

For complete algorithms, refer code implementations.

MATLAB code file AudioCompression.m implements Haar wavelet and AudioCompression2.m file implements Daubenches wavelet. In this example, Windows XP Startup.wav is the sample audio file used for compression.

Comparison of performance metrics such as PSNR, MSE and compression ratio shows that Daubenches algorithm is best suited for lossless compression of speech signals. Advantages of audio compression are less storage space and associated cost, and faster data transfer.

There are several techniques for data compression. You should follow lossless compression technique as lossy audio compression results in data loss.

Image and video can be compressed in a similar way.

Steps to run the program

Run AudioCompresssion.m file. You will get a window as shown in Fig. 1. Select audio file and then press Compress Audio button. You will get output windows as shown in Fig. 5. Compare audio file sizes before and after compression. The compressed audio file is generated as Output1.wav in the same path as the original source file (AudioCompresssion.m).

Program output (Haar wavelet)
Fig. 1: Program output (Haar wavelet)
Original audio signal (size: 414.691kB)
Fig. 2: Original audio signal (size: 414.691kB)
Haar-wavelet-decomposed audio signal (size: 207.367kB)
Fig. 3: Haar-wavelet-decomposed audio signal (size: 207.367kB)
Daubenches-wavelet-decomposed audio signal (size: 192.043kB)
Fig. 4: Daubenches-wavelet-decomposed audio signal (size: 192.043kB)
Graphical user interface for audio compression
Fig. 5: Graphical user interface for audio compression

Now run AudioCompression2.m file. Select audio file and press Compress Audio button. You will get the program output window as shown in Fig. 6. Observe the size of compressed audio. Here, three compressed audio files are generated and saved in the same path as the original source file. These three outputs correspond to different discrete cosine transform (DCT) window sizes of 2, 4 and 8. The percentage change in compressed files may differ depending on the quality of original file and size.

Program output (Daubenches wavelet)
Fig. 6: Program output (Daubenches wavelet)

Download Source Folder


We will be happy to hear your thoughts

Leave a reply

Enable registration in settings - general
Compare items
  • Total (0)
Shopping cart