spessasynth_lib 3.24.34 → 3.24.36

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/index.js CHANGED
@@ -13,7 +13,8 @@ import { MIDIMessage } from "./midi_parser/midi_message.js";
13
13
  import { MIDI } from './midi_parser/midi_loader.js';
14
14
  import { RMIDINFOChunks } from "./midi_parser/rmidi_writer.js";
15
15
  import { MIDIBuilder } from "./midi_parser/midi_builder.js";
16
- import { Synthetizer, VOICE_CAP, DEFAULT_PERCUSSION } from './synthetizer/synthetizer.js';
16
+ import { Synthetizer } from './synthetizer/synthetizer.js';
17
+ import { VOICE_CAP, DEFAULT_PERCUSSION } from "./synthetizer/synth_constants.js";
17
18
  import { Sequencer } from './sequencer/sequencer.js';
18
19
  import { IndexedByteArray } from './utils/indexed_array.js';
19
20
  import { audioBufferToWav } from './utils/buffer_to_wav.js';
@@ -2,9 +2,9 @@ import { messageTypes, midiControllers, MIDIMessage } from "./midi_message.js";
2
2
  import { IndexedByteArray } from "../utils/indexed_array.js";
3
3
  import { SpessaSynthGroupCollapsed, SpessaSynthGroupEnd, SpessaSynthInfo } from "../utils/loggin.js";
4
4
  import { consoleColors } from "../utils/other.js";
5
- import { DEFAULT_PERCUSSION } from "../synthetizer/synthetizer.js";
6
5
 
7
6
  import { customControllers } from "../synthetizer/worklet_system/worklet_utilities/controller_tables.js";
7
+ import { DEFAULT_PERCUSSION } from "../synthetizer/synth_constants.js";
8
8
 
9
9
  /**
10
10
  * @param ticks {number}
@@ -2,11 +2,11 @@ import { combineArrays, IndexedByteArray } from "../utils/indexed_array.js";
2
2
  import { writeRIFFOddSize } from "../soundfont/basic_soundfont/riff_chunk.js";
3
3
  import { getStringBytes, getStringBytesZero } from "../utils/byte_functions/string.js";
4
4
  import { messageTypes, midiControllers, MIDIMessage } from "./midi_message.js";
5
- import { DEFAULT_PERCUSSION } from "../synthetizer/synthetizer.js";
6
5
  import { getGsOn } from "./midi_editor.js";
7
6
  import { SpessaSynthGroup, SpessaSynthGroupEnd, SpessaSynthInfo } from "../utils/loggin.js";
8
7
  import { consoleColors } from "../utils/other.js";
9
8
  import { writeLittleEndian } from "../utils/byte_functions/little_endian.js";
9
+ import { DEFAULT_PERCUSSION } from "../synthetizer/synth_constants.js";
10
10
 
11
11
  /**
12
12
  * @enum {string}
@@ -1,7 +1,7 @@
1
1
  import { SpessaSynthGroupCollapsed, SpessaSynthGroupEnd, SpessaSynthInfo } from "../utils/loggin.js";
2
2
  import { consoleColors } from "../utils/other.js";
3
- import { DEFAULT_PERCUSSION } from "../synthetizer/synthetizer.js";
4
3
  import { messageTypes, midiControllers } from "./midi_message.js";
4
+ import { DEFAULT_PERCUSSION } from "../synthetizer/synth_constants.js";
5
5
 
6
6
  /**
7
7
  * Gets the used programs and keys for this MIDI file with a given sound bank
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spessasynth_lib",
3
- "version": "3.24.34",
3
+ "version": "3.24.36",
4
4
  "description": "MIDI and SoundFont2/DLS library with no compromises",
5
5
  "browser": "index.js",
6
6
  "type": "module",
@@ -4,7 +4,8 @@ import {
4
4
  } from "../../synthetizer/worklet_system/message_protocol/worklet_message.js";
5
5
  import { SongChangeType, WorkletSequencerMessageType, WorkletSequencerReturnMessageType } from "./sequencer_message.js";
6
6
  import { messageTypes, midiControllers } from "../../midi_parser/midi_message.js";
7
- import { MIDI_CHANNEL_COUNT } from "../../synthetizer/synthetizer.js";
7
+
8
+ import { MIDI_CHANNEL_COUNT } from "../../synthetizer/synth_constants.js";
8
9
 
9
10
  /**
10
11
  * @param messageType {WorkletSequencerMessageType}
@@ -14,7 +14,8 @@ import {
14
14
  sendMIDIReset
15
15
  } from "./events.js";
16
16
  import { SpessaSynthWarn } from "../../utils/loggin.js";
17
- import { MIDI_CHANNEL_COUNT } from "../../synthetizer/synthetizer.js";
17
+
18
+ import { MIDI_CHANNEL_COUNT } from "../../synthetizer/synth_constants.js";
18
19
 
19
20
  class WorkletSequencer
20
21
  {
@@ -46,7 +46,8 @@ export function writeDLSSample(sample)
46
46
 
47
47
  for (let i = 0; i < audio.length; i++)
48
48
  {
49
- data16[i] = audio[i] * 32768;
49
+ // 32,767, as 32,768 may cause overflow (because vorbis can go above 1 sometimes)
50
+ data16[i] = audio[i] * 32767;
50
51
  }
51
52
 
52
53
 
@@ -2,13 +2,13 @@ import { DEFAULT_CHORUS_CONFIG } from "./fancy_chorus.js";
2
2
 
3
3
  /**
4
4
  * @typedef {Object} SynthConfig
5
- * @property {boolean} chorusEnabled - indicates if the chorus effect is enabled.
5
+ * @property {boolean?} chorusEnabled - indicates if the chorus effect is enabled.
6
6
  * @property {ChorusConfig?} chorusConfig - the configuration for chorus. Pass undefined to use defaults
7
- * @property {boolean} reverbEnabled - indicates if the reverb effect is enabled.
7
+ * @property {boolean?} reverbEnabled - indicates if the reverb effect is enabled.
8
8
  * @property {AudioBuffer?} reverbImpulseResponse - the impulse response for the reverb. Pass undefined to use defaults
9
9
  * @property {{
10
10
  * worklet: function(context: object, name: string, options?: Object)
11
- * }} audioNodeCreators - custom audio node creation functions for Web Audio wrappers.
11
+ * }?} audioNodeCreators - custom audio node creation functions for Web Audio wrappers.
12
12
  */
