spessasynth_lib 3.22.12 → 3.23.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.
Files changed (52) hide show
  1. package/@types/soundfont/basic_soundfont/basic_soundfont.d.ts +2 -0
  2. package/@types/soundfont/basic_soundfont/basic_zone.d.ts +16 -0
  3. package/@types/soundfont/basic_soundfont/generator.d.ts +2 -1
  4. package/@types/soundfont/basic_soundfont/riff_chunk.d.ts +2 -1
  5. package/@types/soundfont/basic_soundfont/write_dls/art2.d.ts +6 -0
  6. package/@types/soundfont/basic_soundfont/write_dls/articulator.d.ts +28 -0
  7. package/@types/soundfont/basic_soundfont/write_dls/combine_zones.d.ts +8 -0
  8. package/@types/soundfont/basic_soundfont/write_dls/ins.d.ts +7 -0
  9. package/@types/soundfont/basic_soundfont/write_dls/lins.d.ts +5 -0
  10. package/@types/soundfont/basic_soundfont/write_dls/modulator_converter.d.ts +11 -0
  11. package/@types/soundfont/basic_soundfont/write_dls/rgn2.d.ts +7 -0
  12. package/@types/soundfont/basic_soundfont/write_dls/wave.d.ts +6 -0
  13. package/@types/soundfont/basic_soundfont/write_dls/write_dls.d.ts +6 -0
  14. package/@types/soundfont/basic_soundfont/write_dls/wsmp.d.ts +12 -0
  15. package/@types/soundfont/basic_soundfont/write_dls/wvpl.d.ts +8 -0
  16. package/midi_parser/midi_editor.js +0 -0
  17. package/package.json +1 -1
  18. package/soundfont/basic_soundfont/basic_preset.js +23 -12
  19. package/soundfont/basic_soundfont/basic_soundfont.js +2 -0
  20. package/soundfont/basic_soundfont/basic_zone.js +30 -5
  21. package/soundfont/basic_soundfont/generator.js +10 -4
  22. package/soundfont/basic_soundfont/riff_chunk.js +20 -5
  23. package/soundfont/basic_soundfont/write_dls/art2.js +136 -0
  24. package/soundfont/basic_soundfont/write_dls/articulator.js +49 -0
  25. package/soundfont/basic_soundfont/write_dls/combine_zones.js +398 -0
  26. package/soundfont/basic_soundfont/write_dls/ins.js +103 -0
  27. package/soundfont/basic_soundfont/write_dls/lins.js +18 -0
  28. package/soundfont/basic_soundfont/write_dls/modulator_converter.js +324 -0
  29. package/soundfont/basic_soundfont/write_dls/rgn2.js +101 -0
  30. package/soundfont/basic_soundfont/write_dls/wave.js +74 -0
  31. package/soundfont/basic_soundfont/write_dls/write_dls.js +118 -0
  32. package/soundfont/basic_soundfont/write_dls/wsmp.js +74 -0
  33. package/soundfont/basic_soundfont/write_dls/wvpl.js +32 -0
  34. package/soundfont/basic_soundfont/write_sf2/igen.js +3 -3
  35. package/soundfont/basic_soundfont/write_sf2/pgen.js +2 -2
  36. package/soundfont/dls/articulator_converter.js +10 -0
  37. package/soundfont/dls/dls_sample.js +2 -2
  38. package/soundfont/dls/dls_soundfont.js +2 -1
  39. package/soundfont/dls/dls_zone.js +21 -18
  40. package/soundfont/dls/read_articulation.js +18 -30
  41. package/soundfont/dls/read_instrument.js +31 -1
  42. package/soundfont/dls/read_region.js +0 -4
  43. package/soundfont/dls/read_samples.js +17 -17
  44. package/synthetizer/key_modifier_manager.js +1 -1
  45. package/synthetizer/worklet_processor.min.js +13 -12
  46. package/synthetizer/worklet_system/main_processor.js +2 -0
  47. package/synthetizer/worklet_system/worklet_methods/note_on.js +2 -1
  48. package/synthetizer/worklet_system/worklet_methods/reset_controllers.js +4 -12
  49. package/synthetizer/worklet_system/worklet_methods/voice_control.js +4 -3
  50. package/synthetizer/worklet_system/worklet_methods/worklet_soundfont_manager/worklet_soundfont_manager.js +0 -0
  51. package/synthetizer/worklet_system/worklet_utilities/worklet_voice.js +1 -1
  52. package/utils/byte_functions/string.js +1 -1
@@ -62,6 +62,8 @@ import { panVoice } from "./worklet_utilities/stereo_panner.js";
62
62
  // if the note is released faster than that, it forced to last that long
63
63
  // this is used mostly for drum channels, where a lot of midis like to send instant note off after a note on
64
64
  export const MIN_NOTE_LENGTH = 0.03;
