Tone.js/examples/transport.html

70 lines
1.5 KiB
HTML
Raw Normal View History

2014-03-19 21:25:33 +00:00
<html>
<head>
2014-04-06 00:47:59 +00:00
<title>TRANSPORT</title>
2014-03-19 21:25:33 +00:00
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
2014-04-06 00:47:59 +00:00
<script type="text/javascript" src="../deps/require.js"></script>
2014-03-19 21:25:33 +00:00
</head>
<body>
2014-04-06 00:47:59 +00:00
<button>start</button>
<div id="output"></div>
2014-03-19 21:25:33 +00:00
<script type="text/javascript">
2014-04-06 00:47:59 +00:00
require.config({
2014-04-06 20:51:30 +00:00
baseUrl : "../"
2014-04-06 00:47:59 +00:00
});
2014-03-19 21:25:33 +00:00
2014-04-06 20:51:30 +00:00
require(["Tone/core/Tone", "Tone/core/Master", "Tone/core/Transport", "Tone/source/Player"], function(Tone){
2014-04-06 00:47:59 +00:00
2014-03-20 03:59:38 +00:00
Tone.Transport.loop = true;
Tone.Transport.setLoopStart("0:0");
Tone.Transport.setLoopEnd("1:0");
Tone.Transport.setBpm(145);
2014-03-20 03:59:38 +00:00
2014-04-06 00:47:59 +00:00
var player = new Tone.Player("../audio/505/hh.mp3");
player.toMaster();
player.load();
2014-03-19 21:25:33 +00:00
Tone.Transport.setTimeout(function(time){
2014-04-06 00:47:59 +00:00
player.start(time);
$("#output").html("a");
}, "0:0");
2014-03-19 21:25:33 +00:00
Tone.Transport.setTimeout(function(time){
2014-04-06 00:47:59 +00:00
player.start(time);
$("#output").html("series");
}, "0:1");
2014-03-19 21:25:33 +00:00
Tone.Transport.setTimeout(function(time){
2014-04-06 00:47:59 +00:00
player.start(time);
$("#output").html("of");
}, "2n");
2014-04-06 00:47:59 +00:00
Tone.Transport.setTimeout(function(time){
2014-04-06 00:47:59 +00:00
player.start(time);
$("#output").html("timed");
}, "0:3");
2014-04-06 00:47:59 +00:00
Tone.Transport.setTimeout(function(time){
2014-04-06 00:47:59 +00:00
player.start(time);
$("#output").html("events");
}, "0:3:2");
$("button").click(function(){
if (Tone.Transport.state === "playing"){
Tone.Transport.stop(0);
$("button").html("start");
} else {
Tone.Transport.start(0);
$("button").html("stop");
}
2014-04-06 00:47:59 +00:00
})
window.Tone = Tone;
2014-04-06 00:47:59 +00:00
});
2014-03-19 21:25:33 +00:00
</script>
</body>
</html>