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

[TomL,fs] = audioread('Siren_TomL.wav'); %import Tom sample
[TomR,fs] = audioread('Siren_TomR.wav'); %import Tom sample

%% Use the Tom_Master of the lefthand channel

user_tomL = normalizsig(TomL); %normalise the tom sample so that the signal is between 1 and -1

%EQ the tom used for gating
in = user_tomL;
%EQ band 1 input values
fc = 100;   % centre frequency
fb = 100;    % frequency band width
G = 4;      % gain factor
%EQ band 2 input values
fc2 = 5000; % centre frequency
fb2 = 400;  % frequency band width
G2 = 6;     % gain factor
%EQ band 3 input values
fc3 = 300;  %centre frequency
fb3 = 250;  %frequency band width
G3 = -7;    % gain factor

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

x = EQ3tomL; %  Use the normalised tom sample to create the gated signal
holdtime = 0.07; % Time(secs) noise is below threshold before gate activated
ltrhold = 0.6; % threshold for activating gate
utrhold = 0.8; % 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
gatetomL =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 tom

tommasterL = (mix*user_tomL) + (gatetomL'); % sum together a mix of the non-gated and gated tom sample to produce a punchy tom attack with a subtle element of the live tom mic.
tommasterL = tommasterL./max(max(abs(tommasterL))); % normalise the resulting signal
%% Use the Tom_Master of the righthand channel

user_tomR = normalizsig(TomR); %normalise the tom sample so that the signal is between 1 and -1

%EQ the tom used for gating
in = user_tomR;
%EQ band 1 input values
fc = 100;   % centre frequency
fb = 100;    % frequency band width
G = 4;      % gain factor
%EQ band 2 input values
fc2 = 5000; % centre frequency
fb2 = 400;  % frequency band width
G2 = 6;     % gain factor
%EQ band 3 input values
fc3 = 300;  %centre frequency
fb3 = 250;  %frequency band width
G3 = -7;    % gain factor

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

x = EQ3tomR; %  Use the normalised tom sample to create the gated signal
holdtime = 0.07; % Time(secs) noise is below threshold before gate activated
ltrhold = 0.6; % threshold for activating gate
utrhold = 0.8; % 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
gatetomR =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 tom

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