Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

128
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!