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

125
Vistas
Ring modulation using web audio api - javascript

I would like to ask if someone could help me with ring modulation using javascript

Here is my code. I am not sure if I am doing this right. On start button it only plays a oscillator with gain. No mix with audio file.

I tried do something like this GitHub source

Thanks

function audioFileLoader(fileDirectory, impulseFileDirectory) {
  var audioContext = new AudioContext();
  var soundObj = [];
  soundObj.fileDirectory = fileDirectory;
  soundObj.impulseFileDirectory = impulseFileDirectory;

  // buffer loader code
  var getSound = new XMLHttpRequest();
  getSound.open("GET", soundObj.fileDirectory, true);
  getSound.responseType = "arraybuffer";
  getSound.onload = function() {
      audioContext.decodeAudioData(getSound.response, function(buffer) {
          soundObj.soundToPlay = buffer;
      });

  }

  getSound.send();

  soundObj.play = function() {

    var source = audioContext.createBufferSource();
    source.buffer = soundObj.soundToPlay;

    var oscillator = audioContext.createOscillator();
    oscillator.type = 'sine';
    oscillator.frequency.value = 500;

    var gainNode = audioContext.createGain();
    gainNode.gain.value = 0.5; 
     
    oscillator.connect(gainNode);
    source.connect(gainNode);  
    gainNode.connect(audioContext.destination);

    oscillator.start(audioContext.currentTime);
  };

   return soundObj;
};

var example = audioFileLoader("audio/AcGtr.wav");

document.getElementById('ringmodulation').addEventListener("click", example.play, 
false);
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Your code never plays the buffer source, it's missing source.start(). Also var soundObj = [] should be var soundObj = {}.

about 4 years ago · Juan Pablo Isaza 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