Matlab coding for linear predictive code of audio file without using toolbox fun
ID: 2083307 • Letter: M
Question
Matlab coding for linear predictive code of audio file without using toolbox functions . Order of prediction = 10 Sampling rate = 8kHz Frame size = 200 samples Single pulse excitation at the start of sample RMS energy normalizationPlease post code and comments explaining Matlab coding for linear predictive code of audio file without using toolbox functions . Order of prediction = 10 Sampling rate = 8kHz Frame size = 200 samples Single pulse excitation at the start of sample RMS energy normalization
Please post code and comments explaining Matlab coding for linear predictive code of audio file without using toolbox functions . Order of prediction = 10 Sampling rate = 8kHz Frame size = 200 samples Single pulse excitation at the start of sample RMS energy normalization
Please post code and comments explaining Order of prediction = 10 Sampling rate = 8kHz Frame size = 200 samples Single pulse excitation at the start of sample RMS energy normalization
Please post code and comments explaining
Explanation / Answer
enter the following program in matlab
frs = 200; % Frame Size
fL = 2048; % length of fourier transform
Op = 10; % Order of prediction
R = 8000; % Sampling Rate
% input the audio file ,
in = 'kdt_003.wav';
[x, fs] =audioread(in);
% x=audirecord(,);
% LENGTH OF INPUT AUDIFILE,
t=length(x)./frs;
sprintf('Processing the audiofile "%s"', in)
sprintf('The wavefile is %3.2f seconds long', t)
% create a system object to read an audiofile
audioReader = dsp.AudioFileReader('SamplesPerFrame',frs,'OutputDataType','double');
fileInfo = info(audioReader);
Fs = fileInfo.SampleRate;
% Pre-emphasis is carried out using an FIR digital filter System object.
preEmphasisFilter = dsp.FIRFilter('Numerator', [1 -0.95]);
% Create a buffer System object such that you get an output twice
% the length of frame size with an overlap length of frame size.
signalBuffer = dsp.Buffer(2*frs, frs);
% Create a window System object using Hamming window.
hammingWindow = dsp.Window;
% Create an autocorrelator System object inorder to compute
% the lags in the range [0:12] scaled by the length of input.
autoCorrelator = dsp.Autocorrelator('MaximumLagSource','Property','MaximumLag',12,'Scaling', 'Biased');
% Create a System object to compute the reflection coefficients from
% auto-correlation function using Levinson-Durbin recursion and configure
% it to output both polynomial and reflection coefficients for plotting the
% LPC spectrum
levSolver = dsp.LevinsonSolver('AOutputPort',true,'KOutputPort',true);
% Create an FIR digital filter system object for analysis and two all-pole
% digital filter system objects for synthesis and de-emphasis.
analysisFilter = dsp.FIRFilter('Structure','Lattice MA','ReflectionCoefficientsSource','Input port');
synthesisFilter = dsp.AllpoleFilter('Structure','Lattice AR');
deEmphasisFilter = dsp.AllpoleFilter('Denominator',[1 -0.95]);
% Create a system object to play the audio at its sample rate
audioWriter = audioDeviceWriter('SampleRate', Fs);
% Create a system object to play the audio at required sample rate
audioWriter1 = audioDeviceWriter('SampleRate', R);
% Setup plots.
scope = dsp.SpectrumAnalyzer('SampleRate', Fs, ...
'PlotAsTwoSidedSpectrum', false, 'YLimits', [-140, 0], ...
'FrequencyResolutionMethod', 'WindowLength', 'WindowLength', fL,...
'FFTLengthSource', 'Property', 'FFTLength', fL, ...
'Title', 'Linear Prediction of Speech', ...
'ShowLegend', true, 'ChannelNames', {'Signal', 'LPC'});
% call a processing loop to do LPC analysis and synthesis of the input audio signal using the System objects created.
% The loop is stopped when the AudioFileReader System object detects the end of the file.
%RESULTS,
beep;
disp('Press a key to play the original sound!');
pause;
soundsc(x, fs);
disp('Press a key to play the LPC compressed sound!');
pause;
soundsc(x, R);