spessasynth_lib 3.27.1 → 3.27.2

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.27.1",
3
+ "version": "3.27.2",
4
4
  "description": "MIDI and SoundFont2/DLS library for the browsers with no compromises",
5
5
  "browser": "index.js",
6
6
  "type": "module",
@@ -16,17 +16,22 @@ import { audioToWav } from "spessasynth_core";
16
16
  * @param channelOffset {number} channel offset and channel offset + 1 get saved
17
17
  * @param metadata {WaveMetadata}
18
18
  * @param loop {{start: number, end: number}} loop start and end points in seconds. Undefined if no loop
19
+ * @param channelCount {number} the channel count, defaults to all the channels
19
20
  * @returns {Blob}
20
21
  */
21
- export function audioBufferToWav(audioBuffer, normalizeAudio = true, channelOffset = 0, metadata = {}, loop = undefined)
22
+ export function audioBufferToWav(audioBuffer, normalizeAudio = true, channelOffset = 0, metadata = {}, loop = undefined, channelCount = audioBuffer.numberOfChannels)
22
23
  {
23
24
  /**
24
25
  * @type {Float32Array[]}
25
26
  */
26
27
  const channels = [];
27
- for (let i = 0; i < audioBuffer.numberOfChannels; i++)
28
+ for (let i = channelOffset; i < audioBuffer.numberOfChannels; i++)
28
29
  {
29
- channels.push(audioBuffer.getChannelData(channelOffset + i));
30
+ channels.push(audioBuffer.getChannelData(i));
31
+ if (channels.length >= channelCount)
32
+ {
33
+ break;
34
+ }
30
35
  }
31
36
  return new Blob(
32
37
  [audioToWav(channels, audioBuffer.sampleRate, normalizeAudio, metadata, loop)],