Tone.js/examples/noises.html

82 lines
1.9 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
2014-06-20 04:25:00 +00:00
<html>
<head>
<meta charset="utf-8">
2014-06-20 04:25:00 +00:00
<title>NOISES</title>
2014-09-06 19:35:31 +00:00
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<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>
2014-09-04 04:06:01 +00:00
<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">
2014-06-20 04:25:00 +00:00
</head>
<body>
2014-09-04 04:06:01 +00:00
<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>
2014-06-20 04:25:00 +00:00
<script type="text/javascript">
2014-09-04 04:06:01 +00:00
/* globals Tone, GUI */
var noise = new Tone.Noise();
2014-09-06 19:35:31 +00:00
noise.setVolume(-20);
noise.toMaster();
2014-06-20 04:25:00 +00:00
var noiseTypes = ["white", "brown", "pink"];
2014-06-20 04:25:00 +00:00
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);
2014-09-04 04:06:01 +00:00
$("#Noise").text(randomNoise);
}, "8n");
2014-06-20 04:25:00 +00:00
2014-09-04 04:06:01 +00:00
//stop it after 4 measures
Tone.Transport.setTimeout(function(time){
noise.stop(time);
Tone.Transport.stop();
2014-09-04 04:06:01 +00:00
$("#Noise").text("done");
setTimeout(function(){
$("#Noise").text("");
}, 500);
}, "4m");
2014-06-20 04:25:00 +00:00
2014-09-04 04:06:01 +00:00
// GUI //
new GUI.TopBar(Tone);
new GUI.Momentary($("#Button"), function(){
Tone.Transport.start();
noise.start();
2014-09-04 04:06:01 +00:00
$("#Button").remove();
}, "start", "");
2014-06-20 04:25:00 +00:00
</script>
2014-09-04 04:06:01 +00:00
<style type="text/css">
#Content {
text-align: center;
2014-09-06 19:35:31 +00:00
width: 120px;
2014-09-04 04:06:01 +00:00
}
2014-09-06 19:35:31 +00:00
#Content .Momentary{
width: 100%;
2014-09-04 04:06:01 +00:00
}
</style>
2014-06-20 04:25:00 +00:00
</body>
</html>