function out = calculate_db(in,ref,SPL)
%---simple dB calculation---
dsize = size(in,1); %size of input data
out = zeros(dsize,1);
if (SPL==true)
    for i = 1:dsize
        out(i)=(20*log10(in(i)/ref(i)))+94; 
        %based on calibrator giving out 94 dB (SPL)
    end
else
    for i = 1:dsize
        out(i)=20*log10(in(i)/ref(i));
        %conversion of decimal to dB for SNR measurement
    end
end

%Measuring directional characteristics of sound sources
%Made by Benjamin Nimmerrichter 2022/23 for BUT