Nicolas Schluep Functions Submission
This commit is contained in:
parent
64fa15d5a9
commit
ed9faaa333
BIN
src/Strong_Bassline.mp3
Normal file
BIN
src/Strong_Bassline.mp3
Normal file
Binary file not shown.
55
src/epic_effect_schluep.m
Normal file
55
src/epic_effect_schluep.m
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
function output = epic_effect_schluep(input, Fs, LOW, MED, HIGH)
|
||||||
|
% epic_effect_schluep: Outputs a more "epic" version of the input sound.
|
||||||
|
% This is done by amplifying low frequencies and by implementing a chorus
|
||||||
|
% effect. A chorus effect is created when multiple copies of sound delayed
|
||||||
|
% by a small, random amount are added to the original signal. Works best on
|
||||||
|
% songs with a stronger bassline.
|
||||||
|
% Try this function out with "Strong_Bassline.mp3".
|
||||||
|
|
||||||
|
% CONTRIBUTORS:
|
||||||
|
% Nicolas Schluep: Function Author
|
||||||
|
|
||||||
|
% DOCUMENTATION:
|
||||||
|
% input: The input sound in the time-domain.
|
||||||
|
% Fs: The sampling rate of the input signal. A typical value is 44100 Hz.
|
||||||
|
% HIGH: The maximum frequency the filter will amplify. A typical value for
|
||||||
|
% this variable is 1000 Hz.
|
||||||
|
|
||||||
|
non_stereophonic = input(:, 1); % Removes the sterophonic property of the input sound
|
||||||
|
% by just taking the first column of data.
|
||||||
|
|
||||||
|
Len = length(non_stereophonic);
|
||||||
|
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.
|
||||||
|
inputFreq = fftshift(fft(non_stereophonic)); % Creates the Fourier Transform of the
|
||||||
|
% input signal. fftshift() makes it such that the zero frequency is at the
|
||||||
|
% center of the array.
|
||||||
|
lowAmplifyFilter = zeros(1, length(inputFreq));
|
||||||
|
|
||||||
|
% Creating a filter which amplifies lower frequencies.
|
||||||
|
for i = 1:length(lowAmplifyFilter)
|
||||||
|
if abs(F(i)) < HIGH
|
||||||
|
lowAmplifyFilter(i) = 1.25;
|
||||||
|
else
|
||||||
|
lowAmplifyFilter(i) = 1.00;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
lowPassedInput = inputFreq .* transpose(lowAmplifyFilter); %Apply the "lowAmplifyFilter".
|
||||||
|
|
||||||
|
% Adding the chorus effect.
|
||||||
|
realOutput = real(ifft(fftshift(lowPassedInput)));
|
||||||
|
output = realOutput;
|
||||||
|
|
||||||
|
% Adding 100 randomly delayed signals to the original signal which creates the chorus effect.
|
||||||
|
for i = 1:100
|
||||||
|
currentDelay = 0.003 * rand(); % The current delay of the sound in seconds.
|
||||||
|
currentIndex = round(currentDelay * Fs); % Find the first index where the sound should start playing.
|
||||||
|
delayedOutput = [zeros(currentIndex, 1); realOutput]; % Adds "currentIndex" zeros to the front of the
|
||||||
|
% "realOutput" vector to create a slightly delayed version of the signal.
|
||||||
|
delayedOutput = delayedOutput(1:length(realOutput)); % Truncates the "delayedOutput"
|
||||||
|
% vector so that it can be added to the "realOutput" vector.
|
||||||
|
output = output + delayedOutput;
|
||||||
|
end
|
||||||
|
|
||||||
|
output = output ./ 100; % Divide by 100 to decrease the amplitude of the sound to a normal level.
|
56
src/muffled_effect_schluep.m
Normal file
56
src/muffled_effect_schluep.m
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
function output = muffled_effect_schluep(input, Fs, LOW, MED, HIGH)
|
||||||
|
% muffled_effect_schluep: Outputs a muffled version of the the original input
|
||||||
|
% sound in the time domain. This makes it sound as if the audio is being
|
||||||
|
% played in another room.
|
||||||
|
% Try this function out with "Strong_Bassline.mp3".
|
||||||
|
|
||||||
|
% CONTRIBUTORS:
|
||||||
|
% Nicolas Schluep: Function Author
|
||||||
|
|
||||||
|
% DOCUMENTATION:
|
||||||
|
% input: The input sound in the time-domain.
|
||||||
|
% Fs: The sampling rate of the input signal. A typical value is 44100 Hz.
|
||||||
|
% HIGH: The maximum frequency that the low-pass filter will let pass. A
|
||||||
|
% typical value for this variable is 1000 Hz.
|
||||||
|
|
||||||
|
non_stereophonic = input(:, 1); % Removes the sterophonic property of the input sound
|
||||||
|
% by just taking the first column of data.
|
||||||
|
|
||||||
|
Len = length(non_stereophonic);
|
||||||
|
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.
|
||||||
|
inputFreq = fftshift(fft(non_stereophonic)); % Creates the Fourier Transform of the
|
||||||
|
% input signal. fftshift() makes it such that the zero frequency is at the
|
||||||
|
% center of the array.
|
||||||
|
lowPassFilter = zeros(1, length(inputFreq));
|
||||||
|
|
||||||
|
% Creating Low Pass Filter
|
||||||
|
for i = 1:length(lowPassFilter)
|
||||||
|
if abs(F(i)) < HIGH
|
||||||
|
lowPassFilter(i) = 1;
|
||||||
|
else
|
||||||
|
lowPassFilter(i) = 0;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
lowPassedInput = inputFreq .* transpose(lowPassFilter); %Apply the low-pass filter.
|
||||||
|
|
||||||
|
% Adding a slight reverb effect.
|
||||||
|
realOutput = real(ifft(fftshift(lowPassedInput)));
|
||||||
|
|
||||||
|
delay = 0.001; % The delay of the sound in seconds.
|
||||||
|
index = round(delay*Fs); % Find the first index where sound should start playing
|
||||||
|
% by multiplying the delay by the sampling frequency.
|
||||||
|
delayedOutput = [zeros(index, 1); realOutput]; % Adds "index" zeros to the front of the
|
||||||
|
% "realOutput" vector to create a slightly delayed version of the signal.
|
||||||
|
delayedOutput = delayedOutput(1:length(realOutput)); % Truncates the "delayedOutput"
|
||||||
|
% vector so that it can be added to the "realOutput" vector.
|
||||||
|
|
||||||
|
output = (realOutput + delayedOutput) ./ 2.0; % Adds the "realOutput" and "delayedOutput"
|
||||||
|
% vectors to create a reverb effect. Divides by 2 to avoid clipping
|
||||||
|
% effects.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
62
src/seperate_prevalent_schluep.m
Normal file
62
src/seperate_prevalent_schluep.m
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
function output = seperate_prevalent_schluep(input, Fs, LOW, MED, HIGH)
|
||||||
|
% seperate_prevalent_schluep: Attempts to seperate the most prevalent frequencies
|
||||||
|
% from the input sound by finding the most prevalent frequencies and applying
|
||||||
|
% a band-pass filter to a small region around those frequencies.
|
||||||
|
% Try this function out with "Strong_Bassline.mp3".
|
||||||
|
|
||||||
|
% CONTRIBUTORS:
|
||||||
|
% Nicolas Schluep: Function Author
|
||||||
|
|
||||||
|
% DOCUMENTATION:
|
||||||
|
% input: The input sound in the time-domain.
|
||||||
|
% Fs: The sampling rate of the input signal. A typical value is 44100 Hz.
|
||||||
|
% HIGH: The maximum distance around the maximum frequency value that will
|
||||||
|
% not be attenuated. A good range of values is usually 250-500 Hz, but it
|
||||||
|
% depends on the input sound.
|
||||||
|
|
||||||
|
non_stereophonic = input(:, 1); % Removes the sterophonic property of the input sound
|
||||||
|
% by just taking the first column of data.
|
||||||
|
|
||||||
|
Len = length(non_stereophonic);
|
||||||
|
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.
|
||||||
|
inputFreq = fftshift(fft(non_stereophonic)); % Creates the Fourier Transform of the
|
||||||
|
% input signal. fftshift() makes it such that the zero frequency is at the
|
||||||
|
% center of the array.
|
||||||
|
bandPassFilter = zeros(1, length(inputFreq));
|
||||||
|
|
||||||
|
maxAmplitude = 0;
|
||||||
|
mostPrevalentFrequency = 0;
|
||||||
|
|
||||||
|
% Finding the most prevalent frequency.
|
||||||
|
for i = round(length(inputFreq)/2):length(inputFreq)
|
||||||
|
if inputFreq(i) > maxAmplitude
|
||||||
|
maxAmplitude = inputFreq(i);
|
||||||
|
mostPrevalentFrequency = F(i);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
% Determining maximum and minimum frequency values for the Band Pass filter.
|
||||||
|
maxFrequency = mostPrevalentFrequency + HIGH;
|
||||||
|
minFrequency = mostPrevalentFrequency - HIGH;
|
||||||
|
|
||||||
|
if minFrequency < 0.0
|
||||||
|
minFrequency = 0.0;
|
||||||
|
end
|
||||||
|
|
||||||
|
% Creating the Band-Pass filter.
|
||||||
|
for i = 1:length(bandPassFilter)
|
||||||
|
if (abs(F(i)) < maxFrequency) && (abs(F(i)) > minFrequency)
|
||||||
|
bandPassFilter(i) = 1;
|
||||||
|
else
|
||||||
|
bandPassFilter(i) = 0;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
bandPassedInput = inputFreq .* transpose(bandPassFilter); %Apply the Band-Pass Filter.
|
||||||
|
|
||||||
|
output = real(ifft(fftshift(bandPassedInput)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user