-
-
Save potomak/721554 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
// Notes from http://news.ycombinator.com/item?id=1952531 | |
var notes = { | |
"suspended cymbal":"zk", | |
"snare":"bschk", | |
"brush":"pv", | |
"bass":"bk", | |
"flam1":"tk", | |
"roll tap":"vk", | |
"flam2":"kt", | |
"flam tap":"kttp", | |
"hi hat tap":"krp", | |
"short roll":"pv", | |
"better hi hat":"th", | |
"instant rimshot":"thp, ds" | |
}; | |
function writeNote(event) { | |
song.value += event.target.note + " "; | |
} | |
function clear() { | |
song.value = ""; | |
} | |
function play() { | |
var audio = new Audio("http://translate.google.com/translate_tts?q=" + encodeURI(song.value) + "&tl=de"); | |
audio.play(); | |
} | |
function appendButton(attributes, container) { | |
var button = document.createElement("input"); | |
button.type = "button"; | |
for (var name in attributes) { | |
button[name] = attributes[name]; | |
} | |
container.appendChild(button); | |
} | |
var container = document.createElement("div"); | |
var controls = document.createElement("div"); | |
var song = document.createElement("input"); | |
song.type = "text"; | |
song.size = 150; | |
container.appendChild(song); | |
container.appendChild(controls); | |
document.body.appendChild(container); | |
for (var name in notes) { | |
if (notes.hasOwnProperty(name)) { | |
appendButton({ | |
value: name, | |
note: notes[name], | |
onclick: writeNote | |
}, controls); | |
} | |
} | |
appendButton({ | |
value: "play", | |
onclick: play | |
}, controls); | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bookmarklet: | |
javascript:(function(){document.body.appendChild(document.createElement("script")).src="http://bit.ly/googlebeat"})() | |
Instructions: | |
1. Load Google Translate: http://translate.google.com | |
2. Load the bookmarklet in the above comment in the URL bar. | |
3. Click the new buttons at the bottom of the page. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment