nextwebgen.com

The Next Generation Web Now

It’s Friday. Play some drums…. HTML5 style

Filed under: Uncategorized — Dion Almaer at 9:11 am on Friday, July 3, 2009

Brian Arnold created a fun sample drum machine simulator using HTML5 <audio>.

JAVASCRIPT:

  1.  
  2. function playBeat() {
  3.         if (isPlaying) {
  4.                 var nextBeat = 60000 / curTempo / 4;
  5.                 // Turn off all lights on the tracker’s row
  6.                 $(“#tracker li.pip”).removeClass(“active”);
  7.                 // Stop all audio
  8.                 stopAllAudio();
  9.                 // Light up the tracker on the current pip
  10.                 $(“#tracker li.pip.col_” + curBeat).addClass(“active”);
  11.                 // Find each active beat, play it
  12.                 $(“.soundrow[id^=control] li.pip.active.col_” + curBeat).each(function(i){
  13.                         document.getElementById($(this).data(’sound_id’)).play();
  14.                 });
  15.                 // Move the pip forward
  16.                 curBeat = (curBeat + 1) % 16;
  17.                 // Schedule the next one
  18.                 setTimeout(playBeat, nextBeat);
  19.         }
  20. }
  21.  

That’s not all Brian is working on:

I’m also working on something like the ToneMatrix or Tenori-on (Flash and actual devices, respectively) in pure HTML/JS. It works too, but the sounds aren’t exactly designed to be great together (it’s currently working on a C scale) and so if you’re careful, you can get some decent sound but otherwise, it’ll hurt your ears.

Share and Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blogmarks
  • del.icio.us
  • De.lirio.us
  • digg
  • NewsVine
  • YahooMyWeb

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>