Commit d3b3d1a3 authored by Joanna Luberadzka's avatar Joanna Luberadzka

started writing machine listener scripts

parent a32ab663
% revision 1.00.1 beta, 07/01/04
function response = exampleDOA_detect
function response = localizer_detect
global def
global work
......
% revision 1.00.1 beta, 07/01/04
function exampleDOA_init
function localizer_init
% this file is used to initialize model parameters
......@@ -8,12 +8,12 @@ global def
global work
global simwork
% the example model is so simple, there is not much to initialize.
% Some filter coefficients used in example_preproc
addpath(genpath('/home/joanna/DOA4Seminars/DOASVMdemo'));
% load DOASVM model
simwork.sSensors = 'frontmiddle';
simwork.sModeltype = 'HRIR';
simwork.LocModel = load(['LocModel_' simwork.sModeltype '_' simwork.sSensors]);
% 4-6 kHz four-pole Butterworth Bandpass (missing)
% first-order lowpass filter @ 65 Hz
[simwork.lp_b,simwork.lp_a] = folp(65,def.samplerate);
simwork.DOAazimuth = simwork.LocModel.az;
%eof
% revision 1.00.1 beta, 07/01/04
function response = exampleDOA_main
function response = localizer_main
% the model_main function must return the presentation interval selected by the model
......
% revision 1.00.1 beta, 07/01/04
function out = exampleDOA_preproc(in)
function out = localizer_preproc(in)
% in contains one of the 3 intervals presented in the experiment
global def
global work
global simwork
% this is the Viemeister JASA 1979 leaky-integrator model
% 4-6 kHz four-pole Butterworth Bandpass (missing)
% halfwave rectification
tmp = max(in,0);
% first-order lowpass filter @ 65 Hz
tmp = filter(simwork.lp_b, simwork.lp_a, tmp);
% ac-coupled rms = std
out = std(tmp,1);
% that's it
% eof
% [probability DOAazimuth time] = DOASVMloc1(sig,fs)
\ No newline at end of file
sig=in';
fs=def.samplerate;
time = 0:1./simwork.LocModel.fs.*simwork.LocModel.wndlen./2: size(sig,2)./simwork.LocModel.fs -1./simwork.LocModel.fs.*simwork.LocModel.wndlen;
% STFT from Multi-Channel BSS Locate toolbox R. Lebarbenchon and E. Camberlein)
% http://bass-db.gforge.inria.fr/bss_locate/
% Resample to model fs
if fs ~= simwork.LocModel.fs
sig = resample(sig.',simwork.LocModel.fs,fs).';
end
X = MBSS_stft_multi(sig,simwork.LocModel.wndlen);
% Feature extraction
mFeature = [];
for IDXpair = 1:size(simwork.LocModel.vPairs,2)
G_length = simwork.LocModel.wndlen./2+1;
ifftwin = hanning_(2.*G_length);
ifftwin = ifftwin(G_length+1:end);
G = squeeze(conj(X(:,:,simwork.LocModel.vPairs(1,IDXpair))) .* X(:,:,simwork.LocModel.vPairs(2,IDXpair)));
% PHAT weighting
G = G./max(abs(G),eps);
% Apply ifft window
G = G .* ifftwin(:,ones(1,size(G,2))) .*simwork.LocModel.nUpsample;
% zero-padding according to upsampling factor
G = [G;zeros(floor((simwork.LocModel.nUpsample-1).*simwork.LocModel.wndlen./2),size(G,2))];
% reconstruct mirror frequencies, assumes even wndlen
G = [G; conj(G(end-1:-1:2,:))];
% ifft and swap halves of csd to compensate for fftshift
vGCC = ifftshift(ifft(G,[], 1,'symmetric'),1);
% Use only relevant part of GCC-PHAT function
vDelaybins = size(vGCC,1)./2-simwork.LocModel.maxLag(IDXpair)+1:size(vGCC,1)./2+simwork.LocModel.maxLag(IDXpair)+1;
mFeature = [mFeature; vGCC(vDelaybins,:)];
end
% Compute DOA probability map
for IDXt = 1 : size(mFeature,2)
% Apply linear SVM model (one for each direction) to feature vector
c = (simwork.LocModel.w * mFeature(:,IDXt)) + simwork.LocModel.b.';
% map to probability using a sigmoid transformation
probability(:,IDXt) = 1 ./ (1 + exp(-(simwork.LocModel.x.' + c .* simwork.LocModel.y.')));
end
\ No newline at end of file
Markdown is supported
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