My project is playing a piece of audio using tone js and i want to use player.fadeIn to fade the audio in from the beginning.
my goal is to just have a variable to control the fade duration of the player.
any help on this is greatly appreciated thanks :)
The functionality was successful when hardcoding the value as written below. This would fade the audio in with a duration of 5 seconds.
-
player.fadeIn = 5;
-
When I tried to use a variable to represent the fade duration as written below, I would get the following error.
-
player.fadeIn = fadeDuration
ERROR:
Type 'number | undefined' is not assignable to type 'Time'. Type 'undefined' is not assignable to type 'Time'.
-
and if i tried changing the type of fade duration variable to type 'Time' a similar error is presented.
ERROR:
Type 'Time | undefined' is not assignable to type 'Time'. Type 'undefined' is not assignable to type 'Time'.
Asked
Active
Viewed 47 times
0

Cameron
- 1
-
How do you define `fadeDuration` ? – TGrif Jan 23 '23 at 11:23
-
its defined as a number – Cameron Jan 23 '23 at 11:28
-
And where do you assign your value to `fadeDuration`? – wittgenstein Feb 11 '23 at 10:23