2
$\begingroup$

I need to implement an adaptive delta modulation encoder and decoder using matlab for my term project. How can I code a good adaptive delta modulation? How can I change delta(or sigma) to follow speech signals better? After that How can I decode it to recover original signal? I am using an algorithm which has that main idea: if three successive samples are equal, I increased delta with a constant k. It is useful but not enough.

Here is used codes for adaptive delta modulation:

    function [ cn ] = 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 quintized 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

Codes used for adaptive delta demodulation (decoding process):

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

After decoding process I am using a lowpass filter to remove unwanted high frequency harmonics.

$\endgroup$
  • $\begingroup$ Are you implementing a specific algorithm? Do you have a link to the paper or book? $\endgroup$ – Phonon Jan 5 '14 at 10:18
  • $\begingroup$ I added to the question the codes I am using. $\endgroup$ – eeecoder Jan 5 '14 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.