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

81
Views
Problemas para controlar el volumen de la Web Audio API

Encontré una secuencia de comandos en este foro en este enlace para reproducir un clip de audio usando Web Audio API, y funciona bien, sin embargo, tengo problemas para averiguar cómo controlar el volumen. Aparentemente, la clave es usar "createGain", pero he tenido dificultades para que funcione. (También probé la sugerencia "Loopify" en esa página, pero Loopify no te permite controlar el volumen).

Vea en el guión donde el comentario dice "COMIENZA A TRATAR DE AJUSTAR EL VOLUMEN". Creo que estoy cerca de eso, pero simplemente no funciona. La muestra está tratando de reducir el volumen a la mitad.

 // initialize the audio var actx = new (AudioContext || webkitAudioContext)(), src="lo-fi-dub-beat_70bpm.wav", audioData, srcNode; // load the audio fetch(src, {mode: "cors"}).then(function(resp) {return resp.arrayBuffer()}).then(decode); // START TRYING TO SET THE VOLUME var loopAudioGainNode = actx.createGain(); loopAudioGainNode.connect(actx.destination); // <- Perhaps this is needed? loopAudioGainNode.gain.value = .5; // END TRYING TO SET THE VOLUME // decode the audio and start it playing function decode (buffer) { actx.decodeAudioData(buffer, playLoop); } // set a new source node as needed after the audio was stopped function playLoop (abuffer) { if (!audioData) audioData = abuffer; // create a reference for control buttons srcNode = actx.createBufferSource(); // create audio source srcNode.buffer = abuffer; // use decoded buffer srcNode.connect(actx.destination); // create output srcNode.loop = true; // takes care of perfect looping srcNode.start(); // play... }

Gracias por tu ayuda.

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