mirror of
https://github.com/Tonejs/Tone.js
synced 2024-12-30 21:48:45 +00:00
60 lines
1.5 KiB
HTML
60 lines
1.5 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>MonoSynth</title>
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
|
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
|
|
|
<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>
|
|
</head>
|
|
<body>
|
|
<style>
|
|
tone-piano {
|
|
margin-bottom: 10px;
|
|
}
|
|
</style>
|
|
<tone-example>
|
|
<tone-explanation label="MonoSynth">
|
|
<a href="https://tonejs.github.io/docs/MonoSynth">Tone.MonoSynth</a>
|
|
is composed of one oscillator, one filter, and two envelopes.
|
|
Both envelopes are triggered simultaneously when a note is triggered.
|
|
</tone-explanation>
|
|
|
|
<tone-content>
|
|
<tone-piano polyphonic></tone-piano>
|
|
<tone-mono-synth polyphonic></tone-mono-synth>
|
|
</tone-content>
|
|
</tone-example>
|
|
|
|
<script type="text/javascript">
|
|
var synth = new Tone.PolySynth(4, Tone.MonoSynth, {
|
|
"oscillator" : {
|
|
"type" : "square8"
|
|
},
|
|
"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
|
|
}
|
|
}).toMaster();
|
|
|
|
//bind the interface
|
|
document.querySelector("tone-piano").bind(synth);
|
|
document.querySelector("tone-mono-synth").bind(synth);
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|