question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Delay when triggering note onclick

See original GitHub issue

I’m building a React synth using Tone.js, I am experiencing a delay when running an onClick event. I explored the issues and found this: https://github.com/Tonejs/Tone.js/issues/306. Neither of the fixes mentioned here work for me

here is my function:

function playNote (noteToTrigger) {
    Tone.context.lookAhead = 0
    synth.current.triggerAttack(noteToTrigger, Tone.context.currentTime, 100)
  }
const WhiteKey = ({ playNote, note }) => {
  return (
    <div
      onClick={() => playNote(note)}
    >
      White key {note}
    </div>
  )
}

am I implementing this correctly?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tambiencommented, May 11, 2020

That’s alright! This exact problem is actually pretty common. Now it’s documented for other people who might come across the same thing

1reaction
ArKaneVisioncommented, May 11, 2020

I feel really silly but I forgot about the Bluetooth latency, it works now! thanks for taking the time to help out

Read more comments on GitHub >

github_iconTop Results From Across the Web

Shorten the delay from the onclick event on touchscreen devices
1 Answer 1 ... You could disable zoom for instant onClick. ... The delay occurs because the phone is waiting for the second...
Read more >
How to delay a JavaScript function call using JavaScript?
To provide delay in JavaScript function we use a global window object named as setTimeout(). This function allows us to provide a specific...
Read more >
Is there a delay for firing the "click" event for DevExtreme ...
I noticed that my buttons and even simple html elements that have click/onclick events attached to it takes a time to perform (about...
Read more >
[SOLVED] Trigger button delay | Velo by Wix
Hi! I want to delay the time between clicking on the button and triggering its action (in this case, redirecting to a subpage)....
Read more >
setTimeout() - Web APIs - MDN Web Docs
Note that in either case, the actual delay may be longer than ... Firefox will defer firing setTimeout() timers while the current tab...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found