Fixed Functions Nicolas Schluep

This commit is contained in:
Nicolas Schluep 2021-12-10 22:10:26 -08:00
parent 5f1570472a
commit 6dc3ce4d59
4 changed files with 54 additions and 18 deletions

View File

@ -15,13 +15,22 @@ function output = epic_effect_schluep(input, Fs, LOW, MED, HIGH)
% HIGH: The maximum frequency the filter will amplify. A typical value for % HIGH: The maximum frequency the filter will amplify. A typical value for
% this variable is 1000 Hz. % this variable is 1000 Hz.
non_stereophonic = input(:, 1); % Removes the sterophonic property of the input sound n = size(input, 2);
% by just taking the first column of data.
Len = length(non_stereophonic); non_stereophonic = input;
if (n == 1) || (n == 2)
non_stereophonic = input(:, 1); % Removes the sterophonic property of the input sound
% by just taking the first column of data.
non_stereophonic = transpose(non_stereophonic);
end
modified_input = non_stereophonic(1, :);
Len = length(modified_input);
F = Fs * ((-Len/2) : ((Len/2) - 1)) / Len; % Creating the array of frequencies F = Fs * ((-Len/2) : ((Len/2) - 1)) / Len; % Creating the array of frequencies
% which the FFT Shifted version of the signal can be plotted against. % which the FFT Shifted version of the signal can be plotted against.
inputFreq = fftshift(fft(non_stereophonic)); % Creates the Fourier Transform of the inputFreq = fftshift(fft(modified_input)); % Creates the Fourier Transform of the
% input signal. fftshift() makes it such that the zero frequency is at the % input signal. fftshift() makes it such that the zero frequency is at the
% center of the array. % center of the array.
lowAmplifyFilter = zeros(1, length(inputFreq)); lowAmplifyFilter = zeros(1, length(inputFreq));
@ -35,7 +44,8 @@ for i = 1:length(lowAmplifyFilter)
end end
end end
lowPassedInput = inputFreq .* transpose(lowAmplifyFilter); %Apply the "lowAmplifyFilter". lowPassedInput = inputFreq .* lowAmplifyFilter; %Apply the "lowAmplifyFilter".
lowPassedInput = transpose(lowPassedInput);
% Adding the chorus effect. % Adding the chorus effect.
realOutput = real(ifft(fftshift(lowPassedInput))); realOutput = real(ifft(fftshift(lowPassedInput)));
@ -53,3 +63,7 @@ for i = 1:100
end end
output = output ./ 100; % Divide by 100 to decrease the amplitude of the sound to a normal level. output = output ./ 100; % Divide by 100 to decrease the amplitude of the sound to a normal level.
output = transpose(output);
end

View File

@ -13,13 +13,22 @@ function output = muffled_effect_schluep(input, Fs, LOW, MED, HIGH)
% HIGH: The maximum frequency that the low-pass filter will let pass. A % HIGH: The maximum frequency that the low-pass filter will let pass. A
% typical value for this variable is 1000 Hz. % typical value for this variable is 1000 Hz.
non_stereophonic = input(:, 1); % Removes the sterophonic property of the input sound n = size(input, 2);
% by just taking the first column of data.
Len = length(non_stereophonic); non_stereophonic = input;
if (n == 1) || (n == 2)
non_stereophonic = input(:, 1); % Removes the sterophonic property of the input sound
% by just taking the first column of data.
non_stereophonic = transpose(non_stereophonic);
end
modified_input = non_stereophonic(1, :);
Len = length(modified_input);
F = Fs * ((-Len/2) : ((Len/2) - 1)) / Len; % Creating the array of frequencies F = Fs * ((-Len/2) : ((Len/2) - 1)) / Len; % Creating the array of frequencies
% which the FFT Shifted version of the signal can be plotted against. % which the FFT Shifted version of the signal can be plotted against.
inputFreq = fftshift(fft(non_stereophonic)); % Creates the Fourier Transform of the inputFreq = fftshift(fft(modified_input)); % Creates the Fourier Transform of the
% input signal. fftshift() makes it such that the zero frequency is at the % input signal. fftshift() makes it such that the zero frequency is at the
% center of the array. % center of the array.
lowPassFilter = zeros(1, length(inputFreq)); lowPassFilter = zeros(1, length(inputFreq));
@ -33,7 +42,8 @@ for i = 1:length(lowPassFilter)
end end
end end
lowPassedInput = inputFreq .* transpose(lowPassFilter); %Apply the low-pass filter. lowPassedInput = inputFreq .* lowPassFilter; %Apply the low-pass filter.
lowPassedInput = transpose(lowPassedInput);
% Adding a slight reverb effect. % Adding a slight reverb effect.
realOutput = real(ifft(fftshift(lowPassedInput))); realOutput = real(ifft(fftshift(lowPassedInput)));
@ -50,6 +60,10 @@ output = (realOutput + delayedOutput) ./ 2.0; % Adds the "realOutput" and "de
% vectors to create a reverb effect. Divides by 2 to avoid clipping % vectors to create a reverb effect. Divides by 2 to avoid clipping
% effects. % effects.
output = transpose(output);
end

