zplata / tuner-app

Using web audio APIs and Rive to build a tuner web app
4 stars 2 forks source link

animation stuck in idle state (tuningValueInput not being updated) #1

Open naychrist opened 1 year ago

naychrist commented 1 year ago

hey zach thanks for the great stream! Iooks like you didn't commit the latest as tuningValueInput not being updated so animation stuck in idle despite the notes being analysed accurately. I tried adding this code in from the video but doesn't appear to be enough:

      tuningValueInput.value = lerp(
          tuningValueInput.value,
          50 + hzOffPitch,
          0.1
      );

would love to get this running here - any help appreciated!

zplata commented 1 year ago

Hey! Thanks for pointing that out @naychrist. I'm committing now the change. What you have is correct; it should be added after calculating hzOffPitch so curious why it might not be working for you. Any console errors?

naychrist commented 1 year ago

thanks @zplata just pulled latest but same issue. I still get this console warning which I assumed was harmless as the notes are being detected and printed under the rive animation so some audio context must be set up. but maybe not and the page needs to have a click before setting things up? I had assumed that was only needed for audio playback but maybe input too app.js:5 The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu

naychrist commented 1 year ago

hey @zplata just to add to last if I add a link and then move the initialisation of the audio context to after clicking on the link it works, something like:

window.onload = function() {
  var a = document.getElementById("mylink");
  a.onclick = function() {
    audioCtx = new window.AudioContext(); //already declared up top as null
    analyserNode = audioCtx.createAnalyser(); //already declared up top as null
    start();
  }
}