Tone.js/examples/bitCrush.html

37 lines
No EOL
776 B
HTML

<html>
<head>
<title>Bit Crush</title>
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<script type="text/javascript" src="../Tone.js"></script>
<link rel="stylesheet" type="text/css" href="exampleStyle.css">
</head>
<body>
<div>Lower the resolution of the incoming sine wave to 4 bits</div>
<br>
<button>start</button>
<script type="text/javascript">
//components
var sine = new Tone.Oscillator();
var crusher = new Tone.BitCrusher(4);
sine.connect(crusher);
crusher.toMaster();
//called when the start button is clicked
$("button").click(function(){
if (sine.state !== "started"){
sine.start();
$(this).text("stop");
} else {
sine.stop();
$(this).text("start");
}
});
</script>
</body>
</html>