mirror of
https://github.com/Tonejs/Tone.js
synced 2024-12-25 11:03:07 +00:00
updating example links
This commit is contained in:
parent
f06ff17f06
commit
77a8e225f4
25 changed files with 2455 additions and 1760 deletions
|
@ -1,13 +1,24 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>AMSynth</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="174x174"
|
||||
href="./favicon.png"
|
||||
/>
|
||||
<script src="https://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="./js/tone-ui.js"></script>
|
||||
<script src="./js/components.js"></script>
|
||||
|
@ -15,42 +26,46 @@
|
|||
<body>
|
||||
<tone-example label="AMSynth">
|
||||
<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
|
||||
<a href="https://tonejs.github.io/docs/Synth">Tone.Synths</a>
|
||||
where one Tone.Synth modulates the amplitude of a second Tone.Synth.
|
||||
<a href="https://tonejs.github.io/docs/latest/classes/Synth"
|
||||
>Tone.Synths</a
|
||||
>
|
||||
where one Tone.Synth modulates the amplitude of a second
|
||||
Tone.Synth.
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
</div>
|
||||
<div id="content"></div>
|
||||
</tone-example>
|
||||
|
||||
<script type="text/javascript">
|
||||
const synth = new Tone.AMSynth({
|
||||
harmonicity: 2.5,
|
||||
oscillator: {
|
||||
type: "fatsawtooth"
|
||||
type: "fatsawtooth",
|
||||
},
|
||||
envelope: {
|
||||
attack: 0.1,
|
||||
decay: 0.2,
|
||||
sustain: 0.2,
|
||||
release: 0.3
|
||||
release: 0.3,
|
||||
},
|
||||
modulation: {
|
||||
type: "square"
|
||||
type: "square",
|
||||
},
|
||||
modulationEnvelope: {
|
||||
attack: 0.5,
|
||||
decay: 0.01
|
||||
}
|
||||
decay: 0.01,
|
||||
},
|
||||
}).toDestination();
|
||||
|
||||
piano({
|
||||
tone: synth,
|
||||
parent: document.querySelector("#content"),
|
||||
noteon: (note) => synth.triggerAttack(note.name),
|
||||
noteoff: (note) => synth.triggerRelease()
|
||||
noteoff: (note) => synth.triggerRelease(),
|
||||
});
|
||||
|
||||
ui({
|
||||
|
@ -58,7 +73,6 @@
|
|||
name: "AMSynth",
|
||||
parent: document.querySelector("#content"),
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,27 +1,46 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>Analyser</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="174x174"
|
||||
href="./favicon.png"
|
||||
/>
|
||||
|
||||
<script src="https://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="./js/tone-ui.js"></script>
|
||||
<script src="./js/components.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<tone-example label="Analyser">
|
||||
<tone-loader></tone-loader>
|
||||
|
||||
<div slot="explanation">
|
||||
<a href="https://tonejs.github.io/docs/FFT" target="_blank">Tone.FFT</a>
|
||||
returns the amplitude of the incoming signal at different frequencies.
|
||||
<a href="https://tonejs.github.io/docs/Waveform" target="_blank">Tone.Waveform</a>
|
||||
<a
|
||||
href="https://tonejs.github.io/docs/latest/classes/FFT"
|
||||
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.
|
||||
</div>
|
||||
|
||||
|
@ -33,7 +52,7 @@
|
|||
<script type="text/javascript">
|
||||
const player = new Tone.Player({
|
||||
url: "https://tonejs.github.io/audio/berklee/arpeggio2.mp3",
|
||||
loop: true
|
||||
loop: true,
|
||||
}).toDestination();
|
||||
|
||||
const toneMeter = new Tone.Meter();
|
||||
|
@ -52,20 +71,23 @@
|
|||
});
|
||||
meter({
|
||||
tone: toneMeter,
|
||||
parent: document.querySelector("#content")
|
||||
parent: document.querySelector("#content"),
|
||||
});
|
||||
fft({
|
||||
tone: toneFFT,
|
||||
parent: document.querySelector("#content")
|
||||
parent: document.querySelector("#content"),
|
||||
});
|
||||
waveform({
|
||||
tone: toneWaveform,
|
||||
parent: document.querySelector("#content")
|
||||
parent: document.querySelector("#content"),
|
||||
});
|
||||
|
||||
document.querySelector("tone-play-toggle").addEventListener("start", () => player.start());
|
||||
document.querySelector("tone-play-toggle").addEventListener("stop", () => player.stop());
|
||||
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("start", () => player.start());
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("stop", () => player.stop());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,28 +1,48 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>MetalSynth</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="174x174"
|
||||
href="./favicon.png"
|
||||
/>
|
||||
|
||||
<script src="https://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="./js/tone-ui.js"></script>
|
||||
<script src="./js/components.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<tone-example label="Bembe">
|
||||
<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
|
||||
<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.
|
||||
<a href="https://tonejs.github.io/docs/MembraneSynth">Tone.MembraneSynth</a>
|
||||
makes kick and tom-like sounds using a frequency envelope which is triggered on notes attack.
|
||||
<a
|
||||
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 id="content">
|
||||
|
@ -38,16 +58,21 @@
|
|||
envelope: {
|
||||
decay: 0.4,
|
||||
},
|
||||
volume: -15
|
||||
volume: -15,
|
||||
}).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);
|
||||
}), [[300, null, 200],
|
||||
},
|
||||
[
|
||||
[300, null, 200],
|
||||
[null, 200, 200],
|
||||
[null, 200, null],
|
||||
[200, null, 200]
|
||||
], "4n").start(0);
|
||||
[200, null, 200],
|
||||
],
|
||||
"4n"
|
||||
).start(0);
|
||||
|
||||
const conga = new Tone.MembraneSynth({
|
||||
pitchDecay: 0.008,
|
||||
|
@ -55,28 +80,37 @@
|
|||
envelope: {
|
||||
attack: 0.0006,
|
||||
decay: 0.5,
|
||||
sustain: 0
|
||||
}
|
||||
sustain: 0,
|
||||
},
|
||||
}).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);
|
||||
}), ["G3", "C4", "C4", "C4"], "4n").start(0);
|
||||
},
|
||||
["G3", "C4", "C4", "C4"],
|
||||
"4n"
|
||||
).start(0);
|
||||
|
||||
Tone.Transport.bpm.value = 115;
|
||||
|
||||
drawer().add({
|
||||
drawer()
|
||||
.add({
|
||||
tone: conga,
|
||||
title: "Conga"
|
||||
}).add({
|
||||
title: "Conga",
|
||||
})
|
||||
.add({
|
||||
tone: bell,
|
||||
title: "Bell"
|
||||
title: "Bell",
|
||||
});
|
||||
|
||||
// connect the UI with the components
|
||||
document.querySelector("tone-play-toggle").addEventListener("start", () => Tone.Transport.start());
|
||||
document.querySelector("tone-play-toggle").addEventListener("stop", () => Tone.Transport.stop());
|
||||
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("start", () => Tone.Transport.start());
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("stop", () => Tone.Transport.stop());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>Buses</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="174x174"
|
||||
href="./favicon.png"
|
||||
/>
|
||||
|
||||
<script src="https://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="./js/tone-ui.js"></script>
|
||||
<script src="./js/components.js"></script>
|
||||
|
@ -16,18 +27,44 @@
|
|||
<body>
|
||||
<tone-example label="Buses">
|
||||
<div slot="explanation">
|
||||
Buses make it easy to share effects across many instruments. <code>send</code>
|
||||
audio to a named bus from an instrument and then <code>receive</code> that
|
||||
channel on your effect. The gain values are all in decibels.
|
||||
<br><br>
|
||||
Docs on <a href="https://tonejs.github.io/docs/Channel.html#send">send</a> and
|
||||
<a href="https://tonejs.github.io/docs/Channel.html#receive">receive</a>.
|
||||
Buses make it easy to share effects across many instruments.
|
||||
<code>send</code> audio to a named bus from an instrument and
|
||||
then <code>receive</code> that channel on your effect. The gain
|
||||
values are all in decibels. <br /><br />
|
||||
Docs on
|
||||
<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 id="content">
|
||||
<tone-play-toggle></tone-play-toggle>
|
||||
<tone-slider label="Chorus Send" 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>
|
||||
<tone-slider
|
||||
label="Chorus Send"
|
||||
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>
|
||||
</tone-example>
|
||||
|
||||
|
@ -41,16 +78,24 @@
|
|||
// make some effects
|
||||
const chorus = new Tone.Chorus({
|
||||
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");
|
||||
|
||||
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");
|
||||
|
||||
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");
|
||||
|
||||
// send the player to all of the channels
|
||||
|
@ -60,23 +105,36 @@
|
|||
playerChannel.send("reverb");
|
||||
player.connect(playerChannel);
|
||||
|
||||
drawer().add({
|
||||
drawer()
|
||||
.add({
|
||||
tone: chorus,
|
||||
}).add({
|
||||
})
|
||||
.add({
|
||||
tone: reverb,
|
||||
}).add({
|
||||
})
|
||||
.add({
|
||||
tone: cheby,
|
||||
});
|
||||
document.querySelector("tone-play-toggle").addEventListener("start", () => player.start());
|
||||
document.querySelector("tone-play-toggle").addEventListener("stop", () => player.stop());
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("start", () => player.start());
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("stop", () => player.stop());
|
||||
// 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);
|
||||
});
|
||||
document.querySelector("[label=\"Chebyshev Send\"]").addEventListener("input", e => {
|
||||
document
|
||||
.querySelector('[label="Chebyshev Send"]')
|
||||
.addEventListener("input", (e) => {
|
||||
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);
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>Envelope</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="174x174"
|
||||
href="./favicon.png"
|
||||
/>
|
||||
|
||||
<script src="https://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="./js/tone-ui.js"></script>
|
||||
<script src="./js/components.js"></script>
|
||||
|
@ -27,17 +38,27 @@
|
|||
</style>
|
||||
<tone-example label="Envelope">
|
||||
<div slot="explanation">
|
||||
Envelopes ramp amplitude, frequency or any other parameter over time.
|
||||
<a href="https://tonejs.github.io/docs/Envelope">Tone.Envelope</a> 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">
|
||||
Envelopes ramp amplitude, frequency or any other parameter over
|
||||
time.
|
||||
<a href="https://tonejs.github.io/docs/latest/classes/Envelope"
|
||||
>Tone.Envelope</a
|
||||
>
|
||||
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 id="content">
|
||||
<tone-momentary-button></tone-momentary-button>
|
||||
</div>
|
||||
|
||||
</tone-example>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
@ -45,7 +66,7 @@
|
|||
attack: 0.11,
|
||||
decay: 0.21,
|
||||
sustain: 0.5,
|
||||
release: 1.2
|
||||
release: 1.2,
|
||||
}).toDestination();
|
||||
|
||||
// create an oscillator and connect it to the envelope
|
||||
|
@ -54,18 +75,26 @@
|
|||
type: "custom",
|
||||
frequency: "C#4",
|
||||
volume: -8,
|
||||
}).connect(env).start();
|
||||
})
|
||||
.connect(env)
|
||||
.start();
|
||||
|
||||
// bind the interface
|
||||
drawer().add({
|
||||
drawer()
|
||||
.add({
|
||||
tone: env,
|
||||
name: "Envelope"
|
||||
}).add({
|
||||
name: "Envelope",
|
||||
})
|
||||
.add({
|
||||
tone: osc,
|
||||
});
|
||||
|
||||
document.querySelector("tone-momentary-button").addEventListener("down", e => env.triggerAttack());
|
||||
document.querySelector("tone-momentary-button").addEventListener("up", e => env.triggerRelease());
|
||||
document
|
||||
.querySelector("tone-momentary-button")
|
||||
.addEventListener("down", (e) => env.triggerAttack());
|
||||
document
|
||||
.querySelector("tone-momentary-button")
|
||||
.addEventListener("up", (e) => env.triggerRelease());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>Events</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="174x174"
|
||||
href="./favicon.png"
|
||||
/>
|
||||
|
||||
<script src="https://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="./js/tone-ui.js"></script>
|
||||
<script src="./js/components.js"></script>
|
||||
|
@ -16,15 +27,37 @@
|
|||
<body>
|
||||
<tone-example label="Events">
|
||||
<div slot="explanation">
|
||||
Tone's Event classes (<a href="https://tonejs.github.io/docs/ToneEvent">Tone.ToneEvent</a>,
|
||||
<a href="https://tonejs.github.io/docs/Loop">Tone.Loop</a>,
|
||||
<a href="https://tonejs.github.io/docs/Part">Tone.Part</a> and
|
||||
<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/Transport.schedule">Transport.schedule</a> or
|
||||
<a href="https://tonejs.github.io/docs/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/Event">Event</a> before Tone.js 14.x)
|
||||
Tone's Event classes (<a
|
||||
href="https://tonejs.github.io/docs/latest/classes/ToneEvent"
|
||||
>Tone.ToneEvent</a
|
||||
>,
|
||||
<a href="https://tonejs.github.io/docs/latest/classes/Loop"
|
||||
>Tone.Loop</a
|
||||
>,
|
||||
<a href="https://tonejs.github.io/docs/latest/classes/Part"
|
||||
>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 id="content">
|
||||
|
@ -40,15 +73,15 @@
|
|||
envelope: {
|
||||
sustain: 0,
|
||||
attack: 0.02,
|
||||
decay: 0.8
|
||||
decay: 0.8,
|
||||
},
|
||||
octaves: 10,
|
||||
pitchDecay: 0.01,
|
||||
}).toDestination();
|
||||
|
||||
const kickPart = new Tone.Loop(((time) => {
|
||||
const kickPart = new Tone.Loop((time) => {
|
||||
kick.triggerAttackRelease("C2", "8n", time);
|
||||
}), "2n").start(0);
|
||||
}, "2n").start(0);
|
||||
|
||||
/**
|
||||
* SNARE
|
||||
|
@ -58,13 +91,13 @@
|
|||
envelope: {
|
||||
attack: 0.001,
|
||||
decay: 0.2,
|
||||
sustain: 0
|
||||
}
|
||||
sustain: 0,
|
||||
},
|
||||
}).toDestination();
|
||||
|
||||
const snarePart = new Tone.Loop(((time) => {
|
||||
const snarePart = new Tone.Loop((time) => {
|
||||
snare.triggerAttack(time);
|
||||
}), "2n").start("4n");
|
||||
}, "2n").start("4n");
|
||||
|
||||
/**
|
||||
* PIANO
|
||||
|
@ -80,9 +113,19 @@
|
|||
const dChord = ["D4", "F4", "A4", "C5"];
|
||||
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);
|
||||
}), [["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.loopEnd = "1m";
|
||||
|
@ -103,41 +146,52 @@
|
|||
decay: 0.01,
|
||||
sustain: 0.5,
|
||||
baseFrequency: 200,
|
||||
octaves: 2.6
|
||||
}
|
||||
octaves: 2.6,
|
||||
},
|
||||
}).toDestination();
|
||||
|
||||
const bassPart = new Tone.Sequence(((time, note) => {
|
||||
const bassPart = new Tone.Sequence(
|
||||
(time, note) => {
|
||||
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;
|
||||
|
||||
// set the transport
|
||||
Tone.Transport.bpm.value = 90;
|
||||
|
||||
drawer().add({
|
||||
drawer()
|
||||
.add({
|
||||
name: "Kick",
|
||||
tone: kick,
|
||||
open: false,
|
||||
}).add({
|
||||
})
|
||||
.add({
|
||||
name: "Snare",
|
||||
tone: snare,
|
||||
open: false,
|
||||
}).add({
|
||||
})
|
||||
.add({
|
||||
name: "Bass",
|
||||
tone: bass,
|
||||
open: false,
|
||||
}).add({
|
||||
})
|
||||
.add({
|
||||
name: "Keys",
|
||||
tone: keys,
|
||||
open: false,
|
||||
});
|
||||
|
||||
// bind the interface
|
||||
document.querySelector("tone-play-toggle").addEventListener("start", e => Tone.Transport.start());
|
||||
document.querySelector("tone-play-toggle").addEventListener("stop", e => Tone.Transport.stop());
|
||||
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("start", (e) => Tone.Transport.start());
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("stop", (e) => Tone.Transport.stop());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>FMSynth</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="174x174"
|
||||
href="./favicon.png"
|
||||
/>
|
||||
|
||||
<script src="https://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="./js/tone-ui.js"></script>
|
||||
<script src="./js/components.js"></script>
|
||||
|
@ -16,14 +27,18 @@
|
|||
<body>
|
||||
<tone-example label="FMSynth">
|
||||
<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
|
||||
<a href="https://tonejs.github.io/docs/Synth">Tone.Synths</a>
|
||||
where one Tone.Synth modulates the frequency of a second Tone.Synth.
|
||||
<a href="https://tonejs.github.io/docs/latest/classes/Synth"
|
||||
>Tone.Synths</a
|
||||
>
|
||||
where one Tone.Synth modulates the frequency of a second
|
||||
Tone.Synth.
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
</div>
|
||||
<div id="content"></div>
|
||||
</tone-example>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
@ -31,22 +46,22 @@
|
|||
modulationIndex: 12.22,
|
||||
envelope: {
|
||||
attack: 0.01,
|
||||
decay: 0.2
|
||||
decay: 0.2,
|
||||
},
|
||||
modulation: {
|
||||
type: "square"
|
||||
type: "square",
|
||||
},
|
||||
modulationEnvelope: {
|
||||
attack: 0.2,
|
||||
decay: 0.01
|
||||
}
|
||||
decay: 0.01,
|
||||
},
|
||||
}).toDestination();
|
||||
|
||||
piano({
|
||||
tone: synth,
|
||||
parent: document.querySelector("#content"),
|
||||
noteon: (note) => synth.triggerAttack(note.name),
|
||||
noteoff: (note) => synth.triggerRelease()
|
||||
noteoff: (note) => synth.triggerRelease(),
|
||||
});
|
||||
|
||||
ui({
|
||||
|
|
|
@ -1,21 +1,33 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>Grain Player</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="174x174"
|
||||
href="./favicon.png"
|
||||
/>
|
||||
|
||||
<script src="https://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="./js/tone-ui.js"></script>
|
||||
<script src="./js/components.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<style type="text/css">
|
||||
tone-play-toggle, tone-fft {
|
||||
tone-play-toggle,
|
||||
tone-fft {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
|
@ -28,11 +40,18 @@
|
|||
</style>
|
||||
<tone-example label="Granular Synthesis">
|
||||
<div slot="explanation">
|
||||
<a href="https://tonejs.github.io/docs/GrainPlayer">Tone.GrainPlayer</a> 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.
|
||||
<a
|
||||
href="https://tonejs.github.io/docs/latest/classes/GrainPlayer"
|
||||
>Tone.GrainPlayer</a
|
||||
>
|
||||
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>
|
||||
|
||||
<tone-loader></tone-loader>
|
||||
|
@ -57,9 +76,12 @@
|
|||
});
|
||||
|
||||
// bind the interface
|
||||
document.querySelector("tone-play-toggle").addEventListener("start", () => player.start());
|
||||
document.querySelector("tone-play-toggle").addEventListener("stop", () => player.stop());
|
||||
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("start", () => player.start());
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("stop", () => player.stop());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>FatOscillator</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="174x174"
|
||||
href="./favicon.png"
|
||||
/>
|
||||
|
||||
<script src="https://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="./js/tone-ui.js"></script>
|
||||
<script src="./js/components.js"></script>
|
||||
|
@ -21,14 +32,28 @@
|
|||
</style>
|
||||
<tone-example label="Supersaw">
|
||||
<div slot="explanation">
|
||||
<a href="https://tonejs.github.io/docs/FatOscillator">Tone.FatOscillator</a> creates multiple oscillators
|
||||
and detunes them slightly from each other to thicken the sound. The <code>count</code> parameter sets
|
||||
the number of oscillators and <code>spread</code> sets the total spread (in cents) between the oscillators.
|
||||
<br><br>
|
||||
FatOscillator is also available in <a href="https://tonejs.github.io/docs/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>
|
||||
<a
|
||||
href="https://tonejs.github.io/docs/latest/classes/FatOscillator"
|
||||
>Tone.FatOscillator</a
|
||||
>
|
||||
creates multiple oscillators and detunes them slightly from each
|
||||
other to thicken the sound. The <code>count</code> parameter
|
||||
sets the number of oscillators and <code>spread</code> sets the
|
||||
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 id="content">
|
||||
|
@ -41,214 +66,223 @@
|
|||
oscillator: {
|
||||
type: "fatsawtooth",
|
||||
count: 3,
|
||||
spread: 30
|
||||
spread: 30,
|
||||
},
|
||||
envelope: {
|
||||
attack: 0.01,
|
||||
decay: 0.1,
|
||||
sustain: 0.5,
|
||||
release: 0.4,
|
||||
attackCurve: "exponential"
|
||||
attackCurve: "exponential",
|
||||
},
|
||||
}).toDestination();
|
||||
|
||||
// Van Halen - Jump MIDI from http://www.midiworld.com/files/1121/
|
||||
// converted using
|
||||
const part = new Tone.Part(((time, note) => {
|
||||
synth.triggerAttackRelease(note.noteName, note.duration, time, note.velocity);
|
||||
}), [{
|
||||
const part = new Tone.Part(
|
||||
(time, note) => {
|
||||
synth.triggerAttackRelease(
|
||||
note.noteName,
|
||||
note.duration,
|
||||
time,
|
||||
note.velocity
|
||||
);
|
||||
},
|
||||
[
|
||||
{
|
||||
time: "192i",
|
||||
noteName: "G4",
|
||||
velocity: 0.8110236220472441,
|
||||
duration: "104i"
|
||||
duration: "104i",
|
||||
},
|
||||
{
|
||||
time: "192i",
|
||||
noteName: "B4",
|
||||
velocity: 0.7874015748031497,
|
||||
duration: "104i"
|
||||
duration: "104i",
|
||||
},
|
||||
{
|
||||
time: "192i",
|
||||
noteName: "D5",
|
||||
velocity: 0.8031496062992126,
|
||||
duration: "104i"
|
||||
duration: "104i",
|
||||
},
|
||||
{
|
||||
time: "480i",
|
||||
noteName: "G4",
|
||||
velocity: 0.7559055118110236,
|
||||
duration: "104i"
|
||||
duration: "104i",
|
||||
},
|
||||
{
|
||||
time: "480i",
|
||||
noteName: "C5",
|
||||
velocity: 0.6850393700787402,
|
||||
duration: "104i"
|
||||
duration: "104i",
|
||||
},
|
||||
{
|
||||
time: "480i",
|
||||
noteName: "E5",
|
||||
velocity: 0.6771653543307087,
|
||||
duration: "104i"
|
||||
duration: "104i",
|
||||
},
|
||||
{
|
||||
time: "768i",
|
||||
noteName: "F4",
|
||||
velocity: 0.8661417322834646,
|
||||
duration: "104i"
|
||||
duration: "104i",
|
||||
},
|
||||
{
|
||||
time: "768i",
|
||||
noteName: "A4",
|
||||
velocity: 0.8346456692913385,
|
||||
duration: "104i"
|
||||
duration: "104i",
|
||||
},
|
||||
{
|
||||
time: "768i",
|
||||
noteName: "C5",
|
||||
velocity: 0.8188976377952756,
|
||||
duration: "104i"
|
||||
duration: "104i",
|
||||
},
|
||||
{
|
||||
time: "1056i",
|
||||
noteName: "F4",
|
||||
velocity: 0.7007874015748031,
|
||||
duration: "104i"
|
||||
duration: "104i",
|
||||
},
|
||||
{
|
||||
time: "1056i",
|
||||
noteName: "A4",
|
||||
velocity: 0.6850393700787402,
|
||||
duration: "104i"
|
||||
duration: "104i",
|
||||
},
|
||||
{
|
||||
time: "1056i",
|
||||
noteName: "C5",
|
||||
velocity: 0.6614173228346457,
|
||||
duration: "104i"
|
||||
duration: "104i",
|
||||
},
|
||||
{
|
||||
time: "1248i",
|
||||
noteName: "G4",
|
||||
velocity: 0.6771653543307087,
|
||||
duration: "104i"
|
||||
duration: "104i",
|
||||
},
|
||||
{
|
||||
time: "1248i",
|
||||
noteName: "B4",
|
||||
velocity: 0.6771653543307087,
|
||||
duration: "104i"
|
||||
duration: "104i",
|
||||
},
|
||||
{
|
||||
time: "1248i",
|
||||
noteName: "D5",
|
||||
velocity: 0.7165354330708661,
|
||||
duration: "104i"
|
||||
duration: "104i",
|
||||
},
|
||||
{
|
||||
time: "1440i",
|
||||
noteName: "G4",
|
||||
velocity: 0.8818897637795275,
|
||||
duration: "248i"
|
||||
duration: "248i",
|
||||
},
|
||||
{
|
||||
time: "1440i",
|
||||
noteName: "B4",
|
||||
velocity: 0.84251968503937,
|
||||
duration: "248i"
|
||||
duration: "248i",
|
||||
},
|
||||
{
|
||||
time: "1440i",
|
||||
noteName: "D5",
|
||||
velocity: 0.8818897637795275,
|
||||
duration: "248i"
|
||||
duration: "248i",
|
||||
},
|
||||
{
|
||||
time: "1728i",
|
||||
noteName: "G4",
|
||||
velocity: 0.8267716535433071,
|
||||
duration: "104i"
|
||||
duration: "104i",
|
||||
},
|
||||
{
|
||||
time: "1728i",
|
||||
noteName: "C5",
|
||||
velocity: 0.8031496062992126,
|
||||
duration: "104i"
|
||||
duration: "104i",
|
||||
},
|
||||
{
|
||||
time: "1728i",
|
||||
noteName: "E5",
|
||||
velocity: 0.8188976377952756,
|
||||
duration: "104i"
|
||||
duration: "104i",
|
||||
},
|
||||
{
|
||||
time: "2016i",
|
||||
noteName: "F4",
|
||||
velocity: 0.7086614173228346,
|
||||
duration: "104i"
|
||||
duration: "104i",
|
||||
},
|
||||
{
|
||||
time: "2016i",
|
||||
noteName: "A4",
|
||||
velocity: 0.7244094488188977,
|
||||
duration: "104i"
|
||||
duration: "104i",
|
||||
},
|
||||
{
|
||||
time: "2016i",
|
||||
noteName: "C5",
|
||||
velocity: 0.7007874015748031,
|
||||
duration: "104i"
|
||||
duration: "104i",
|
||||
},
|
||||
{
|
||||
time: "2208i",
|
||||
noteName: "C4",
|
||||
velocity: 0.9921259842519685,
|
||||
duration: "296i"
|
||||
duration: "296i",
|
||||
},
|
||||
{
|
||||
time: "2208i",
|
||||
noteName: "F4",
|
||||
velocity: 0.968503937007874,
|
||||
duration: "200i"
|
||||
duration: "200i",
|
||||
},
|
||||
{
|
||||
time: "2208i",
|
||||
noteName: "A4",
|
||||
velocity: 0.9606299212598425,
|
||||
duration: "208i"
|
||||
duration: "208i",
|
||||
},
|
||||
{
|
||||
time: "2400i",
|
||||
noteName: "E4",
|
||||
velocity: 0.7559055118110236,
|
||||
duration: "104i"
|
||||
duration: "104i",
|
||||
},
|
||||
{
|
||||
time: "2400i",
|
||||
noteName: "G4",
|
||||
velocity: 0.7007874015748031,
|
||||
duration: "104i"
|
||||
duration: "104i",
|
||||
},
|
||||
{
|
||||
time: "2592i",
|
||||
noteName: "C4",
|
||||
velocity: 0.968503937007874,
|
||||
duration: "488i"
|
||||
duration: "488i",
|
||||
},
|
||||
{
|
||||
time: "2592i",
|
||||
noteName: "D4",
|
||||
velocity: 0.9448818897637795,
|
||||
duration: "488i"
|
||||
duration: "488i",
|
||||
},
|
||||
{
|
||||
time: "2592i",
|
||||
noteName: "G4",
|
||||
velocity: 0.937007874015748,
|
||||
duration: "488i"
|
||||
}
|
||||
]).start(0);
|
||||
duration: "488i",
|
||||
},
|
||||
]
|
||||
).start(0);
|
||||
|
||||
part.loop = true;
|
||||
part.loopEnd = "4m";
|
||||
|
@ -260,9 +294,12 @@
|
|||
});
|
||||
|
||||
// bind the interface
|
||||
document.querySelector("tone-play-toggle").addEventListener("start", () => Tone.Transport.start());
|
||||
document.querySelector("tone-play-toggle").addEventListener("stop", () => Tone.Transport.stop());
|
||||
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("start", () => Tone.Transport.start());
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("stop", () => Tone.Transport.stop());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>LFO Effects</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="174x174"
|
||||
href="./favicon.png"
|
||||
/>
|
||||
|
||||
<script src="https://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="./js/tone-ui.js"></script>
|
||||
<script src="./js/components.js"></script>
|
||||
|
@ -16,72 +27,143 @@
|
|||
<body>
|
||||
<tone-example label="LFO Effects">
|
||||
<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.
|
||||
<br><br>
|
||||
Docs on <a href="https://tonejs.github.io/docs/AutoPanner">Tone.AutoPanner</a>,
|
||||
<a href="https://tonejs.github.io/docs/AutoFilter">Tone.AutoFilter</a>, and
|
||||
<a href="https://tonejs.github.io/docs/Tremolo">Tone.Tremolo</a>
|
||||
These effects use an
|
||||
<a href="https://tonejs.github.io/docs/latest/classes/LFO"
|
||||
>LFO</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 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-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-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-content>
|
||||
</div>
|
||||
</tone-example>
|
||||
|
||||
<script type="text/javascript">
|
||||
// AutoPanner - a panning modulation effect
|
||||
const panner = new Tone.AutoPanner({
|
||||
frequency: 4,
|
||||
depth: 1
|
||||
}).toDestination().start();
|
||||
depth: 1,
|
||||
})
|
||||
.toDestination()
|
||||
.start();
|
||||
|
||||
// AutoFilter - a filter modulation effect
|
||||
const filter = new Tone.AutoFilter({
|
||||
frequency: 2,
|
||||
depth: 0.6
|
||||
}).toDestination().start();
|
||||
depth: 0.6,
|
||||
})
|
||||
.toDestination()
|
||||
.start();
|
||||
|
||||
// Tremolo - an amplitude modulation effect
|
||||
const tremolo = new Tone.Tremolo({
|
||||
frequency: 0.6,
|
||||
depth: 0.7
|
||||
}).toDestination().start();
|
||||
depth: 0.7,
|
||||
})
|
||||
.toDestination()
|
||||
.start();
|
||||
|
||||
// the input oscillators
|
||||
const pannerOsc = new Tone.Oscillator({
|
||||
volume: -12,
|
||||
type: "square6",
|
||||
frequency: "C4"
|
||||
frequency: "C4",
|
||||
}).connect(panner);
|
||||
|
||||
const filterOsc = new Tone.Oscillator({
|
||||
volume: -12,
|
||||
type: "square6",
|
||||
frequency: "E4"
|
||||
frequency: "E4",
|
||||
}).connect(filter);
|
||||
|
||||
const tremoloOsc = new Tone.Oscillator({
|
||||
volume: -12,
|
||||
type: "square6",
|
||||
frequency: "A4"
|
||||
frequency: "A4",
|
||||
}).connect(tremolo);
|
||||
|
||||
// bind the interface
|
||||
document.querySelector("#osc0").addEventListener("start", () => pannerOsc.start());
|
||||
document.querySelector("#osc0").addEventListener("stop", () => pannerOsc.stop());
|
||||
document.querySelector("#panner").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));
|
||||
document
|
||||
.querySelector("#osc0")
|
||||
.addEventListener("start", () => pannerOsc.start());
|
||||
document
|
||||
.querySelector("#osc0")
|
||||
.addEventListener("stop", () => pannerOsc.stop());
|
||||
document
|
||||
.querySelector("#panner")
|
||||
.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>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>Meter</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="174x174"
|
||||
href="./favicon.png"
|
||||
/>
|
||||
|
||||
<script src="https://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="./js/tone-ui.js"></script>
|
||||
<script src="./js/components.js"></script>
|
||||
|
@ -17,7 +28,11 @@
|
|||
<tone-example label="Meter">
|
||||
<tone-loader></tone-loader>
|
||||
<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.
|
||||
</div>
|
||||
|
||||
|
@ -29,7 +44,7 @@
|
|||
<script type="text/javascript">
|
||||
const player = new Tone.Player({
|
||||
url: "https://tonejs.github.io/audio/berklee/Resonant_FM_laser1.mp3",
|
||||
loop: true
|
||||
loop: true,
|
||||
}).toDestination();
|
||||
|
||||
const toneMeter = new Tone.Meter({
|
||||
|
@ -39,19 +54,22 @@
|
|||
|
||||
meter({
|
||||
tone: toneMeter,
|
||||
parent: document.querySelector("#content")
|
||||
parent: document.querySelector("#content"),
|
||||
});
|
||||
|
||||
ui({
|
||||
tone: player,
|
||||
name: "Player",
|
||||
parent: document.querySelector("#content")
|
||||
parent: document.querySelector("#content"),
|
||||
});
|
||||
|
||||
// bind the interface
|
||||
document.querySelector("tone-play-toggle").addEventListener("start", () => player.start());
|
||||
document.querySelector("tone-play-toggle").addEventListener("stop", () => player.stop());
|
||||
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("start", () => player.start());
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("stop", () => player.stop());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>Mixer</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="174x174"
|
||||
href="./favicon.png"
|
||||
/>
|
||||
|
||||
<script src="https://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="./js/tone-ui.js"></script>
|
||||
<script src="./js/components.js"></script>
|
||||
|
@ -26,7 +37,15 @@
|
|||
<body>
|
||||
<tone-example label="Channel">
|
||||
<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>
|
||||
|
||||
<tone-loader></tone-loader>
|
||||
|
@ -38,19 +57,21 @@
|
|||
<script type="text/javascript">
|
||||
function makeChannel(name, url, pan) {
|
||||
const channel = new Tone.Channel({
|
||||
pan
|
||||
pan,
|
||||
}).toDestination();
|
||||
const player = new Tone.Player({
|
||||
url: `https://tonejs.github.io/audio/berklee/${url}.mp3`,
|
||||
loop: true
|
||||
}).sync().start(0);
|
||||
loop: true,
|
||||
})
|
||||
.sync()
|
||||
.start(0);
|
||||
player.connect(channel);
|
||||
|
||||
// add a UI element
|
||||
ui({
|
||||
name,
|
||||
tone: channel,
|
||||
parent: document.querySelector("#content")
|
||||
parent: document.querySelector("#content"),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -59,7 +80,7 @@
|
|||
Tone.Destination.chain(toneMeter);
|
||||
meter({
|
||||
tone: toneMeter,
|
||||
parent: document.querySelector("#content")
|
||||
parent: document.querySelector("#content"),
|
||||
});
|
||||
|
||||
makeChannel("Guitar 0", "comping1", 1);
|
||||
|
@ -67,8 +88,12 @@
|
|||
makeChannel("Guitar 2", "comping3", 0.25);
|
||||
makeChannel("Guitar 3", "comping4", -0.25);
|
||||
|
||||
document.querySelector("tone-play-toggle").addEventListener("start", () => Tone.Transport.start());
|
||||
document.querySelector("tone-play-toggle").addEventListener("stop", () => Tone.Transport.stop());
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("start", () => Tone.Transport.start());
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("stop", () => Tone.Transport.stop());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>MonoSynth</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="174x174"
|
||||
href="./favicon.png"
|
||||
/>
|
||||
|
||||
<script src="https://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="./js/tone-ui.js"></script>
|
||||
<script src="./js/components.js"></script>
|
||||
|
@ -21,20 +32,22 @@
|
|||
</style>
|
||||
<tone-example label="MonoSynth">
|
||||
<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.
|
||||
Both envelopes are triggered simultaneously when a note is triggered.
|
||||
Both envelopes are triggered simultaneously when a note is
|
||||
triggered.
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
</div>
|
||||
<div id="content"></div>
|
||||
</tone-example>
|
||||
|
||||
<script type="text/javascript">
|
||||
const synth = new Tone.PolySynth(Tone.MonoSynth, {
|
||||
volume: -8,
|
||||
oscillator: {
|
||||
type: "square8"
|
||||
type: "square8",
|
||||
},
|
||||
envelope: {
|
||||
attack: 0.05,
|
||||
|
@ -48,22 +61,21 @@
|
|||
sustain: 0.1,
|
||||
release: 0.8,
|
||||
baseFrequency: 300,
|
||||
octaves: 4
|
||||
}
|
||||
octaves: 4,
|
||||
},
|
||||
}).toDestination();
|
||||
|
||||
piano({
|
||||
noteon: (note) => synth.triggerAttack(note.name),
|
||||
noteoff: (note) => synth.triggerRelease(note.name),
|
||||
parent: document.querySelector("#content")
|
||||
parent: document.querySelector("#content"),
|
||||
});
|
||||
|
||||
ui({
|
||||
tone: synth,
|
||||
parent: document.querySelector("#content"),
|
||||
name: "MonoSynth"
|
||||
name: "MonoSynth",
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,21 +1,33 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>Noise</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="174x174"
|
||||
href="./favicon.png"
|
||||
/>
|
||||
|
||||
<script src="https://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="./js/tone-ui.js"></script>
|
||||
<script src="./js/components.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<style>
|
||||
tone-trigger, tone-oscilloscope {
|
||||
tone-trigger,
|
||||
tone-oscilloscope {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
tone-oscilloscope {
|
||||
|
@ -26,7 +38,9 @@
|
|||
</style>
|
||||
<tone-example label="Noise">
|
||||
<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!
|
||||
</div>
|
||||
|
||||
|
@ -39,7 +53,7 @@
|
|||
// make the noise and connect it to the output
|
||||
const noise = new Tone.Noise({
|
||||
volume: -10,
|
||||
type: "brown"
|
||||
type: "brown",
|
||||
}).toDestination();
|
||||
|
||||
const toneWaveform = new Tone.Waveform();
|
||||
|
@ -56,8 +70,12 @@
|
|||
});
|
||||
|
||||
// bind the inteface
|
||||
document.querySelector("tone-momentary-button").addEventListener("down", () => noise.start());
|
||||
document.querySelector("tone-momentary-button").addEventListener("up", () => noise.stop());
|
||||
document
|
||||
.querySelector("tone-momentary-button")
|
||||
.addEventListener("down", () => noise.start());
|
||||
document
|
||||
.querySelector("tone-momentary-button")
|
||||
.addEventListener("up", () => noise.stop());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>Offline</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="174x174"
|
||||
href="./favicon.png"
|
||||
/>
|
||||
|
||||
<script src="https://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="./js/tone-ui.js"></script>
|
||||
<script src="./js/components.js"></script>
|
||||
|
@ -22,9 +33,16 @@
|
|||
<tone-example label="Offline Rendering">
|
||||
<tone-loader></tone-loader>
|
||||
<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.
|
||||
<br><br>
|
||||
<a href="https://tonejs.github.io/docs/Tone#offline-static">Tone.Offline</a> docs.
|
||||
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.
|
||||
<br /><br />
|
||||
<a
|
||||
href="https://tonejs.github.io/docs/latest/functions/Offline.html"
|
||||
>Tone.Offline</a
|
||||
>
|
||||
docs.
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
@ -37,7 +55,6 @@
|
|||
const player = new Tone.Player().toDestination();
|
||||
|
||||
const renderingPromise = Tone.Offline(({ transport }) => {
|
||||
|
||||
const reverb = new Tone.Reverb().toDestination();
|
||||
|
||||
const pannerA = new Tone.Panner(-1).connect(reverb);
|
||||
|
@ -45,15 +62,19 @@
|
|||
envelope: {
|
||||
attack: 0.01,
|
||||
decay: 5,
|
||||
sustain: 0
|
||||
sustain: 0,
|
||||
},
|
||||
oscillator: {
|
||||
type: "sawtooth4"
|
||||
}
|
||||
type: "sawtooth4",
|
||||
},
|
||||
}).connect(pannerA);
|
||||
const seqA = new Tone.Sequence(((time, note) => {
|
||||
const seqA = new Tone.Sequence(
|
||||
(time, note) => {
|
||||
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;
|
||||
|
||||
const pannerB = new Tone.Panner(1).connect(reverb);
|
||||
|
@ -61,27 +82,35 @@
|
|||
envelope: {
|
||||
attack: 0.001,
|
||||
decay: 3,
|
||||
sustain: 0
|
||||
sustain: 0,
|
||||
},
|
||||
oscillator: {
|
||||
type: "square8"
|
||||
}
|
||||
type: "square8",
|
||||
},
|
||||
}).connect(pannerB);
|
||||
const seqB = new Tone.Sequence(((time, note) => {
|
||||
const seqB = new Tone.Sequence(
|
||||
(time, note) => {
|
||||
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;
|
||||
|
||||
const bass = new Tone.MonoSynth({
|
||||
envelope: {
|
||||
attack: 0.01,
|
||||
decay: 3,
|
||||
sustain: 0.1
|
||||
sustain: 0.1,
|
||||
},
|
||||
}).toDestination();
|
||||
const bassSeq = new Tone.Sequence(((time, note) => {
|
||||
const bassSeq = new Tone.Sequence(
|
||||
(time, note) => {
|
||||
bass.triggerAttackRelease(note, "1n", time);
|
||||
}), ["C2", "C2", "F1", "F1"], "4n").start(0);
|
||||
},
|
||||
["C2", "C2", "F1", "F1"],
|
||||
"4n"
|
||||
).start(0);
|
||||
bassSeq.loop = false;
|
||||
|
||||
transport.bpm.value = 150;
|
||||
|
@ -92,12 +121,19 @@
|
|||
}, 7);
|
||||
|
||||
// set the buffer when it's done
|
||||
renderingPromise.then(buffer => player.buffer = buffer);
|
||||
renderingPromise.then(() => document.querySelector("tone-play-toggle").disabled = false);
|
||||
|
||||
document.querySelector("tone-play-toggle").addEventListener("start", () => player.start());
|
||||
document.querySelector("tone-play-toggle").addEventListener("stop", () => player.stop());
|
||||
renderingPromise.then((buffer) => (player.buffer = buffer));
|
||||
renderingPromise.then(
|
||||
() =>
|
||||
(document.querySelector("tone-play-toggle").disabled =
|
||||
false)
|
||||
);
|
||||
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("start", () => player.start());
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("stop", () => player.stop());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>Oscillator</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="174x174"
|
||||
href="./favicon.png"
|
||||
/>
|
||||
|
||||
<script src="https://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="./js/tone-ui.js"></script>
|
||||
<script src="./js/components.js"></script>
|
||||
|
@ -21,10 +32,14 @@
|
|||
<body>
|
||||
<tone-example label="Oscillator">
|
||||
<div slot="explanation">
|
||||
The oscillator has 4 basic types which can be altered by setting the number
|
||||
of partials and partials array.
|
||||
<br><br>
|
||||
<a href="https://tonejs.github.io/docs/Oscillator">Tone.Oscillator</a> docs.
|
||||
The oscillator has 4 basic types which can be altered by setting
|
||||
the number of partials and partials array.
|
||||
<br /><br />
|
||||
<a
|
||||
href="https://tonejs.github.io/docs/latest/classes/Oscillator"
|
||||
>Tone.Oscillator</a
|
||||
>
|
||||
docs.
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
@ -32,22 +47,25 @@
|
|||
</div>
|
||||
</tone-example>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
const osc = new Tone.Oscillator({
|
||||
type: "square",
|
||||
frequency: 440,
|
||||
volume: -16
|
||||
volume: -16,
|
||||
}).toDestination();
|
||||
|
||||
ui({
|
||||
tone: osc,
|
||||
parent: document.querySelector("#content")
|
||||
parent: document.querySelector("#content"),
|
||||
});
|
||||
|
||||
// bind the interface
|
||||
document.querySelector("tone-momentary-button").addEventListener("down", () => osc.start());
|
||||
document.querySelector("tone-momentary-button").addEventListener("up", () => osc.stop());
|
||||
document
|
||||
.querySelector("tone-momentary-button")
|
||||
.addEventListener("down", () => osc.start());
|
||||
document
|
||||
.querySelector("tone-momentary-button")
|
||||
.addEventListener("up", () => osc.stop());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>Ping Pong Delay</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="174x174"
|
||||
href="./favicon.png"
|
||||
/>
|
||||
|
||||
<script src="https://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="./js/tone-ui.js"></script>
|
||||
<script src="./js/components.js"></script>
|
||||
|
@ -18,9 +29,15 @@
|
|||
<tone-loader></tone-loader>
|
||||
|
||||
<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.
|
||||
<br><br>
|
||||
<a href="https://tonejs.github.io/docs/PingPongDelay">Tone.PingPongDelay</a> docs.
|
||||
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.
|
||||
<br /><br />
|
||||
<a
|
||||
href="https://tonejs.github.io/docs/latest/classes/PingPongDelay"
|
||||
>Tone.PingPongDelay</a
|
||||
>
|
||||
docs.
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
@ -33,22 +50,28 @@
|
|||
const feedbackDelay = new Tone.PingPongDelay({
|
||||
delayTime: "8n",
|
||||
feedback: 0.6,
|
||||
wet: 0.5
|
||||
wet: 0.5,
|
||||
}).toDestination();
|
||||
|
||||
// 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 });
|
||||
feedbackDelay.connect(toneMeter);
|
||||
|
||||
meter({
|
||||
tone: toneMeter,
|
||||
parent: document.querySelector("#content")
|
||||
parent: document.querySelector("#content"),
|
||||
});
|
||||
|
||||
document.querySelector("tone-momentary-button").addEventListener("down", () => player.start());
|
||||
document.querySelector("tone-momentary-button").addEventListener("up", () => player.stop());
|
||||
document
|
||||
.querySelector("tone-momentary-button")
|
||||
.addEventListener("down", () => player.start());
|
||||
document
|
||||
.querySelector("tone-momentary-button")
|
||||
.addEventListener("up", () => player.stop());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>Pitch Shift</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="174x174"
|
||||
href="./favicon.png"
|
||||
/>
|
||||
|
||||
<script src="https://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="./js/tone-ui.js"></script>
|
||||
<script src="./js/components.js"></script>
|
||||
|
@ -23,20 +34,32 @@
|
|||
<tone-example label="Pitch Shift">
|
||||
<div slot="explanation">
|
||||
This example demonstrates the Pitch Shift effect.
|
||||
<br><br>
|
||||
<a href="https://tonejs.github.io/docs/PitchShift">Tone.Pitch Shift</a> docs.
|
||||
<br /><br />
|
||||
<a
|
||||
href="https://tonejs.github.io/docs/latest/classes/PitchShift"
|
||||
>Tone.Pitch Shift</a
|
||||
>
|
||||
docs.
|
||||
</div>
|
||||
|
||||
<tone-loader></tone-loader>
|
||||
<div id="content">
|
||||
<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>
|
||||
</tone-example>
|
||||
|
||||
<script type="text/javascript">
|
||||
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;
|
||||
|
||||
const toneFFT = new Tone.FFT();
|
||||
|
@ -47,13 +70,19 @@
|
|||
});
|
||||
|
||||
// bind the interface
|
||||
document.querySelector("tone-play-toggle").addEventListener("start", () => player.start());
|
||||
document.querySelector("tone-play-toggle").addEventListener("stop", () => player.stop());
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("start", () => player.start());
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("stop", () => player.stop());
|
||||
// document.querySelector("tone-play-toggle").addEventListener('start', () => {
|
||||
// debugger;
|
||||
// });
|
||||
|
||||
document.querySelector("tone-slider").addEventListener("input", e => {
|
||||
document
|
||||
.querySelector("tone-slider")
|
||||
.addEventListener("input", (e) => {
|
||||
pitchShift.pitch = parseFloat(e.target.value);
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>Player</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="174x174"
|
||||
href="./favicon.png"
|
||||
/>
|
||||
|
||||
<script src="https://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="./js/tone-ui.js"></script>
|
||||
<script src="./js/components.js"></script>
|
||||
|
@ -22,8 +33,10 @@
|
|||
<tone-example label="Player">
|
||||
<tone-loader></tone-loader>
|
||||
<div slot="explanation">
|
||||
Click on the button to play the audio file on loop
|
||||
using <a href="https://tonejs.github.io/docs/Player">Tone.Player</a>.
|
||||
Click on the button to play the audio file on loop using
|
||||
<a href="https://tonejs.github.io/docs/latest/classes/Player"
|
||||
>Tone.Player</a
|
||||
>.
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
@ -42,13 +55,16 @@
|
|||
|
||||
ui({
|
||||
tone: player,
|
||||
parent: document.querySelector("#content")
|
||||
parent: document.querySelector("#content"),
|
||||
});
|
||||
|
||||
// bind the interface
|
||||
document.querySelector("tone-play-toggle").addEventListener("start", () => player.start());
|
||||
document.querySelector("tone-play-toggle").addEventListener("stop", () => player.stop());
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("start", () => player.start());
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("stop", () => player.stop());
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>PolySynth</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="174x174"
|
||||
href="./favicon.png"
|
||||
/>
|
||||
|
||||
<script src="https://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="./js/tone-ui.js"></script>
|
||||
<script src="./js/components.js"></script>
|
||||
|
@ -21,30 +32,31 @@
|
|||
</style>
|
||||
<tone-example label="Polyphony">
|
||||
<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
|
||||
instruments passed in as the second parameter. PolySynth is
|
||||
not a synthesizer by itself, it merely manages voices of
|
||||
one of the other types of synths, allowing any of the
|
||||
monophonic synthesizers to be polyphonic.
|
||||
instruments passed in as the second parameter. PolySynth is not
|
||||
a synthesizer by itself, it merely manages voices of one of the
|
||||
other types of synths, allowing any of the monophonic
|
||||
synthesizers to be polyphonic.
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
</div>
|
||||
<div id="content"></div>
|
||||
</tone-example>
|
||||
|
||||
<script type="text/javascript">
|
||||
const synth = new Tone.PolySynth(Tone.Synth, {
|
||||
oscillator: {
|
||||
partials: [0, 2, 3, 4],
|
||||
}
|
||||
},
|
||||
}).toDestination();
|
||||
|
||||
piano({
|
||||
parent: document.querySelector("#content"),
|
||||
polyphonic: true,
|
||||
noteon: note => synth.triggerAttack(note.name),
|
||||
noteoff: note => synth.triggerRelease(note.name)
|
||||
noteon: (note) => synth.triggerAttack(note.name),
|
||||
noteoff: (note) => synth.triggerRelease(note.name),
|
||||
});
|
||||
|
||||
ui({
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>Reverb</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="174x174"
|
||||
href="./favicon.png"
|
||||
/>
|
||||
|
||||
<script src="https://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="./js/tone-ui.js"></script>
|
||||
<script src="./js/components.js"></script>
|
||||
|
@ -21,11 +32,14 @@
|
|||
</style>
|
||||
<tone-example label="Reverb">
|
||||
<div slot="explanation">
|
||||
<a href="https://tonejs.github.io/docs/Reverb">Tone.Reverb</a>
|
||||
is a convolution-based reverb. An impulse response is created 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.
|
||||
<a href="https://tonejs.github.io/docs/latest/classes/Reverb"
|
||||
>Tone.Reverb</a
|
||||
>
|
||||
is a convolution-based reverb. An impulse response is created
|
||||
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 id="content">
|
||||
|
@ -44,13 +58,16 @@
|
|||
|
||||
ui({
|
||||
parent: document.querySelector("#content"),
|
||||
tone: reverb
|
||||
tone: reverb,
|
||||
});
|
||||
|
||||
// bind the interface
|
||||
document.querySelector("tone-play-toggle").addEventListener("start", () => player.start());
|
||||
document.querySelector("tone-play-toggle").addEventListener("stop", () => player.stop());
|
||||
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("start", () => player.start());
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("stop", () => player.stop());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>Sampler</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="174x174"
|
||||
href="./favicon.png"
|
||||
/>
|
||||
|
||||
<script src="https://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="./js/tone-ui.js"></script>
|
||||
<script src="./js/components.js"></script>
|
||||
|
@ -23,11 +34,20 @@
|
|||
<tone-loader></tone-loader>
|
||||
|
||||
<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 id="content">
|
||||
</div>
|
||||
<div id="content"></div>
|
||||
</tone-example>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
@ -62,18 +82,17 @@
|
|||
"D#7": "Ds7.mp3",
|
||||
"F#7": "Fs7.mp3",
|
||||
A7: "A7.mp3",
|
||||
C8: "C8.mp3"
|
||||
C8: "C8.mp3",
|
||||
},
|
||||
release: 1,
|
||||
baseUrl: "https://tonejs.github.io/audio/salamander/"
|
||||
baseUrl: "https://tonejs.github.io/audio/salamander/",
|
||||
}).toDestination();
|
||||
|
||||
piano({
|
||||
parent: document.querySelector("#content"),
|
||||
noteon: note => sampler.triggerAttack(note.name),
|
||||
noteoff: note => sampler.triggerRelease(note.name),
|
||||
noteon: (note) => sampler.triggerAttack(note.name),
|
||||
noteoff: (note) => sampler.triggerRelease(note.name),
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>Signal</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="174x174"
|
||||
href="./favicon.png"
|
||||
/>
|
||||
|
||||
<script src="https://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="./js/tone-ui.js"></script>
|
||||
<script src="./js/components.js"></script>
|
||||
|
@ -25,22 +36,34 @@
|
|||
<body>
|
||||
<tone-example label="Control Voltage">
|
||||
<div slot="explanation">
|
||||
One of the most powerful features of Tone.js and the Web Audio API is the ability to
|
||||
perform math and logic on audio-rate signal. Signals
|
||||
can be ramped and scheduled to control Audio Parameters and
|
||||
other Signals making it simple to create elaborate,
|
||||
interconnected automations.
|
||||
<br><br>
|
||||
This example applies a series of mappings to a
|
||||
signal value and applies the results of those mappings
|
||||
to the frequency attribute of 2
|
||||
<a href="https://tonejs.github.io/docs/Oscillator">Tone.Oscillators</a>
|
||||
and a <a href="https://tonejs.github.io/docs/LFO">Tone.LFO</a>.
|
||||
One of the most powerful features of Tone.js and the Web Audio
|
||||
API is the ability to perform math and logic on audio-rate
|
||||
signal. Signals can be ramped and scheduled to control Audio
|
||||
Parameters and other Signals making it simple to create
|
||||
elaborate, interconnected automations.
|
||||
<br /><br />
|
||||
This example applies a series of mappings to a signal value and
|
||||
applies the results of those mappings to the frequency attribute
|
||||
of 2
|
||||
<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 id="content">
|
||||
<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>
|
||||
</tone-example>
|
||||
|
||||
|
@ -51,12 +74,12 @@
|
|||
// two oscillators panned hard left / hard right
|
||||
const rightOsc = new Tone.Oscillator({
|
||||
type: "sawtooth",
|
||||
volume: -20
|
||||
volume: -20,
|
||||
}).connect(merge, 0, 0);
|
||||
|
||||
const leftOsc = new Tone.Oscillator({
|
||||
type: "square",
|
||||
volume: -20
|
||||
volume: -20,
|
||||
}).connect(merge, 0, 1);
|
||||
|
||||
// create an oscillation that goes from 0 to 1200
|
||||
|
@ -64,8 +87,10 @@
|
|||
const detuneLFO = new Tone.LFO({
|
||||
type: "square",
|
||||
min: 0,
|
||||
max: 1200
|
||||
}).fan(rightOsc.detune, leftOsc.detune).start();
|
||||
max: 1200,
|
||||
})
|
||||
.fan(rightOsc.detune, leftOsc.detune)
|
||||
.start();
|
||||
|
||||
// the frequency signal
|
||||
const frequency = new Tone.Signal(0.5);
|
||||
|
@ -86,21 +111,25 @@
|
|||
frequency.chain(detuneScale, detuneLFO.frequency);
|
||||
|
||||
// start the oscillators with the play button
|
||||
document.querySelector("tone-play-toggle").addEventListener("start", () => {
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("start", () => {
|
||||
rightOsc.start();
|
||||
leftOsc.start();
|
||||
});
|
||||
document.querySelector("tone-play-toggle").addEventListener("stop", () => {
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("stop", () => {
|
||||
rightOsc.stop();
|
||||
leftOsc.stop();
|
||||
});
|
||||
|
||||
// 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);
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>Synth</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="174x174"
|
||||
href="./favicon.png"
|
||||
/>
|
||||
|
||||
<script src="https://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="./js/tone-ui.js"></script>
|
||||
<script src="./js/components.js"></script>
|
||||
|
@ -21,14 +32,26 @@
|
|||
</style>
|
||||
<tone-example label="Synth">
|
||||
<div slot="explanation">
|
||||
<a href="https://tonejs.github.io/docs/Synth" target="_blank">Tone.Synth</a> is composed simply of a
|
||||
<a href="https://tonejs.github.io/docs/OmniOscillator" target="_blank">Tone.OmniOscillator</a>
|
||||
<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
|
||||
<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 id="content">
|
||||
</div>
|
||||
<div id="content"></div>
|
||||
</tone-example>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
@ -36,7 +59,7 @@
|
|||
oscillator: {
|
||||
type: "amtriangle",
|
||||
harmonicity: 0.5,
|
||||
modulationType: "sine"
|
||||
modulationType: "sine",
|
||||
},
|
||||
envelope: {
|
||||
attackCurve: "exponential",
|
||||
|
@ -45,14 +68,14 @@
|
|||
sustain: 0.2,
|
||||
release: 1.5,
|
||||
},
|
||||
portamento: 0.05
|
||||
portamento: 0.05,
|
||||
}).toDestination();
|
||||
|
||||
piano({
|
||||
tone: synth,
|
||||
parent: document.querySelector("#content"),
|
||||
noteon: (note) => synth.triggerAttack(note.name),
|
||||
noteoff: (note) => synth.triggerRelease()
|
||||
noteoff: (note) => synth.triggerRelease(),
|
||||
});
|
||||
|
||||
ui({
|
||||
|
@ -60,7 +83,6 @@
|
|||
name: "Synth",
|
||||
parent: document.querySelector("#content"),
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,14 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>Step Sequencer</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="174x174"
|
||||
href="./favicon.png"
|
||||
/>
|
||||
|
||||
<script src="https://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="./js/tone-ui.js"></script>
|
||||
<script src="./js/components.js"></script>
|
||||
|
@ -22,13 +33,25 @@
|
|||
<tone-example label="Step Sequencer">
|
||||
<tone-loader></tone-loader>
|
||||
<div slot="explanation">
|
||||
<a href="https://tonejs.github.io/docs/Transport">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.
|
||||
<a
|
||||
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 id="content">
|
||||
<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>
|
||||
</div>
|
||||
</tone-example>
|
||||
|
@ -42,16 +65,27 @@
|
|||
3: "Fs2.mp3",
|
||||
},
|
||||
fadeOut: "64n",
|
||||
baseUrl: "https://tonejs.github.io/audio/casio/"
|
||||
baseUrl: "https://tonejs.github.io/audio/casio/",
|
||||
}).toDestination();
|
||||
|
||||
document.querySelector("tone-play-toggle").addEventListener("start", () => Tone.Transport.start());
|
||||
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 }) => {
|
||||
document
|
||||
.querySelector("tone-play-toggle")
|
||||
.addEventListener("start", () => Tone.Transport.start());
|
||||
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");
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue