tone 14.8.32 → 14.8.33

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.
@@ -50,7 +50,7 @@ export class FrequencyClass<Type extends number = Hertz> extends TimeClass<Type,
50
50
  },
51
51
  },
52
52
  note: {
53
- regexp: /^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i,
53
+ regexp: /^([a-g]{1}(?:b|#|##|x|bb|###|#x|x#|bbb)?)(-?[0-9]+)/i,
54
54
  method(pitch, octave): number {
55
55
  const index = noteToScaleIndex[pitch.toLowerCase()];
56
56
  const noteNumber = index + (parseInt(octave, 10) + 1) * 12;
@@ -219,13 +219,13 @@ export class FrequencyClass<Type extends number = Hertz> extends TimeClass<Type,
219
219
  * @hidden
220
220
  */
221
221
  const noteToScaleIndex = {
222
- cbb: -2, cb: -1, c: 0, "c#": 1, cx: 2,
223
- dbb: 0, db: 1, d: 2, "d#": 3, dx: 4,
224
- ebb: 2, eb: 3, e: 4, "e#": 5, ex: 6,
225
- fbb: 3, fb: 4, f: 5, "f#": 6, fx: 7,
226
- gbb: 5, gb: 6, g: 7, "g#": 8, gx: 9,
227
- abb: 7, ab: 8, a: 9, "a#": 10, ax: 11,
228
- bbb: 9, bb: 10, b: 11, "b#": 12, bx: 13,
222
+ cbbb: -3, cbb: -2, cb: -1, c: 0, "c#": 1, cx: 2, "c##": 2, "c###": 3, "cx#": 3, "c#x": 3,
223
+ dbbb: -1, dbb: 0, db: 1, d: 2, "d#": 3, dx: 4, "d##": 4, "d###": 5, "dx#": 5, "d#x": 5,
224
+ ebbb: 1, ebb: 2, eb: 3, e: 4, "e#": 5, ex: 6, "e##": 6, "e###": 7, "ex#": 7, "e#x": 7,
225
+ fbbb: 2, fbb: 3, fb: 4, f: 5, "f#": 6, fx: 7, "f##": 7, "f###": 8, "fx#": 8, "f#x": 8,
226
+ gbbb: 4, gbb: 5, gb: 6, g: 7, "g#": 8, gx: 9, "g##": 9, "g###": 10, "gx#": 10, "g#x": 10,
227
+ abbb: 6, abb: 7, ab: 8, a: 9, "a#": 10, ax: 11, "a##": 11, "a###": 12, "ax#": 12, "a#x": 12,
228
+ bbbb: 8, bbb: 9, bb: 10, b: 11, "b#": 12, bx: 13, "b##": 13, "b###": 14, "bx#": 14, "b#x": 14,
229
229
  };
230
230
 
231
231
  /**
@@ -7,25 +7,29 @@ import { Oscillator } from "Tone/source";
7
7
  import { Offline } from "test/helper/Offline";
8
8
 
9
9
  describe("Chorus", () => {
10
-
11
10
  BasicTests(Chorus);
12
11
  EffectTests(Chorus);
13
12
 
14
13
  it("matches a file", () => {
15
- return CompareToFile(() => {
16
- const chorus = new Chorus().toDestination().start();
17
- const osc = new Oscillator(220, "sawtooth").connect(chorus).start();
18
- }, "chorus.wav", 0.1);
14
+ return CompareToFile(
15
+ () => {
16
+ const chorus = new Chorus().toDestination().start();
17
+ const osc = new Oscillator(220, "sawtooth")
18
+ .connect(chorus)
19
+ .start();
20
+ },
21
+ "chorus.wav",
22
+ 0.25
23
+ );
19
24
  });
20
25
 
21
26
  context("API", () => {
22
-
23
27
  it("can pass in options in the constructor", () => {
24
28
  const chorus = new Chorus({
25
29
  frequency: 2,
26
30
  delayTime: 1,
27
31
  depth: 0.4,
28
- spread: 90
32
+ spread: 90,
29
33
  });
30
34
  expect(chorus.frequency.value).to.be.closeTo(2, 0.01);
31
35
  expect(chorus.delayTime).to.be.closeTo(1, 0.01);
@@ -84,4 +88,3 @@ describe("Chorus", () => {
84
88
  });
85
89
  });
86
90
  });
87
-
@@ -4,7 +4,10 @@ import { omitFromObject, optionsFromArguments } from "../core/util/Defaults";
4
4
  import { RecursivePartial } from "../core/util/Interface";
5
5
  import { Noise, NoiseOptions } from "../source/Noise";
6
6
  import { Instrument, InstrumentOptions } from "./Instrument";
7
- import { ToneAudioNode, ToneAudioNodeOptions } from "../core/context/ToneAudioNode";
7
+ import {
8
+ ToneAudioNode,
9
+ ToneAudioNodeOptions,
10
+ } from "../core/context/ToneAudioNode";
8
11
  import { Envelope, EnvelopeOptions } from "../component/envelope/Envelope";
9
12
  import { Source } from "../source/Source";
10
13
 
@@ -14,7 +17,7 @@ export interface NoiseSynthOptions extends InstrumentOptions {
14
17
  }
15
18
 
16
19
  /**
17
- * Tone.NoiseSynth is composed of [[Noise]] through an [[AmplitudeEnvelope]].
20
+ * Tone.NoiseSynth is composed of [[Noise]] through an [[AmplitudeEnvelope]].
18
21
  * ```
19
22
  * +-------+ +-------------------+
20
23
  * | Noise +>--> AmplitudeEnvelope +>--> Output
@@ -26,7 +29,6 @@ export interface NoiseSynthOptions extends InstrumentOptions {
26
29
  * @category Instrument
27
30
  */
28
31
  export class NoiseSynth extends Instrument<NoiseSynthOptions> {
29
-
30
32
  readonly name = "NoiseSynth";
31
33
 
32
34
  /**
@@ -39,17 +41,30 @@ export class NoiseSynth extends Instrument<NoiseSynthOptions> {
39
41
  */
40
42
  readonly envelope: AmplitudeEnvelope;
41
43
 
42
- constructor(options?: RecursivePartial<NoiseSynthOptions>)
44
+ constructor(options?: RecursivePartial<NoiseSynthOptions>);
43
45
  constructor() {
44
46
  super(optionsFromArguments(NoiseSynth.getDefaults(), arguments));
45
- const options = optionsFromArguments(NoiseSynth.getDefaults(), arguments);
46
- this.noise = new Noise(Object.assign({
47
- context: this.context,
48
- }, options.noise));
47
+ const options = optionsFromArguments(
48
+ NoiseSynth.getDefaults(),
49
+ arguments
50
+ );
51
+ this.noise = new Noise(
52
+ Object.assign(
53
+ {
54
+ context: this.context,
55
+ },
56
+ options.noise
57
+ )
58
+ );
49
59
 
50
- this.envelope = new AmplitudeEnvelope(Object.assign({
51
- context: this.context,
52
- }, options.envelope));
60
+ this.envelope = new AmplitudeEnvelope(
61
+ Object.assign(
62
+ {
63
+ context: this.context,
64
+ },
65
+ options.envelope
66
+ )
67
+ );
53
68
 
54
69
  // connect the noise to the output
55
70
  this.noise.chain(this.envelope, this.output);
@@ -58,17 +73,23 @@ export class NoiseSynth extends Instrument<NoiseSynthOptions> {
58
73
  static getDefaults(): NoiseSynthOptions {
59
74
  return Object.assign(Instrument.getDefaults(), {
60
75
  envelope: Object.assign(
61
- omitFromObject(Envelope.getDefaults(), Object.keys(ToneAudioNode.getDefaults())),
76
+ omitFromObject(
77
+ Envelope.getDefaults(),
78
+ Object.keys(ToneAudioNode.getDefaults())
79
+ ),
62
80
  {
63
81
  decay: 0.1,
64
82
  sustain: 0.0,
65
- },
83
+ }
66
84
  ),
67
85
  noise: Object.assign(
68
- omitFromObject(Noise.getDefaults(), Object.keys(Source.getDefaults())),
86
+ omitFromObject(
87
+ Noise.getDefaults(),
88
+ Object.keys(Source.getDefaults())
89
+ ),
69
90
  {
70
91
  type: "white",
71
- },
92
+ }
72
93
  ),
73
94
  });
74
95
  }
@@ -87,7 +108,11 @@ export class NoiseSynth extends Instrument<NoiseSynthOptions> {
87
108
  // start the noise
88
109
  this.noise.start(time);
89
110
  if (this.envelope.sustain === 0) {
90
- this.noise.stop(time + this.toSeconds(this.envelope.attack) + this.toSeconds(this.envelope.decay));
111
+ this.noise.stop(
112
+ time +
113
+ this.toSeconds(this.envelope.attack) +
114
+ this.toSeconds(this.envelope.decay)
115
+ );
91
116
  }
92
117
  return this;
93
118
  }
@@ -110,7 +135,21 @@ export class NoiseSynth extends Instrument<NoiseSynthOptions> {
110
135
  return this;
111
136
  }
112
137
 
113
- triggerAttackRelease(duration: Time, time?: Time, velocity: NormalRange = 1): this {
138
+ /**
139
+ * Trigger the attack and then the release after the duration.
140
+ * @param duration The amount of time to hold the note for
141
+ * @param time The time the note should start
142
+ * @param velocity The volume of the note (0-1)
143
+ * @example
144
+ * const noiseSynth = new Tone.NoiseSynth().toDestination();
145
+ * // hold the note for 0.5 seconds
146
+ * noiseSynth.triggerAttackRelease(0.5);
147
+ */
148
+ triggerAttackRelease(
149
+ duration: Time,
150
+ time?: Time,
151
+ velocity: NormalRange = 1
152
+ ): this {
114
153
  time = this.toSeconds(time);
115
154
  duration = this.toSeconds(duration);
116
155
  this.triggerAttack(time, velocity);
package/Tone/version.ts CHANGED
@@ -1 +1 @@
1
- export const version: string = "14.8.32";
1
+ export const version: string = "14.8.33";