spessasynth_core 1.0.4 → 1.0.6
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/.idea/inspectionProfiles/Project_Default.xml +0 -0
- package/.idea/jsLibraryMappings.xml +0 -0
- package/.idea/modules.xml +0 -0
- package/.idea/spessasynth_core.iml +0 -0
- package/.idea/vcs.xml +0 -0
- package/LICENSE +0 -0
- package/README.md +15 -1
- package/index.js +2 -1
- package/package.json +2 -2
- package/spessasynth_core/midi_parser/README.md +0 -0
- package/spessasynth_core/midi_parser/midi_loader.js +0 -0
- package/spessasynth_core/midi_parser/midi_message.js +0 -0
- package/spessasynth_core/sequencer/sequencer.js +0 -0
- package/spessasynth_core/sequencer/worklet_sequencer/play.js +0 -0
- package/spessasynth_core/sequencer/worklet_sequencer/process_event.js +0 -0
- package/spessasynth_core/sequencer/worklet_sequencer/process_tick.js +0 -0
- package/spessasynth_core/sequencer/worklet_sequencer/song_control.js +0 -0
- package/spessasynth_core/soundfont/README.md +0 -0
- package/spessasynth_core/soundfont/chunk/generators.js +0 -0
- package/spessasynth_core/soundfont/chunk/instruments.js +0 -0
- package/spessasynth_core/soundfont/chunk/modulators.js +0 -0
- package/spessasynth_core/soundfont/chunk/presets.js +0 -0
- package/spessasynth_core/soundfont/chunk/riff_chunk.js +0 -0
- package/spessasynth_core/soundfont/chunk/samples.js +0 -0
- package/spessasynth_core/soundfont/chunk/zones.js +0 -0
- package/spessasynth_core/soundfont/soundfont_parser.js +0 -0
- package/spessasynth_core/synthetizer/README.md +0 -0
- package/spessasynth_core/synthetizer/synthesizer.js +0 -0
- package/spessasynth_core/synthetizer/worklet_system/README.md +0 -0
- package/spessasynth_core/synthetizer/worklet_system/worklet_methods/controller_control.js +0 -0
- package/spessasynth_core/synthetizer/worklet_system/worklet_methods/data_entry.js +0 -0
- package/spessasynth_core/synthetizer/worklet_system/worklet_methods/note_off.js +0 -0
- package/spessasynth_core/synthetizer/worklet_system/worklet_methods/note_on.js +2 -2
- package/spessasynth_core/synthetizer/worklet_system/worklet_methods/program_control.js +0 -0
- package/spessasynth_core/synthetizer/worklet_system/worklet_methods/system_exclusive.js +0 -0
- package/spessasynth_core/synthetizer/worklet_system/worklet_methods/tuning_control.js +0 -0
- package/spessasynth_core/synthetizer/worklet_system/worklet_methods/vibrato_control.js +0 -0
- package/spessasynth_core/synthetizer/worklet_system/worklet_methods/voice_control.js +51 -15
- package/spessasynth_core/synthetizer/worklet_system/worklet_utilities/lfo.js +0 -0
- package/spessasynth_core/synthetizer/worklet_system/worklet_utilities/lowpass_filter.js +0 -0
- package/spessasynth_core/synthetizer/worklet_system/worklet_utilities/modulation_envelope.js +0 -0
- package/spessasynth_core/synthetizer/worklet_system/worklet_utilities/modulator_curves.js +0 -0
- package/spessasynth_core/synthetizer/worklet_system/worklet_utilities/stereo_panner.js +0 -0
- package/spessasynth_core/synthetizer/worklet_system/worklet_utilities/unit_converter.js +0 -0
- package/spessasynth_core/synthetizer/worklet_system/worklet_utilities/volume_envelope.js +0 -0
- package/spessasynth_core/synthetizer/worklet_system/worklet_utilities/wavetable_oscillator.js +0 -0
- package/spessasynth_core/synthetizer/worklet_system/worklet_utilities/worklet_modulator.js +0 -0
- package/spessasynth_core/synthetizer/worklet_system/worklet_utilities/worklet_processor_channel.js +0 -0
- package/spessasynth_core/synthetizer/worklet_system/worklet_utilities/worklet_voice.js +0 -0
- package/spessasynth_core/utils/README.md +0 -0
- package/spessasynth_core/utils/buffer_to_wav.js +0 -0
- package/spessasynth_core/utils/byte_functions.js +0 -0
- package/spessasynth_core/utils/loggin.js +0 -0
- package/spessasynth_core/utils/other.js +0 -0
- package/spessasynth_core/utils/shiftable_array.js +0 -0
- package/spessasynth_core/utils/stbvorbis_sync.js +0 -0
|
File without changes
|
|
File without changes
|
package/.idea/modules.xml
CHANGED
|
File without changes
|
|
File without changes
|
package/.idea/vcs.xml
CHANGED
|
File without changes
|
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
@@ -59,6 +59,7 @@ import("spessasynth_core").then(core => {
|
|
|
59
59
|
- [Sequencer](#sequencer)
|
|
60
60
|
- [MIDI](#midi)
|
|
61
61
|
- [SoundFont2](#soundfont2)
|
|
62
|
+
- [How to disable console output](#logging)
|
|
62
63
|
|
|
63
64
|
### Importing the library
|
|
64
65
|
spessasynth_core is an es6 package.
|
|
@@ -373,4 +374,17 @@ console.log(`The track lasts for ${sequencer.duration} seconds!`);
|
|
|
373
374
|
See [MIDI on SpessaSynth wiki](https://github.com/spessasus/SpessaSynth/wiki/MIDI-Class)
|
|
374
375
|
|
|
375
376
|
## SoundFont2
|
|
376
|
-
See [SoundFont2 on SpessaSynth wiki](https://github.com/spessasus/SpessaSynth/wiki/SoundFont2-Class)
|
|
377
|
+
See [SoundFont2 on SpessaSynth wiki](https://github.com/spessasus/SpessaSynth/wiki/SoundFont2-Class)
|
|
378
|
+
|
|
379
|
+
## Logging
|
|
380
|
+
By default, SpessaSynth prints out a lot of stuff to console.
|
|
381
|
+
Here's how you can disable it:
|
|
382
|
+
```js
|
|
383
|
+
// import (or require) here
|
|
384
|
+
SpessaSynthLogging(enableInfo, enableWarning, enableGroup, enableTable);
|
|
385
|
+
```
|
|
386
|
+
All the input variables are booleans corresponding to the things SpessaSynth logs.
|
|
387
|
+
- Info - all general info such as parsing soundfonts, midi files, RPN changes, etc.
|
|
388
|
+
- Warnings - all messages unrecognized by the synthesizer, other warnings
|
|
389
|
+
- group - the groups for parsing the soundfont and midi files.
|
|
390
|
+
- table - the debug table `when enableDebugging` is set to `true` for `synth.noteOn`
|
package/index.js
CHANGED
|
@@ -3,5 +3,6 @@ import {Sequencer} from "./spessasynth_core/sequencer/sequencer.js";
|
|
|
3
3
|
import {MIDI} from "./spessasynth_core/midi_parser/midi_loader.js";
|
|
4
4
|
import {rawDataToWav} from "./spessasynth_core/utils/buffer_to_wav.js";
|
|
5
5
|
import {SoundFont2} from "./spessasynth_core/soundfont/soundfont_parser.js";
|
|
6
|
+
import {SpessaSynthLogging} from "./spessasynth_core/utils/loggin.js";
|
|
6
7
|
|
|
7
|
-
export { Synthesizer, Sequencer, MIDI, SoundFont2, rawDataToWav };
|
|
8
|
+
export { Synthesizer, Sequencer, MIDI, SoundFont2, rawDataToWav, SpessaSynthLogging };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spessasynth_core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "SoundFont2 synthesizer library for node.js",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "https://github.com/spessasus/spessasynth_core.git"
|
|
12
|
+
"url": "git+https://github.com/spessasus/spessasynth_core.git"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|
|
15
15
|
"sf2",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -64,12 +64,12 @@ export function noteOn(channel, midiNote, velocity, enableDebugging = false)
|
|
|
64
64
|
computeModulators(voice, this.workletProcessorChannels[channel].midiControllers);
|
|
65
65
|
voice.currentAttenuationDb = 100;
|
|
66
66
|
})
|
|
67
|
-
channelVoices.push(...voices);
|
|
68
67
|
|
|
69
68
|
this.totalVoicesAmount += voices.length;
|
|
70
69
|
// cap the voices
|
|
71
70
|
if(this.totalVoicesAmount > VOICE_CAP)
|
|
72
71
|
{
|
|
73
|
-
this.voiceKilling(
|
|
72
|
+
this.voiceKilling(voices.length);
|
|
74
73
|
}
|
|
74
|
+
channelVoices.push(...voices);
|
|
75
75
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -143,6 +143,35 @@ export function renderVoice(channel, voice, output, reverbOutput, chorusOutput)
|
|
|
143
143
|
chorusOutput, voice.modulatedGenerators[generatorTypes.chorusEffectsSend]);
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
+
/**
|
|
147
|
+
* @param channel {WorkletProcessorChannel}
|
|
148
|
+
* @param voice {WorkletVoice}
|
|
149
|
+
* @return {number}
|
|
150
|
+
*/
|
|
151
|
+
function getPriority(channel, voice)
|
|
152
|
+
{
|
|
153
|
+
let priority = 0;
|
|
154
|
+
if(channel.drumChannel)
|
|
155
|
+
{
|
|
156
|
+
// important
|
|
157
|
+
priority += 5;
|
|
158
|
+
}
|
|
159
|
+
if(voice.isInRelease)
|
|
160
|
+
{
|
|
161
|
+
// not important
|
|
162
|
+
priority -= 5;
|
|
163
|
+
}
|
|
164
|
+
// less velocity = less important
|
|
165
|
+
priority += voice.velocity / 25; // map to 0-5
|
|
166
|
+
// the newer, more important
|
|
167
|
+
priority -= voice.volumeEnvelopeState;
|
|
168
|
+
if(voice.isInRelease)
|
|
169
|
+
{
|
|
170
|
+
priority -= 5;
|
|
171
|
+
}
|
|
172
|
+
priority -= voice.currentAttenuationDb / 50;
|
|
173
|
+
return priority;
|
|
174
|
+
}
|
|
146
175
|
|
|
147
176
|
/**
|
|
148
177
|
* @this {Synthesizer}
|
|
@@ -150,23 +179,30 @@ export function renderVoice(channel, voice, output, reverbOutput, chorusOutput)
|
|
|
150
179
|
*/
|
|
151
180
|
export function voiceKilling(amount)
|
|
152
181
|
{
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* @type {WorkletVoice[]}
|
|
158
|
-
*/
|
|
159
|
-
voicesOrderedByVelocity = voicesOrderedByVelocity.flat();
|
|
160
|
-
voicesOrderedByVelocity.sort((v1, v2) => v1.velocity - v2.velocity);
|
|
161
|
-
if(voicesOrderedByVelocity.length < amount)
|
|
182
|
+
let allVoices = [];
|
|
183
|
+
for (const channel of this.workletProcessorChannels)
|
|
162
184
|
{
|
|
163
|
-
|
|
185
|
+
for (const voice of channel.voices)
|
|
186
|
+
{
|
|
187
|
+
if (!voice.finished)
|
|
188
|
+
{
|
|
189
|
+
const priority = getPriority(channel, voice);
|
|
190
|
+
allVoices.push({ channel, voice, priority });
|
|
191
|
+
}
|
|
192
|
+
}
|
|
164
193
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
194
|
+
|
|
195
|
+
// Step 2: Sort voices by priority (ascending order)
|
|
196
|
+
allVoices.sort((a, b) => a.priority - b.priority);
|
|
197
|
+
const voicesToRemove = allVoices.slice(0, amount);
|
|
198
|
+
|
|
199
|
+
for (const { channel, voice } of voicesToRemove)
|
|
200
|
+
{
|
|
201
|
+
const index = channel.voices.indexOf(voice);
|
|
202
|
+
if (index > -1)
|
|
203
|
+
{
|
|
204
|
+
channel.voices.splice(index, 1);
|
|
205
|
+
}
|
|
170
206
|
}
|
|
171
207
|
}
|
|
172
208
|
|
|
File without changes
|
|
File without changes
|
package/spessasynth_core/synthetizer/worklet_system/worklet_utilities/modulation_envelope.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/spessasynth_core/synthetizer/worklet_system/worklet_utilities/wavetable_oscillator.js
CHANGED
|
File without changes
|
|
File without changes
|
package/spessasynth_core/synthetizer/worklet_system/worklet_utilities/worklet_processor_channel.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|