Code covered by the BSD License  

Highlights from
Echo Canceller Workbook targeting a dsPIC

image thumbnail

Echo Canceller Workbook targeting a dsPIC

by

 

22 Jan 2008 (Updated )

This set of models and word documents show an echo canceller development workflow.

ec_fixed_setup.m
%% Echo Cancellation Data Specification

% This file is best navigated using "Show cell titles"
% Note that this is an m-script which means all variables
% are evaluated in the base workspace.
%
% Signal Objects Note:
% Since multiple signals in model will have this name it is 
% important to explicitly resolve these signals in the model's
% Configuration Parameters Dialog
%     Diagnostics -> Data Validity -> Explicit Only
%   Copyright 2008 The MathWorks, Inc.

%% Model parameters
load sm_filt;  % spkr_to_mic_filter coefficients
sm_length = length(spkr_to_mic_filter);  % variable from sm_filt mat file
spkr_to_mic_delay = spkr_to_mic_delay;    % also part of sm_file file
pic_frame_size = 80;
Fs = 8000;
Ts = 1/Fs;
mpt_dimensions = [pic_frame_size 1];
ec_length = 32;
%ec_window_len = 256;   % 256/8000 = 32 msec should be long enough to capture echo energy.

%% Input Signal: rin_linear
rin_linear = mpt.Signal;
rin_linear.SamplingMode ='Frame based';
rin_linear.Dimensions = mpt_dimensions;
rin_linear.Description = 'Far End Voice';
rin_linear.DataType = 'fixdt(1,16,14)';
rin_linear.RTWInfo.StorageClass = 'ImportedExtern';

%% Input Signal: sin_linear
sin_linear = mpt.Signal;
sin_linear.SamplingMode ='Frame based';
sin_linear.Dimensions = mpt_dimensions;
sin_linear.Description = 'Near end voice plus echo';
sin_linear.DataType = 'fixdt(1,16,14)';
sin_linear.RTWInfo.StorageClass = 'ImportedExtern'; 

%% Input Signal: sout_linear
sout_linear = mpt.Signal;
sout_linear.SamplingMode ='Frame based';
sout_linear.Dimensions = mpt_dimensions;
sout_linear.Description = 'Echo Cancelled Output (near end)';
sout_linear.DataType = 'fixdt(1,16,14)';
sout_linear.RTWInfo.StorageClass = 'ImportedExtern';

%% Input Signal: Echo Cancellor Weights (Wts)
Wts = mpt.Signal;
Wts.SamplingMode ='Sample based';
Wts.Dimensions = ec_length;
Wts.Description = 'Echo Cancellor Taps';
Wts.DataType = 'fixdt(1,16,15)';
Wts.RTWInfo.StorageClass = 'Auto';

%% LMS Parameters
temp = eval(Wts.DataType);
LMS_Wts_WordLen = temp.WordLength;
LMS_Wts_FracLen = temp.FractionLength;
LMS_Prod_WordLen = 16;
LMS_Prod_FracLen = 15;
LMS_Accum_WordLen = 32;
LMS_Accum_FracLen = 20;
LMS_Parms_WordLen = 16;
LMS_StepSize_FracLen = 15;
LMS_Leakage_FracLen = 15;

%% Input Signal: bypass
bypass = mpt.Signal;
bypass.SamplingMode = 'Sample based';
bypass.Dimensions = 1;
bypass.Description = 'Enable the Echo Canceller';
bypass.DataType = 'int16';
bypass.RTWInfo.StorageClass = 'Auto';

%% Input Signal: mu
mu = mpt.Signal;
mu.SamplingMode = 'Sample based';
mu.Dimensions = 1;
mu.Description = 'Echo Canceller Step Size';
mu.DataType = 'fixdt(1,16,15)';
mu.RTWInfo.StorageClass = 'ImportedExtern';  % originally 'Auto'

%% Input Signal: reset
reset = mpt.Signal;
reset.SamplingMode = 'Sample based';
reset.Dimensions = 1;
reset.Description = 'Clear the echo canceller taps to all zeros';
reset.DataType = 'int16';
reset.RTWInfo.StorageClass = 'Auto';

Contact us