Skip to content

Commit

Permalink
Added support for OGG, updated the version of modernizer that the pro…
Browse files Browse the repository at this point in the history
…ject uses, got rid of unused SWF files.

Signed-off-by: David Hilowitz <dhilowitz@gmail.com>
  • Loading branch information
dhilowitz committed Apr 30, 2012
1 parent 7597a22 commit aff457b
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 79 deletions.
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TITO
====

A musical instrument that uses a bouncing ball gravity model to trigger and manipulate audio samples. Uses: HTML5 Canvas for visuals, Flash for Audio.
A musical instrument that uses a bouncing ball gravity model to trigger and manipulate audio samples. Uses: HTML5 Canvas for visuals, HTML5 for Audio.

See it in action here: http://www.chromeexperiments.com/detail/tito/
45 changes: 45 additions & 0 deletions _/js/JSAudioTagSoundGeneration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
function JSAudioTagSoundGeneration(numVoices) {
this.numVoices = numVoices;
this.voices = new Array(this.numVoices);
this.lastVoice = -1;
this.format = Modernizr.audio.ogg ? 'ogg' :
Modernizr.audio.mp3 ? 'mp3' :
Modernizr.audio.wav ? 'wav' :
'm4a';
}

JSAudioTagSoundGeneration.prototype.init = function init()
{
for(var voiceIndex = 0; voiceIndex < this.numVoices; voiceIndex++)
{
this.voices[voiceIndex] = new Audio();
//this.voices[voiceIndex].autoplay = true;
}
}

JSAudioTagSoundGeneration.prototype.playNote = function playNote(noteNumber)
{
if( (this.lastVoice + 1) >= this.numVoices)
this.lastVoice = 0;
else
this.lastVoice++;

var noteURL = this.getNoteURL(noteNumber);
//d("playNote: " + noteNumber + " on voice " + this.lastVoice + ((noteURL != null) ? " (URL: " + this.getNoteURL(noteNumber) + ")" : ""));

if(noteURL != null)
{
this.voices[this.lastVoice].src = "_/snd/" + noteURL;
this.voices[this.lastVoice].play();
}
}

JSAudioTagSoundGeneration.prototype.getNoteURL = function getNoteURL(noteNumber)
{
if(noteNumber >= 48 && noteNumber <= 112)
{
return "autoharp/" + this.format + "/" + zeroPad(noteNumber, 3) + "." + this.format;
}
return null;
}

28 changes: 0 additions & 28 deletions _/js/modernizr-1.5.min.js

This file was deleted.

Loading

0 comments on commit aff457b

Please sign in to comment.