vendredi 26 décembre 2014

Timbre.js keyboard input doesn't seem to work


I'm trying to learn the timbre.js javascript library. On the project page there is a functional preview of using the keyboard input to change oscillator pitch but once the code is copied to a new HTML document on my computer it no longer works. Simpler code snippets from the project page work fine once copied over though.


The project page is here: http://mohayonao.github.io/timbre.js/PragmaSynth.html


This is the code:



<script src="timbre.js"></script>
<script>

var VCO = T("saw", {freq:880, mul:0.2}).play();

var keydict = T("ndict.key");
var midicps = T("midicps");
T("keyboard").on("keydown", function(e) {
var midi = keydict.at(e.keyCode);
if (midi) {
VCO.freq.value = midicps.at(midi);
}
}).start();

</script>




Aucun commentaire:

Enregistrer un commentaire