spessasynth_lib 3.26.0 → 3.26.1

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.
@@ -0,0 +1,18 @@
1
+ import { BasicMIDI, SynthesizerSnapshot } from "spessasynth_core";
2
+
3
+ /**
4
+ * The absolute path (from the spessasynth_lib folder) to the worklet module
5
+ * @type {string}
6
+ */
7
+ export const WORKLET_URL_ABSOLUTE = "synthetizer/worklet_processor.min.js";
8
+ /**
9
+ * @typedef {Object} StartRenderingDataConfig
10
+ * @property {BasicMIDI} parsedMIDI - the MIDI to render
11
+ * @property {SynthesizerSnapshot?} snapshot - the snapshot to apply
12
+ * @property {boolean?} oneOutput - if synth should use one output with 32 channels (2 audio channels for each midi channel).
13
+ * this disabled chorus and reverb.
14
+ * @property {number?} loopCount - the times to loop the song
15
+ * @property {SequencerOptions?} sequencerOptions - the options to pass to the sequencer
16
+ */
17
+
18
+ export const WORKLET_PROCESSOR_NAME = "spessasynth-worklet-processor";
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @typedef {Object} WaveMetadata
3
+ * @property {string|undefined} title - the song's title
4
+ * @property {string|undefined} artist - the song's artist
5
+ * @property {string|undefined} album - the song's album
6
+ * @property {string|undefined} genre - the song's genre
7
+ */
8
+
9
+ import { audioToWav } from "spessasynth_core";
10
+
11
+ // noinspection JSUnusedGlobalSymbols
12
+ /**
13
+ *
14
+ * @param audioBuffer {AudioBuffer}
15
+ * @param normalizeAudio {boolean} find the max sample point and set it to 1, and scale others with it
16
+ * @param channelOffset {number} channel offset and channel offset + 1 get saved
17
+ * @param metadata {WaveMetadata}
18
+ * @param loop {{start: number, end: number}} loop start and end points in seconds. Undefined if no loop
19
+ * @returns {Blob}
20
+ */
21
+ export function audioBufferToWav(audioBuffer, normalizeAudio = true, channelOffset = 0, metadata = {}, loop = undefined)
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" });
28
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Fills the object with default values
3
+ * @param obj {Object}
4
+ * @param defObj {Object}
5
+ * @returns {Object}
6
+ */
7
+ export function fillWithDefaults(obj, defObj)
8
+ {
9
+ if (obj === undefined)
10
+ {
11
+ obj = {};
12
+ }
13
+ for (const key in defObj)
14
+ {
15
+ if (defObj.hasOwnProperty(key) && !(key in obj))
16
+ {
17
+ obj[key] = defObj[key];
18
+ }
19
+ }
20
+ return obj;
21
+ }
package/utils/other.js ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * other.js
3
+ * purpose: contains some useful functions that don't belong in any specific category
4
+ */
5
+
6
+ import { SpessaSynthCoreUtils } from "spessasynth_core";
7
+
8
+ const consoleColors = SpessaSynthCoreUtils.consoleColors;
9
+
10
+ export { consoleColors };
11
+