mirror of
https://github.com/jeffvli/feishin.git
synced 2024-11-20 06:27:09 +01:00
Handle negative values on gain calculation (#834)
This commit is contained in:
parent
8ec4551b46
commit
b65c972da1
@ -341,7 +341,7 @@ export const AudioPlayer = forwardRef(
|
|||||||
// Set the current replaygain
|
// Set the current replaygain
|
||||||
if (current) {
|
if (current) {
|
||||||
const newVolume = calculateReplayGain(current) * volume;
|
const newVolume = calculateReplayGain(current) * volume;
|
||||||
webAudio.gain.gain.setValueAtTime(newVolume, 0);
|
webAudio.gain.gain.setValueAtTime(Math.max(0, newVolume), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the next track replaygain right before the end of this track
|
// Set the next track replaygain right before the end of this track
|
||||||
@ -349,7 +349,10 @@ export const AudioPlayer = forwardRef(
|
|||||||
const next = sources[3 - currentPlayer];
|
const next = sources[3 - currentPlayer];
|
||||||
if (next && current) {
|
if (next && current) {
|
||||||
const newVolume = calculateReplayGain(next) * volume;
|
const newVolume = calculateReplayGain(next) * volume;
|
||||||
webAudio.gain.gain.setValueAtTime(newVolume, (current.duration - 1) / 1000);
|
webAudio.gain.gain.setValueAtTime(
|
||||||
|
Math.max(0, newVolume),
|
||||||
|
Math.max(0, (current.duration - 1) / 1000),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
calculateReplayGain,
|
calculateReplayGain,
|
||||||
|
Loading…
Reference in New Issue
Block a user