Tone.js/examples/player.html
2015-02-13 10:52:16 -05:00

67 lines
No EOL
1.8 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>PLAYER</title>
<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="../build/Tone.js"></script>
<script type="text/javascript" src="./deps/nexusUI.js"></script>
<script type="text/javascript" src="./deps/prism.js"></script>
<script type="text/javascript" src="./scripts/Interface.js"></script>
<link rel="stylesheet" type="text/css" href="./style/examples.css">
<link rel="stylesheet" type="text/css" href="./style/prism.css">
<script type="text/javascript">
// jshint ignore: start
</script>
</head>
<body>
<div id="Explanation">
Player
<br>
<br>
Press "on" to hear a grain from the player. Change the start and end points of the grain by adjusting the range slider.
</div>
<div id="Content">
<div id="LoadingBar"></div>
<div id="Rack"></div>
<div id="Code"></div>
</div>
<script id="ToneCode" type="text/javascript">
//the player
var player = new Tone.Player("./audio/casio/A1.mp3")
.toMaster();
//loop setting
player.loop = true;
player.loopStart = 0.1;
player.loopEnd = 0.11;
</script>
<script id="GUI" type="text/javascript">
var duration = 2.521655328798186;
Interface.Loading("LoadingBar");
Interface.Toggle("Rack", function(on){
if (on){
player.start();
} else {
player.stop();
}
});
Interface.Rack("Rack", "Player");
var range = Interface.Range("Rack", function(data){
player.loopStart = data.start * duration;
player.loopEnd = data.stop * duration;
});
range.label = "grain";
range.val.start = duration * player.loopStart;
range.val.stop = duration * player.loopEnd;
range.draw();
Interface.Code("Code", "ToneCode");
</script>
</body>
</html>