2014-04-02 20:09:02 +00:00
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Bit Crush</title>
|
|
|
|
|
2014-04-16 00:05:11 +00:00
|
|
|
<script type="text/javascript" src='../build/Tone.js'></script>
|
|
|
|
|
2014-04-02 20:09:02 +00:00
|
|
|
</head>
|
|
|
|
<body>
|
2014-04-16 04:23:58 +00:00
|
|
|
<button>start</button>
|
2014-04-02 20:09:02 +00:00
|
|
|
<script type="text/javascript">
|
2014-04-16 00:05:11 +00:00
|
|
|
|
|
|
|
//components
|
|
|
|
var sine = new Tone.Oscillator();
|
|
|
|
var crusher = new Tone.BitCrusher(5);
|
|
|
|
|
|
|
|
//connections
|
|
|
|
sine.connect(crusher);
|
|
|
|
crusher.toMaster();
|
2014-04-02 20:09:02 +00:00
|
|
|
|
2014-04-16 00:05:11 +00:00
|
|
|
//INTERFACE//
|
2014-04-02 20:09:02 +00:00
|
|
|
|
2014-04-16 00:05:11 +00:00
|
|
|
var button = document.querySelector("button");
|
2014-04-02 20:09:02 +00:00
|
|
|
|
2014-04-16 00:05:11 +00:00
|
|
|
//called when the start button is clicked
|
2014-04-16 04:23:58 +00:00
|
|
|
button.onclick = function(){
|
2014-04-16 00:05:11 +00:00
|
|
|
if (!sine.started){
|
|
|
|
sine.start();
|
|
|
|
button.textContent = "stop";
|
|
|
|
} else {
|
|
|
|
sine.stop();
|
|
|
|
button.textContent = "start";
|
|
|
|
}
|
|
|
|
}
|
2014-04-06 00:47:59 +00:00
|
|
|
|
2014-04-02 20:09:02 +00:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|