spessasynth_lib 3.26.23 → 3.26.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spessasynth_lib",
3
- "version": "3.26.23",
3
+ "version": "3.26.25",
4
4
  "description": "MIDI and SoundFont2/DLS library for the browsers with no compromises",
5
5
  "browser": "index.js",
6
6
  "type": "module",
@@ -31,7 +31,8 @@
31
31
  "web-midi-api",
32
32
  "player",
33
33
  "soundfont2",
34
- "soundfont3"
34
+ "soundfont3",
35
+ "audio-buffer-to-wav"
35
36
  ],
36
37
  "author": {
37
38
  "name": "spessasus",
@@ -10,8 +10,8 @@ import { audioToWav } from "spessasynth_core";
10
10
 
11
11
  // noinspection JSUnusedGlobalSymbols
12
12
  /**
13
- *
14
- * @param audioBuffer {AudioBuffer}
13
+ * Converts an audio buffer into a wave file
14
+ * @param audioBuffer {AudioBuffer} variable channels
15
15
  * @param normalizeAudio {boolean} find the max sample point and set it to 1, and scale others with it
16
16
  * @param channelOffset {number} channel offset and channel offset + 1 get saved
17
17
  * @param metadata {WaveMetadata}
@@ -20,9 +20,16 @@ import { audioToWav } from "spessasynth_core";
20
20
  */
21
21
  export function audioBufferToWav(audioBuffer, normalizeAudio = true, channelOffset = 0, metadata = {}, loop = undefined)
22
22
  {
23
- return new Blob([audioToWav({
24
- leftChannel: audioBuffer.getChannelData(channelOffset),
25
- rightChannel: audioBuffer.getChannelData(channelOffset + 1),
26
- sampleRate: audioBuffer.sampleRate
27
- }, normalizeAudio, metadata, loop)], { type: "audio/wav" });
23
+ /**
24
+ * @type {Float32Array[]}
25
+ */
26
+ const channels = [];
27
+ for (let i = 0; i < audioBuffer.numberOfChannels; i++)
28
+ {
29
+ channels.push(audioBuffer.getChannelData(channelOffset + i));
30
+ }
31
+ return new Blob(
32
+ [audioToWav(channels, audioBuffer.sampleRate, normalizeAudio, metadata, loop)],
33
+ { type: "audio/wav" }
34
+ );
28
35
  }