Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a Fs check between source and function input #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions Functions/simulate_measurement_mvs.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
% required:
% sources: Cell{Sources} - array of sources obj
% array: MicArray - mic array obj
% Traj: Trajectory - trajectory obj - with postion x,y,z and time_vector
% Traj: Trajectory - trajectory obj - with postion x,y,z and time_vector
% array with at least two points
%
%
% optional:
% 'Fs': int - samplingrate
% 'c0': float - sound speed in air - prefer preferably use setGlobalC0
% to change that value
% 'Noise': float - value in db to add noise to data
% 'Noise': float - value in db to add noise to data
%
% Output:
%
%
% varargout{1}: SAudio - Simulated audio for each mic in array
% varargout{2}: Sources - Sources with the created audio
% varargout{3}: Trajectory - Sources trajectory
Expand All @@ -31,7 +31,7 @@

% Optional inputs
for i=1:2:length(varargin)
sArgs(varargin{i}) = varargin{i+1};
sArgs(varargin{i}) = varargin{i+1};
end

%%%%%% Sources Properties %%%%%%%%%
Expand All @@ -52,6 +52,14 @@
for i=1:1:n_sources
%%%% Source %%%%%%%
source = sources{i};
%%%% Check Fs %%%%%
if source.Fs ~= sArgs('Fs')
error(strjoin(["Frequency sample doesn't match! Source{", num2str(i), ...
"} has a Fs of ", num2str(source.Fs), ...
" Hz and the function input value is Fs of ", num2str(sArgs('Fs')), ...
" Hz. Therefore, they don't match! Please check your inputs."], ''));
end
%%%% Get positions from the Source %%%%%
x_s = pos('x') + source.position('x');
y_s = pos('y') + source.position('y');
z_s = pos('z') + source.position('z');
Expand All @@ -72,7 +80,7 @@
%%%%%%% Pressure %%%%%%%%%%%%%%%
P(:,:,i) = H.*s(i,:);
%%%%%%% Wave reception time %%%%
T_reception(:,:,i) = t + t_ray;
T_reception(:,:,i) = t + t_ray;
end

%%%% Ignoring interp for some reasons
Expand All @@ -82,7 +90,7 @@

% min_t = [];
% max_t = [];
%
%
% for i=1:1:n_sources
% min_t = [min_t min(T_reception(:,:,i),[],2).'];
% max_t = [max_t max(T_reception(:,:,i),[],2).'];
Expand Down