diff --git a/DarellsAnnex/DarellbandpassFilter.m b/DarellsAnnex/DarellbandpassFilter.m new file mode 100644 index 0000000..918358a --- /dev/null +++ b/DarellsAnnex/DarellbandpassFilter.m @@ -0,0 +1,20 @@ +function output_y = DarellbandpassFilter(y,Fs,LOW,MED,HIGH) + Len = length(y); + F = Fs * (-Len/2 : (Len/2 - 1))/Len ; + Mod_Freq = fftshift(fft(y)); + lenf = length(F); + output = 0 .* Mod_Freq; % zero array of len f + + for n = 1:lenf + if ((LOW < abs(F(n))) && HIGH > abs(F(n))) + output(n) = 1; + else + output(n) = 0; + end + end + + filtered_Mod_Freq = fftshift(Mod_Freq .* output); + + output_y = real(ifft(filtered_Mod_Freq)); + +end \ No newline at end of file diff --git a/src/Main_test.m b/src/Main_test.m index 259df39..895ca53 100644 --- a/src/Main_test.m +++ b/src/Main_test.m @@ -33,3 +33,4 @@ x = DarellPitchEnvelope(x, fs, attack,decay,sustain,release); %output new sound %play over 5 counts, should only hear 200hz playtime = 5; play_continuous(x, fs, playtime) +