13
13
 
14
14
 
@@ -13,13 +13,13 @@
13
13
 
14
14
  /**
15
15
  * @typedef {Object} ChorusConfig
16
- * @property {number} nodesAmount - the amount of delay nodes (for each channel) and the corresponding oscillators
17
- * @property {number} defaultDelay - the initial delay, in seconds
18
- * @property {number} delayVariation - the difference between delays in the delay nodes
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 time oscillator frequency, in Hz.
21
- * @property {number} oscillatorFrequencyVariation - the difference between frequencies of oscillators, in Hz
22
- * @property {number} oscillatorGain - how much will oscillator alter the delay in delay nodes, in seconds
16
+ * @property {number?} nodesAmount - the amount of delay nodes (for each channel) and the corresponding oscillators
17
+ * @property {number?} defaultDelay - the initial delay, in seconds
18
+ * @property {number?} delayVariation - the difference between delays in the delay nodes
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 time oscillator frequency, in Hz.
21
+ * @property {number?} oscillatorFrequencyVariation - the difference between frequencies of oscillators, in Hz
22
+ * @property {number?} oscillatorGain - how much will oscillator alter the delay in delay nodes, in seconds
23
23
  */
24
24
 
25
25
  const NODES_AMOUNT = 4;
@@ -1,3 +1,5 @@
1
+ import { reverbBufferBinary } from "./reverb_as_binary.js";
2
+
1
3
  /**
2
4
  * Creates a reverb processor
3
5
  * @param context {BaseAudioContext}
@@ -13,12 +15,10 @@ export function getReverbProcessor(context, reverbBuffer = undefined)
13
15
  }
14
16
  else
15
17
  {
16
- // resolve relative url
17
- const impulseURL = new URL("impulse_response_2.flac", import.meta.url);
18
- fetch(impulseURL).then(async response =>
18
+ // decode
19
+ context.decodeAudioData(reverbBufferBinary.buffer).then(b =>
19
20
  {
20
- const data = await response.arrayBuffer();
21
- convolver.buffer = await context.decodeAudioData(data);
21
+ convolver.buffer = b;
22
22
  });
23
23
  }
24
24
  return convolver;
@@ -0,0 +1,15 @@
1
+ import { rb } from "./reverb_buffer.min.js";
2
+
3
+ const binaryString = atob(rb);
4
+ const binary = new Uint8Array(binaryString.length);
5
+ for (let i = 0; i < binaryString.length; i++)
6
+ {
7
+ binary[i] = binaryString.charCodeAt(i);
8
+ }
9
+
10
+
11
+ /**
12
+ * @type {ArrayBuffer}
13
+ */
14
+ const reverbBufferBinary = binary.buffer;
15
+ export { reverbBufferBinary };