Tone.js/examples/noises.html
2014-09-04 15:20:25 -04:00

79 lines
No EOL
1.8 KiB
HTML

<html>
<head>
<title>NOISES</title>
<script type="text/javascript" src="./deps/jquery.min.js"></script>
<script type="text/javascript" src="./deps/jquery-ui.js"></script>
<script type="text/javascript" src="./deps/jquery.ui.touch-punch.js"></script>
<script type="text/javascript" src="../build/Tone.js"></script>
<script type="text/javascript" src="./Widgets.js"></script>
<script type="text/javascript" src="./ExampleList.js"></script>
<link rel="stylesheet" type="text/css" href="./style/widgets.css">
<link rel="stylesheet" type="text/css" href="./style/jquery-ui.css">
</head>
<body>
<div id="Container">
<div id="Explanation">
Noise
<br>
<br>
Tone has 3 different types of noise. Here's a little noise song.
</div>
<div id="Content">
<div id="Button"></div>
<div id='Noise'></div>
</div>
<script type="text/javascript">
/* globals Tone, GUI */
var noise = new Tone.Noise();
noise.toMaster();
var noiseTypes = ["white", "brown", "pink"];
Tone.Transport.setInterval(function(time){
//set a random noise type
var randomIndex = Math.floor(Math.random()* noiseTypes.length);
var randomNoise = noiseTypes[randomIndex];
noise.setType(randomNoise, time);
$("#Noise").text(randomNoise);
}, "8n");
//stop it after 4 measures
Tone.Transport.setTimeout(function(time){
noise.stop(time);
Tone.Transport.stop();
$("#Noise").text("done");
setTimeout(function(){
$("#Noise").text("");
}, 500);
}, "4m");
// GUI //
new GUI.StartButton(Tone.startMobile);
new GUI.TopBar(Tone);
new GUI.Momentary($("#Button"), function(){
Tone.Transport.start();
noise.start();
$("#Button").remove();
}, "start", "");
</script>
<style type="text/css">
#Content {
text-align: center;
width: 100px;
height: 50px;
}
#Content #Button{
width: 100px;
}
</style>
</body>
</html>