updating example links (#1246)

This commit is contained in:
Yotam Mann 2024-05-15 15:24:20 -04:00 committed by GitHub
parent f06ff17f06
commit 73f158f686
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 2455 additions and 1760 deletions

View file

@ -1,13 +1,24 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>AMSynth</title> <title>AMSynth</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png"> 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://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script> <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"/> <link
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
rel="stylesheet"
/>
<script src="../build/Tone.js"></script> <script src="../build/Tone.js"></script>
<script src="./js/tone-ui.js"></script> <script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script> <script src="./js/components.js"></script>
@ -15,42 +26,46 @@
<body> <body>
<tone-example label="AMSynth"> <tone-example label="AMSynth">
<div slot="explanation"> <div slot="explanation">
<a href="https://tonejs.github.io/docs/AMSynth">Tone.AMSynth</a> <a href="https://tonejs.github.io/docs/latest/classes/AMSynth"
>Tone.AMSynth</a
>
is composed of two is composed of two
<a href="https://tonejs.github.io/docs/Synth">Tone.Synths</a> <a href="https://tonejs.github.io/docs/latest/classes/Synth"
where one Tone.Synth modulates the amplitude of a second Tone.Synth. >Tone.Synths</a
>
where one Tone.Synth modulates the amplitude of a second
Tone.Synth.
</div> </div>
<div id="content"> <div id="content"></div>
</div>
</tone-example> </tone-example>
<script type="text/javascript"> <script type="text/javascript">
const synth = new Tone.AMSynth({ const synth = new Tone.AMSynth({
harmonicity: 2.5, harmonicity: 2.5,
oscillator: { oscillator: {
type: "fatsawtooth" type: "fatsawtooth",
}, },
envelope: { envelope: {
attack: 0.1, attack: 0.1,
decay: 0.2, decay: 0.2,
sustain: 0.2, sustain: 0.2,
release: 0.3 release: 0.3,
}, },
modulation: { modulation: {
type: "square" type: "square",
}, },
modulationEnvelope: { modulationEnvelope: {
attack: 0.5, attack: 0.5,
decay: 0.01 decay: 0.01,
} },
}).toDestination(); }).toDestination();
piano({ piano({
tone: synth, tone: synth,
parent: document.querySelector("#content"), parent: document.querySelector("#content"),
noteon: (note) => synth.triggerAttack(note.name), noteon: (note) => synth.triggerAttack(note.name),
noteoff: (note) => synth.triggerRelease() noteoff: (note) => synth.triggerRelease(),
}); });
ui({ ui({
@ -58,7 +73,6 @@
name: "AMSynth", name: "AMSynth",
parent: document.querySelector("#content"), parent: document.querySelector("#content"),
}); });
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,27 +1,46 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>Analyser</title> <title>Analyser</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png"> 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://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script> <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"/> <link
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
rel="stylesheet"
/>
<script src="../build/Tone.js"></script> <script src="../build/Tone.js"></script>
<script src="./js/tone-ui.js"></script> <script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script> <script src="./js/components.js"></script>
</head> </head>
<body> <body>
<tone-example label="Analyser"> <tone-example label="Analyser">
<tone-loader></tone-loader> <tone-loader></tone-loader>
<div slot="explanation"> <div slot="explanation">
<a href="https://tonejs.github.io/docs/FFT" target="_blank">Tone.FFT</a> <a
returns the amplitude of the incoming signal at different frequencies. href="https://tonejs.github.io/docs/latest/classes/FFT"
<a href="https://tonejs.github.io/docs/Waveform" target="_blank">Tone.Waveform</a> target="_blank"
>Tone.FFT</a
>
returns the amplitude of the incoming signal at different
frequencies.
<a
href="https://tonejs.github.io/docs/latest/classes/Waveform"
target="_blank"
>Tone.Waveform</a
>
returns the signal value between 0-1. returns the signal value between 0-1.
</div> </div>
@ -33,7 +52,7 @@
<script type="text/javascript"> <script type="text/javascript">
const player = new Tone.Player({ const player = new Tone.Player({
url: "https://tonejs.github.io/audio/berklee/arpeggio2.mp3", url: "https://tonejs.github.io/audio/berklee/arpeggio2.mp3",
loop: true loop: true,
}).toDestination(); }).toDestination();
const toneMeter = new Tone.Meter(); const toneMeter = new Tone.Meter();
@ -52,20 +71,23 @@
}); });
meter({ meter({
tone: toneMeter, tone: toneMeter,
parent: document.querySelector("#content") parent: document.querySelector("#content"),
}); });
fft({ fft({
tone: toneFFT, tone: toneFFT,
parent: document.querySelector("#content") parent: document.querySelector("#content"),
}); });
waveform({ waveform({
tone: toneWaveform, tone: toneWaveform,
parent: document.querySelector("#content") parent: document.querySelector("#content"),
}); });
document.querySelector("tone-play-toggle").addEventListener("start", () => player.start()); document
document.querySelector("tone-play-toggle").addEventListener("stop", () => player.stop()); .querySelector("tone-play-toggle")
.addEventListener("start", () => player.start());
document
.querySelector("tone-play-toggle")
.addEventListener("stop", () => player.stop());
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,28 +1,48 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>MetalSynth</title> <title>MetalSynth</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png"> 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://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script> <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"/> <link
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
rel="stylesheet"
/>
<script src="../build/Tone.js"></script> <script src="../build/Tone.js"></script>
<script src="./js/tone-ui.js"></script> <script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script> <script src="./js/components.js"></script>
</head> </head>
<body> <body>
<tone-example label="Bembe"> <tone-example label="Bembe">
<div slot="explanation"> <div slot="explanation">
<a href="https://tonejs.github.io/docs/MetalSynth">Tone.MetalSynth</a> <a
href="https://tonejs.github.io/docs/latest/classes/MetalSynth"
>Tone.MetalSynth</a
>
creates metallic, inharmonic sounds using 6 creates metallic, inharmonic sounds using 6
<a href="https://tonejs.github.io/docs/FMOscillator">Tone.FMOscillators</a> <a
href="https://tonejs.github.io/docs/latest/classes/FMOscillator"
>Tone.FMOscillators</a
>
with a tuning based on the TR-808 Cymbal. with a tuning based on the TR-808 Cymbal.
<a href="https://tonejs.github.io/docs/MembraneSynth">Tone.MembraneSynth</a> <a
makes kick and tom-like sounds using a frequency envelope which is triggered on notes attack. href="https://tonejs.github.io/docs/latest/classes/MembraneSynth"
>Tone.MembraneSynth</a
>
makes kick and tom-like sounds using a frequency envelope which
is triggered on notes attack.
</div> </div>
<div id="content"> <div id="content">
@ -38,16 +58,21 @@
envelope: { envelope: {
decay: 0.4, decay: 0.4,
}, },
volume: -15 volume: -15,
}).toDestination(); }).toDestination();
const bellPart = new Tone.Sequence(((time, freq) => { const bellPart = new Tone.Sequence(
(time, freq) => {
bell.triggerAttack(freq, time, Math.random() * 0.5 + 0.5); bell.triggerAttack(freq, time, Math.random() * 0.5 + 0.5);
}), [[300, null, 200], },
[
[300, null, 200],
[null, 200, 200], [null, 200, 200],
[null, 200, null], [null, 200, null],
[200, null, 200] [200, null, 200],
], "4n").start(0); ],
"4n"
).start(0);
const conga = new Tone.MembraneSynth({ const conga = new Tone.MembraneSynth({
pitchDecay: 0.008, pitchDecay: 0.008,
@ -55,28 +80,37 @@
envelope: { envelope: {
attack: 0.0006, attack: 0.0006,
decay: 0.5, decay: 0.5,
sustain: 0 sustain: 0,
} },
}).toDestination(); }).toDestination();
const congaPart = new Tone.Sequence(((time, pitch) => { const congaPart = new Tone.Sequence(
(time, pitch) => {
conga.triggerAttack(pitch, time, Math.random() * 0.5 + 0.5); conga.triggerAttack(pitch, time, Math.random() * 0.5 + 0.5);
}), ["G3", "C4", "C4", "C4"], "4n").start(0); },
["G3", "C4", "C4", "C4"],
"4n"
).start(0);
Tone.Transport.bpm.value = 115; Tone.Transport.bpm.value = 115;
drawer().add({ drawer()
.add({
tone: conga, tone: conga,
title: "Conga" title: "Conga",
}).add({ })
.add({
tone: bell, tone: bell,
title: "Bell" title: "Bell",
}); });
// connect the UI with the components // connect the UI with the components
document.querySelector("tone-play-toggle").addEventListener("start", () => Tone.Transport.start()); document
document.querySelector("tone-play-toggle").addEventListener("stop", () => Tone.Transport.stop()); .querySelector("tone-play-toggle")
.addEventListener("start", () => Tone.Transport.start());
document
.querySelector("tone-play-toggle")
.addEventListener("stop", () => Tone.Transport.stop());
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,14 +1,25 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>Buses</title> <title>Buses</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png"> 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://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script> <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"/> <link
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
rel="stylesheet"
/>
<script src="../build/Tone.js"></script> <script src="../build/Tone.js"></script>
<script src="./js/tone-ui.js"></script> <script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script> <script src="./js/components.js"></script>
@ -16,18 +27,44 @@
<body> <body>
<tone-example label="Buses"> <tone-example label="Buses">
<div slot="explanation"> <div slot="explanation">
Buses make it easy to share effects across many instruments. <code>send</code> Buses make it easy to share effects across many instruments.
audio to a named bus from an instrument and then <code>receive</code> that <code>send</code> audio to a named bus from an instrument and
channel on your effect. The gain values are all in decibels. then <code>receive</code> that channel on your effect. The gain
<br><br> values are all in decibels. <br /><br />
Docs on <a href="https://tonejs.github.io/docs/Channel.html#send">send</a> and Docs on
<a href="https://tonejs.github.io/docs/Channel.html#receive">receive</a>. <a
href="https://tonejs.github.io/docs/latest/classes/Channel.html#send"
>send</a
>
and
<a
href="https://tonejs.github.io/docs/latest/classes/Channel.html#receive"
>receive</a
>.
</div> </div>
<div id="content"> <div id="content">
<tone-play-toggle></tone-play-toggle> <tone-play-toggle></tone-play-toggle>
<tone-slider label="Chorus Send" min="-60" max="6" value="-60" units="db"></tone-slider> <tone-slider
<tone-slider label="Chebyshev Send" min="-60" max="6" value="-60" units="db"></tone-slider> label="Chorus Send"
<tone-slider label="Reverb Send" min="-60" max="6" value="-60" units="db"></tone-slider> min="-60"
max="6"
value="-60"
units="db"
></tone-slider>
<tone-slider
label="Chebyshev Send"
min="-60"
max="6"
value="-60"
units="db"
></tone-slider>
<tone-slider
label="Reverb Send"
min="-60"
max="6"
value="-60"
units="db"
></tone-slider>
</div> </div>
</tone-example> </tone-example>
@ -41,16 +78,24 @@
// make some effects // make some effects
const chorus = new Tone.Chorus({ const chorus = new Tone.Chorus({
wet: 1, wet: 1,
}).toDestination().start(); })
const chorusChannel = new Tone.Channel({ volume: -60 }).connect(chorus); .toDestination()
.start();
const chorusChannel = new Tone.Channel({ volume: -60 }).connect(
chorus
);
chorusChannel.receive("chorus"); chorusChannel.receive("chorus");
const cheby = new Tone.Chebyshev(50).toDestination(); const cheby = new Tone.Chebyshev(50).toDestination();
const chebyChannel = new Tone.Channel({ volume: -60 }).connect(cheby); const chebyChannel = new Tone.Channel({ volume: -60 }).connect(
cheby
);
chebyChannel.receive("cheby"); chebyChannel.receive("cheby");
const reverb = new Tone.Reverb(3).toDestination(); const reverb = new Tone.Reverb(3).toDestination();
const reverbChannel = new Tone.Channel({ volume: -60 }).connect(reverb); const reverbChannel = new Tone.Channel({ volume: -60 }).connect(
reverb
);
reverbChannel.receive("reverb"); reverbChannel.receive("reverb");
// send the player to all of the channels // send the player to all of the channels
@ -60,23 +105,36 @@
playerChannel.send("reverb"); playerChannel.send("reverb");
player.connect(playerChannel); player.connect(playerChannel);
drawer().add({ drawer()
.add({
tone: chorus, tone: chorus,
}).add({ })
.add({
tone: reverb, tone: reverb,
}).add({ })
.add({
tone: cheby, tone: cheby,
}); });
document.querySelector("tone-play-toggle").addEventListener("start", () => player.start()); document
document.querySelector("tone-play-toggle").addEventListener("stop", () => player.stop()); .querySelector("tone-play-toggle")
.addEventListener("start", () => player.start());
document
.querySelector("tone-play-toggle")
.addEventListener("stop", () => player.stop());
// bind the interface // bind the interface
document.querySelector("[label=\"Chorus Send\"]").addEventListener("input", e => { document
.querySelector('[label="Chorus Send"]')
.addEventListener("input", (e) => {
chorusChannel.volume.value = parseFloat(e.target.value); chorusChannel.volume.value = parseFloat(e.target.value);
}); });
document.querySelector("[label=\"Chebyshev Send\"]").addEventListener("input", e => { document
.querySelector('[label="Chebyshev Send"]')
.addEventListener("input", (e) => {
chebyChannel.volume.value = parseFloat(e.target.value); chebyChannel.volume.value = parseFloat(e.target.value);
}); });
document.querySelector("[label=\"Reverb Send\"]").addEventListener("input", e => { document
.querySelector('[label="Reverb Send"]')
.addEventListener("input", (e) => {
reverbChannel.volume.value = parseFloat(e.target.value); reverbChannel.volume.value = parseFloat(e.target.value);
}); });
</script> </script>

