function [ source_p, SOURCE ] = arrayProcessing( SOURCE, kgrid )
%UNTITLED9 Summary of this function goes here
num_column=length(SOURCE.delay(:,1))
num_row=length(SOURCE.delay(1,:))

num_sources=num_column*num_row;


max_delay=round(0.02/kgrid.dt); %[samples]
length_signal=length(SOURCE.signal);
length_delay=max_delay+length_signal;

[source_p(1:num_sources,1:length_delay)] = zeros;

SOURCE.delay_bin=round(SOURCE.delay/1000/kgrid.dt);    %[samples]

SOURCE.delay_bin = transpose(SOURCE.delay_bin);
SOURCE.polarity_bin=transpose(SOURCE.polarity);

for i=1:num_sources;
    source_p(i,(1+SOURCE.delay_bin(i)):(SOURCE.delay_bin(i)+length(SOURCE.signal))) = SOURCE.signal.*SOURCE.polarity_bin(i);
end
end

