[snare,fs] = audioread('Siren_snareUp.wav');

user_snare = normalizsig(snare); %normalise the snare sample so that the signal is between 1 and -1

%EQ the snare used for gating
in = user_snare;
%EQ band 1 input values
fc = 200;   % centre frequency
fb = 80;    % frequency band width
G = 4;      % gain factor
%EQ band 2 input values
fc2 = 5000; % centre frequency
fb2 = 100;  % frequency band width
G2 = 3;     % gain factor
%EQ band 3 input values
fc3 = 700;  %centre frequency
fb3 = 500;  %frequency band width
G3 = -5;    % gain factor

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

x = EQ3snare; %  Use the normalised snare sample to create the gated signal
holdtime = 0.06; % Time(secs) noise is below threshold before gate activated
ltrhold = 0.5; % threshold for activating gate
utrhold = 0.6; % threshold for deactivating gate
release = 0.1; % 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
gatesnare =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 snare

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