From 48a6dfa8ad4ccf0be3e73ecf8ed2f8a02e3b2844 Mon Sep 17 00:00:00 2001 From: SeaSponge <61109988+Squidwarder@users.noreply.github.com> Date: Fri, 10 Dec 2021 09:07:09 -0800 Subject: [PATCH] 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 --- src/{NotWorking => Helper}/fade_out.m | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) rename src/{NotWorking => Helper}/fade_out.m (77%) diff --git a/src/NotWorking/fade_out.m b/src/Helper/fade_out.m similarity index 77% rename from src/NotWorking/fade_out.m rename to src/Helper/fade_out.m index f0821d3..954a1bb 100644 --- a/src/NotWorking/fade_out.m +++ b/src/Helper/fade_out.m @@ -11,18 +11,29 @@ function output = fade_out(input, time) len = length(input); + % need to use time as a whole number + time = round(time); + % if time parameter longer than signal, treat time as % the duration of original signal if time > len time = len 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 multiplier = (1 : time) / time; % fade out effect: from full volume of signal to no volume - multiplier = flip(multiplier) + multiplier = flip(multiplier); while length(multiplier) < len multiplier = [multiplier 0];