Wcompress for 1D data

3 views (last 30 days)
faten Abushmmala
faten Abushmmala on 23 Sep 2022
Commented: faten Abushmmala on 27 Sep 2022
is there another function in matlab for compressing 1D data (speech or any signal) that is equivalent to wcompress ?
faten Abushmmala
faten Abushmmala on 25 Sep 2022
Yes, i kept changing the threshold the signal changed rapidly but the file size kept the same, I think that wdencmp is not entirely equivalent to wcompress ,I think wcompress has more work involved than applying wavelet transformation

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 25 Sep 2022
but i notice that the size of the data file after and before the wdencmp is the same,
What you are writing to the file is the reconstructed signal, not the wavelet coefficients. The size of the reconstructed signal is the same as the size of the input.
You are expecting that the output file will be smaller than the original file. That implies one of two possibilities:
  1. Perhaps you are getting confused about what is being written to the file, and are thinking that just the compressed coefficients are being written to the file; Or
  2. Perhaps you expecting that audiowrite() does compression on the signal it is asked to write, and you are expecting that the reconstructed signal will happen to be more compressible under whatever compression algorithm that audiowrite() might potentially be using.
But is audiowrite() compressing when you write with those parametes?
N = 32768;
Fs = 8000;
testsignal0 = zeros(N, 1); %should be entirely predictable
testsignal1 = linspace(-1, 1, N) .'; %should be pretty predictable
testsignal2 = rand(N, 1); %should be barely predictable
audiowrite('testsignal0.wav', testsignal0, Fs);
audiowrite('testsignal1.wav', testsignal1, Fs);
audiowrite('testsignal2.wav', testsignal2, Fs);
!ls -l testsignal*.wav
-rw-r--r-- 1 mluser worker 65580 Sep 25 01:37 testsignal0.wav -rw-r--r-- 1 mluser worker 65580 Sep 25 01:37 testsignal1.wav -rw-r--r-- 1 mluser worker 65580 Sep 25 01:37 testsignal2.wav
You can see that the files are all exactly the same size -- 2 bytes per sample (per channel) plus a 44 byte header.
So... any difference you are seeing in the size of the files is due to one of two possibilities:
  • the original .wav file might have been written with a different audio encoder; Or
  • the original .wav file had additional headers (such as copyright information or song name) that is not being written out when you audiowrite()
faten Abushmmala
faten Abushmmala on 27 Sep 2022
Thanks you so much! , I will test the code now

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!