Commit f16b55b4 authored by Fredrik Bagge Carlsson's avatar Fredrik Bagge Carlsson
Browse files

mhm

parent f60695be
......@@ -2,31 +2,12 @@ clear;
close all;
clc;
% To be modified
% % % % % %% Request interaural time differences (ITDs)
% % % % % requests = {'itd'};
% % % % %
% % % % % % Parameters of the auditory filterbank processor
% % % % % fb_type = 'gammatone';
% % % % % fb_lowFreqHz = 80;
% % % % % fb_highFreqHz = 8000;
% % % % % fb_nChannels = 32;
% % % % %
% % % % % % Parameters of innerhaircell processor
% % % % % ihc_method = 'dau';
% % % % %
% % % % % % Parameters of crosscorrelation processor
% % % % % cc_wSizeSec = 0.02;
% % % % % cc_hSizeSec = 0.01;
% % % % % cc_wname = 'hann';
% % % % %
% % % % % % Summary of parameters
% % % % % par = genParStruct('fb_type',fb_type,'fb_lowFreqHz',fb_lowFreqHz,...
% % % % % 'fb_highFreqHz',fb_highFreqHz,'fb_nChannels',fb_nChannels,...
% % % % % 'ihc_method',ihc_method,'cc_wSizeSec',cc_wSizeSec,...
% % % % % 'cc_hSizeSec',cc_hSizeSec,'cc_wname',cc_wname);
fs = 24414;
chunks = 2048;
dt = chunks/fs;
[Bf, Af] = butter(3,8000/fs); % filter vectors
%% Setup objects
% Initialize localization models using braodband and subband settings
......@@ -43,18 +24,15 @@ par_sub = genParStruct('cc_bBroadband',0,'cc_wSizeSec',winSec,...
mObj = manager(dObj,'localization',par_sub);
%% Model parameters
fs = 24414;
chunks = 2048;
dt = chunks/fs;
sigma_w = 1;
Q = [2/4*dt^4, 1/2*dt^3; 1/2*dt^3, dt^2]*sigma_w; % Process noise covariance
R = 1; % Measurement noise covariance
x = [0; 0]; % Initial state
P = [10, 0; 0, 10]; % Initial state covariance
Q = [2/4*dt^4, 1/2*dt^3; 1/2*dt^3, dt^2]*sigma_w; % Process noise covariance
R = 1; % Measurement noise covariance
x = [0; 0]; % Initial state
P = [10, 0; 0, 10]; % Initial state covariance
A = [1, dt; 0, 1]; % System matrix (do not change)
c = [1; 0]; % Output vector (do not change)
A = [1, dt; 0, 1]; % System matrix
c = [1; 0]; % Output vector
% Check definiteness of covariance matrices
if ~all(eig(Q) > 0) || ~all(eig(R) > 0) || ~all(eig(A) > 0)
......@@ -72,7 +50,7 @@ addpath('./ekfukf-toolbox');
figure(1)
N = 100;
N = 100; % The number of steps to run this stuff.
% Initialize posterior mean and covariance
posteriorMean = zeros(size(A, 1), N);
......@@ -82,20 +60,28 @@ posteriorCovariance = zeros(size(A, 1), size(A, 1), N);
% =======================================================
% Main loop - Perform localization and tracking
% =======================================================
tic();
t_old = toc();
for l = 1:N
audio = get_audio();
t_new = toc();
dti = t_new - t_old();
% Request processing
mObj.processSignal(audio);
azimEst = dObj.localization{1}.Data(end,1); % There might be an issue with several sources here!
% Perform Kalman filter prediction and update, TODO: consider changing this
% crappy filter for a PF
[x, P] = kf_predict(x, P, A, Q);
Qi = [1/4*dti^4+1e-6, 1/2*dti^3; 1/2*dti^3, dti^2]*sigma_w; % Process noise covariance
Ai = [1, dti; 0, 1];
[x, P] = kf_predict(x, P, Ai, Qi);
[x, P] = kf_update(x, P, azimEst, c', R);
posteriorMean(:, l) = x;
posteriorCovariance(:, :, l) = P;
pause(0.5)
pause(max(,0))
t_old = t_new;
end
% Plot measurements
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment