Volume e Pan master
This commit is contained in:
1 parent
e27b7ddee3
commit
1174d71518
4 files changed
+134
-9
No files matched your search
@@ -5,6 +5,7 @@ import { getTotalSteps } from "./utils.js";
|
||||
|
||||
let audioContext;
|
||||
let mainGainNode;
|
||||
let masterPannerNode;
|
||||
|
||||
const timerDisplay = document.getElementById('timer-display');
|
||||
|
||||
@@ -19,13 +20,29 @@ export function initializeAudioContext() {
|
||||
if (!audioContext) {
|
||||
audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
||||
mainGainNode = audioContext.createGain();
|
||||
mainGainNode.connect(audioContext.destination);
|
||||
masterPannerNode = audioContext.createStereoPanner();
|
||||
|
||||
// Roteamento: Gain Master -> Panner Master -> Saída
|
||||
mainGainNode.connect(masterPannerNode);
|
||||
masterPannerNode.connect(audioContext.destination);
|
||||
}
|
||||
if (audioContext.state === "suspended") {
|
||||
audioContext.resume();
|
||||
}
|
||||
}
|
||||
|
||||
export function updateMasterVolume(volume) {
|
||||
if (mainGainNode) {
|
||||
mainGainNode.gain.setValueAtTime(volume, audioContext.currentTime);
|
||||
}
|
||||
}
|
||||
|
||||
export function updateMasterPan(pan) {
|
||||
if (masterPannerNode) {
|
||||
masterPannerNode.pan.setValueAtTime(pan, audioContext.currentTime);
|
||||
}
|
||||
}
|
||||
|
||||
function formatTime(milliseconds) {
|
||||
const totalSeconds = Math.floor(milliseconds / 1000);
|
||||
const minutes = Math.floor(totalSeconds / 60).toString().padStart(2, '0');
|
||||
|
||||
Reference in new issue
Block a user