diff --git a/get_audio.m b/get_audio.m index 2e2332d0a0146c87108d2024de0ff698a02adbda..ee80bd7d97aa98bc4533e714fc628ded2760ea8a 100644 --- a/get_audio.m +++ b/get_audio.m @@ -1,4 +1,4 @@ -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); diff --git a/get_audio_loop.m b/get_audio_loop.m index 6b9b9f10683a09ce5593dbb8092e8898e2c0d1a0..6b77a15fad5af4dd8887c7b7ba8c3f7773bb7bc6 100644 --- a/get_audio_loop.m +++ b/get_audio_loop.m @@ -1,13 +1,13 @@ -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() diff --git a/track_audio.m b/track_audio.m index 63ca64d75c183a64a25d9504376636fa79dfef23..46474185a81df7ce6219e07355c7b1838473df2e 100644 --- a/track_audio.m +++ b/track_audio.m @@ -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