65
+ // this sounds way nicer for instant hi-hat cutoff
66
+ export const MIN_EXCLUSIVE_LENGTH = 0.07;
65
67
 
66
68
  export const SYNTHESIZER_GAIN = 1.0;
67
69
 
@@ -2,6 +2,7 @@ import { computeModulators } from "../worklet_utilities/worklet_modulator.js";
2
2
  import { WorkletVolumeEnvelope } from "../worklet_utilities/volume_envelope.js";
3
3
  import { WorkletModulationEnvelope } from "../worklet_utilities/modulation_envelope.js";
4
4
  import { generatorTypes } from "../../../soundfont/basic_soundfont/generator.js";
5
+ import { MIN_EXCLUSIVE_LENGTH } from "../main_processor.js";
5
6
 
6
7
  /**
7
8
  * Append the voices
@@ -80,7 +81,7 @@ export function noteOn(channel, midiNote, velocity, enableDebugging = false, sen
80
81
  {
81
82
  if (v.generators[generatorTypes.exclusiveClass] === exclusive)
82
83
  {
83
- this.releaseVoice(v);
84
+ this.releaseVoice(v, MIN_EXCLUSIVE_LENGTH);
84
85
  v.modulatedGenerators[generatorTypes.releaseVolEnv] = -7000; // make the release nearly instant
85
86
  v.modulatedGenerators[generatorTypes.releaseModEnv] = -7000;
86
87
  WorkletVolumeEnvelope.recalculate(v);
@@ -131,13 +131,6 @@ export function resetControllers(channel)
131
131
  return lockedCCs;
132
132
  }, []);
133
133
  // save excluded controllers as reset doesn't affect them
134
- let excludedCCvalues = excludedCCs.map(ccNum =>
135
- {
136
- return {
137
- ccNum: ccNum,
138
- ccVal: channelObject.midiControllers[ccNum]
139
- };
140
- });
141
134
 
142
135
  channelObject.channelOctaveTuning.fill(0);
143
136
  channelObject.keyCentTuning.fill(0);
@@ -145,6 +138,10 @@ export function resetControllers(channel)
145
138
  // reset the array
146
139
  for (let i = 0; i < resetArray.length; i++)
147
140
  {
141
+ if (channelObject.lockedControllers[i])
142
+ {
143
+ return;
144
+ }
148
145
  const resetValue = resetArray[i];
149
146
  if (channelObject.midiControllers[i] !== resetValue && i < 127)
150
147
  {
@@ -160,11 +157,6 @@ export function resetControllers(channel)
160
157
  channelObject.channelVibrato = { rate: 0, depth: 0, delay: 0 };
161
158
  channelObject.holdPedal = false;
162
159
 
163
- excludedCCvalues.forEach((cc) =>
164
- {
165
- channelObject.midiControllers[cc.ccNum] = cc.ccVal;
166
- });
167
-
168
160
  // reset custom controllers
169
161
  // special case: transpose does not get affected
170
162
  const transpose = channelObject.customControllers[customControllers.channelTransposeFine];
@@ -260,14 +260,15 @@ export function voiceKilling(amount)
260
260
  /**
261
261
  * Stops the voice
262
262
  * @param voice {WorkletVoice} the voice to stop
263
+ * @param minNoteLength {number} minimum note length in seconds
263
264
  * @this {SpessaSynthProcessor}
264
265
  */
265
- export function releaseVoice(voice)
266
+ export function releaseVoice(voice, minNoteLength = MIN_NOTE_LENGTH)
266
267
  {
267
268
  voice.releaseStartTime = currentTime;
268
269
  // check if the note is shorter than the min note time, if so, extend it
269
- if (voice.releaseStartTime - voice.startTime < MIN_NOTE_LENGTH)
270
+ if (voice.releaseStartTime - voice.startTime < minNoteLength)
270
271
  {
271
- voice.releaseStartTime = voice.startTime + MIN_NOTE_LENGTH;
272
+ voice.releaseStartTime = voice.startTime + minNoteLength;
272
273
  }
273
274
  }
@@ -332,7 +332,7 @@ export function getWorkletVoices(channel,
332
332
  */
333
333
  let workletVoices;
334
334
 
335
- const cached = channelObject.cachedVoices[midiNote][velocity];
335
+ const cached = channelObject.cachedVoices[midiNote]?.[velocity];
336
336
 
337
337
  // override patch
338
338
  const overridePatch = this.keyModifierManager.hasOverridePatch(channel, midiNote);
@@ -20,7 +20,7 @@ export function readBytesAsString(dataArray, bytes, encoding = undefined, trimEn
20
20
  {
21
21
  continue;
22
22
  }
23
- if (byte < 32 || byte > 127)
23
+ if ((byte < 32 || byte > 127) && byte !== 10) // 10 is "\n"
24
24
  {
25
25
  if (trimEnd)
26
26
  {