tone 15.5.21 → 15.5.23
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/Tone/core/clock/TickSource.ts +1 -1
- package/Tone/core/clock/Transport.ts +1 -1
- package/Tone/core/type/Frequency.test.ts +11 -3
- package/Tone/core/type/Frequency.ts +27 -13
- package/Tone/core/type/Midi.test.ts +1 -0
- package/Tone/core/type/TimeBase.ts +17 -6
- package/Tone/core/worklet/ToneAudioWorklet.ts +6 -5
- package/Tone/signal/SyncedSignal.ts +1 -1
- package/Tone/source/OneShotSource.ts +1 -1
- package/Tone/source/buffer/Player.ts +3 -2
- package/Tone/version.ts +1 -1
- package/build/Tone.js +1 -1
- package/build/Tone.js.map +1 -1
- package/build/esm/core/clock/TickSource.js.map +1 -1
- package/build/esm/core/clock/Transport.js +1 -1
- package/build/esm/core/clock/Transport.js.map +1 -1
- package/build/esm/core/type/Frequency.js +9 -7
- package/build/esm/core/type/Frequency.js.map +1 -1
- package/build/esm/core/type/TimeBase.d.ts +2 -2
- package/build/esm/core/type/TimeBase.js +1 -1
- package/build/esm/core/type/TimeBase.js.map +1 -1
- package/build/esm/core/worklet/ToneAudioWorklet.js +1 -3
- package/build/esm/core/worklet/ToneAudioWorklet.js.map +1 -1
- package/build/esm/source/OneShotSource.js +1 -1
- package/build/esm/source/OneShotSource.js.map +1 -1
- package/build/esm/source/buffer/Player.js.map +1 -1
- package/build/esm/version.js +1 -1
- package/package.json +1 -1
|
@@ -236,7 +236,7 @@ export class TransportInstance
|
|
|
236
236
|
* called on every tick
|
|
237
237
|
* @param tickTime clock relative tick time
|
|
238
238
|
*/
|
|
239
|
-
private _processTick(tickTime: Seconds, ticks: Ticks): void {
|
|
239
|
+
private _processTick(tickTime: Seconds, ticks: Ticks = 0): void {
|
|
240
240
|
// do the loop test
|
|
241
241
|
if (this._loop.get(tickTime)) {
|
|
242
242
|
if (ticks >= this._loopEnd) {
|
|
@@ -128,9 +128,17 @@ describe("FrequencyClass", () => {
|
|
|
128
128
|
});
|
|
129
129
|
|
|
130
130
|
it("evaluates transport time", () => {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
131
|
+
return Offline(({ transport }) => {
|
|
132
|
+
transport.bpm.value = 120;
|
|
133
|
+
transport.timeSignature = 4;
|
|
134
|
+
expect(Frequency("1:0").valueOf()).to.equal(0.5);
|
|
135
|
+
expect(Frequency("2:0:0").valueOf()).to.equal(0.25);
|
|
136
|
+
expect(Frequency("1:1").valueOf()).to.be.closeTo(0.4, 0.0001);
|
|
137
|
+
expect(Frequency("1:0:2").valueOf()).to.be.closeTo(
|
|
138
|
+
120 / (60 * 4.5),
|
|
139
|
+
0.0001
|
|
140
|
+
);
|
|
141
|
+
});
|
|
134
142
|
});
|
|
135
143
|
|
|
136
144
|
it("evaluates midi", () => {
|
|
@@ -2,7 +2,12 @@ import { getContext } from "../Global.js";
|
|
|
2
2
|
import { intervalToFrequencyRatio, mtof } from "./Conversions.js";
|
|
3
3
|
import { ftom, getA4, setA4 } from "./Conversions.js";
|
|
4
4
|
import { TimeClass } from "./Time.js";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
TimeBaseClass,
|
|
7
|
+
TimeBaseUnit,
|
|
8
|
+
TimeExpression,
|
|
9
|
+
TimeValue,
|
|
10
|
+
} from "./TimeBase.js";
|
|
6
11
|
import {
|
|
7
12
|
Frequency,
|
|
8
13
|
Hertz,
|
|
@@ -51,17 +56,22 @@ export class FrequencyClass<Type extends number = Hertz> extends TimeClass<
|
|
|
51
56
|
return Object.assign({}, super._getExpressions(), {
|
|
52
57
|
midi: {
|
|
53
58
|
regexp: /^(\d+(?:\.\d+)?midi)/,
|
|
54
|
-
method(value): number {
|
|
59
|
+
method(this: TimeBaseClass<any, any>, value: string): number {
|
|
60
|
+
const numericValue = parseFloat(value);
|
|
55
61
|
if (this.defaultUnits === "midi") {
|
|
56
|
-
return
|
|
62
|
+
return numericValue;
|
|
57
63
|
} else {
|
|
58
|
-
return FrequencyClass.mtof(
|
|
64
|
+
return FrequencyClass.mtof(numericValue as MidiNote);
|
|
59
65
|
}
|
|
60
66
|
},
|
|
61
67
|
},
|
|
62
68
|
note: {
|
|
63
69
|
regexp: /^([a-g]{1}(?:b|#|##|x|bb|###|#x|x#|bbb)?)(-?[0-9]+)/i,
|
|
64
|
-
method(
|
|
70
|
+
method(
|
|
71
|
+
this: TimeBaseClass<any, any>,
|
|
72
|
+
pitch: string,
|
|
73
|
+
octave: string
|
|
74
|
+
): number {
|
|
65
75
|
const index = noteToScaleIndex[pitch.toLowerCase()];
|
|
66
76
|
const noteNumber = index + (parseInt(octave, 10) + 1) * 12;
|
|
67
77
|
if (this.defaultUnits === "midi") {
|
|
@@ -73,20 +83,24 @@ export class FrequencyClass<Type extends number = Hertz> extends TimeClass<
|
|
|
73
83
|
},
|
|
74
84
|
tr: {
|
|
75
85
|
regexp: /^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,
|
|
76
|
-
method(
|
|
77
|
-
|
|
86
|
+
method(
|
|
87
|
+
this: TimeBaseClass<any, any>,
|
|
88
|
+
m: string,
|
|
89
|
+
q: string,
|
|
90
|
+
s: string
|
|
91
|
+
): number {
|
|
92
|
+
const self = this as FrequencyClass<any>;
|
|
93
|
+
let totalBeats = 0;
|
|
78
94
|
if (m && m !== "0") {
|
|
79
|
-
|
|
80
|
-
this._getTimeSignature() * parseFloat(m)
|
|
81
|
-
);
|
|
95
|
+
totalBeats += self._getTimeSignature() * parseFloat(m);
|
|
82
96
|
}
|
|
83
97
|
if (q && q !== "0") {
|
|
84
|
-
|
|
98
|
+
totalBeats += parseFloat(q);
|
|
85
99
|
}
|
|
86
100
|
if (s && s !== "0") {
|
|
87
|
-
|
|
101
|
+
totalBeats += parseFloat(s) / 4;
|
|
88
102
|
}
|
|
89
|
-
return
|
|
103
|
+
return self._beatsToUnits(totalBeats);
|
|
90
104
|
},
|
|
91
105
|
},
|
|
92
106
|
});
|
|
@@ -68,6 +68,7 @@ describe("MidiClass", () => {
|
|
|
68
68
|
|
|
69
69
|
it("can convert from Midi", () => {
|
|
70
70
|
expect(Midi(Midi(2)).valueOf()).to.equal(2);
|
|
71
|
+
expect(Midi(60, "midi").valueOf()).to.equal(60);
|
|
71
72
|
expect(Midi(Midi("64n")).valueOf()).to.equal(24);
|
|
72
73
|
expect(Midi(Midi(64, "n")).valueOf()).to.equal(24);
|
|
73
74
|
});
|
|
@@ -30,13 +30,21 @@ export type TimeBaseUnit =
|
|
|
30
30
|
|
|
31
31
|
export interface TypeFunction {
|
|
32
32
|
regexp: RegExp;
|
|
33
|
-
method: (
|
|
33
|
+
method: (
|
|
34
|
+
this: TimeBaseClass<any, any>,
|
|
35
|
+
value: string,
|
|
36
|
+
...args: string[]
|
|
37
|
+
) => number;
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
export interface TimeExpression<Type extends number> {
|
|
37
41
|
[key: string]: {
|
|
38
42
|
regexp: RegExp;
|
|
39
|
-
method: (
|
|
43
|
+
method: (
|
|
44
|
+
this: TimeBaseClass<any, any>,
|
|
45
|
+
value: string,
|
|
46
|
+
...args: string[]
|
|
47
|
+
) => Type;
|
|
40
48
|
};
|
|
41
49
|
}
|
|
42
50
|
|
|
@@ -110,7 +118,7 @@ export abstract class TimeBaseClass<
|
|
|
110
118
|
regexp: /^(\d+)m$/i,
|
|
111
119
|
},
|
|
112
120
|
n: {
|
|
113
|
-
method: (value, dot) => {
|
|
121
|
+
method: (value: string, dot: string) => {
|
|
114
122
|
const numericValue = parseInt(value, 10);
|
|
115
123
|
const scalar = dot === "." ? 1.5 : 1;
|
|
116
124
|
if (numericValue === 1) {
|
|
@@ -155,7 +163,7 @@ export abstract class TimeBaseClass<
|
|
|
155
163
|
regexp: /^(\d+)t$/i,
|
|
156
164
|
},
|
|
157
165
|
tr: {
|
|
158
|
-
method: (m, q, s) => {
|
|
166
|
+
method: (m: string, q: string, s: string) => {
|
|
159
167
|
let total = 0;
|
|
160
168
|
if (m && m !== "0") {
|
|
161
169
|
total += this._beatsToUnits(
|
|
@@ -213,9 +221,12 @@ export abstract class TimeBaseClass<
|
|
|
213
221
|
const expr = this._expressions[this._units];
|
|
214
222
|
const matching = this._val.toString().trim().match(expr.regexp);
|
|
215
223
|
if (matching) {
|
|
216
|
-
return expr.method.apply(
|
|
224
|
+
return expr.method.apply(
|
|
225
|
+
this,
|
|
226
|
+
matching.slice(1) as [string, ...string[]]
|
|
227
|
+
);
|
|
217
228
|
} else {
|
|
218
|
-
return expr.method.call(this, this._val);
|
|
229
|
+
return expr.method.call(this, String(this._val));
|
|
219
230
|
}
|
|
220
231
|
} else if (isString(this._val)) {
|
|
221
232
|
return parseFloat(this._val) as Type;
|
|
@@ -6,8 +6,8 @@ import { noOp } from "../util/Interface.js";
|
|
|
6
6
|
import { getWorkletGlobalScope } from "./WorkletGlobalScope.js";
|
|
7
7
|
|
|
8
8
|
export interface ToneAudioWorkletOptions extends ToneAudioNodeOptions {
|
|
9
|
-
workletOptions?: Partial<AudioWorkletNodeOptions
|
|
10
|
-
}
|
|
9
|
+
workletOptions?: Partial<AudioWorkletNodeOptions>;
|
|
10
|
+
}
|
|
11
11
|
export abstract class ToneAudioWorklet<
|
|
12
12
|
Options extends ToneAudioWorkletOptions,
|
|
13
13
|
> extends ToneAudioNode<Options> {
|
|
@@ -65,7 +65,8 @@ export abstract class ToneAudioWorklet<
|
|
|
65
65
|
);
|
|
66
66
|
|
|
67
67
|
if (options.workletOptions) {
|
|
68
|
-
this.workletOptions = Object.assign(
|
|
68
|
+
this.workletOptions = Object.assign(
|
|
69
|
+
{},
|
|
69
70
|
this.workletOptions,
|
|
70
71
|
options.workletOptions
|
|
71
72
|
);
|
|
@@ -84,8 +85,8 @@ export abstract class ToneAudioWorklet<
|
|
|
84
85
|
name,
|
|
85
86
|
this.workletOptions
|
|
86
87
|
);
|
|
87
|
-
this._worklet.onprocessorerror =
|
|
88
|
-
this.onprocessorerror
|
|
88
|
+
this._worklet.onprocessorerror = (e) =>
|
|
89
|
+
this.onprocessorerror((e as ErrorEvent).message);
|
|
89
90
|
this.onReady(this._worklet);
|
|
90
91
|
}
|
|
91
92
|
});
|
|
@@ -217,7 +217,7 @@ export abstract class OneShotSource<
|
|
|
217
217
|
/**
|
|
218
218
|
* Get the playback state at the given time
|
|
219
219
|
*/
|
|
220
|
-
getStateAtTime =
|
|
220
|
+
getStateAtTime = (time: Time): BasicPlaybackState => {
|
|
221
221
|
const computedTime = this.toSeconds(time);
|
|
222
222
|
if (
|
|
223
223
|
this._startTime !== -1 &&
|
|
@@ -8,6 +8,7 @@ import { noOp } from "../../core/util/Interface.js";
|
|
|
8
8
|
import { Timeline } from "../../core/util/Timeline.js";
|
|
9
9
|
import { isUndef } from "../../core/util/TypeCheck.js";
|
|
10
10
|
import { ToneConstantSource } from "../../signal/ToneConstantSource.js";
|
|
11
|
+
import { OneShotSource } from "../OneShotSource.js";
|
|
11
12
|
import { Source, SourceOptions } from "../Source.js";
|
|
12
13
|
import { ToneBufferSource } from "./ToneBufferSource.js";
|
|
13
14
|
|
|
@@ -231,12 +232,12 @@ export class Player extends Source<PlayerOptions> {
|
|
|
231
232
|
/**
|
|
232
233
|
* Internal callback when the buffer is done playing.
|
|
233
234
|
*/
|
|
234
|
-
private _onSourceEnd(source:
|
|
235
|
+
private _onSourceEnd(source: OneShotSource<any>): void {
|
|
235
236
|
// invoke the onstop function
|
|
236
237
|
this.onstop(this);
|
|
237
238
|
|
|
238
239
|
// delete the source from the active sources
|
|
239
|
-
this._activeSources.delete(source);
|
|
240
|
+
this._activeSources.delete(source as ToneBufferSource);
|
|
240
241
|
if (
|
|
241
242
|
this._activeSources.size === 0 &&
|
|
242
243
|
!this._synced &&
|
package/Tone/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version: string = "15.5.
|
|
1
|
+
export const version: string = "15.5.23";
|