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
|
|
|
|
2020-07-18 00:58:09 +00:00
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script>
|
2020-07-18 00:36:42 +00:00
|
|
|
<link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet"/>
|
2019-01-09 01:21:29 +00:00
|
|
|
<script src="../build/Tone.js"></script>
|
2020-07-18 00:58:09 +00:00
|
|
|
<script src="./js/tone-ui.js"></script>
|
|
|
|
<script src="./js/components.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>
|
2020-07-18 00:36:42 +00:00
|
|
|
<tone-example label="Granular Synthesis">
|
|
|
|
<div slot="explanation">
|
2019-01-09 01:21:29 +00:00
|
|
|
<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.
|
2020-07-18 00:36:42 +00:00
|
|
|
</div>
|
2019-01-09 01:21:29 +00:00
|
|
|
|
|
|
|
<tone-loader></tone-loader>
|
|
|
|
|
2020-07-18 00:36:42 +00:00
|
|
|
<div id="content">
|
2019-01-09 01:21:29 +00:00
|
|
|
<tone-play-toggle></tone-play-toggle>
|
2020-07-18 00:36:42 +00:00
|
|
|
</div>
|
2019-01-09 01:21:29 +00:00
|
|
|
</tone-example>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
2020-07-19 00:20:19 +00:00
|
|
|
// the player
|
|
|
|
const player = new Tone.GrainPlayer({
|
|
|
|
url: "https://tonejs.github.io/audio/berklee/arpeggio3crazy.mp3",
|
|
|
|
loop: true,
|
|
|
|
grainSize: 0.1,
|
|
|
|
overlap: 0.05,
|
2020-07-18 00:36:42 +00:00
|
|
|
}).toDestination();
|
|
|
|
|
|
|
|
ui({
|
2020-07-19 00:20:19 +00:00
|
|
|
parent: document.querySelector("#content"),
|
2020-07-18 00:36:42 +00:00
|
|
|
tone: player,
|
2020-07-19 00:20:19 +00:00
|
|
|
});
|
2016-07-06 00:33:16 +00:00
|
|
|
|
2020-07-19 00:20:19 +00:00
|
|
|
// bind the interface
|
2020-07-18 00:36:42 +00:00
|
|
|
document.querySelector("tone-play-toggle").addEventListener("start", () => player.start());
|
|
|
|
document.querySelector("tone-play-toggle").addEventListener("stop", () => player.stop());
|
|
|
|
|
2016-07-06 00:33:16 +00:00
|
|
|
</script>
|
|
|
|
</body>
|
2017-03-18 16:35:37 +00:00
|
|
|
</html>
|