View File

@ -14,13 +14,22 @@ function output = seperate_prevalent_schluep(input, Fs, LOW, MED, HIGH)
% not be attenuated. A good range of values is usually 250-500 Hz, but it % not be attenuated. A good range of values is usually 250-500 Hz, but it
% depends on the input sound. % depends on the input sound.
non_stereophonic = input(:, 1); % Removes the sterophonic property of the input sound n = size(input, 2);
% by just taking the first column of data.
Len = length(non_stereophonic); non_stereophonic = input;
if (n == 1) || (n == 2)
non_stereophonic = input(:, 1); % Removes the sterophonic property of the input sound
% by just taking the first column of data.
non_stereophonic = transpose(non_stereophonic);
end
modified_input = non_stereophonic(1, :);
Len = length(modified_input);
F = Fs * ((-Len/2) : ((Len/2) - 1)) / Len; % Creating the array of frequencies F = Fs * ((-Len/2) : ((Len/2) - 1)) / Len; % Creating the array of frequencies
% which the FFT Shifted version of the signal can be plotted against. % which the FFT Shifted version of the signal can be plotted against.
inputFreq = fftshift(fft(non_stereophonic)); % Creates the Fourier Transform of the inputFreq = fftshift(fft(modified_input)); % Creates the Fourier Transform of the
% input signal. fftshift() makes it such that the zero frequency is at the % input signal. fftshift() makes it such that the zero frequency is at the
% center of the array. % center of the array.
bandPassFilter = zeros(1, length(inputFreq)); bandPassFilter = zeros(1, length(inputFreq));
@ -53,10 +62,12 @@ for i = 1:length(bandPassFilter)
end end
end end
bandPassedInput = inputFreq .* transpose(bandPassFilter); %Apply the Band-Pass Filter. bandPassedInput = inputFreq .* bandPassFilter; %Apply the Band-Pass Filter.
output = real(ifft(fftshift(bandPassedInput))); output = real(ifft(fftshift(bandPassedInput)));
end

View File

@ -11,17 +11,14 @@ function output = FilterSelect(input,Fs,LOW,MED,HIGH,number)
output = DarellbandpassFilter(input,Fs,LOW,MED,HIGH); output = DarellbandpassFilter(input,Fs,LOW,MED,HIGH);
elseif(number == "AmplifyRange") elseif(number == "AmplifyRange")
output = amplifyFreqRange(input, Fs, LOW, MED, HIGH); output = amplifyFreqRange(input, Fs, LOW, MED, HIGH);
%{
elseif(number == "EpicEffect") elseif(number == "EpicEffect")
output = epic_effect_schluep(input, Fs, LOW, MED, HIGH); output = epic_effect_schluep(input, Fs, LOW, MED, HIGH);
elseif(number == "MuffledEffect") elseif(number == "MuffledEffect")
output = muffled_effect_schluep(input, Fs, LOW, MED, HIGH); output = muffled_effect_schluep(input, Fs, LOW, MED, HIGH);
elseif(number == "SeparatePrevalent") elseif(number == "SeparatePrevalent")
output = seperate_prevalent_schluep(input, Fs, LOW, MED, HIGH); output = seperate_prevalent_schluep(input, Fs, LOW, MED, HIGH);
%}
elseif(number == "IdealBandReject") elseif(number == "IdealBandReject")
output = bandreject_filter(input, Fs, LOW, HIGH); output = bandreject_filter(input, Fs, LOW, HIGH);
elseif(number == "EnchanceTarget") elseif(number == "EnchanceTarget")
output = AnuragEnhanceTarget(input, Fs, LOW, MED, HIGH); output = AnuragEnhanceTarget(input, Fs, LOW, MED, HIGH);
elseif(number == "DampenTarget") elseif(number == "DampenTarget")