spessasynth_lib 3.21.6 → 3.21.7
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/@types/synthetizer/audio_effects/fancy_chorus.d.ts +7 -3
- package/@types/synthetizer/synthetizer.d.ts +11 -0
- package/package.json +1 -1
- package/synthetizer/audio_effects/fancy_chorus.js +32 -3
- package/synthetizer/synthetizer.js +24 -0
- package/synthetizer/worklet_processor.min.js +9 -9
- package/synthetizer/worklet_system/worklet_utilities/stereo_panner.js +1 -1
- package/synthetizer/worklet_system/worklet_utilities/volume_envelope.js +7 -0
|
@@ -15,6 +15,10 @@ export class FancyChorus {
|
|
|
15
15
|
*/
|
|
16
16
|
constructor(output: AudioNode, config?: ChorusConfig);
|
|
17
17
|
input: ChannelSplitterNode;
|
|
18
|
+
merger: ChannelMergerNode;
|
|
19
|
+
chorusLeft: ChorusNode[];
|
|
20
|
+
chorusRight: ChorusNode[];
|
|
21
|
+
delete(): void;
|
|
18
22
|
/**
|
|
19
23
|
* @param freq {number}
|
|
20
24
|
* @param delay {number}
|
|
@@ -50,7 +54,7 @@ export type ChorusConfig = {
|
|
|
50
54
|
*/
|
|
51
55
|
stereoDifference: number;
|
|
52
56
|
/**
|
|
53
|
-
* - the initial delay oscillator frequency, in Hz.
|
|
57
|
+
* - the initial delay time oscillator frequency, in Hz.
|
|
54
58
|
*/
|
|
55
59
|
oscillatorFrequency: number;
|
|
56
60
|
/**
|
|
@@ -79,7 +83,7 @@ export type ChorusConfig = {
|
|
|
79
83
|
* @property {number} defaultDelay - the initial delay, in seconds
|
|
80
84
|
* @property {number} delayVariation - the difference between delays in the delay nodes
|
|
81
85
|
* @property {number} stereoDifference - the difference of delays between two channels (added to the left channel and subtracted from the right)
|
|
82
|
-
* @property {number} oscillatorFrequency - the initial delay oscillator frequency, in Hz.
|
|
86
|
+
* @property {number} oscillatorFrequency - the initial delay time oscillator frequency, in Hz.
|
|
83
87
|
* @property {number} oscillatorFrequencyVariation - the difference between frequencies of oscillators, in Hz
|
|
84
88
|
* @property {number} oscillatorGain - how much will oscillator alter the delay in delay nodes, in seconds
|
|
85
89
|
*/
|
|
@@ -87,7 +91,7 @@ declare const NODES_AMOUNT: 4;
|
|
|
87
91
|
declare const DEFAULT_DELAY: 0.03;
|
|
88
92
|
declare const DELAY_VARIATION: 0.01;
|
|
89
93
|
declare const STEREO_DIFF: 0.02;
|
|
90
|
-
declare const OSC_FREQ: 0.
|
|
94
|
+
declare const OSC_FREQ: 0.2;
|
|
91
95
|
declare const OSC_FREQ_VARIATION: 0.05;
|
|
92
96
|
declare const OSC_GAIN: 0.003;
|
|
93
97
|
export {};
|
|
@@ -33,6 +33,7 @@ export class Synthetizer {
|
|
|
33
33
|
*/
|
|
34
34
|
constructor(targetNode: AudioNode, soundFontBuffer: ArrayBuffer, enableEventSystem?: boolean, startRenderingData?: StartRenderingDataConfig, effectsConfig?: EffectsConfig);
|
|
35
35
|
context: BaseAudioContext;
|
|
36
|
+
targetNode: AudioNode;
|
|
36
37
|
/**
|
|
37
38
|
* Allows to set up custom event listeners for the synthesizer
|
|
38
39
|
* @type {EventHandler}
|
|
@@ -305,6 +306,16 @@ export class Synthetizer {
|
|
|
305
306
|
* @param message {ArrayLike<number>} the midi message, each number is a byte
|
|
306
307
|
*/
|
|
307
308
|
sendMessage(message: ArrayLike<number>): void;
|
|
309
|
+
/**
|
|
310
|
+
* Updates the reverb processor with a new impulse response
|
|
311
|
+
* @param buffer {AudioBuffer} the new reverb impulse response
|
|
312
|
+
*/
|
|
313
|
+
setReverbResponse(buffer: AudioBuffer): void;
|
|
314
|
+
/**
|
|
315
|
+
* Updates the chorus processor parameters
|
|
316
|
+
* @param config {ChorusConfig} the new chorus
|
|
317
|
+
*/
|
|
318
|
+
setChorusConfig(config: ChorusConfig): void;
|
|
308
319
|
reverbateEverythingBecauseWhyNot(): string;
|
|
309
320
|
}
|
|
310
321
|
export type StartRenderingDataConfig = {
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* @property {number} defaultDelay - the initial delay, in seconds
|
|
18
18
|
* @property {number} delayVariation - the difference between delays in the delay nodes
|
|
19
19
|
* @property {number} stereoDifference - the difference of delays between two channels (added to the left channel and subtracted from the right)
|
|
20
|
-
* @property {number} oscillatorFrequency - the initial delay oscillator frequency, in Hz.
|
|
20
|
+
* @property {number} oscillatorFrequency - the initial delay time oscillator frequency, in Hz.
|
|
21
21
|
* @property {number} oscillatorFrequencyVariation - the difference between frequencies of oscillators, in Hz
|
|
22
22
|
* @property {number} oscillatorGain - how much will oscillator alter the delay in delay nodes, in seconds
|
|
23
23
|
*/
|
|
@@ -27,7 +27,7 @@ const DEFAULT_DELAY = 0.03;
|
|
|
27
27
|
const DELAY_VARIATION = 0.01;
|
|
28
28
|
const STEREO_DIFF = 0.02;
|
|
29
29
|
|
|
30
|
-
const OSC_FREQ = 0.
|
|
30
|
+
const OSC_FREQ = 0.2;
|
|
31
31
|
const OSC_FREQ_VARIATION = 0.05;
|
|
32
32
|
const OSC_GAIN = 0.003;
|
|
33
33
|
|
|
@@ -99,6 +99,35 @@ export class FancyChorus
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
merger.connect(output);
|
|
102
|
+
this.merger = merger;
|
|
103
|
+
this.chorusLeft = chorusNodesLeft;
|
|
104
|
+
this.chorusRight = chorusNodesRight;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
delete()
|
|
108
|
+
{
|
|
109
|
+
this.input.disconnect();
|
|
110
|
+
delete this.input;
|
|
111
|
+
this.merger.disconnect();
|
|
112
|
+
delete this.merger;
|
|
113
|
+
for (const chorusLeftElement of this.chorusLeft)
|
|
114
|
+
{
|
|
115
|
+
chorusLeftElement.delay.disconnect();
|
|
116
|
+
chorusLeftElement.oscillator.disconnect();
|
|
117
|
+
chorusLeftElement.oscillatorGain.disconnect();
|
|
118
|
+
delete chorusLeftElement.delay;
|
|
119
|
+
delete chorusLeftElement.oscillatorGain;
|
|
120
|
+
delete chorusLeftElement.oscillatorGain;
|
|
121
|
+
}
|
|
122
|
+
for (const chorusRightElement of this.chorusRight)
|
|
123
|
+
{
|
|
124
|
+
chorusRightElement.delay.disconnect();
|
|
125
|
+
chorusRightElement.oscillator.disconnect();
|
|
126
|
+
chorusRightElement.oscillatorGain.disconnect();
|
|
127
|
+
delete chorusRightElement.delay;
|
|
128
|
+
delete chorusRightElement.oscillatorGain;
|
|
129
|
+
delete chorusRightElement.oscillatorGain;
|
|
130
|
+
}
|
|
102
131
|
}
|
|
103
132
|
|
|
104
133
|
/**
|
|
@@ -126,7 +155,7 @@ export class FancyChorus
|
|
|
126
155
|
|
|
127
156
|
oscillator.connect(gainNode);
|
|
128
157
|
gainNode.connect(delayNode.delayTime);
|
|
129
|
-
oscillator.start(context.currentTime
|
|
158
|
+
oscillator.start(context.currentTime /*+ delay*/);
|
|
130
159
|
|
|
131
160
|
this.input.connect(delayNode, input);
|
|
132
161
|
delayNode.connect(output, 0, outputNum);
|
|
@@ -63,6 +63,7 @@ export class Synthetizer
|
|
|
63
63
|
{
|
|
64
64
|
SpessaSynthInfo("%cInitializing SpessaSynth synthesizer...", consoleColors.info);
|
|
65
65
|
this.context = targetNode.context;
|
|
66
|
+
this.targetNode = targetNode;
|
|
66
67
|
const oneOutputMode = startRenderingData?.oneOutput === true;
|
|
67
68
|
|
|
68
69
|
/**
|
|
@@ -812,6 +813,29 @@ export class Synthetizer
|
|
|
812
813
|
}
|
|
813
814
|
}
|
|
814
815
|
|
|
816
|
+
/**
|
|
817
|
+
* Updates the reverb processor with a new impulse response
|
|
818
|
+
* @param buffer {AudioBuffer} the new reverb impulse response
|
|
819
|
+
*/
|
|
820
|
+
setReverbResponse(buffer)
|
|
821
|
+
{
|
|
822
|
+
this.reverbProcessor.buffer = buffer;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
/**
|
|
826
|
+
* Updates the chorus processor parameters
|
|
827
|
+
* @param config {ChorusConfig} the new chorus
|
|
828
|
+
*/
|
|
829
|
+
setChorusConfig(config)
|
|
830
|
+
{
|
|
831
|
+
console.log(config);
|
|
832
|
+
this.worklet.disconnect(this.chorusProcessor.input);
|
|
833
|
+
this.chorusProcessor.delete();
|
|
834
|
+
delete this.chorusProcessor;
|
|
835
|
+
this.chorusProcessor = new FancyChorus(this.targetNode, config);
|
|
836
|
+
this.worklet.connect(this.chorusProcessor.input, 1);
|
|
837
|
+
}
|
|
838
|
+
|
|
815
839
|
reverbateEverythingBecauseWhyNot()
|
|
816
840
|
{
|
|
817
841
|
for (let i = 0; i < this.channelsAmount; i++)
|