Merge pull request #19 from ltcptgeneral/pitchshiftenvelope

added pitch shift envelope (file name amplifyFreqRange.m)
This commit is contained in:
khannuuuuur 2021-12-06 09:04:34 -08:00 committed by GitHub
commit 415c353844
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

23
src/amplifyFreqRange.m Normal file
View File

@ -0,0 +1,23 @@
function output = amplifyFreqRange(input, fs, low, high, multiplier)
%Amplifies frequencies within a specified range, leaves all other
%frequencies the same.
%By Conner Hsu
%input: 1D array representing the sound signal in the time domain
%fs: sampling frequency
%low: a scalar representing the lower bound of frequencies to be amplified
%high: a scalar representing the upper bound of frequencies to be amplified
%multiplier: a scalar that multiplies frequencies between low and high
%Returns modified signal in the time domain.
len = length(input);
f = fs*(-len/2:len/2-1)/len;
outputW = fftshift(fft(input));
for i = 1:length(outputW)
if (low < abs(f(i)) && abs(f(i)) < high)
outputW(i) = outputW(i)*multiplier;
end
end
output = real(ifft(fftshift(outputW)));
end