Tone.js/examples/grainPlayer.html

61 lines
1.7 KiB
HTML
Raw Normal View History

2016-07-06 00:33:16 +00:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
2019-01-09 01:21:29 +00:00
<title>Grain Player</title>
2016-07-06 00:33:16 +00:00
2019-01-09 01:21:29 +00:00
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
2016-07-06 00:33:16 +00:00
2019-01-09 01:21:29 +00:00
<script src="https://unpkg.com/@webcomponents/webcomponentsjs@^2/webcomponents-bundle.js"></script>
<script src="../build/Tone.js"></script>
<script src="./js/tonejs-ui.js"></script>
2016-07-06 00:33:16 +00:00
</head>
<body>
2019-01-09 01:21:29 +00:00
<style type="text/css">
tone-play-toggle, tone-fft {
margin-bottom: 10px;
}
tone-fft {
background-color: black;
height: 40px;
width: 100%;
border-radius: 20px;
}
</style>
<tone-example>
<tone-explanation label="Granular Synthesis">
<a href="https://tonejs.github.io/docs/GrainPlayer">Tone.GrainPlayer</a> uses
2016-07-06 00:33:16 +00:00
<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.
2019-01-09 01:21:29 +00:00
</tone-explanation>
<tone-loader></tone-loader>
<tone-content>
<tone-fft></tone-fft>
<tone-play-toggle></tone-play-toggle>
<tone-grain-player></tone-grain-player>
</tone-content>
</tone-example>
<script type="text/javascript">
2016-07-06 00:33:16 +00:00
//the player
var player = new Tone.GrainPlayer({
"url" : "./audio/FWDL.[mp3|ogg]",
2016-07-06 00:33:16 +00:00
"loop" : true,
"grainSize" : 0.1,
"overlap" : 0.05,
}).toMaster();
2019-01-09 01:21:29 +00:00
//bind the interface
document.querySelector("tone-fft").bind(player);
document.querySelector("tone-play-toggle").bind(player);
document.querySelector("tone-grain-player").bind(player);
2016-07-06 00:33:16 +00:00
</script>
</body>
</html>