spessasynth_lib 3.25.13 → 3.25.15

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.
@@ -4,22 +4,32 @@ import { reverbBufferBinary } from "./reverb_as_binary.js";
4
4
  * Creates a reverb processor
5
5
  * @param context {BaseAudioContext}
6
6
  * @param reverbBuffer {AudioBuffer}
7
- * @returns {ConvolverNode}
7
+ * @returns {{conv: ConvolverNode, promise: Promise<AudioBuffer>}}
8
8
  */
9
9
  export function getReverbProcessor(context, reverbBuffer = undefined)
10
10
  {
11
+ let solve;
12
+ /**
13
+ * @type {Promise<AudioBuffer>}
14
+ */
15
+ let promise = new Promise(r => solve = r);
11
16
  const convolver = context.createConvolver();
12
17
  if (reverbBuffer)
13
18
  {
14
19
  convolver.buffer = reverbBuffer;
20
+ solve();
15
21
  }
16
22
  else
17
23
  {
18
24
  // decode
19
- context.decodeAudioData(reverbBufferBinary.slice(0, reverbBufferBinary.byteLength)).then(b =>
25
+ promise = context.decodeAudioData(reverbBufferBinary.slice(0));
26
+ promise.then(b =>
20
27
  {
21
28
  convolver.buffer = b;
22
29
  });
23
30
  }
24
- return convolver;
31
+ return {
32
+ conv: convolver,
33
+ promise: promise
34
+ };
25
35
  }
@@ -1,6 +1,8 @@
1
- import { rb } from "./reverb_buffer.min.js";
1
+ import { rbCompressed } from "./rb_compressed.min.js";
2
+ import { inflateSync } from "../../externals/fflate/fflate.min.js";
2
3
 
3
- const binaryString = atob(rb);
4
+ // convert the base64 string to array buffer
5
+ const binaryString = atob(rbCompressed);
4
6
  const binary = new Uint8Array(binaryString.length);
5
7
  for (let i = 0; i < binaryString.length; i++)
6
8
  {
@@ -9,7 +11,8 @@ for (let i = 0; i < binaryString.length; i++)
9
11
 
10
12
 
11
13
  /**
14
+ * the reverb is zlib compressed, decompress here
12
15
  * @type {ArrayBuffer}
13
16
  */
14
- const reverbBufferBinary = binary.buffer;
17
+ const reverbBufferBinary = inflateSync(binary).buffer;
15
18
  export { reverbBufferBinary };
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * @typedef {Object} StartRenderingDataConfig
3
3
  * @property {BasicMIDI} parsedMIDI - the MIDI to render
4
- * @property {SynthesizerSnapshot} snapshot - the snapshot to apply
5
- * @property {boolean|undefined} oneOutput - if synth should use one output with 32 channels (2 audio channels for each midi channel).
4
+ * @property {SynthesizerSnapshot?} snapshot - the snapshot to apply
5
+ * @property {boolean?} oneOutput - if synth should use one output with 32 channels (2 audio channels for each midi channel).
6
6
  * this disabled chorus and reverb.
7
- * @property {number|undefined} loopCount - the times to loop the song
8
- * @property {SequencerOptions} sequencerOptions - the options to pass to the sequencer
7
+ * @property {number?} loopCount - the times to loop the song
8
+ * @property {SequencerOptions?} sequencerOptions - the options to pass to the sequencer
9
9
  */
10
10
 
11
11
  export const WORKLET_PROCESSOR_NAME = "spessasynth-worklet-system";
@@ -207,7 +207,9 @@ export class Synthetizer
207
207
  const chorusOn = this.effectsConfig?.chorusEnabled ?? true;
208
208
  if (reverbOn)
209
209
  {
210
- this.reverbProcessor = getReverbProcessor(this.context, this.effectsConfig.reverbImpulseResponse);
210
+ const proc = getReverbProcessor(this.context, this.effectsConfig.reverbImpulseResponse);
211
+ this.reverbProcessor = proc.conv;
212
+ this.isReady = Promise.all([this.isReady, proc.promise]);
211
213
  this.reverbProcessor.connect(targetNode);
212
214
  this.worklet.connect(this.reverbProcessor, 0);
213
215
  }