View file

@ -1,14 +1,25 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>Envelope</title> <title>Envelope</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png"> 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://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script> <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"/> <link
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
rel="stylesheet"
/>
<script src="../build/Tone.js"></script> <script src="../build/Tone.js"></script>
<script src="./js/tone-ui.js"></script> <script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script> <script src="./js/components.js"></script>
@ -27,17 +38,27 @@
</style> </style>
<tone-example label="Envelope"> <tone-example label="Envelope">
<div slot="explanation"> <div slot="explanation">
Envelopes ramp amplitude, frequency or any other parameter over time. Envelopes ramp amplitude, frequency or any other parameter over
<a href="https://tonejs.github.io/docs/Envelope">Tone.Envelope</a> and the classes that extend it time.
implement an <a href="https://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope" target="_blank">ADSR</a> envelope type <a href="https://tonejs.github.io/docs/latest/classes/Envelope"
which splits its ramp into four distinct phases: Attack, Decay, Sustain, Release. >Tone.Envelope</a
<img src="https://upload.wikimedia.org/wikipedia/commons/e/ea/ADSR_parameter.svg"> >
and the classes that extend it implement an
<a
href="https://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope"
target="_blank"
>ADSR</a
>
envelope type which splits its ramp into four distinct phases:
Attack, Decay, Sustain, Release.
<img
src="https://upload.wikimedia.org/wikipedia/commons/e/ea/ADSR_parameter.svg"
/>
</div> </div>
<div id="content"> <div id="content">
<tone-momentary-button></tone-momentary-button> <tone-momentary-button></tone-momentary-button>
</div> </div>
</tone-example> </tone-example>
<script type="text/javascript"> <script type="text/javascript">
@ -45,7 +66,7 @@
attack: 0.11, attack: 0.11,
decay: 0.21, decay: 0.21,
sustain: 0.5, sustain: 0.5,
release: 1.2 release: 1.2,
}).toDestination(); }).toDestination();
// create an oscillator and connect it to the envelope // create an oscillator and connect it to the envelope
@ -54,18 +75,26 @@
type: "custom", type: "custom",
frequency: "C#4", frequency: "C#4",
volume: -8, volume: -8,
}).connect(env).start(); })
.connect(env)
.start();
// bind the interface // bind the interface
drawer().add({ drawer()
.add({
tone: env, tone: env,
name: "Envelope" name: "Envelope",
}).add({ })
.add({
tone: osc, tone: osc,
}); });
document.querySelector("tone-momentary-button").addEventListener("down", e => env.triggerAttack()); document
document.querySelector("tone-momentary-button").addEventListener("up", e => env.triggerRelease()); .querySelector("tone-momentary-button")
.addEventListener("down", (e) => env.triggerAttack());
document
.querySelector("tone-momentary-button")
.addEventListener("up", (e) => env.triggerRelease());
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,14 +1,25 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>Events</title> <title>Events</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png"> 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://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script> <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"/> <link
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
rel="stylesheet"
/>
<script src="../build/Tone.js"></script> <script src="../build/Tone.js"></script>
<script src="./js/tone-ui.js"></script> <script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script> <script src="./js/components.js"></script>
@ -16,15 +27,37 @@
<body> <body>
<tone-example label="Events"> <tone-example label="Events">
<div slot="explanation"> <div slot="explanation">
Tone's Event classes (<a href="https://tonejs.github.io/docs/ToneEvent">Tone.ToneEvent</a>, Tone's Event classes (<a
<a href="https://tonejs.github.io/docs/Loop">Tone.Loop</a>, href="https://tonejs.github.io/docs/latest/classes/ToneEvent"
<a href="https://tonejs.github.io/docs/Part">Tone.Part</a> and >Tone.ToneEvent</a
<a href="https://tonejs.github.io/docs/Sequence">Tone.Sequence</a>) >,
simplify scheduling events along the Transport. Each class abstracts away calls to <a href="https://tonejs.github.io/docs/latest/classes/Loop"
<a href="https://tonejs.github.io/docs/Transport.schedule">Transport.schedule</a> or >Tone.Loop</a
<a href="https://tonejs.github.io/docs/Transport.scheduleRepeat">scheduleRepeat</a> >,
and lets you create precise, rhythmic events which are startable, stoppable and loopable. <a href="https://tonejs.github.io/docs/latest/classes/Part"
(note that ToneEvent was called <a href="https://tonejs.github.io/docs/Event">Event</a> before Tone.js 14.x) >Tone.Part</a
>
and
<a href="https://tonejs.github.io/docs/latest/classes/Sequence"
>Tone.Sequence</a
>) simplify scheduling events along the Transport. Each class
abstracts away calls to
<a
href="https://tonejs.github.io/docs/latest/classes/Transport.schedule"
>Transport.schedule</a
>
or
<a
href="https://tonejs.github.io/docs/latest/classes/Transport.scheduleRepeat"
>scheduleRepeat</a
>
and lets you create precise, rhythmic events which are
startable, stoppable and loopable. (note that ToneEvent was
called
<a href="https://tonejs.github.io/docs/latest/classes/Event"
>Event</a
>
before Tone.js 14.x)
</div> </div>
<div id="content"> <div id="content">
@ -40,15 +73,15 @@
envelope: { envelope: {
sustain: 0, sustain: 0,
attack: 0.02, attack: 0.02,
decay: 0.8 decay: 0.8,
}, },
octaves: 10, octaves: 10,
pitchDecay: 0.01, pitchDecay: 0.01,
}).toDestination(); }).toDestination();
const kickPart = new Tone.Loop(((time) => { const kickPart = new Tone.Loop((time) => {
kick.triggerAttackRelease("C2", "8n", time); kick.triggerAttackRelease("C2", "8n", time);
}), "2n").start(0); }, "2n").start(0);
/** /**
* SNARE * SNARE
@ -58,13 +91,13 @@
envelope: { envelope: {
attack: 0.001, attack: 0.001,
decay: 0.2, decay: 0.2,
sustain: 0 sustain: 0,
} },
}).toDestination(); }).toDestination();
const snarePart = new Tone.Loop(((time) => { const snarePart = new Tone.Loop((time) => {
snare.triggerAttack(time); snare.triggerAttack(time);
}), "2n").start("4n"); }, "2n").start("4n");
/** /**
* PIANO * PIANO
@ -80,9 +113,19 @@
const dChord = ["D4", "F4", "A4", "C5"]; const dChord = ["D4", "F4", "A4", "C5"];
const gChord = ["B3", "D4", "E4", "A4"]; const gChord = ["B3", "D4", "E4", "A4"];
const pianoPart = new Tone.Part(((time, chord) => { const pianoPart = new Tone.Part(
(time, chord) => {
keys.triggerAttackRelease(chord, "8n", time); keys.triggerAttackRelease(chord, "8n", time);
}), [["0:0:2", cChord], ["0:1", cChord], ["0:1:3", dChord], ["0:2:2", cChord], ["0:3", cChord], ["0:3:2", gChord]]).start("2m"); },
[
["0:0:2", cChord],
["0:1", cChord],
["0:1:3", dChord],
["0:2:2", cChord],
["0:3", cChord],
["0:3:2", gChord],
]
).start("2m");
pianoPart.loop = true; pianoPart.loop = true;
pianoPart.loopEnd = "1m"; pianoPart.loopEnd = "1m";
@ -103,41 +146,52 @@
decay: 0.01, decay: 0.01,
sustain: 0.5, sustain: 0.5,
baseFrequency: 200, baseFrequency: 200,
octaves: 2.6 octaves: 2.6,
} },
}).toDestination(); }).toDestination();
const bassPart = new Tone.Sequence(((time, note) => { const bassPart = new Tone.Sequence(
(time, note) => {
bass.triggerAttackRelease(note, "16n", time); bass.triggerAttackRelease(note, "16n", time);
}), ["C2", ["C3", ["C3", "D2"]], "E2", ["D2", "A1"]], "4n").start(0); },
["C2", ["C3", ["C3", "D2"]], "E2", ["D2", "A1"]],
"4n"
).start(0);
bassPart.probability = 0.9; bassPart.probability = 0.9;
// set the transport // set the transport
Tone.Transport.bpm.value = 90; Tone.Transport.bpm.value = 90;
drawer().add({ drawer()
.add({
name: "Kick", name: "Kick",
tone: kick, tone: kick,
open: false, open: false,
}).add({ })
.add({
name: "Snare", name: "Snare",
tone: snare, tone: snare,
open: false, open: false,
}).add({ })
.add({
name: "Bass", name: "Bass",
tone: bass, tone: bass,
open: false, open: false,
}).add({ })
.add({
name: "Keys", name: "Keys",
tone: keys, tone: keys,
open: false, open: false,
}); });
// bind the interface // bind the interface
document.querySelector("tone-play-toggle").addEventListener("start", e => Tone.Transport.start()); document
document.querySelector("tone-play-toggle").addEventListener("stop", e => Tone.Transport.stop()); .querySelector("tone-play-toggle")
.addEventListener("start", (e) => Tone.Transport.start());
document
.querySelector("tone-play-toggle")
.addEventListener("stop", (e) => Tone.Transport.stop());
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,14 +1,25 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>FMSynth</title> <title>FMSynth</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png"> 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://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script> <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"/> <link
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
rel="stylesheet"
/>
<script src="../build/Tone.js"></script> <script src="../build/Tone.js"></script>
<script src="./js/tone-ui.js"></script> <script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script> <script src="./js/components.js"></script>
@ -16,14 +27,18 @@
<body> <body>
<tone-example label="FMSynth"> <tone-example label="FMSynth">
<div slot="explanation"> <div slot="explanation">
<a href="https://tonejs.github.io/docs/FMSynth">Tone.FMSynth</a> <a href="https://tonejs.github.io/docs/latest/classes/FMSynth"
>Tone.FMSynth</a
>
is composed of two is composed of two
<a href="https://tonejs.github.io/docs/Synth">Tone.Synths</a> <a href="https://tonejs.github.io/docs/latest/classes/Synth"
where one Tone.Synth modulates the frequency of a second Tone.Synth. >Tone.Synths</a
>
where one Tone.Synth modulates the frequency of a second
Tone.Synth.
</div> </div>
<div id="content"> <div id="content"></div>
</div>
</tone-example> </tone-example>
<script type="text/javascript"> <script type="text/javascript">
@ -31,22 +46,22 @@
modulationIndex: 12.22, modulationIndex: 12.22,
envelope: { envelope: {
attack: 0.01, attack: 0.01,
decay: 0.2 decay: 0.2,
}, },
modulation: { modulation: {
type: "square" type: "square",
}, },
modulationEnvelope: { modulationEnvelope: {
attack: 0.2, attack: 0.2,
decay: 0.01 decay: 0.01,
} },
}).toDestination(); }).toDestination();
piano({ piano({
tone: synth, tone: synth,
parent: document.querySelector("#content"), parent: document.querySelector("#content"),
noteon: (note) => synth.triggerAttack(note.name), noteon: (note) => synth.triggerAttack(note.name),
noteoff: (note) => synth.triggerRelease() noteoff: (note) => synth.triggerRelease(),
}); });
ui({ ui({

View file

@ -1,21 +1,33 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>Grain Player</title> <title>Grain Player</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png"> 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://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script> <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"/> <link
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
rel="stylesheet"
/>
<script src="../build/Tone.js"></script> <script src="../build/Tone.js"></script>
<script src="./js/tone-ui.js"></script> <script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script> <script src="./js/components.js"></script>
</head> </head>
<body> <body>
<style type="text/css"> <style type="text/css">
tone-play-toggle, tone-fft { tone-play-toggle,
tone-fft {
margin-bottom: 10px; margin-bottom: 10px;
} }
@ -28,11 +40,18 @@
</style> </style>
<tone-example label="Granular Synthesis"> <tone-example label="Granular Synthesis">
<div slot="explanation"> <div slot="explanation">
<a href="https://tonejs.github.io/docs/GrainPlayer">Tone.GrainPlayer</a> uses <a
<a href="https://en.wikipedia.org/wiki/Granular_synthesis">granular synthesis</a> href="https://tonejs.github.io/docs/latest/classes/GrainPlayer"
to enable you to adjust pitch and playback rate independently. The grainSize is the >Tone.GrainPlayer</a
amount of time each small chunk of audio is played for and the overlap is the >
amount of crossfading transition time between successive grains. 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>
<tone-loader></tone-loader> <tone-loader></tone-loader>
@ -57,9 +76,12 @@
}); });
// bind the interface // bind the interface
document.querySelector("tone-play-toggle").addEventListener("start", () => player.start()); document
document.querySelector("tone-play-toggle").addEventListener("stop", () => player.stop()); .querySelector("tone-play-toggle")
.addEventListener("start", () => player.start());
document
.querySelector("tone-play-toggle")
.addEventListener("stop", () => player.stop());
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,14 +1,25 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>FatOscillator</title> <title>FatOscillator</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png"> 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://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script> <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"/> <link
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
rel="stylesheet"
/>
<script src="../build/Tone.js"></script> <script src="../build/Tone.js"></script>
<script src="./js/tone-ui.js"></script> <script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script> <script src="./js/components.js"></script>
@ -21,14 +32,28 @@
</style> </style>
<tone-example label="Supersaw"> <tone-example label="Supersaw">
<div slot="explanation"> <div slot="explanation">
<a href="https://tonejs.github.io/docs/FatOscillator">Tone.FatOscillator</a> creates multiple oscillators <a
and detunes them slightly from each other to thicken the sound. The <code>count</code> parameter sets href="https://tonejs.github.io/docs/latest/classes/FatOscillator"
the number of oscillators and <code>spread</code> sets the total spread (in cents) between the oscillators. >Tone.FatOscillator</a
<br><br> >
FatOscillator is also available in <a href="https://tonejs.github.io/docs/OmniOscillator">Tone.OmniOscillator</a> creates multiple oscillators and detunes them slightly from each
by prefixing another type with "fat", then use the count and spread to control the number and detune of the oscillators. To create a "supersaw": <code>omniOscillator.type = "fatsawtooth"</code>. other to thicken the sound. The <code>count</code> parameter
<br><br> sets the number of oscillators and <code>spread</code> sets the
<a href="http://www.midiworld.com/files/1121/">Jump by Van Halen MIDI</a> converted using <a href="https://tonejs.github.io/Midi/">@tonejs/midi</a> total spread (in cents) between the oscillators. <br /><br />
FatOscillator is also available in
<a
href="https://tonejs.github.io/docs/latest/classes/OmniOscillator"
>Tone.OmniOscillator</a
>
by prefixing another type with "fat", then use the count and
spread to control the number and detune of the oscillators. To
create a "supersaw":
<code>omniOscillator.type = "fatsawtooth"</code>. <br /><br />
<a href="http://www.midiworld.com/files/1121/"
>Jump by Van Halen MIDI</a
>
converted using
<a href="https://tonejs.github.io/Midi/">@tonejs/midi</a>
</div> </div>
<div id="content"> <div id="content">
@ -41,214 +66,223 @@
oscillator: { oscillator: {
type: "fatsawtooth", type: "fatsawtooth",
count: 3, count: 3,
spread: 30 spread: 30,
}, },
envelope: { envelope: {
attack: 0.01, attack: 0.01,
decay: 0.1, decay: 0.1,
sustain: 0.5, sustain: 0.5,
release: 0.4, release: 0.4,
attackCurve: "exponential" attackCurve: "exponential",
}, },
}).toDestination(); }).toDestination();
// Van Halen - Jump MIDI from http://www.midiworld.com/files/1121/ // Van Halen - Jump MIDI from http://www.midiworld.com/files/1121/
// converted using // converted using
const part = new Tone.Part(((time, note) => { const part = new Tone.Part(
synth.triggerAttackRelease(note.noteName, note.duration, time, note.velocity); (time, note) => {
}), [{ synth.triggerAttackRelease(
note.noteName,
note.duration,
time,
note.velocity
);
},
[
{
time: "192i", time: "192i",
noteName: "G4", noteName: "G4",
velocity: 0.8110236220472441, velocity: 0.8110236220472441,
duration: "104i" duration: "104i",
}, },
{ {
time: "192i", time: "192i",
noteName: "B4", noteName: "B4",
velocity: 0.7874015748031497, velocity: 0.7874015748031497,
duration: "104i" duration: "104i",
}, },
{ {
time: "192i", time: "192i",
noteName: "D5", noteName: "D5",
velocity: 0.8031496062992126, velocity: 0.8031496062992126,
duration: "104i" duration: "104i",
}, },
{ {
time: "480i", time: "480i",
noteName: "G4", noteName: "G4",
velocity: 0.7559055118110236, velocity: 0.7559055118110236,
duration: "104i" duration: "104i",
}, },
{ {
time: "480i", time: "480i",
noteName: "C5", noteName: "C5",
velocity: 0.6850393700787402, velocity: 0.6850393700787402,
duration: "104i" duration: "104i",
}, },
{ {
time: "480i", time: "480i",
noteName: "E5", noteName: "E5",
velocity: 0.6771653543307087, velocity: 0.6771653543307087,
duration: "104i" duration: "104i",
}, },
{ {
time: "768i", time: "768i",
noteName: "F4", noteName: "F4",
velocity: 0.8661417322834646, velocity: 0.8661417322834646,
duration: "104i" duration: "104i",
}, },
{ {
time: "768i", time: "768i",
noteName: "A4", noteName: "A4",
velocity: 0.8346456692913385, velocity: 0.8346456692913385,
duration: "104i" duration: "104i",
}, },
{ {
time: "768i", time: "768i",
noteName: "C5", noteName: "C5",
velocity: 0.8188976377952756, velocity: 0.8188976377952756,
duration: "104i" duration: "104i",
}, },
{ {
time: "1056i", time: "1056i",
noteName: "F4", noteName: "F4",
velocity: 0.7007874015748031, velocity: 0.7007874015748031,
duration: "104i" duration: "104i",
}, },
{ {
time: "1056i", time: "1056i",
noteName: "A4", noteName: "A4",
velocity: 0.6850393700787402, velocity: 0.6850393700787402,
duration: "104i" duration: "104i",
}, },
{ {
time: "1056i", time: "1056i",
noteName: "C5", noteName: "C5",
velocity: 0.6614173228346457, velocity: 0.6614173228346457,
duration: "104i" duration: "104i",
}, },
{ {
time: "1248i", time: "1248i",
noteName: "G4", noteName: "G4",
velocity: 0.6771653543307087, velocity: 0.6771653543307087,
duration: "104i" duration: "104i",
}, },
{ {
time: "1248i", time: "1248i",
noteName: "B4", noteName: "B4",
velocity: 0.6771653543307087, velocity: 0.6771653543307087,
duration: "104i" duration: "104i",
}, },
{ {
time: "1248i", time: "1248i",
noteName: "D5", noteName: "D5",
velocity: 0.7165354330708661, velocity: 0.7165354330708661,
duration: "104i" duration: "104i",
}, },
{ {
time: "1440i", time: "1440i",
noteName: "G4", noteName: "G4",
velocity: 0.8818897637795275, velocity: 0.8818897637795275,
duration: "248i" duration: "248i",
}, },
{ {
time: "1440i", time: "1440i",
noteName: "B4", noteName: "B4",
velocity: 0.84251968503937, velocity: 0.84251968503937,
duration: "248i" duration: "248i",
}, },
{ {
time: "1440i", time: "1440i",
noteName: "D5", noteName: "D5",
velocity: 0.8818897637795275, velocity: 0.8818897637795275,
duration: "248i" duration: "248i",
}, },
{ {
time: "1728i", time: "1728i",
noteName: "G4", noteName: "G4",
velocity: 0.8267716535433071, velocity: 0.8267716535433071,
duration: "104i" duration: "104i",
}, },
{ {
time: "1728i", time: "1728i",
noteName: "C5", noteName: "C5",
velocity: 0.8031496062992126, velocity: 0.8031496062992126,
duration: "104i" duration: "104i",
}, },
{ {
time: "1728i", time: "1728i",
noteName: "E5", noteName: "E5",
velocity: 0.8188976377952756, velocity: 0.8188976377952756,
duration: "104i" duration: "104i",
}, },
{ {
time: "2016i", time: "2016i",
noteName: "F4", noteName: "F4",
velocity: 0.7086614173228346, velocity: 0.7086614173228346,
duration: "104i" duration: "104i",
}, },
{ {
time: "2016i", time: "2016i",
noteName: "A4", noteName: "A4",
velocity: 0.7244094488188977, velocity: 0.7244094488188977,
duration: "104i" duration: "104i",
}, },
{ {
time: "2016i", time: "2016i",
noteName: "C5", noteName: "C5",
velocity: 0.7007874015748031, velocity: 0.7007874015748031,
duration: "104i" duration: "104i",
}, },
{ {
time: "2208i", time: "2208i",
noteName: "C4", noteName: "C4",
velocity: 0.9921259842519685, velocity: 0.9921259842519685,
duration: "296i" duration: "296i",
}, },
{ {
time: "2208i", time: "2208i",
noteName: "F4", noteName: "F4",
velocity: 0.968503937007874, velocity: 0.968503937007874,
duration: "200i" duration: "200i",
}, },
{ {
time: "2208i", time: "2208i",
noteName: "A4", noteName: "A4",
velocity: 0.9606299212598425, velocity: 0.9606299212598425,
duration: "208i" duration: "208i",
}, },
{ {
time: "2400i", time: "2400i",
noteName: "E4", noteName: "E4",
velocity: 0.7559055118110236, velocity: 0.7559055118110236,
duration: "104i" duration: "104i",
}, },
{ {
time: "2400i", time: "2400i",
noteName: "G4", noteName: "G4",
velocity: 0.7007874015748031, velocity: 0.7007874015748031,
duration: "104i" duration: "104i",
}, },
{ {
time: "2592i", time: "2592i",
noteName: "C4", noteName: "C4",
velocity: 0.968503937007874, velocity: 0.968503937007874,
duration: "488i" duration: "488i",
}, },
{ {
time: "2592i", time: "2592i",
noteName: "D4", noteName: "D4",
velocity: 0.9448818897637795, velocity: 0.9448818897637795,
duration: "488i" duration: "488i",
}, },
{ {
time: "2592i", time: "2592i",
noteName: "G4", noteName: "G4",
velocity: 0.937007874015748, velocity: 0.937007874015748,
duration: "488i" duration: "488i",
} },
]).start(0); ]
).start(0);
part.loop = true; part.loop = true;
part.loopEnd = "4m"; part.loopEnd = "4m";
@ -260,9 +294,12 @@
}); });
// bind the interface // bind the interface
document.querySelector("tone-play-toggle").addEventListener("start", () => Tone.Transport.start()); document
document.querySelector("tone-play-toggle").addEventListener("stop", () => Tone.Transport.stop()); .querySelector("tone-play-toggle")
.addEventListener("start", () => Tone.Transport.start());
document
.querySelector("tone-play-toggle")
.addEventListener("stop", () => Tone.Transport.stop());
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,14 +1,25 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>LFO Effects</title> <title>LFO Effects</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png"> 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://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script> <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"/> <link
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
rel="stylesheet"
/>
<script src="../build/Tone.js"></script> <script src="../build/Tone.js"></script>
<script src="./js/tone-ui.js"></script> <script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script> <script src="./js/components.js"></script>
@ -16,72 +27,143 @@
<body> <body>
<tone-example label="LFO Effects"> <tone-example label="LFO Effects">
<div slot="explanation"> <div slot="explanation">
These effects use an <a href="https://tonejs.github.io/docs/LFO">LFO</a> (Low Frequency Oscillator) to modulate the effect. Click and drag the dot to change the frequency and depth of the effect. These effects use an
<br><br> <a href="https://tonejs.github.io/docs/latest/classes/LFO"
Docs on <a href="https://tonejs.github.io/docs/AutoPanner">Tone.AutoPanner</a>, >LFO</a
<a href="https://tonejs.github.io/docs/AutoFilter">Tone.AutoFilter</a>, and >
<a href="https://tonejs.github.io/docs/Tremolo">Tone.Tremolo</a> (Low Frequency Oscillator) to modulate the effect. Click and
drag the dot to change the frequency and depth of the effect.
<br /><br />
Docs on
<a
href="https://tonejs.github.io/docs/latest/classes/AutoPanner"
>Tone.AutoPanner</a
>,
<a
href="https://tonejs.github.io/docs/latest/classes/AutoFilter"
>Tone.AutoFilter</a
>, and
<a href="https://tonejs.github.io/docs/latest/classes/Tremolo"
>Tone.Tremolo</a
>
</div> </div>
<div id="content"> <div id="content">
<tone-slider label="Panner" id="panner" units="hz" value="4" step="0.5" min="1" max="15"></tone-slider> <tone-slider
label="Panner"
id="panner"
units="hz"
value="4"
step="0.5"
min="1"
max="15"
></tone-slider>
<tone-play-toggle id="osc0"></tone-play-toggle> <tone-play-toggle id="osc0"></tone-play-toggle>
<tone-slider label="Filter" id="filter" units="hz" value="4" step="0.5" min="1" max="15"></tone-slider> <tone-slider
label="Filter"
id="filter"
units="hz"
value="4"
step="0.5"
min="1"
max="15"
></tone-slider>
<tone-play-toggle id="osc1"></tone-play-toggle> <tone-play-toggle id="osc1"></tone-play-toggle>
<tone-slider label="Tremolo" id="tremolo" units="hz" value="4" step="0.5" min="1" max="15"></tone-slider> <tone-slider
label="Tremolo"
id="tremolo"
units="hz"
value="4"
step="0.5"
min="1"
max="15"
></tone-slider>
<tone-play-toggle id="osc2"></tone-play-toggle> <tone-play-toggle id="osc2"></tone-play-toggle>
</tone-content> </div>
</tone-example> </tone-example>
<script type="text/javascript"> <script type="text/javascript">
// AutoPanner - a panning modulation effect // AutoPanner - a panning modulation effect
const panner = new Tone.AutoPanner({ const panner = new Tone.AutoPanner({
frequency: 4, frequency: 4,
depth: 1 depth: 1,
}).toDestination().start(); })
.toDestination()
.start();
// AutoFilter - a filter modulation effect // AutoFilter - a filter modulation effect
const filter = new Tone.AutoFilter({ const filter = new Tone.AutoFilter({
frequency: 2, frequency: 2,
depth: 0.6 depth: 0.6,
}).toDestination().start(); })
.toDestination()
.start();
// Tremolo - an amplitude modulation effect // Tremolo - an amplitude modulation effect
const tremolo = new Tone.Tremolo({ const tremolo = new Tone.Tremolo({
frequency: 0.6, frequency: 0.6,
depth: 0.7 depth: 0.7,
}).toDestination().start(); })
.toDestination()
.start();
// the input oscillators // the input oscillators
const pannerOsc = new Tone.Oscillator({ const pannerOsc = new Tone.Oscillator({
volume: -12, volume: -12,
type: "square6", type: "square6",
frequency: "C4" frequency: "C4",
}).connect(panner); }).connect(panner);
const filterOsc = new Tone.Oscillator({ const filterOsc = new Tone.Oscillator({
volume: -12, volume: -12,
type: "square6", type: "square6",
frequency: "E4" frequency: "E4",
}).connect(filter); }).connect(filter);
const tremoloOsc = new Tone.Oscillator({ const tremoloOsc = new Tone.Oscillator({
volume: -12, volume: -12,
type: "square6", type: "square6",
frequency: "A4" frequency: "A4",
}).connect(tremolo); }).connect(tremolo);
// bind the interface // bind the interface
document.querySelector("#osc0").addEventListener("start", () => pannerOsc.start()); document
document.querySelector("#osc0").addEventListener("stop", () => pannerOsc.stop()); .querySelector("#osc0")
document.querySelector("#panner").addEventListener("input", (e) => panner.frequency.value = parseFloat(e.target.value)); .addEventListener("start", () => pannerOsc.start());
document.querySelector("#osc1").addEventListener("start", () => filterOsc.start()); document
document.querySelector("#osc1").addEventListener("stop", () => filterOsc.stop()); .querySelector("#osc0")
document.querySelector("#filter").addEventListener("input", (e) => filter.frequency.value = parseFloat(e.target.value)); .addEventListener("stop", () => pannerOsc.stop());
document.querySelector("#osc2").addEventListener("start", () => tremoloOsc.start()); document
document.querySelector("#osc2").addEventListener("stop", () => tremoloOsc.stop()); .querySelector("#panner")
document.querySelector("#tremolo").addEventListener("input", (e) => tremolo.frequency.value = parseFloat(e.target.value)); .addEventListener(
"input",
(e) => (panner.frequency.value = parseFloat(e.target.value))
);
document
.querySelector("#osc1")
.addEventListener("start", () => filterOsc.start());
document
.querySelector("#osc1")
.addEventListener("stop", () => filterOsc.stop());
document
.querySelector("#filter")
.addEventListener(
"input",
(e) => (filter.frequency.value = parseFloat(e.target.value))
);
document
.querySelector("#osc2")
.addEventListener("start", () => tremoloOsc.start());
document
.querySelector("#osc2")
.addEventListener("stop", () => tremoloOsc.stop());
document
.querySelector("#tremolo")
.addEventListener(
"input",
(e) =>
(tremolo.frequency.value = parseFloat(e.target.value))
);
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,14 +1,25 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>Meter</title> <title>Meter</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png"> 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://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script> <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"/> <link
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
rel="stylesheet"
/>
<script src="../build/Tone.js"></script> <script src="../build/Tone.js"></script>
<script src="./js/tone-ui.js"></script> <script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script> <script src="./js/components.js"></script>
@ -17,7 +28,11 @@
<tone-example label="Meter"> <tone-example label="Meter">
<tone-loader></tone-loader> <tone-loader></tone-loader>
<div slot="explanation"> <div slot="explanation">
<a href="https://tonejs.github.io/docs/Meter" target="_blank">Tone.Meter</a> <a
href="https://tonejs.github.io/docs/latest/classes/Meter"
target="_blank"
>Tone.Meter</a
>
gives you the level of the incoming signal in decibels. gives you the level of the incoming signal in decibels.
</div> </div>
@ -29,7 +44,7 @@
<script type="text/javascript"> <script type="text/javascript">
const player = new Tone.Player({ const player = new Tone.Player({
url: "https://tonejs.github.io/audio/berklee/Resonant_FM_laser1.mp3", url: "https://tonejs.github.io/audio/berklee/Resonant_FM_laser1.mp3",
loop: true loop: true,
}).toDestination(); }).toDestination();
const toneMeter = new Tone.Meter({ const toneMeter = new Tone.Meter({
@ -39,19 +54,22 @@
meter({ meter({
tone: toneMeter, tone: toneMeter,
parent: document.querySelector("#content") parent: document.querySelector("#content"),
}); });
ui({ ui({
tone: player, tone: player,
name: "Player", name: "Player",
parent: document.querySelector("#content") parent: document.querySelector("#content"),
}); });
// bind the interface // bind the interface
document.querySelector("tone-play-toggle").addEventListener("start", () => player.start()); document
document.querySelector("tone-play-toggle").addEventListener("stop", () => player.stop()); .querySelector("tone-play-toggle")
.addEventListener("start", () => player.start());
document
.querySelector("tone-play-toggle")
.addEventListener("stop", () => player.stop());
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,14 +1,25 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>Mixer</title> <title>Mixer</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png"> 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://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script> <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"/> <link
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
rel="stylesheet"
/>
<script src="../build/Tone.js"></script> <script src="../build/Tone.js"></script>
<script src="./js/tone-ui.js"></script> <script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script> <script src="./js/components.js"></script>
@ -26,7 +37,15 @@
<body> <body>
<tone-example label="Channel"> <tone-example label="Channel">
<div slot="explanation"> <div slot="explanation">
<a href="https://tonejs.github.io/docs/Channel">Tone.Channel</a> provides a simple channel interface. It allows for panning and volume changes as well as the ability to <a href="https://tonejs.github.io/docs/Solo">solo</a> (exclude audio in other Tone.Channels). <a href="https://tonejs.github.io/docs/latest/classes/Channel"
>Tone.Channel</a
>
provides a simple channel interface. It allows for panning and
volume changes as well as the ability to
<a href="https://tonejs.github.io/docs/latest/classes/Solo"
>solo</a
>
(exclude audio in other Tone.Channels).
</div> </div>
<tone-loader></tone-loader> <tone-loader></tone-loader>
@ -38,19 +57,21 @@
<script type="text/javascript"> <script type="text/javascript">
function makeChannel(name, url, pan) { function makeChannel(name, url, pan) {
const channel = new Tone.Channel({ const channel = new Tone.Channel({
pan pan,
}).toDestination(); }).toDestination();
const player = new Tone.Player({ const player = new Tone.Player({
url: `https://tonejs.github.io/audio/berklee/${url}.mp3`, url: `https://tonejs.github.io/audio/berklee/${url}.mp3`,
loop: true loop: true,
}).sync().start(0); })
.sync()
.start(0);
player.connect(channel); player.connect(channel);
// add a UI element // add a UI element
ui({ ui({
name, name,
tone: channel, tone: channel,
parent: document.querySelector("#content") parent: document.querySelector("#content"),
}); });
} }
@ -59,7 +80,7 @@
Tone.Destination.chain(toneMeter); Tone.Destination.chain(toneMeter);
meter({ meter({
tone: toneMeter, tone: toneMeter,
parent: document.querySelector("#content") parent: document.querySelector("#content"),
}); });
makeChannel("Guitar 0", "comping1", 1); makeChannel("Guitar 0", "comping1", 1);
@ -67,8 +88,12 @@
makeChannel("Guitar 2", "comping3", 0.25); makeChannel("Guitar 2", "comping3", 0.25);
makeChannel("Guitar 3", "comping4", -0.25); makeChannel("Guitar 3", "comping4", -0.25);
document.querySelector("tone-play-toggle").addEventListener("start", () => Tone.Transport.start()); document
document.querySelector("tone-play-toggle").addEventListener("stop", () => Tone.Transport.stop()); .querySelector("tone-play-toggle")
.addEventListener("start", () => Tone.Transport.start());
document
.querySelector("tone-play-toggle")
.addEventListener("stop", () => Tone.Transport.stop());
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,14 +1,25 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>MonoSynth</title> <title>MonoSynth</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png"> 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://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script> <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"/> <link
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
rel="stylesheet"
/>
<script src="../build/Tone.js"></script> <script src="../build/Tone.js"></script>
<script src="./js/tone-ui.js"></script> <script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script> <script src="./js/components.js"></script>
@ -21,20 +32,22 @@
</style> </style>
<tone-example label="MonoSynth"> <tone-example label="MonoSynth">
<div slot="explanation"> <div slot="explanation">
<a href="https://tonejs.github.io/docs/MonoSynth">Tone.MonoSynth</a> <a href="https://tonejs.github.io/docs/latest/classes/MonoSynth"
>Tone.MonoSynth</a
>
is composed of one oscillator, one filter, and two envelopes. is composed of one oscillator, one filter, and two envelopes.
Both envelopes are triggered simultaneously when a note is triggered. Both envelopes are triggered simultaneously when a note is
triggered.
</div> </div>
<div id="content"> <div id="content"></div>
</div>
</tone-example> </tone-example>
<script type="text/javascript"> <script type="text/javascript">
const synth = new Tone.PolySynth(Tone.MonoSynth, { const synth = new Tone.PolySynth(Tone.MonoSynth, {
volume: -8, volume: -8,
oscillator: { oscillator: {
type: "square8" type: "square8",
}, },
envelope: { envelope: {
attack: 0.05, attack: 0.05,
@ -48,22 +61,21 @@
sustain: 0.1, sustain: 0.1,
release: 0.8, release: 0.8,
baseFrequency: 300, baseFrequency: 300,
octaves: 4 octaves: 4,
} },
}).toDestination(); }).toDestination();
piano({ piano({
noteon: (note) => synth.triggerAttack(note.name), noteon: (note) => synth.triggerAttack(note.name),
noteoff: (note) => synth.triggerRelease(note.name), noteoff: (note) => synth.triggerRelease(note.name),
parent: document.querySelector("#content") parent: document.querySelector("#content"),
}); });
ui({ ui({
tone: synth, tone: synth,
parent: document.querySelector("#content"), parent: document.querySelector("#content"),
name: "MonoSynth" name: "MonoSynth",
}); });
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,21 +1,33 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>Noise</title> <title>Noise</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png"> 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://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script> <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"/> <link
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
rel="stylesheet"
/>
<script src="../build/Tone.js"></script> <script src="../build/Tone.js"></script>
<script src="./js/tone-ui.js"></script> <script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script> <script src="./js/components.js"></script>
</head> </head>
<body> <body>
<style> <style>
tone-trigger, tone-oscilloscope { tone-trigger,
tone-oscilloscope {
margin-bottom: 10px; margin-bottom: 10px;
} }
tone-oscilloscope { tone-oscilloscope {
@ -26,7 +38,9 @@
</style> </style>
<tone-example label="Noise"> <tone-example label="Noise">
<div slot="explanation"> <div slot="explanation">
<a href="https://tonejs.github.io/docs/Noise">Tone.Noise</a> <a href="https://tonejs.github.io/docs/latest/classes/Noise"
>Tone.Noise</a
>
has 3 different types of noise. Careful, it's loud! has 3 different types of noise. Careful, it's loud!
</div> </div>
@ -39,7 +53,7 @@
// make the noise and connect it to the output // make the noise and connect it to the output
const noise = new Tone.Noise({ const noise = new Tone.Noise({
volume: -10, volume: -10,
type: "brown" type: "brown",
}).toDestination(); }).toDestination();
const toneWaveform = new Tone.Waveform(); const toneWaveform = new Tone.Waveform();
@ -56,8 +70,12 @@
}); });
// bind the inteface // bind the inteface
document.querySelector("tone-momentary-button").addEventListener("down", () => noise.start()); document
document.querySelector("tone-momentary-button").addEventListener("up", () => noise.stop()); .querySelector("tone-momentary-button")
.addEventListener("down", () => noise.start());
document
.querySelector("tone-momentary-button")
.addEventListener("up", () => noise.stop());
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,14 +1,25 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>Offline</title> <title>Offline</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png"> 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://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script> <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"/> <link
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
rel="stylesheet"
/>
<script src="../build/Tone.js"></script> <script src="../build/Tone.js"></script>
<script src="./js/tone-ui.js"></script> <script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script> <script src="./js/components.js"></script>
@ -22,9 +33,16 @@
<tone-example label="Offline Rendering"> <tone-example label="Offline Rendering">
<tone-loader></tone-loader> <tone-loader></tone-loader>
<div slot="explanation"> <div slot="explanation">
Tone.Offline renders a chunk of Tone.js code into an AudioBuffer. An offline instance of Tone.Transport is passed into the callback which can be used to schedule events. It may take a moment to render the sound. Tone.Offline renders a chunk of Tone.js code into an
<br><br> AudioBuffer. An offline instance of Tone.Transport is passed
<a href="https://tonejs.github.io/docs/Tone#offline-static">Tone.Offline</a> docs. into the callback which can be used to schedule events. It may
take a moment to render the sound.
<br /><br />
<a
href="https://tonejs.github.io/docs/latest/functions/Offline.html"
>Tone.Offline</a
>
docs.
</div> </div>
<div id="content"> <div id="content">
@ -37,7 +55,6 @@
const player = new Tone.Player().toDestination(); const player = new Tone.Player().toDestination();
const renderingPromise = Tone.Offline(({ transport }) => { const renderingPromise = Tone.Offline(({ transport }) => {
const reverb = new Tone.Reverb().toDestination(); const reverb = new Tone.Reverb().toDestination();
const pannerA = new Tone.Panner(-1).connect(reverb); const pannerA = new Tone.Panner(-1).connect(reverb);
@ -45,15 +62,19 @@
envelope: { envelope: {
attack: 0.01, attack: 0.01,
decay: 5, decay: 5,
sustain: 0 sustain: 0,
}, },
oscillator: { oscillator: {
type: "sawtooth4" type: "sawtooth4",
} },
}).connect(pannerA); }).connect(pannerA);
const seqA = new Tone.Sequence(((time, note) => { const seqA = new Tone.Sequence(
(time, note) => {
synthA.triggerAttack(note, time); synthA.triggerAttack(note, time);
}), ["A4", "G4", "G#4", "F#4", "E4"], "8n").start(0); },
["A4", "G4", "G#4", "F#4", "E4"],
"8n"
).start(0);
seqA.loop = false; seqA.loop = false;
const pannerB = new Tone.Panner(1).connect(reverb); const pannerB = new Tone.Panner(1).connect(reverb);
@ -61,27 +82,35 @@
envelope: { envelope: {
attack: 0.001, attack: 0.001,
decay: 3, decay: 3,
sustain: 0 sustain: 0,
}, },
oscillator: { oscillator: {
type: "square8" type: "square8",
} },
}).connect(pannerB); }).connect(pannerB);
const seqB = new Tone.Sequence(((time, note) => { const seqB = new Tone.Sequence(
(time, note) => {
synthB.triggerAttack(note, time); synthB.triggerAttack(note, time);
}), ["G#4", "A4", "G4", "F4", "C4"], "8n").start("16n"); },
["G#4", "A4", "G4", "F4", "C4"],
"8n"
).start("16n");
seqB.loop = false; seqB.loop = false;
const bass = new Tone.MonoSynth({ const bass = new Tone.MonoSynth({
envelope: { envelope: {
attack: 0.01, attack: 0.01,
decay: 3, decay: 3,
sustain: 0.1 sustain: 0.1,
}, },
}).toDestination(); }).toDestination();
const bassSeq = new Tone.Sequence(((time, note) => { const bassSeq = new Tone.Sequence(
(time, note) => {
bass.triggerAttackRelease(note, "1n", time); bass.triggerAttackRelease(note, "1n", time);
}), ["C2", "C2", "F1", "F1"], "4n").start(0); },
["C2", "C2", "F1", "F1"],
"4n"
).start(0);
bassSeq.loop = false; bassSeq.loop = false;
transport.bpm.value = 150; transport.bpm.value = 150;
@ -92,12 +121,19 @@
}, 7); }, 7);
// set the buffer when it's done // set the buffer when it's done
renderingPromise.then(buffer => player.buffer = buffer); renderingPromise.then((buffer) => (player.buffer = buffer));
renderingPromise.then(() => document.querySelector("tone-play-toggle").disabled = false); renderingPromise.then(
() =>
document.querySelector("tone-play-toggle").addEventListener("start", () => player.start()); (document.querySelector("tone-play-toggle").disabled =
document.querySelector("tone-play-toggle").addEventListener("stop", () => player.stop()); false)
);
document
.querySelector("tone-play-toggle")
.addEventListener("start", () => player.start());
document
.querySelector("tone-play-toggle")
.addEventListener("stop", () => player.stop());
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,14 +1,25 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>Oscillator</title> <title>Oscillator</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png"> 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://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script> <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"/> <link
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
rel="stylesheet"
/>
<script src="../build/Tone.js"></script> <script src="../build/Tone.js"></script>
<script src="./js/tone-ui.js"></script> <script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script> <script src="./js/components.js"></script>
@ -21,10 +32,14 @@
<body> <body>
<tone-example label="Oscillator"> <tone-example label="Oscillator">
<div slot="explanation"> <div slot="explanation">
The oscillator has 4 basic types which can be altered by setting the number The oscillator has 4 basic types which can be altered by setting
of partials and partials array. the number of partials and partials array.
<br><br> <br /><br />
<a href="https://tonejs.github.io/docs/Oscillator">Tone.Oscillator</a> docs. <a
href="https://tonejs.github.io/docs/latest/classes/Oscillator"
>Tone.Oscillator</a
>
docs.
</div> </div>
<div id="content"> <div id="content">
@ -32,22 +47,25 @@
</div> </div>
</tone-example> </tone-example>
<script type="text/javascript"> <script type="text/javascript">
const osc = new Tone.Oscillator({ const osc = new Tone.Oscillator({
type: "square", type: "square",
frequency: 440, frequency: 440,
volume: -16 volume: -16,
}).toDestination(); }).toDestination();
ui({ ui({
tone: osc, tone: osc,
parent: document.querySelector("#content") parent: document.querySelector("#content"),
}); });
// bind the interface // bind the interface
document.querySelector("tone-momentary-button").addEventListener("down", () => osc.start()); document
document.querySelector("tone-momentary-button").addEventListener("up", () => osc.stop()); .querySelector("tone-momentary-button")
.addEventListener("down", () => osc.start());
document
.querySelector("tone-momentary-button")
.addEventListener("up", () => osc.stop());
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,14 +1,25 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>Ping Pong Delay</title> <title>Ping Pong Delay</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png"> 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://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script> <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"/> <link
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
rel="stylesheet"
/>
<script src="../build/Tone.js"></script> <script src="../build/Tone.js"></script>
<script src="./js/tone-ui.js"></script> <script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script> <script src="./js/components.js"></script>
@ -18,9 +29,15 @@
<tone-loader></tone-loader> <tone-loader></tone-loader>
<div slot="explanation"> <div slot="explanation">
A Ping Pong Delay is a stereo feedback delay where the delay bounces back and forth between the left and right channels. Hit the button to trigger a snare sample into the effect. A Ping Pong Delay is a stereo feedback delay where the delay
<br><br> bounces back and forth between the left and right channels. Hit
<a href="https://tonejs.github.io/docs/PingPongDelay">Tone.PingPongDelay</a> docs. the button to trigger a snare sample into the effect.
<br /><br />
<a
href="https://tonejs.github.io/docs/latest/classes/PingPongDelay"
>Tone.PingPongDelay</a
>
docs.
</div> </div>
<div id="content"> <div id="content">
@ -33,22 +50,28 @@
const feedbackDelay = new Tone.PingPongDelay({ const feedbackDelay = new Tone.PingPongDelay({
delayTime: "8n", delayTime: "8n",
feedback: 0.6, feedback: 0.6,
wet: 0.5 wet: 0.5,
}).toDestination(); }).toDestination();
// play a snare sound through it // play a snare sound through it
const player = new Tone.Player("https://tonejs.github.io/audio/drum-samples/CR78/snare.mp3").connect(feedbackDelay); const player = new Tone.Player(
"https://tonejs.github.io/audio/drum-samples/CR78/snare.mp3"
).connect(feedbackDelay);
const toneMeter = new Tone.Meter({ channelCount: 2 }); const toneMeter = new Tone.Meter({ channelCount: 2 });
feedbackDelay.connect(toneMeter); feedbackDelay.connect(toneMeter);
meter({ meter({
tone: toneMeter, tone: toneMeter,
parent: document.querySelector("#content") parent: document.querySelector("#content"),
}); });
document.querySelector("tone-momentary-button").addEventListener("down", () => player.start()); document
document.querySelector("tone-momentary-button").addEventListener("up", () => player.stop()); .querySelector("tone-momentary-button")
.addEventListener("down", () => player.start());
document
.querySelector("tone-momentary-button")
.addEventListener("up", () => player.stop());
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,14 +1,25 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>Pitch Shift</title> <title>Pitch Shift</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png"> 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://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script> <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"/> <link
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
rel="stylesheet"
/>
<script src="../build/Tone.js"></script> <script src="../build/Tone.js"></script>
<script src="./js/tone-ui.js"></script> <script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script> <script src="./js/components.js"></script>
@ -23,20 +34,32 @@
<tone-example label="Pitch Shift"> <tone-example label="Pitch Shift">
<div slot="explanation"> <div slot="explanation">
This example demonstrates the Pitch Shift effect. This example demonstrates the Pitch Shift effect.
<br><br> <br /><br />
<a href="https://tonejs.github.io/docs/PitchShift">Tone.Pitch Shift</a> docs. <a
href="https://tonejs.github.io/docs/latest/classes/PitchShift"
>Tone.Pitch Shift</a
>
docs.
</div> </div>
<tone-loader></tone-loader> <tone-loader></tone-loader>
<div id="content"> <div id="content">
<tone-play-toggle></tone-play-toggle> <tone-play-toggle></tone-play-toggle>
<tone-slider label="pitch" min="-12" max="12" value="0" units="hz"></tone-slider> <tone-slider
label="pitch"
min="-12"
max="12"
value="0"
units="hz"
></tone-slider>
</div> </div>
</tone-example> </tone-example>
<script type="text/javascript"> <script type="text/javascript">
const pitchShift = new Tone.PitchShift().toDestination(); const pitchShift = new Tone.PitchShift().toDestination();
const player = new Tone.Player("https://tonejs.github.io/audio/berklee/groovin_analogsynth1.mp3").connect(pitchShift); const player = new Tone.Player(
"https://tonejs.github.io/audio/berklee/groovin_analogsynth1.mp3"
).connect(pitchShift);
player.loop = true; player.loop = true;
const toneFFT = new Tone.FFT(); const toneFFT = new Tone.FFT();
@ -47,13 +70,19 @@
}); });
// bind the interface // bind the interface
document.querySelector("tone-play-toggle").addEventListener("start", () => player.start()); document
document.querySelector("tone-play-toggle").addEventListener("stop", () => player.stop()); .querySelector("tone-play-toggle")
.addEventListener("start", () => player.start());
document
.querySelector("tone-play-toggle")
.addEventListener("stop", () => player.stop());
// document.querySelector("tone-play-toggle").addEventListener('start', () => { // document.querySelector("tone-play-toggle").addEventListener('start', () => {
// debugger; // debugger;
// }); // });
document.querySelector("tone-slider").addEventListener("input", e => { document
.querySelector("tone-slider")
.addEventListener("input", (e) => {
pitchShift.pitch = parseFloat(e.target.value); pitchShift.pitch = parseFloat(e.target.value);
}); });
</script> </script>

View file

@ -1,14 +1,25 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>Player</title> <title>Player</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png"> 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://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script> <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"/> <link
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
rel="stylesheet"
/>
<script src="../build/Tone.js"></script> <script src="../build/Tone.js"></script>
<script src="./js/tone-ui.js"></script> <script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script> <script src="./js/components.js"></script>
@ -22,8 +33,10 @@
<tone-example label="Player"> <tone-example label="Player">
<tone-loader></tone-loader> <tone-loader></tone-loader>
<div slot="explanation"> <div slot="explanation">
Click on the button to play the audio file on loop Click on the button to play the audio file on loop using
using <a href="https://tonejs.github.io/docs/Player">Tone.Player</a>. <a href="https://tonejs.github.io/docs/latest/classes/Player"
>Tone.Player</a
>.
</div> </div>
<div id="content"> <div id="content">
@ -42,13 +55,16 @@
ui({ ui({
tone: player, tone: player,
parent: document.querySelector("#content") parent: document.querySelector("#content"),
}); });
// bind the interface // bind the interface
document.querySelector("tone-play-toggle").addEventListener("start", () => player.start()); document
document.querySelector("tone-play-toggle").addEventListener("stop", () => player.stop()); .querySelector("tone-play-toggle")
.addEventListener("start", () => player.start());
document
.querySelector("tone-play-toggle")
.addEventListener("stop", () => player.stop());
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,14 +1,25 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>PolySynth</title> <title>PolySynth</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png"> 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://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script> <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"/> <link
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
rel="stylesheet"
/>
<script src="../build/Tone.js"></script> <script src="../build/Tone.js"></script>
<script src="./js/tone-ui.js"></script> <script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script> <script src="./js/components.js"></script>
@ -21,30 +32,31 @@
</style> </style>
<tone-example label="Polyphony"> <tone-example label="Polyphony">
<div slot="explanation"> <div slot="explanation">
<a href="https://tonejs.github.io/docs/PolySynth">Tone.PolySynth</a> <a href="https://tonejs.github.io/docs/latest/classes/PolySynth"
>Tone.PolySynth</a
>
handles voice creation and allocation for any monophonic handles voice creation and allocation for any monophonic
instruments passed in as the second parameter. PolySynth is instruments passed in as the second parameter. PolySynth is not
not a synthesizer by itself, it merely manages voices of a synthesizer by itself, it merely manages voices of one of the
one of the other types of synths, allowing any of the other types of synths, allowing any of the monophonic
monophonic synthesizers to be polyphonic. synthesizers to be polyphonic.
</div> </div>
<div id="content"> <div id="content"></div>
</div>
</tone-example> </tone-example>
<script type="text/javascript"> <script type="text/javascript">
const synth = new Tone.PolySynth(Tone.Synth, { const synth = new Tone.PolySynth(Tone.Synth, {
oscillator: { oscillator: {
partials: [0, 2, 3, 4], partials: [0, 2, 3, 4],
} },
}).toDestination(); }).toDestination();
piano({ piano({
parent: document.querySelector("#content"), parent: document.querySelector("#content"),
polyphonic: true, polyphonic: true,
noteon: note => synth.triggerAttack(note.name), noteon: (note) => synth.triggerAttack(note.name),
noteoff: note => synth.triggerRelease(note.name) noteoff: (note) => synth.triggerRelease(note.name),
}); });
ui({ ui({

View file

@ -1,14 +1,25 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>Reverb</title> <title>Reverb</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png"> 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://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script> <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"/> <link
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
rel="stylesheet"
/>
<script src="../build/Tone.js"></script> <script src="../build/Tone.js"></script>
<script src="./js/tone-ui.js"></script> <script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script> <script src="./js/components.js"></script>
@ -21,11 +32,14 @@
</style> </style>
<tone-example label="Reverb"> <tone-example label="Reverb">
<div slot="explanation"> <div slot="explanation">
<a href="https://tonejs.github.io/docs/Reverb">Tone.Reverb</a> <a href="https://tonejs.github.io/docs/latest/classes/Reverb"
is a convolution-based reverb. An impulse response is created with a >Tone.Reverb</a
decaying noise burst when you click 'Generate Reverb'. The 'Decay Time' controls >
how long the noise burst lasts. If the 'Decay Time' is changed, a new noise burst is a convolution-based reverb. An impulse response is created
will need to be generated. with a decaying noise burst when you click 'Generate Reverb'.
The 'Decay Time' controls how long the noise burst lasts. If the
'Decay Time' is changed, a new noise burst will need to be
generated.
</div> </div>
<div id="content"> <div id="content">
@ -44,13 +58,16 @@
ui({ ui({
parent: document.querySelector("#content"), parent: document.querySelector("#content"),
tone: reverb tone: reverb,
}); });
// bind the interface // bind the interface
document.querySelector("tone-play-toggle").addEventListener("start", () => player.start()); document
document.querySelector("tone-play-toggle").addEventListener("stop", () => player.stop()); .querySelector("tone-play-toggle")
.addEventListener("start", () => player.start());
document
.querySelector("tone-play-toggle")
.addEventListener("stop", () => player.stop());
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,14 +1,25 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>Sampler</title> <title>Sampler</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png"> 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://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script> <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"/> <link
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
rel="stylesheet"
/>
<script src="../build/Tone.js"></script> <script src="../build/Tone.js"></script>
<script src="./js/tone-ui.js"></script> <script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script> <script src="./js/components.js"></script>
@ -23,11 +34,20 @@
<tone-loader></tone-loader> <tone-loader></tone-loader>
<div slot="explanation"> <div slot="explanation">
<a href="https://tonejs.github.io/docs/Sampler" target="_blank">Tone.Sampler</a> makes it easy to create an instrument from audio samples. Pass in an object which maps the note's pitch or midi value to the url, then you can trigger the attack and release of that note like other instruments. By automatically repitching the samples, it is possible to play pitches which were not explicitly included which can save loading time. <a
href="https://tonejs.github.io/docs/latest/classes/Sampler"
target="_blank"
>Tone.Sampler</a
>
makes it easy to create an instrument from audio samples. Pass
in an object which maps the note's pitch or midi value to the
url, then you can trigger the attack and release of that note
like other instruments. By automatically repitching the samples,
it is possible to play pitches which were not explicitly
included which can save loading time.
</div> </div>
<div id="content"> <div id="content"></div>
</div>
</tone-example> </tone-example>
<script type="text/javascript"> <script type="text/javascript">
@ -62,18 +82,17 @@
"D#7": "Ds7.mp3", "D#7": "Ds7.mp3",
"F#7": "Fs7.mp3", "F#7": "Fs7.mp3",
A7: "A7.mp3", A7: "A7.mp3",
C8: "C8.mp3" C8: "C8.mp3",
}, },
release: 1, release: 1,
baseUrl: "https://tonejs.github.io/audio/salamander/" baseUrl: "https://tonejs.github.io/audio/salamander/",
}).toDestination(); }).toDestination();
piano({ piano({
parent: document.querySelector("#content"), parent: document.querySelector("#content"),
noteon: note => sampler.triggerAttack(note.name), noteon: (note) => sampler.triggerAttack(note.name),
noteoff: note => sampler.triggerRelease(note.name), noteoff: (note) => sampler.triggerRelease(note.name),
}); });
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,14 +1,25 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>Signal</title> <title>Signal</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png"> 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://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script> <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"/> <link
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
rel="stylesheet"
/>
<script src="../build/Tone.js"></script> <script src="../build/Tone.js"></script>
<script src="./js/tone-ui.js"></script> <script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script> <script src="./js/components.js"></script>
@ -25,22 +36,34 @@
<body> <body>
<tone-example label="Control Voltage"> <tone-example label="Control Voltage">
<div slot="explanation"> <div slot="explanation">
One of the most powerful features of Tone.js and the Web Audio API is the ability to One of the most powerful features of Tone.js and the Web Audio
perform math and logic on audio-rate signal. Signals API is the ability to perform math and logic on audio-rate
can be ramped and scheduled to control Audio Parameters and signal. Signals can be ramped and scheduled to control Audio
other Signals making it simple to create elaborate, Parameters and other Signals making it simple to create
interconnected automations. elaborate, interconnected automations.
<br><br> <br /><br />
This example applies a series of mappings to a This example applies a series of mappings to a signal value and
signal value and applies the results of those mappings applies the results of those mappings to the frequency attribute
to the frequency attribute of 2 of 2
<a href="https://tonejs.github.io/docs/Oscillator">Tone.Oscillators</a> <a
and a <a href="https://tonejs.github.io/docs/LFO">Tone.LFO</a>. href="https://tonejs.github.io/docs/latest/classes/Oscillator"
>Tone.Oscillators</a
>
and a
<a href="https://tonejs.github.io/docs/latest/classes/LFO"
>Tone.LFO</a
>.
</div> </div>
<div id="content"> <div id="content">
<tone-play-toggle></tone-play-toggle> <tone-play-toggle></tone-play-toggle>
<tone-slider label="Modulation Rate" min="0.1" max="1" exp="2" value="0.5"></tone-slider> <tone-slider
label="Modulation Rate"
min="0.1"
max="1"
exp="2"
value="0.5"
></tone-slider>
</div> </div>
</tone-example> </tone-example>
@ -51,12 +74,12 @@
// two oscillators panned hard left / hard right // two oscillators panned hard left / hard right
const rightOsc = new Tone.Oscillator({ const rightOsc = new Tone.Oscillator({
type: "sawtooth", type: "sawtooth",
volume: -20 volume: -20,
}).connect(merge, 0, 0); }).connect(merge, 0, 0);
const leftOsc = new Tone.Oscillator({ const leftOsc = new Tone.Oscillator({
type: "square", type: "square",
volume: -20 volume: -20,
}).connect(merge, 0, 1); }).connect(merge, 0, 1);
// create an oscillation that goes from 0 to 1200 // create an oscillation that goes from 0 to 1200
@ -64,8 +87,10 @@
const detuneLFO = new Tone.LFO({ const detuneLFO = new Tone.LFO({
type: "square", type: "square",
min: 0, min: 0,
max: 1200 max: 1200,
}).fan(rightOsc.detune, leftOsc.detune).start(); })
.fan(rightOsc.detune, leftOsc.detune)
.start();
// the frequency signal // the frequency signal
const frequency = new Tone.Signal(0.5); const frequency = new Tone.Signal(0.5);
@ -86,21 +111,25 @@
frequency.chain(detuneScale, detuneLFO.frequency); frequency.chain(detuneScale, detuneLFO.frequency);
// start the oscillators with the play button // start the oscillators with the play button
document.querySelector("tone-play-toggle").addEventListener("start", () => { document
.querySelector("tone-play-toggle")
.addEventListener("start", () => {
rightOsc.start(); rightOsc.start();
leftOsc.start(); leftOsc.start();
}); });
document.querySelector("tone-play-toggle").addEventListener("stop", () => { document
.querySelector("tone-play-toggle")
.addEventListener("stop", () => {
rightOsc.stop(); rightOsc.stop();
leftOsc.stop(); leftOsc.stop();
}); });
// ramp the frequency with the slider // ramp the frequency with the slider
document.querySelector("tone-slider").addEventListener("input", e => { document
.querySelector("tone-slider")
.addEventListener("input", (e) => {
frequency.rampTo(parseFloat(e.target.value), 0.1); frequency.rampTo(parseFloat(e.target.value), 0.1);
}); });
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,14 +1,25 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>Synth</title> <title>Synth</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png"> 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://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script> <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"/> <link
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
rel="stylesheet"
/>
<script src="../build/Tone.js"></script> <script src="../build/Tone.js"></script>
<script src="./js/tone-ui.js"></script> <script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script> <script src="./js/components.js"></script>
@ -21,14 +32,26 @@
</style> </style>
<tone-example label="Synth"> <tone-example label="Synth">
<div slot="explanation"> <div slot="explanation">
<a href="https://tonejs.github.io/docs/Synth" target="_blank">Tone.Synth</a> is composed simply of a <a
<a href="https://tonejs.github.io/docs/OmniOscillator" target="_blank">Tone.OmniOscillator</a> href="https://tonejs.github.io/docs/latest/classes/Synth"
target="_blank"
>Tone.Synth</a
>
is composed simply of a
<a
href="https://tonejs.github.io/docs/latest/classes/OmniOscillator"
target="_blank"
>Tone.OmniOscillator</a
>
routed through a routed through a
<a href="https://tonejs.github.io/docs/AmplitudeEnvelope" target="_blank">Tone.AmplitudeEnvelope</a>. <a
href="https://tonejs.github.io/docs/latest/classes/AmplitudeEnvelope"
target="_blank"
>Tone.AmplitudeEnvelope</a
>.
</div> </div>
<div id="content"> <div id="content"></div>
</div>
</tone-example> </tone-example>
<script type="text/javascript"> <script type="text/javascript">
@ -36,7 +59,7 @@
oscillator: { oscillator: {
type: "amtriangle", type: "amtriangle",
harmonicity: 0.5, harmonicity: 0.5,
modulationType: "sine" modulationType: "sine",
}, },
envelope: { envelope: {
attackCurve: "exponential", attackCurve: "exponential",
@ -45,14 +68,14 @@
sustain: 0.2, sustain: 0.2,
release: 1.5, release: 1.5,
}, },
portamento: 0.05 portamento: 0.05,
}).toDestination(); }).toDestination();
piano({ piano({
tone: synth, tone: synth,
parent: document.querySelector("#content"), parent: document.querySelector("#content"),
noteon: (note) => synth.triggerAttack(note.name), noteon: (note) => synth.triggerAttack(note.name),
noteoff: (note) => synth.triggerRelease() noteoff: (note) => synth.triggerRelease(),
}); });
ui({ ui({
@ -60,7 +83,6 @@
name: "Synth", name: "Synth",
parent: document.querySelector("#content"), parent: document.querySelector("#content"),
}); });
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,14 +1,25 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>Step Sequencer</title> <title>Step Sequencer</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png"> 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://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script> <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"/> <link
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
rel="stylesheet"
/>
<script src="../build/Tone.js"></script> <script src="../build/Tone.js"></script>
<script src="./js/tone-ui.js"></script> <script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script> <script src="./js/components.js"></script>
@ -22,13 +33,25 @@
<tone-example label="Step Sequencer"> <tone-example label="Step Sequencer">
<tone-loader></tone-loader> <tone-loader></tone-loader>
<div slot="explanation"> <div slot="explanation">
<a href="https://tonejs.github.io/docs/Transport">Tone.Transport</a> <a
is the application-wide timekeeper. It's clock source enables sample-accurate scheduling as well as tempo-curves and automation. This example uses Tone.Sequence to invoke a callback every 16th note. href="https://tonejs.github.io/docs/latest/functions/getTransport.html"
>Tone.Transport</a
>
is the application-wide timekeeper. It's clock source enables
sample-accurate scheduling as well as tempo-curves and
automation. This example uses Tone.Sequence to invoke a callback
every 16th note.
</div> </div>
<div id="content"> <div id="content">
<tone-play-toggle></tone-play-toggle> <tone-play-toggle></tone-play-toggle>
<tone-slider label="tempo" units="bpm" min="60" max="240" value="120"></tone-slider> <tone-slider
label="tempo"
units="bpm"
min="60"
max="240"
value="120"
></tone-slider>
<tone-step-sequencer></tone-step-sequencer> <tone-step-sequencer></tone-step-sequencer>
</div> </div>
</tone-example> </tone-example>
@ -42,16 +65,27 @@
3: "Fs2.mp3", 3: "Fs2.mp3",
}, },
fadeOut: "64n", fadeOut: "64n",
baseUrl: "https://tonejs.github.io/audio/casio/" baseUrl: "https://tonejs.github.io/audio/casio/",
}).toDestination(); }).toDestination();
document.querySelector("tone-play-toggle").addEventListener("start", () => Tone.Transport.start()); document
document.querySelector("tone-play-toggle").addEventListener("stop", () => Tone.Transport.stop()); .querySelector("tone-play-toggle")
document.querySelector("tone-slider").addEventListener("input", (e) => Tone.Transport.bpm.value = parseFloat(e.target.value)); .addEventListener("start", () => Tone.Transport.start());
document.querySelector("tone-step-sequencer").addEventListener("trigger", ({ detail }) => { document
.querySelector("tone-play-toggle")
.addEventListener("stop", () => Tone.Transport.stop());
document
.querySelector("tone-slider")
.addEventListener(
"input",
(e) =>
(Tone.Transport.bpm.value = parseFloat(e.target.value))
);
document
.querySelector("tone-step-sequencer")
.addEventListener("trigger", ({ detail }) => {
keys.player(detail.row).start(detail.time, 0, "16t"); keys.player(detail.row).start(detail.time, 0, "16t");
}); });
</script> </script>
</body> </body>
</html> </html>