tone 14.8.48 → 14.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/Tone/component/analysis/FFT.ts +1 -0
- package/Tone/component/analysis/Meter.ts +1 -1
- package/Tone/component/channel/Channel.ts +1 -1
- package/Tone/core/clock/TickSource.ts +2 -2
- package/Tone/core/clock/Ticker.ts +1 -1
- package/Tone/core/context/Context.ts +1 -1
- package/Tone/core/context/ToneAudioBuffer.ts +5 -5
- package/Tone/core/context/ToneAudioNode.ts +1 -1
- package/Tone/core/context/ToneWithContext.ts +1 -1
- package/Tone/core/type/Frequency.ts +2 -1
- package/Tone/effect/Chorus.test.ts +2 -2
- package/Tone/effect/Chorus.ts +3 -3
- package/Tone/effect/Distortion.ts +1 -1
- package/Tone/event/Loop.ts +2 -1
- package/Tone/fromContext.ts +1 -1
- package/Tone/instrument/DuoSynth.ts +1 -1
- package/Tone/instrument/PolySynth.ts +0 -1
- package/Tone/source/buffer/Player.test.ts +16 -13
- package/Tone/source/buffer/Players.ts +1 -1
- package/Tone/source/oscillator/OmniOscillator.ts +1 -1
- package/Tone/version.ts +1 -1
- package/build/Tone.js +1 -1
- package/build/Tone.js.map +1 -1
- package/build/esm/component/analysis/FFT.d.ts +1 -0
- package/build/esm/component/analysis/FFT.js +1 -0
- package/build/esm/component/analysis/FFT.js.map +1 -1
- package/build/esm/component/analysis/Meter.js.map +1 -1
- package/build/esm/component/channel/Channel.d.ts +1 -1
- package/build/esm/component/channel/Channel.js +1 -1
- package/build/esm/core/clock/TickSource.js +2 -2
- package/build/esm/core/clock/TickSource.js.map +1 -1
- package/build/esm/core/clock/Ticker.js.map +1 -1
- package/build/esm/core/context/Context.d.ts +1 -1
- package/build/esm/core/context/Context.js +1 -1
- package/build/esm/core/context/ToneAudioBuffer.js.map +1 -1
- package/build/esm/core/context/ToneAudioNode.d.ts +1 -1
- package/build/esm/core/context/ToneAudioNode.js +1 -1
- package/build/esm/core/context/ToneWithContext.d.ts +1 -1
- package/build/esm/core/context/ToneWithContext.js +1 -1
- package/build/esm/core/type/Frequency.js +1 -0
- package/build/esm/core/type/Frequency.js.map +1 -1
- package/build/esm/effect/Chorus.d.ts +1 -1
- package/build/esm/effect/Chorus.js +1 -1
- package/build/esm/effect/Distortion.d.ts +1 -1
- package/build/esm/effect/Distortion.js +1 -1
- package/build/esm/event/Loop.js +2 -1
- package/build/esm/event/Loop.js.map +1 -1
- package/build/esm/fromContext.js.map +1 -1
- package/build/esm/instrument/DuoSynth.d.ts +1 -1
- package/build/esm/instrument/DuoSynth.js +1 -1
- package/build/esm/instrument/PolySynth.d.ts +0 -1
- package/build/esm/instrument/PolySynth.js +0 -1
- package/build/esm/instrument/PolySynth.js.map +1 -1
- package/build/esm/source/UserMedia.d.ts +1 -1
- package/build/esm/source/buffer/Players.d.ts +1 -1
- package/build/esm/source/buffer/Players.js +1 -1
- package/build/esm/source/oscillator/OmniOscillator.d.ts +1 -1
- package/build/esm/source/oscillator/OmniOscillator.js +1 -1
- package/build/esm/version.js +1 -1
- package/build/esm/version.js.map +1 -1
- package/package.json +4 -4
- package/CHANGELOG.md +0 -313
- package/docs/tone.json +0 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Tone.js
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
-
[](https://codecov.io/gh/Tonejs/Tone.js)
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Tone.js is a Web Audio framework for creating interactive music in the browser. The architecture of Tone.js aims to be familiar to both musicians and audio programmers creating web-based audio applications. On the high-level, Tone offers common DAW (digital audio workstation) features like a global transport for synchronizing and scheduling events as well as prebuilt synths and effects. Additionally, Tone provides high-performance building blocks to create your own synthesizers, effects, and complex control signals.
|
|
@@ -12,7 +12,7 @@ Tone.js is a Web Audio framework for creating interactive music in the browser.
|
|
|
12
12
|
|
|
13
13
|
# Installation
|
|
14
14
|
|
|
15
|
-
There are two ways to incorporate Tone.js into a
|
|
15
|
+
There are two ways to incorporate Tone.js into a project. First, it can be installed locally into a project using `npm`:
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
18
|
npm install tone // Install the latest stable version
|
|
@@ -13,6 +13,7 @@ export interface FFTOptions extends MeterBaseOptions {
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Get the current frequency data of the connected audio source using a fast Fourier transform.
|
|
16
|
+
* Read more about FFT algorithms on [Wikipedia] (https://en.wikipedia.org/wiki/Fast_Fourier_transform).
|
|
16
17
|
* @category Component
|
|
17
18
|
*/
|
|
18
19
|
export class FFT extends MeterBase<FFTOptions> {
|
|
@@ -103,7 +103,7 @@ export class Meter extends MeterBase<MeterOptions> {
|
|
|
103
103
|
const rms = Math.sqrt(totalSquared / values.length);
|
|
104
104
|
// the rms can only fall at the rate of the smoothing
|
|
105
105
|
// but can jump up instantly
|
|
106
|
-
this._rms[index] = Math.max(rms, this._rms[index]
|
|
106
|
+
this._rms[index] = Math.max(rms, this._rms[index] * this.smoothing);
|
|
107
107
|
return this.normalRange ? this._rms[index] : gainToDb(this._rms[index]);
|
|
108
108
|
});
|
|
109
109
|
if (this.channels === 1) {
|
|
@@ -91,7 +91,7 @@ export class Channel extends ToneAudioNode<ChannelOptions> {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
/**
|
|
94
|
-
* Solo/unsolo the channel. Soloing is only relative to other [[
|
|
94
|
+
* Solo/unsolo the channel. Soloing is only relative to other [[Channel]]s and [[Solo]] instances
|
|
95
95
|
*/
|
|
96
96
|
get solo(): boolean {
|
|
97
97
|
return this._solo.solo;
|
|
@@ -200,7 +200,7 @@ export class TickSource<TypeName extends "bpm" | "hertz"> extends ToneWithContex
|
|
|
200
200
|
if (lastState.state === "started" && e.state !== "started") {
|
|
201
201
|
elapsedTicks += this.frequency.getTicksAtTime(e.time) - this.frequency.getTicksAtTime(periodStartTime);
|
|
202
202
|
// do not memoize the temporary event
|
|
203
|
-
if (e.time
|
|
203
|
+
if (e.time !== tmpEvent.time) {
|
|
204
204
|
eventToMemoize = { state: e.state, time: e.time, ticks: elapsedTicks };
|
|
205
205
|
}
|
|
206
206
|
}
|
|
@@ -275,7 +275,7 @@ export class TickSource<TypeName extends "bpm" | "hertz"> extends ToneWithContex
|
|
|
275
275
|
if (lastState.state === "started" && e.state !== "started") {
|
|
276
276
|
elapsedSeconds += e.time - periodStartTime;
|
|
277
277
|
// do not memoize the temporary event
|
|
278
|
-
if (e.time
|
|
278
|
+
if (e.time !== tmpEvent.time) {
|
|
279
279
|
eventToMemoize = { state: e.state, time: e.time, seconds: elapsedSeconds };
|
|
280
280
|
}
|
|
281
281
|
}
|
|
@@ -42,7 +42,7 @@ export class Ticker {
|
|
|
42
42
|
|
|
43
43
|
this._callback = callback;
|
|
44
44
|
this._type = type;
|
|
45
|
-
this._minimumUpdateInterval = Math.max(
|
|
45
|
+
this._minimumUpdateInterval = Math.max(128/(contextSampleRate || 44100), .001);
|
|
46
46
|
this.updateInterval = updateInterval;
|
|
47
47
|
|
|
48
48
|
// create the clock source for the first time
|
|
@@ -475,7 +475,7 @@ export class Context extends BaseContext {
|
|
|
475
475
|
|
|
476
476
|
/**
|
|
477
477
|
* Starts the audio context from a suspended state. This is required
|
|
478
|
-
* to initially start the AudioContext. See [[
|
|
478
|
+
* to initially start the AudioContext. See [[start]]
|
|
479
479
|
*/
|
|
480
480
|
resume(): Promise<void> {
|
|
481
481
|
if (isAudioContext(this._context)) {
|
|
@@ -397,9 +397,9 @@ export class ToneAudioBuffer extends Tone {
|
|
|
397
397
|
const location = document.createElement("a");
|
|
398
398
|
location.href = baseUrl + url;
|
|
399
399
|
location.pathname = (location.pathname + location.hash)
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
400
|
+
.split("/")
|
|
401
|
+
.map(encodeURIComponent)
|
|
402
|
+
.join("/");
|
|
403
403
|
|
|
404
404
|
const response = await fetch(location.href);
|
|
405
405
|
if (!response.ok) {
|
|
@@ -425,8 +425,8 @@ export class ToneAudioBuffer extends Tone {
|
|
|
425
425
|
const extensions = url.split(".");
|
|
426
426
|
const extension = extensions[extensions.length - 1];
|
|
427
427
|
const response = document
|
|
428
|
-
|
|
429
|
-
|
|
428
|
+
.createElement("audio")
|
|
429
|
+
.canPlayType("audio/" + extension);
|
|
430
430
|
return response !== "";
|
|
431
431
|
}
|
|
432
432
|
|
|
@@ -385,7 +385,7 @@ export function disconnect(
|
|
|
385
385
|
* const player1 = new Tone.Player("https://tonejs.github.io/audio/drum-samples/conga-rhythm.mp3");
|
|
386
386
|
* const filter = new Tone.Filter("G5").toDestination();
|
|
387
387
|
* // connect nodes to a common destination
|
|
388
|
-
* fanIn(player, player1, filter);
|
|
388
|
+
* Tone.fanIn(player, player1, filter);
|
|
389
389
|
*/
|
|
390
390
|
export function fanIn(...nodes: OutputNode[]): void {
|
|
391
391
|
const dstNode = nodes.pop();
|
|
@@ -97,7 +97,7 @@ export abstract class ToneWithContext<Options extends ToneWithContextOptions> ex
|
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
99
|
* Convert the incoming time to seconds.
|
|
100
|
-
* This is calculated against the current [[
|
|
100
|
+
* This is calculated against the current [[Transport]] bpm
|
|
101
101
|
* @example
|
|
102
102
|
* const gain = new Tone.Gain();
|
|
103
103
|
* setInterval(() => console.log(gain.toSeconds("4n")), 100);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable key-spacing */
|
|
1
2
|
import { getContext } from "../Global";
|
|
2
3
|
import { intervalToFrequencyRatio, mtof } from "./Conversions";
|
|
3
4
|
import { ftom, getA4, setA4 } from "./Conversions";
|
|
@@ -215,7 +216,7 @@ export class FrequencyClass<Type extends number = Hertz> extends TimeClass<Type,
|
|
|
215
216
|
//-------------------------------------
|
|
216
217
|
|
|
217
218
|
/**
|
|
218
|
-
* Note to scale index.
|
|
219
|
+
* Note to scale index.
|
|
219
220
|
* @hidden
|
|
220
221
|
*/
|
|
221
222
|
const noteToScaleIndex = {
|
package/Tone/effect/Chorus.ts
CHANGED
|
@@ -17,15 +17,15 @@ export interface ChorusOptions extends StereoFeedbackEffectOptions {
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Chorus is a stereo chorus effect composed of a left and right delay with an [[LFO]] applied to the delayTime of each channel.
|
|
20
|
-
* When [[feedback]] is set to a value larger than 0, you also get Flanger-type effects.
|
|
20
|
+
* When [[feedback]] is set to a value larger than 0, you also get Flanger-type effects.
|
|
21
21
|
* Inspiration from [Tuna.js](https://github.com/Dinahmoe/tuna/blob/master/tuna.js).
|
|
22
|
-
* Read more on the chorus effect on [
|
|
22
|
+
* Read more on the chorus effect on [Sound On Sound](http://www.soundonsound.com/sos/jun04/articles/synthsecrets.htm).
|
|
23
23
|
*
|
|
24
24
|
* @example
|
|
25
25
|
* const chorus = new Tone.Chorus(4, 2.5, 0.5).toDestination().start();
|
|
26
26
|
* const synth = new Tone.PolySynth().connect(chorus);
|
|
27
27
|
* synth.triggerAttackRelease(["C3", "E3", "G3"], "8n");
|
|
28
|
-
*
|
|
28
|
+
*
|
|
29
29
|
* @category Effect
|
|
30
30
|
*/
|
|
31
31
|
export class Chorus extends StereoFeedbackEffect<ChorusOptions> {
|
|
@@ -10,7 +10,7 @@ export interface DistortionOptions extends EffectOptions {
|
|
|
10
10
|
/**
|
|
11
11
|
* A simple distortion effect using Tone.WaveShaper.
|
|
12
12
|
* Algorithm from [this stackoverflow answer](http://stackoverflow.com/a/22313408).
|
|
13
|
-
*
|
|
13
|
+
* Read more about distortion on [Wikipedia] (https://en.wikipedia.org/wiki/Distortion_(music)).
|
|
14
14
|
* @example
|
|
15
15
|
* const dist = new Tone.Distortion(0.8).toDestination();
|
|
16
16
|
* const fm = new Tone.FMSynth().connect(dist);
|
package/Tone/event/Loop.ts
CHANGED
|
@@ -58,7 +58,8 @@ export class Loop<Options extends LoopOptions = LoopOptions> extends ToneWithCon
|
|
|
58
58
|
loop: true,
|
|
59
59
|
loopEnd: options.interval,
|
|
60
60
|
playbackRate: options.playbackRate,
|
|
61
|
-
probability: options.probability
|
|
61
|
+
probability: options.probability,
|
|
62
|
+
humanize: options.humanize,
|
|
62
63
|
});
|
|
63
64
|
|
|
64
65
|
this.callback = options.callback;
|
package/Tone/fromContext.ts
CHANGED
|
@@ -18,7 +18,7 @@ export interface DuoSynthOptions extends MonophonicOptions {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* DuoSynth is a monophonic synth composed of two [[
|
|
21
|
+
* DuoSynth is a monophonic synth composed of two [[MonoSynth]]s run in parallel with control over the
|
|
22
22
|
* frequency ratio between the two voices and vibrato effect.
|
|
23
23
|
* @example
|
|
24
24
|
* const duoSynth = new Tone.DuoSynth().toDestination();
|
|
@@ -285,7 +285,6 @@ export class PolySynth<Voice extends Monophonic<any> = Synth> extends Instrument
|
|
|
285
285
|
* @param notes The notes to play. Accepts a single Frequency or an array of frequencies.
|
|
286
286
|
* @param time When the release will be triggered.
|
|
287
287
|
* @example
|
|
288
|
-
* @example
|
|
289
288
|
* const poly = new Tone.PolySynth(Tone.AMSynth).toDestination();
|
|
290
289
|
* poly.triggerAttack(["Ab3", "C4", "F5"]);
|
|
291
290
|
* // trigger the release of the given notes.
|
|
@@ -502,9 +502,9 @@ describe("Player", () => {
|
|
|
502
502
|
const player = new Player(buffer);
|
|
503
503
|
player.toDestination();
|
|
504
504
|
player
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
505
|
+
.start(0, 0, 0.05)
|
|
506
|
+
.start(0.1, 0, 0.05)
|
|
507
|
+
.start(0.2, 0, 0.05);
|
|
508
508
|
player.stop(0.1);
|
|
509
509
|
}, 0.3).then((buff) => {
|
|
510
510
|
expect(buff.getTimeOfLastSound()).to.be.closeTo(0.1, 0.02);
|
|
@@ -559,9 +559,9 @@ describe("Player", () => {
|
|
|
559
559
|
it("plays synced to the Transport", () => {
|
|
560
560
|
return Offline(({ transport }) => {
|
|
561
561
|
const player = new Player(buffer)
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
562
|
+
.sync()
|
|
563
|
+
.start(0)
|
|
564
|
+
.toDestination();
|
|
565
565
|
transport.start(0);
|
|
566
566
|
}, 0.05).then((buff) => {
|
|
567
567
|
expect(buff.isSilent()).to.be.false;
|
|
@@ -587,13 +587,13 @@ describe("Player", () => {
|
|
|
587
587
|
it("offsets correctly when started by the Transport", () => {
|
|
588
588
|
const testSample =
|
|
589
589
|
buffer.toArray(0)[
|
|
590
|
-
|
|
590
|
+
Math.floor(0.13125 * getContext().sampleRate)
|
|
591
591
|
];
|
|
592
592
|
return Offline(({ transport }) => {
|
|
593
593
|
const player = new Player(buffer)
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
594
|
+
.sync()
|
|
595
|
+
.start(0, 0.1)
|
|
596
|
+
.toDestination();
|
|
597
597
|
transport.start(0, 0.03125);
|
|
598
598
|
}, 0.05).then((buff) => {
|
|
599
599
|
expect(buff.toArray()[0][0]).to.equal(testSample);
|
|
@@ -709,12 +709,15 @@ describe("Player", () => {
|
|
|
709
709
|
setTimeout(() => {
|
|
710
710
|
player.restart(undefined, undefined, 1);
|
|
711
711
|
const checkStopTimes = new Set();
|
|
712
|
-
|
|
713
|
-
|
|
712
|
+
// @ts-ignore
|
|
713
|
+
player._activeSources.forEach(source => {
|
|
714
|
+
// @ts-ignore
|
|
715
|
+
checkStopTimes.add(source._stopTime);
|
|
714
716
|
});
|
|
715
717
|
getContext().lookAhead = originalLookAhead;
|
|
716
718
|
// ensure each source has a different stopTime
|
|
717
|
-
|
|
719
|
+
// @ts-ignore
|
|
720
|
+
expect(checkStopTimes.size).to.equal(player._activeSources.size);
|
|
718
721
|
done();
|
|
719
722
|
}, 250);
|
|
720
723
|
},
|
|
@@ -206,7 +206,7 @@ export class Players extends ToneAudioNode<PlayersOptions> {
|
|
|
206
206
|
* const players = new Tone.Players();
|
|
207
207
|
* players.add("gong", "https://tonejs.github.io/audio/berklee/gong_1.mp3", () => {
|
|
208
208
|
* console.log("gong loaded");
|
|
209
|
-
* players.
|
|
209
|
+
* players.player("gong").start();
|
|
210
210
|
* });
|
|
211
211
|
*/
|
|
212
212
|
add(name: string, url: string | ToneAudioBuffer | AudioBuffer, callback?: () => void): this {
|
|
@@ -315,7 +315,7 @@ export class OmniOscillator<OscType extends AnyOscillator>
|
|
|
315
315
|
|
|
316
316
|
/**
|
|
317
317
|
* The width of the oscillator when sourceType === "pulse".
|
|
318
|
-
* See [[PWMOscillator
|
|
318
|
+
* See [[PWMOscillator]]
|
|
319
319
|
*/
|
|
320
320
|
get width(): IsPulseOscillator<OscType, Signal<"audioRange">> {
|
|
321
321
|
if (this._getOscType(this._oscillator, "pulse")) {
|
package/Tone/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version: string = "14.
|
|
1
|
+
export const version: string = "14.9.0";
|