%Read in the audio samples for the left and right channels of the Overheads

[OHL,fs] = audioread('Siren_OHL.wav'); %import kick sample
[OHR,fs] = audioread('Siren_OHR.wav'); %import kick sample

%% Use the DrumMaster on the left hand channel

user_OHL = normalizsig(OHL); %normalise the OH sample so that the signal is between 1 and -1

%EQ the OH sample used for gating
in = user_OHL;
%EQ band 1 input values
fc = 500;   % centre frequency
fb = 100;    % frequency band width
G = 4;      % gain factor
%EQ band 2 input values
fc2 = 9000; % centre frequency
fb2 = 500;  % frequency band width
G2 = 6;     % gain factor
%EQ band 3 input values
fc3 = 1000;  %centre frequency
fb3 = 250;  %frequency band width
G3 = -7;    % gain factor

%3 band EQ process in steps (EQ1, EQ2, EQ3)
[EQ1OHL] = EQ(in, fc, fs ,fb, G);
[EQ2OHL] = EQ(EQ1OHL, fc2, fs, fb2, G2);
[EQ3OHL] = EQ(EQ2OHL, fc3, fs, fb3, G3);

x = EQ3OHL; %  Use the normalised OH sample to create the gated signal
holdtime = 0.07; % Time(secs) noise is below threshold before gate activated
ltrhold = 0.4; % threshold for activating gate
utrhold = 0.5; % threshold for deactivating gate
release = 0.5; % time(secs) before sound is zero after gate activated
attack = 0.2; % time (secs) before sound is equal to input after gate has been deactivated
a = 0.8; % The smoothing pole
fs = 44100; % sampling frequency of the sample
gateOHL =noisegtabs(x,holdtime,ltrhold,utrhold,release,attack,a,fs); %call the noise gate function

mix = 0.3; % mix ratio of non-gated sample, to be summed with the gated OH

OHLmaster = (mix*user_OHL) + (gateOHL'); % sum together a mix of the non-gated and gated OH sample to produce a punchy attack with a subtle element of the live mic.
OHLmaster = OHLmaster./max(max(abs(OHLmaster))); % normalise the resulting signal
%% Use the DrumMaster on the right hand channel

user_OHR = normalizsig(OHR); %normalise the OH sample so that the signal is between 1 and -1

%EQ the OH sample used for gating
in = user_OHR;
%EQ band 1 input values
fc = 500;   % centre frequency
fb = 100;    % frequency band width
G = 4;      % gain factor
%EQ band 2 input values
fc2 = 9000; % centre frequency
fb2 = 500;  % frequency band width
G2 = 6;     % gain factor
%EQ band 3 input values
fc3 = 1000;  %centre frequency
fb3 = 250;  %frequency band width
G3 = -7;    % gain factor

%3 band EQ process in steps (EQ1, EQ2, EQ3)
[EQ1OHR] = EQ(in, fc, fs ,fb, G);
[EQ2OHR] = EQ(EQ1OHR, fc2, fs, fb2, G2);
[EQ3OHR] = EQ(EQ2OHR, fc3, fs, fb3, G3);

x = EQ3OHR; %  Use the normalised OH sample to create the gated signal
holdtime = 0.07; % Time(secs) noise is below threshold before gate activated
ltrhold = 0.5; % threshold for activating gate
utrhold = 0.7; % threshold for deactivating gate
release = 0.5; % time(secs) before sound is zero after gate activated
attack = 0.1; % time (secs) before sound is equal to input after gate has been deactivated
a = 0.8; % The smoothing pole
fs = 44100; % sampling frequency of the sample
gateOHR =noisegtabs(x,holdtime,ltrhold,utrhold,release,attack,a,fs); %call the noise gate function

mix = 0.3; % mix ratio of non-gated sample, to be summed with the gated OH

OHRmaster = (mix*user_OHR) + (gateOHR'); % sum together a mix of the non-gated and gated sample to produce a punchy attack with a subtle element of the live mic.
OHRmaster = OHRmaster./max(max(abs(OHRmaster))); % normalise the resulting signal
