Hello everyone!!! How to 4 again pushed on input signal? method use the adaptive delta modulation?

I tried this code. This code is correct but this code 2 again pushed input signal. I want to 4 again pushed the input signal ??? the use method is adaptive delta modulation ???? please help me ?
% % ---Adaptive Delta Modulation close all; clear all; clc; % fs = 8000; [y, fs]=wavread('road.wav'); y(:,2)=[]; [cn , delta]= adm_enc(y); decoder_adm = adm_dec(cn); subplot(311); plot(y); axis([1 171520 -2 2]); title('Original Speech signal'); subplot(312);stem(delta); title('Delta'); subplot(313); plot(decoder_adm); axis([1 171520 -2 2]); title('ADM Decoder'); % wavplay(y,fs); % wavplay(decoder_adm,fs); % % % % ---
filename1 = decoder_adm ; wavwrite(filename1,fs,'new.wav'); % wavwrite(decoder_adm,fs,8,'new.wav') -------------- %ADM encoder function [ cn, delta ] = adm_enc( signal ) delta_min = 0.6250/5; % minimum step size k=1.5; % m = 0.85; % scaling constant L = length(signal); % length of input signal Mq = zeros(1,L); %aproximated or quantized signal dq = zeros(1,L); %quantized error or difference between original signal and aproximated signal cn = zeros(1,L); %encoded output as a binary signal delta=ones(1,L); for n=2:L
d = signal(n) - Mq(n-1); % error or difference between input (original) signal and approximation
if d>0 % if error is greater than 0
dq(n)=delta_min; % equate output to delta_min
else
dq(n)=-1.*delta_min; % equate output to -delta_min
end
if dq(n)==dq(n-1) && dq(n-1) == dq(n-2) % if two previous outputs are equal
delta(n)=k.*delta(n-1); % scale step size
else
delta(n)=delta_min; % otherwise equate output to min step size
end
Mq(n) = Mq(n-1) + delta(n).*dq(n); % calculate approximation signal
end
for i=1:length(cn) % encode the output as a binary signal
if dq(i)==delta_min
cn(i)=1;
else
cn(i)=0;
end
end
end
---------------------------
ADM decoder
function [ signal ] = adm_dec( cn )
delta_min = 0.6250/5; % minimum step size
L = length(cn); % length of input signal
k=1.5; % scaling constant
signal = zeros(1,L); % initializations delta=ones(1,L); for i=1:length(cn) % decode binary input as output of adm if cn(i)==1 Mq(i)=delta_min; else Mq(i)=-1.*delta_min; end end for n=2:L
if Mq(n)==Mq(n-1) % if two sequential input values are equal
delta(n)=k.*delta(n-1); % scale step size
else
delta(n)=delta_min; % otherwise equate step size to min step size
end
signal(n) = signal(n-1) + delta(n).*Mq(n); % calculate output of adm
end
end

Answers (0)

This question is closed.

Tags

Asked:

on 7 May 2015

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!