Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

222
Vistas
(Javascript) Microphone and audio from mediastream are out of sync

I wrote a recorder that records microphone from getUsermedia and audio which is from local using Howler JS. I created mediastream destination, and connected each sources (mic, audio) to the destination. audio seems fine, but microphone is delayed about 2seconds. I can't figure out the problem. could you help me guys?

var recorder;
const stop = document.getElementsByClassName("stop");
const record = document.getElementsByClassName("record");

let mediaDest = Howler.ctx.createMediaStreamDestination();
Howler.masterGain.connect(mediaDest);
function onRecordingReady(e) {
  // 'e' has 'blob event'
  //var audio = document.getElementById("audio");
  audioBlob = e.data; // e.data has blob.
  //audio.src = URL.createObjectURL(e.data);
}

let audioBlob;
let audioURL = "";

navigator.mediaDevices.getUserMedia({ audio: true }).then(function (stream) {
  let userMic = Howler.ctx.createMediaStreamSource(stream);
  userMic.connect(mediaDest);
  Howler.masterGain.connect(mediaDest);
  recorder = new MediaRecorder(mediaDest.stream);
  recorder.addEventListener("dataavailable", onRecordingReady);
  recorder.addEventListener("stop", function () {
    W3Module.convertWebmToMP3(audioBlob).then((mp3blob) => {
      const downloadLink = document.createElement("a");
      downloadLink.href = URL.createObjectURL(mp3blob);
      downloadLink.setAttribute("download", "audio");
      //downloadLink.click();
      var audio = document.getElementById("audio");
      audio.src = URL.createObjectURL(mp3blob);
      console.log(mp3blob);
    });
  });
});

record[0].addEventListener("click", function () {
  recorder.start();
});

stop[0].addEventListener("click", function () {
  recorder.stop();
});
about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I figured out the solution. I didn't know I could connect MediaStreamAudioSourceNode to GainNode. If someone is suffering this issue, just connect one Node to another Node rather than connect each node to the destination.

I connected the sourceNode to the GainNode, and connected GainNode to the destination.

========================= It was not the solution... GainNode playback in realtime whenever input is present...so, even if i can remove the latency, annoying playback occurs.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda