Commit ff7f28cd authored by Martin Karlsson's avatar Martin Karlsson
Browse files

yo mannen

parent babc8d37
function signal = get_audio()
function signal = get_audio(N)
global bass;
......@@ -18,7 +18,11 @@ end
p = bass.Audio();
lastIndex = p.Audio.lastFrameIndex;
diffIndex = lastIndex - lastLastIndex;
if nargin < 1
diffIndex = lastIndex - lastLastIndex;
else
diffIndex = N;
end
tempLeft = cell2mat(p.Audio.left);
tempLeft = tempLeft(max(end-diffIndex+1,1):end);
......
figure;
% figure;
allAudioLeft = [];
allAudioRight = [];
lastLastIndex = 0;
lastIndex = 0;
count = 0;
while count < 5
while count < 60
p = bass.Audio();
if count == 0
fs = p.Audio.sampleRate;
......@@ -25,13 +25,13 @@ while count < 5
lastLastIndex = lastIndex;
count = count+1
plot(tempLeft);
set(gca,'ylim',[-2^16/2 2^16/2])
drawnow
% plot(tempLeft);
% set(gca,'ylim',[-2^16/2 2^16/2])
% drawnow
end
allAudio = [allAudioLeft, allAudioRight];
bass.Stop()
% bass.Stop()
......@@ -12,9 +12,9 @@ dt = chunks/fs;
%% Setup objects
% Initialize localization models using braodband and subband settings
% Window size in seconds
% Window size in seconds
winSec = 20E-3;
% Lowest and highest center frequency in Hertz of the gammatone filterbank
fLowHz = 80;
fHighHz = 8000;
......@@ -62,7 +62,7 @@ N = 100; % The number of steps to run this stuff.
% Initialize posterior mean and covariance
posteriorMean = zeros(size(A, 1), N);
posteriorCovariance = zeros(size(A, 1), size(A, 1), N);
measuredLocations = zeros(N,1);
% =======================================================
% Main loop - Perform localization and tracking
......@@ -70,8 +70,9 @@ posteriorCovariance = zeros(size(A, 1), size(A, 1), N);
display('Entering main loop')
tic();
t_old = toc();
for l = 1:N
audio = get_audio();
audio = get_audio(2048);
t_new = toc();
dti = t_new - t_old();
% Request processing
......@@ -88,31 +89,16 @@ for l = 1:N
posteriorMean(:, l) = x;
posteriorCovariance(:, :, l) = P;
% pause(max(,0))
measuredLocations(l) = azimEst;
% pause(max(,0))
pause(0.01)
t_old = t_new;
end
% Plot measurements
subplot(2, nFiles / 2, k);
timeAxis = linspace(0, nSamples / fsHz, nFrames);
plot(timeAxis, measuredLocations, 'x', 'LineWidth', 2);
axis([0, nSamples / fsHz, -90, 90]);
plot(measuredLocations, 'x', 'LineWidth', 2);
xlabel('Time / s');
ylabel('Azimuth / deg');
grid on; hold on;
plot(timeAxis, posteriorMean(1, :), 'g', 'LineWidth', 2);
plot(posteriorMean(1, :), 'g', 'LineWidth', 2);
% Plot ground truth
plot(timeAxis, gtTrajectory, 'r--', 'LineWidth', 2);
legend('Measurements', 'Estimated trajectory', 'Ground truth');
% Compute RMSE
rmse = sqrt(sum((posteriorMean(1, :) - gtTrajectory).^2) ./ nFrames);
if ~strcmpi(noiseType, 'none')
title([upper(soundType), ', ', upper(noiseType), ' NOISE AT ', ...
num2str(snr), ' dB SNR, ', 'RMSE: ', num2str(rmse), '°']);
else
title([upper(soundType), ', NO NOISE, ', 'RMSE: ', ...
num2str(rmse), '°']);
end
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