function [ BEAM, ARMAP,MAP_pre, beam_drawing, sensor_data ] = precomputeBeam( kgrid2, source, SOURCE,info,BOUND)

% =========================================================================
% MEDIUM INPUTS
% =========================================================================
height_z=floor(info.list_level/kgrid2.dz)+round(BOUND.boundary_thck/kgrid2.dz);
thck_wall=0;
thck_abs=0;
alpha_abs=0.2;      % [-]
c_air=343;          % [m/s]
[ rho_abs ] = AlphaToRho( alpha_abs );
medium.alpha_coeff = 0.75; % [dB/(MHz^y cm)]
medium.alpha_power = 1.5;
medium.sound_speed_ref = c_air;
medium.sound_speed_ref = c_air;
[medium.density, medium.sound_speed] = ...
    makeMediumLayers3D( kgrid2,thck_wall, thck_abs, rho_abs );
%REDEFINE kgrid2
kgrid2.makeTime(medium.sound_speed,0.3,1.5);
%REDEFINE SENSOR
sensor.mask = zeros(kgrid2.Nx,kgrid2.Ny,kgrid2.Nz);
sensor.mask(1:kgrid2.Nx, 1:kgrid2.Ny, height_z)=1;
sensor.record = {'p','p_max','p_rms'};

%DEFINE SIGNAL
%N = round(1/kgrid2.dt*0.2);    % number of samples
%signal=120*pinknoise(1,N);
%[ source_p ] = arrayProcessing( SOURCE, kgrid2 );
SOURCE.source_start_freq= 28.2;     %[Hz]
SOURCE.source_end_freq=112;        %[Hz]
% SIGNAL
signal=10*synthSweep(1.5,1/kgrid2.dt,SOURCE.source_start_freq, SOURCE.source_end_freq );

% FILTERING
num_column=length(SOURCE.delay(:,1));
num_row=length(SOURCE.delay(1,:));
num_sources=num_column*num_row;
for i=1:num_sources;
source.p(i,:)  = filterTimeSeries(kgrid2, medium, source.p(i,:) );
end
% =========================================================================
% COMPUTATION
% =========================================================================
[ sensor_data, sensor] = COMP_SPLdata( kgrid2, medium, source )
[ p_filtered ] = thirdOctaveFilter( sensor_data.p, 1/kgrid2.dt );
[ MAP_pre ] = getMapData( p_filtered, kgrid2 );
[ BEAM, ARMAP, beam_drawing] = analyzeFAR( MAP_pre, kgrid2, SOURCE.center_array_X, -9 );

%[ imp_resp, freq_resp] = analyzeImpResp( signal, sensor_data ,kgrid2);



end

