How do I calculate the compression ratio of my LPC code.
1 次查看(过去 30 天)
显示 更早的评论
%MAIN BODY
clear all;
clc;
%TAKING INPUT WAVEFILE,
inpfilenm = 'a1.wav';
[y, Fs] =audioread(inpfilenm);
% x=wavrecord(,);
%LENGTH (IN SEC) OF INPUT WAVEFILE,
t=length(y)./Fs;
sprintf('Processing the wavefile "%s"', inpfilenm)
sprintf('The wavefile is %3.2f seconds long', t)
%THE ALGORITHM STARTS HERE,
M=10; %prediction order
[aCoeff, pitch_plot, voiced, gain] = f_ENCODER(y, Fs, M); %pitch_plot is pitch periods
synth_speech = f_DECODER (aCoeff, pitch_plot, voiced, gain);
0 个评论
采纳的回答
Shubh
2024-1-22
Hi,
The compression ratio is a measure of how much the data has been reduced in size after applying a compression algorithm. In this case, I assumed a simple compression model where the original signal is represented by LPC (Linear Predictive Coding) coefficients. Here's the complete code:
%MAIN BODY
clear all;
clc;
% TAKING INPUT WAVEFILE
inpfilenm = 'a1.wav';
[y, Fs] = audioread(inpfilenm);
% LENGTH (IN SEC) OF INPUT WAVEFILE
t = length(y) / Fs;
sprintf('Processing the wavefile "%s"', inpfilenm)
sprintf('The wavefile is %3.2f seconds long', t)
% THE ALGORITHM STARTS HERE
M = 10; % prediction order
[aCoeff, pitch_plot, voiced, gain] = f_ENCODER(y, Fs, M); % pitch_plot is pitch periods
synth_speech = f_DECODER(aCoeff, pitch_plot, voiced, gain);
% CALCULATING COMPRESSION RATIO
original_size = numel(y) * 2 * 8; % 16 bits per sample
encoded_size = numel(aCoeff) * 8; % assuming each coefficient is 64 bits
compression_ratio = original_size / encoded_size;
disp(['Compression Ratio: ', num2str(compression_ratio)]);
The compression ratio is then displayed using "disp(['Compression Ratio: ', num2str(compression_ratio)]);".
Hope this helps!
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Signal Modeling 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!