File tree 1 file changed +4
-4
lines changed
1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -150,13 +150,13 @@ export class AudioController {
150
150
}
151
151
152
152
private fadeFromTo ( from : number , to : number , duration : number ) {
153
- console . info ( `AudioController: start fade (${ from } , ${ to } , ${ duration } )` )
154
- const startTime = Date . now ( )
155
-
156
153
const replayGainFactor = this . replayGainFactor ( )
157
154
from *= replayGainFactor
158
155
to *= replayGainFactor
159
156
157
+ console . info ( `AudioController: start fade (${ from } , ${ to } , ${ duration } )` )
158
+ const startTime = Date . now ( )
159
+
160
160
const step = ( to - from ) / duration
161
161
if ( duration <= 0.0 ) {
162
162
this . audio . volume = to
@@ -173,7 +173,7 @@ export class AudioController {
173
173
return
174
174
}
175
175
const elapsed = Date . now ( ) - startTime
176
- this . audio . volume = clamp ( 0.0 , this . volume , from + ( elapsed * step ) )
176
+ this . audio . volume = clamp ( 0.0 , Math . max ( from , to ) , from + ( elapsed * step ) )
177
177
this . handle = setTimeout ( run , 10 )
178
178
}
179
179
run ( )
You can’t perform that action at this time.
0 commit comments