Tone.js/examples/grainPlayer.html
2017-03-26 16:39:19 -04:00

100 lines
2.2 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>GRAINPLAYER</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="icon" type="image/png" sizes="174x174" href="./style/favicon.png">
<script src="../build/Tone.js"></script>
<script src="./scripts/jquery.min.js"></script>
<script src="./scripts/draggabilly.js"></script>
<script src="./scripts/StartAudioContext.js"></script>
<script src="./scripts/Interface.js"></script>
<script src="https://tonejs.github.io/Logo/build/Logo.js"></script>
<link rel="stylesheet" type="text/css" href="./style/examples.css">
<script>
// jshint ignore: start
</script>
</head>
<body>
<div id="Content">
<div id="Title">Granular Synthesis</div>
<div id="Explanation">
<a href="https://tonejs.github.io/docs/#GrainPlayer">Tone.GrainPlayer</a> uses
<a href="https://en.wikipedia.org/wiki/Granular_synthesis">granular synthesis</a>
to enable you to adjust pitch and playback rate independently. The grainSize is the
amount of time each small chunk of audio is played for and the overlap is the
amount of crossfading transition time between successive grains.
</div>
<div id="Sliders"></div>
</div>
<script>
//the player
var player = new Tone.GrainPlayer({
"url" : "./audio/FWDL.mp3",
"loop" : true,
"grainSize" : 0.1,
"overlap" : 0.05,
}).toMaster();
// GUI //
Interface.Loader();
Interface.Button({
text : "Start",
activeText : "Stop",
type : "toggle",
start : function(){
player.start();
},
end : function(){
player.stop();
}
});
Interface.Slider({
param : "playbackRate",
name : "playbackRate",
parent : $("#Sliders"),
tone : player,
min : 0.5,
max : 2,
});
Interface.Slider({
param : "detune",
name : "detune",
parent : $("#Sliders"),
tone : player,
min : -1200,
max : 1200,
});
Interface.Slider({
param : "grainSize",
name : "grainSize",
parent : $("#Sliders"),
tone : player,
min : 0.01,
max : 0.2,
});
Interface.Slider({
param : "overlap",
name : "overlap",
parent : $("#Sliders"),
tone : player,
min : 0,
max : 0.2,
});
</script>
</body>
</html>