2

I made a small (like really small) piano in Javascript/HTML, but the sound is delayed. Is there any way to optimize its performance?

Thanks for your help!

var c = new Audio("https://dl.dropbox.com/u/37434025/PianoTones/piano_middle_C.mp3"); function playC() { var c2 = c.cloneNode(); c2.play(); } var d = new Audio("https://dl.dropbox.com/u/37434025/PianoTones/piano_D.mp3"); function playD() { var d2 = d.cloneNode(); d2.play(); } 
3
  • 1
    For runnable code snippets, please use Stack Snippets (the <> toolbar button) so everything is here on-site. Commented Nov 5, 2016 at 11:54
  • 1
    Gothdo is right. If you pre-clone the nodes, the only delay is the delay inside the sound data (which you'll also want to get rid of, it's a good fifth of a second long -- plenty long enough for a human to perceive). Commented Nov 5, 2016 at 12:00
  • Alright I'll try preloading the files. Thanks for your input, everybody. Commented Nov 5, 2016 at 12:01

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.