spessasynth_lib 3.16.5 → 3.20.0
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/@types/index.d.ts +5 -4
- package/@types/midi_parser/basic_midi.d.ts +125 -0
- package/@types/midi_parser/midi_builder.d.ts +69 -0
- package/@types/midi_parser/midi_data.d.ts +2 -2
- package/@types/midi_parser/midi_editor.d.ts +4 -4
- package/@types/midi_parser/midi_loader.d.ts +3 -100
- package/@types/midi_parser/midi_writer.d.ts +2 -2
- package/@types/midi_parser/rmidi_writer.d.ts +3 -3
- package/@types/midi_parser/used_keys_loaded.d.ts +2 -2
- package/@types/sequencer/sequencer.d.ts +1 -1
- package/@types/soundfont/basic_soundfont/basic_sample.d.ts +2 -2
- package/@types/soundfont/basic_soundfont/basic_zone.d.ts +12 -12
- package/@types/soundfont/basic_soundfont/basic_zones.d.ts +4 -0
- package/@types/soundfont/basic_soundfont/riff_chunk.d.ts +6 -0
- package/@types/soundfont/basic_soundfont/write_sf2/soundfont_trimmer.d.ts +2 -2
- package/@types/soundfont/dls/articulator_converter.d.ts +10 -0
- package/@types/soundfont/dls/dls_destinations.d.ts +29 -0
- package/@types/soundfont/dls/dls_preset.d.ts +13 -0
- package/@types/soundfont/dls/dls_sample.d.ts +18 -0
- package/@types/soundfont/dls/dls_soundfont.d.ts +31 -0
- package/@types/soundfont/dls/dls_sources.d.ts +22 -0
- package/@types/soundfont/dls/dls_zone.d.ts +22 -0
- package/@types/soundfont/dls/read_articulation.d.ts +12 -0
- package/@types/soundfont/dls/read_instrument.d.ts +5 -0
- package/@types/soundfont/dls/read_instrument_list.d.ts +5 -0
- package/@types/soundfont/dls/read_lart.d.ts +7 -0
- package/@types/soundfont/dls/read_region.d.ts +7 -0
- package/@types/soundfont/dls/read_samples.d.ts +5 -0
- package/@types/soundfont/load_soundfont.d.ts +6 -0
- package/@types/soundfont/read_sf2/generators.d.ts +18 -5
- package/@types/soundfont/read_sf2/modulators.d.ts +1 -0
- package/@types/soundfont/soundfont.d.ts +2 -1
- package/@types/synthetizer/synthetizer.d.ts +2 -2
- package/@types/utils/byte_functions/little_endian.d.ts +1 -1
- package/README.md +27 -15
- package/index.js +6 -4
- package/midi_parser/basic_midi.js +146 -0
- package/midi_parser/midi_builder.js +281 -0
- package/midi_parser/midi_data.js +1 -1
- package/midi_parser/midi_editor.js +2 -2
- package/midi_parser/midi_loader.js +38 -56
- package/midi_parser/midi_writer.js +1 -1
- package/midi_parser/rmidi_writer.js +2 -2
- package/midi_parser/used_keys_loaded.js +1 -1
- package/package.json +1 -1
- package/sequencer/sequencer.js +1 -1
- package/sequencer/worklet_sequencer/song_control.js +3 -3
- package/sequencer/worklet_sequencer/worklet_sequencer.js +1 -1
- package/soundfont/README.md +6 -2
- package/soundfont/basic_soundfont/basic_sample.js +3 -3
- package/soundfont/basic_soundfont/basic_zone.js +28 -28
- package/soundfont/basic_soundfont/basic_zones.js +15 -19
- package/soundfont/basic_soundfont/riff_chunk.js +20 -4
- package/soundfont/basic_soundfont/write_sf2/soundfont_trimmer.js +1 -1
- package/soundfont/dls/articulator_converter.js +311 -0
- package/soundfont/dls/dls_destinations.js +38 -0
- package/soundfont/dls/dls_preset.js +32 -0
- package/soundfont/dls/dls_sample.js +58 -0
- package/soundfont/dls/dls_soundfont.js +150 -0
- package/soundfont/dls/dls_sources.js +26 -0
- package/soundfont/dls/dls_zone.js +75 -0
- package/soundfont/dls/read_articulation.js +327 -0
- package/soundfont/dls/read_instrument.js +100 -0
- package/soundfont/dls/read_instrument_list.js +17 -0
- package/soundfont/dls/read_lart.js +35 -0
- package/soundfont/dls/read_region.js +129 -0
- package/soundfont/dls/read_samples.js +174 -0
- package/soundfont/load_soundfont.js +21 -0
- package/soundfont/read_sf2/generators.js +41 -6
- package/soundfont/read_sf2/instruments.js +2 -2
- package/soundfont/read_sf2/modulators.js +8 -8
- package/soundfont/read_sf2/presets.js +7 -7
- package/soundfont/read_sf2/samples.js +8 -8
- package/soundfont/read_sf2/zones.js +5 -5
- package/soundfont/soundfont.js +8 -3
- package/synthetizer/synthetizer.js +1 -1
- package/synthetizer/worklet_processor.min.js +10 -7
- package/synthetizer/worklet_system/main_processor.js +1 -2
- package/synthetizer/worklet_system/worklet_methods/program_control.js +6 -3
- package/synthetizer/worklet_system/worklet_methods/worklet_soundfont_manager/worklet_soundfont_manager.js +5 -5
- package/utils/buffer_to_wav.js +5 -26
- package/utils/byte_functions/little_endian.js +1 -1
- /package/@types/{midi_handler → external_midi}/midi_handler.d.ts +0 -0
- /package/@types/{midi_handler → external_midi}/web_midi_link.d.ts +0 -0
- /package/{midi_handler → external_midi}/README.md +0 -0
- /package/{midi_handler → external_midi}/midi_handler.js +0 -0
- /package/{midi_handler → external_midi}/web_midi_link.js +0 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { DEFAULT_PERCUSSION, DEFAULT_SYNTH_MODE, VOICE_CAP } from '../synthetizer.js'
|
|
2
|
-
import { SoundFont2 } from '../../soundfont/soundfont.js'
|
|
3
2
|
import { WorkletSequencer } from '../../sequencer/worklet_sequencer/worklet_sequencer.js'
|
|
4
3
|
import { SpessaSynthInfo } from '../../utils/loggin.js'
|
|
5
4
|
import { consoleColors } from '../../utils/other.js'
|
|
@@ -134,7 +133,7 @@ class SpessaSynthProcessor extends AudioWorkletProcessor
|
|
|
134
133
|
|
|
135
134
|
/**
|
|
136
135
|
* Overrides the main soundfont (embedded for example
|
|
137
|
-
* @type {
|
|
136
|
+
* @type {BasicSoundFont}
|
|
138
137
|
*/
|
|
139
138
|
this.overrideSoundfont = undefined;
|
|
140
139
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { midiControllers } from '../../../midi_parser/midi_message.js'
|
|
2
|
-
import { SoundFont2 } from '../../../soundfont/soundfont.js'
|
|
3
2
|
import { clearSamplesList } from '../worklet_utilities/worklet_voice.js'
|
|
4
3
|
import { generatorTypes } from '../../../soundfont/read_sf2/generators.js'
|
|
5
4
|
import { returnMessageType } from '../message_protocol/worklet_message.js'
|
|
6
5
|
import { SpessaSynthInfo } from '../../../utils/loggin.js'
|
|
7
6
|
import { consoleColors } from '../../../utils/other.js'
|
|
7
|
+
import { loadSoundFont } from '../../../soundfont/load_soundfont.js'
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* executes a program change
|
|
@@ -196,7 +196,10 @@ export function clearSoundFont(sendPresets = true, clearOverride = true)
|
|
|
196
196
|
{
|
|
197
197
|
channelObject.cachedVoices.push([]);
|
|
198
198
|
}
|
|
199
|
-
|
|
199
|
+
if(!clearOverride)
|
|
200
|
+
{
|
|
201
|
+
channelObject.lockPreset = false;
|
|
202
|
+
}
|
|
200
203
|
this.programChange(i, channelObject.preset.program);
|
|
201
204
|
}
|
|
202
205
|
if(sendPresets)
|
|
@@ -217,7 +220,7 @@ export function reloadSoundFont(buffer, isOverride = false)
|
|
|
217
220
|
{
|
|
218
221
|
if(isOverride)
|
|
219
222
|
{
|
|
220
|
-
this.overrideSoundfont =
|
|
223
|
+
this.overrideSoundfont = loadSoundFont(buffer);
|
|
221
224
|
// assign sample offset
|
|
222
225
|
this.overrideSoundfont.setSampleIDOffset(this.soundfontManager.totalSoundfontOffset)
|
|
223
226
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { SoundFont2 } from '../../../../soundfont/soundfont.js'
|
|
2
1
|
import { SpessaSynthWarn } from '../../../../utils/loggin.js'
|
|
3
2
|
import { WorkletSoundfontManagerMessageType } from './sfman_message.js'
|
|
3
|
+
import { loadSoundFont } from '../../../../soundfont/load_soundfont.js'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @typedef {Object} SoundFontType
|
|
7
7
|
* @property {string} id - unique id for the soundfont
|
|
8
|
-
* @property {
|
|
8
|
+
* @property {BasicSoundFont} soundfont - the soundfont itself
|
|
9
9
|
* @property {number} bankOffset - the soundfont's bank offset
|
|
10
10
|
*/
|
|
11
11
|
|
|
@@ -110,7 +110,7 @@ export class WorkletSoundfontManager
|
|
|
110
110
|
*/
|
|
111
111
|
reloadManager(soundFontArrayBuffer)
|
|
112
112
|
{
|
|
113
|
-
const font =
|
|
113
|
+
const font = loadSoundFont(soundFontArrayBuffer);
|
|
114
114
|
/**
|
|
115
115
|
* All the soundfonts, ordered from the most important to the least.
|
|
116
116
|
* @type {SoundFontType[]}
|
|
@@ -159,7 +159,7 @@ export class WorkletSoundfontManager
|
|
|
159
159
|
}
|
|
160
160
|
this.soundfontList.push({
|
|
161
161
|
id: id,
|
|
162
|
-
soundfont:
|
|
162
|
+
soundfont: loadSoundFont(buffer),
|
|
163
163
|
bankOffset: bankOffset
|
|
164
164
|
});
|
|
165
165
|
this.generatePresetList();
|
|
@@ -182,7 +182,7 @@ export class WorkletSoundfontManager
|
|
|
182
182
|
* Gets a given preset from the soundfont stack
|
|
183
183
|
* @param bankNumber {number}
|
|
184
184
|
* @param programNumber {number}
|
|
185
|
-
* @returns {
|
|
185
|
+
* @returns {BasicPreset} the preset
|
|
186
186
|
*/
|
|
187
187
|
getPreset(bankNumber, programNumber)
|
|
188
188
|
{
|
package/utils/buffer_to_wav.js
CHANGED
|
@@ -113,39 +113,18 @@ export function audioBufferToWav(audioBuffer, normalizeAudio = true, channelOffs
|
|
|
113
113
|
wavData.set(header, 0);
|
|
114
114
|
|
|
115
115
|
// Interleave audio data (combine channels)
|
|
116
|
-
let multiplier;
|
|
116
|
+
let multiplier = 32767;
|
|
117
117
|
if(normalizeAudio)
|
|
118
118
|
{
|
|
119
119
|
// find min and max values to prevent clipping when converting to 16 bits
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
const max = Math.max(
|
|
123
|
-
channel1Data.reduce((max, value) => (value > max ? value : max), -Infinity),
|
|
124
|
-
channel2Data.reduce((max, value) => (value > max ? value : max), -Infinity)
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
const min = Math.min(
|
|
128
|
-
channel1Data.reduce((min, value) => (value < min ? value : min), Infinity),
|
|
129
|
-
channel2Data.reduce((min, value) => (value < min ? value : min), Infinity)
|
|
130
|
-
);
|
|
131
|
-
const maxAbsValue = Math.max(max, Math.abs(min));
|
|
132
|
-
multiplier = initialMultiplier / maxAbsValue;
|
|
133
|
-
}
|
|
134
|
-
else
|
|
135
|
-
{
|
|
136
|
-
multiplier = 32767;
|
|
137
|
-
// clip audio
|
|
138
|
-
for(let i = 0; i < length; i++)
|
|
139
|
-
{
|
|
140
|
-
channel1Data[i] = Math.min(1, Math.max(-1, channel1Data[i]));
|
|
141
|
-
channel2Data[i] = Math.min(1, Math.max(-1, channel2Data[i]));
|
|
142
|
-
}
|
|
120
|
+
const maxAbsValue = channel1Data.map((v, i) => Math.max(Math.abs(v), Math.abs(channel2Data[i]))).reduce( (a,b) => Math.max(a,b))
|
|
121
|
+
multiplier = maxAbsValue > 0 ? (32767 / maxAbsValue) : 1;
|
|
143
122
|
}
|
|
144
123
|
for (let i = 0; i < length; i++)
|
|
145
124
|
{
|
|
146
125
|
// interleave both channels
|
|
147
|
-
const sample1 = channel1Data[i] * multiplier;
|
|
148
|
-
const sample2 = channel2Data[i] * multiplier;
|
|
126
|
+
const sample1 = Math.min(1, Math.max(-1, channel1Data[i])) * multiplier;
|
|
127
|
+
const sample2 = Math.min(1, Math.max(-1,channel2Data[i])) * multiplier;
|
|
149
128
|
|
|
150
129
|
// convert to 16-bit
|
|
151
130
|
wavData[offset++] = sample1 & 0xff;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|