Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

295
Visualizações
Using Tone.js to add filters to an existing audio stream

I was able to add filters to an existing audio stream using the biquadfilter but was interested in trying to use Tone.js instead. But I'm having issues connecting everything together. I keep getting a DomException when trying to connect the filter to an audioContext.

function addFilter(fq) {

    var audioCtx = new (window.AudioContext || window.webkitAudioContext);
    var mediaElem = document.getElementById('myAudioElement');

    //Tone.context = audioCtx;
    Tone.context.createMediaElementSource(mediaElem)

    const bqfilter = new Tone.Filter(fq, 'lowpass').toDestination();

    Tone.connect(bqfilter, audioCtx.destination);
    //bqfilter.chain(audioCtx.destination)
});

The error message is just DomException when I try to connect or chain the filter to the audioCtx.destination. This seems to follow most of the other examples I've found online so I'm not sure why this is throwing an exception.

*edit: included the stacktrace from the dev console

Uncaught DOMException                 Tone.js:formatted:2181 
connect     @ Tone.js:formatted:2181
To          @ Tone.js:formatted:8710
(anonymous) @ audiocontrols:983
dispatch    @ jquery.min.js:2
v.handle    @ jquery.min.js:2
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You don't need to create your own AudioContext. You can just use the one from Tone.js. In fact that is even required. Otherwise your own AudioNode can't be connected to the one created by Tone.js.

The following should work:

function addFilter(fq) {
  const audioElement = document.getElementById('myAudioElement');
  const mediaElementSource = Tone.context.createMediaElementSource(audioElement);
  const filter = new Tone.Filter(fq, 'lowpass').toDestination();

  Tone.connect(mediaElementSource, filter);
});

Please not that the AudioContext might be blocked by the browser's autoplay policy as described here: https://github.com/Tonejs/Tone.js#starting-audio.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda