From 576e49d4289b99f5ad5ccce2feb5c555cc8190bd Mon Sep 17 00:00:00 2001 From: khannuuuuur Date: Mon, 6 Dec 2021 09:01:44 -0800 Subject: [PATCH] added pitch shift envelope (file name amplifyFreqRange.m) --- src/amplifyFreqRange.m | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/amplifyFreqRange.m diff --git a/src/amplifyFreqRange.m b/src/amplifyFreqRange.m new file mode 100644 index 0000000..88adc8d --- /dev/null +++ b/src/amplifyFreqRange.m @@ -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 \ No newline at end of file