Is lossless compression resistant to noise?
1 view (last 30 days)
Show older comments
Hi everyone
I wanna ask you again
I did lossless compression on audio with various bits per sample (24, 16, and 8 bits per sample ) and inputted noise into it.
as follows :
[y,Fs]=audioread('water.wav');
y = y + 0.01*randn(size(y)); % adjust noise amplitude to your needs
m = max(abs(y(:))); % R2015 and below
y = y./m; % normalize data
audiowrite('testing8bit.flac',y,Fs,'BitsPerSample', 8);
audiowrite('testing8bit.wav',y,Fs)
This code is obtained from the answer to my previous question in Matlab MathWorks
Then I did the Objective Difference Grade (ODG) measurement on the lossless compressed audio, and the result is -3 almost close to -4
Why is the result like that? why not close to zero
Isn't lossless supposed to be noise-resistant
Does anyone understand why this can happen?
thank you
2 Comments
Image Analyst
on 24 Sep 2021
You added noise to the signal. Why should the difference be zero or close to it? If you take an original signal and add noise to it then save it losslessly and recall it, it will be identical to the noisy signal you saved, but of course not identical to the signal before noise was added to it.
DGM
on 24 Sep 2021
Edited: DGM
on 24 Sep 2021
I should point out that the WAV file has 16-bit resolution, but the FLAC is only 8-bit. That alone should produce a measurable difference if you're comparing the results against y+noise.
You might be misunderstanding what lossless means in this context. All it means is that the original uncompressed integer datastream can be reconstructed without error. It doesn't mean that the original or reconstructed integer data matches a floating-point or wider integer source without error. You can see that by converting the data to integer explicitly and then comparing against that.
% test data for this example
load handel.mat
filename = 'handel.wav';
audiowrite(filename,y,Fs);
[y,Fs]=audioread(filename);
y = y + 0.01*randn(size(y)); % adjust noise amplitude to your needs
m = max(abs(y(:))); % R2015 and below
y = y./m; % normalize data
yi = int16(y*32768); % convert to integer
% using the same resolution for each, matching yi
audiowrite('testing8bit.wav',yi,Fs,'BitsPerSample',16);
audiowrite('testing8bit.flac',yi,Fs,'BitsPerSample',16);
% read without converting to DPFP
A = audioread('testing8bit.wav','native');
B = audioread('testing8bit.flac','native');
% i don't have ODG, but this should suffice for an example
immse(A,yi)
immse(B,yi)
Answers (0)
See Also
Categories
Find more on Audio I/O and Waveform Generation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!