Tone.js/examples/monoSynth.html

70 lines
1.6 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
2015-06-26 05:23:05 +00:00
<title>MonoSynth</title>
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">
2015-02-20 05:59:19 +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>
<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>
</head>
2019-01-09 01:21:29 +00:00
<body>
<style>
tone-piano {
margin-bottom: 10px;
}
</style>
<tone-example label="MonoSynth">
<div slot="explanation">
2019-01-09 01:21:29 +00:00
<a href="https://tonejs.github.io/docs/MonoSynth">Tone.MonoSynth</a>
2015-06-27 22:02:55 +00:00
is composed of one oscillator, one filter, and two envelopes.
2015-06-26 05:23:05 +00:00
Both envelopes are triggered simultaneously when a note is triggered.
</div>
<div id="content">
</div>
2019-01-09 01:21:29 +00:00
</tone-example>
2015-06-26 05:23:05 +00:00
2019-01-09 01:21:29 +00:00
<script type="text/javascript">
const synth = new Tone.PolySynth(Tone.MonoSynth, {
volume: -8,
oscillator: {
type: "square8"
2015-06-26 05:23:05 +00:00
},
envelope: {
attack: 0.05,
decay: 0.3,
sustain: 0.4,
release: 0.8,
},
filterEnvelope: {
attack: 0.001,
decay: 0.7,
sustain: 0.1,
release: 0.8,
baseFrequency: 300,
octaves: 4
2015-06-26 05:23:05 +00:00
}
}).toDestination();
2015-06-26 05:23:05 +00:00
piano({
noteon: (note) => synth.triggerAttack(note.name),
noteoff: (note) => synth.triggerRelease(note.name),
2020-07-19 00:20:19 +00:00
parent: document.querySelector("#content")
});
ui({
tone: synth,
2020-07-19 00:20:19 +00:00
parent: document.querySelector("#content"),
name: "MonoSynth"
});
2014-09-02 04:25:38 +00:00
</script>
</body>
</html>