Fixed fade_out.m and moved it to "Helper" folder

Made it so that it now accepts instances of time where: t < 1 or t is not a whole number.
Also moved it to the 'Helper' folder
This commit is contained in:
SeaSponge 2021-12-10 09:07:09 -08:00 committed by GitHub
parent 23fb666a57
commit 48a6dfa8ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,18 +11,29 @@ function output = fade_out(input, time)
len = length(input); len = length(input);
% need to use time as a whole number
time = round(time);
% if time parameter longer than signal, treat time as % if time parameter longer than signal, treat time as
% the duration of original signal % the duration of original signal
if time > len if time > len
time = len time = len
end end
% in order to create array, time >=1
% if not, it's arbitrarily set to 1
% in which case the fade_in effect
% is virtually nonexistent
if time < 1
time = 1;
end
% set multiplier as 1D array % set multiplier as 1D array
multiplier = (1 : time) / time; multiplier = (1 : time) / time;
% fade out effect: from full volume of signal to no volume % fade out effect: from full volume of signal to no volume
multiplier = flip(multiplier) multiplier = flip(multiplier);
while length(multiplier) < len while length(multiplier) < len
multiplier = [multiplier 0]; multiplier = [multiplier 0];