필터 지우기
필터 지우기

How do I calculate the compression ratio of my LPC code.

조회 수: 3 (최근 30일)
Mert Sari
Mert Sari 2024년 1월 20일
댓글: Mert Sari 2024년 1월 22일
%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);

채택된 답변

Shubh
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 CenterFile Exchange에서 Signal Modeling에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by