spessasynth_core 3.26.17 → 3.26.19

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 (62) hide show
  1. package/index.js +5 -3
  2. package/package.json +1 -1
  3. package/src/externals/README.md +6 -0
  4. package/src/sequencer/README.md +5 -1
  5. package/src/soundfont/README.md +6 -8
  6. package/src/soundfont/basic_soundfont/basic_global_zone.js +16 -0
  7. package/src/soundfont/basic_soundfont/basic_instrument.js +26 -22
  8. package/src/soundfont/basic_soundfont/basic_instrument_zone.js +35 -0
  9. package/src/soundfont/basic_soundfont/basic_preset.js +53 -42
  10. package/src/soundfont/basic_soundfont/basic_preset_zone.js +30 -0
  11. package/src/soundfont/basic_soundfont/{basic_soundfont.js → basic_soundbank.js} +96 -55
  12. package/src/soundfont/basic_soundfont/basic_zone.js +73 -5
  13. package/src/soundfont/basic_soundfont/generator.js +4 -163
  14. package/src/soundfont/basic_soundfont/generator_types.js +151 -0
  15. package/src/soundfont/basic_soundfont/modulator.js +217 -65
  16. package/src/soundfont/basic_soundfont/write_dls/art2.js +3 -2
  17. package/src/soundfont/basic_soundfont/write_dls/combine_zones.js +28 -45
  18. package/src/soundfont/basic_soundfont/write_dls/ins.js +11 -27
  19. package/src/soundfont/basic_soundfont/write_dls/modulator_converter.js +2 -2
  20. package/src/soundfont/basic_soundfont/write_dls/rgn2.js +2 -2
  21. package/src/soundfont/basic_soundfont/write_sf2/ibag.js +22 -19
  22. package/src/soundfont/basic_soundfont/write_sf2/igen.js +33 -29
  23. package/src/soundfont/basic_soundfont/write_sf2/imod.js +26 -16
  24. package/src/soundfont/basic_soundfont/write_sf2/inst.js +4 -5
  25. package/src/soundfont/basic_soundfont/write_sf2/pbag.js +21 -18
  26. package/src/soundfont/basic_soundfont/write_sf2/pgen.js +32 -29
  27. package/src/soundfont/basic_soundfont/write_sf2/phdr.js +4 -2
  28. package/src/soundfont/basic_soundfont/write_sf2/pmod.js +26 -16
  29. package/src/soundfont/basic_soundfont/write_sf2/write.js +14 -8
  30. package/src/soundfont/dls/articulator_converter.js +9 -3
  31. package/src/soundfont/dls/dls_preset.js +2 -3
  32. package/src/soundfont/dls/dls_soundfont.js +2 -3
  33. package/src/soundfont/dls/dls_sources.js +7 -6
  34. package/src/soundfont/dls/dls_zone.js +13 -16
  35. package/src/soundfont/dls/read_articulation.js +2 -1
  36. package/src/soundfont/dls/read_instrument.js +7 -10
  37. package/src/soundfont/dls/read_lart.js +5 -5
  38. package/src/soundfont/dls/read_region.js +3 -3
  39. package/src/soundfont/read_sf2/instruments.js +10 -1
  40. package/src/soundfont/read_sf2/modulators.js +10 -23
  41. package/src/soundfont/read_sf2/presets.js +10 -1
  42. package/src/soundfont/read_sf2/soundfont.js +3 -5
  43. package/src/soundfont/read_sf2/zones.js +30 -70
  44. package/src/synthetizer/README.md +3 -3
  45. package/src/synthetizer/audio_engine/README.md +1 -1
  46. package/src/synthetizer/audio_engine/engine_components/compute_modulator.js +20 -19
  47. package/src/synthetizer/audio_engine/engine_components/dynamic_modulator_system.js +11 -3
  48. package/src/synthetizer/audio_engine/engine_components/lowpass_filter.js +1 -1
  49. package/src/synthetizer/audio_engine/engine_components/midi_audio_channel.js +1 -1
  50. package/src/synthetizer/audio_engine/engine_components/modulation_envelope.js +1 -1
  51. package/src/synthetizer/audio_engine/engine_components/stereo_panner.js +1 -1
  52. package/src/synthetizer/audio_engine/engine_components/voice.js +7 -10
  53. package/src/synthetizer/audio_engine/engine_components/volume_envelope.js +2 -1
  54. package/src/synthetizer/audio_engine/engine_methods/controller_control/reset_controllers.js +0 -4
  55. package/src/synthetizer/audio_engine/engine_methods/data_entry/awe32.js +1 -1
  56. package/src/synthetizer/audio_engine/engine_methods/data_entry/data_entry_coarse.js +7 -0
  57. package/src/synthetizer/audio_engine/engine_methods/note_on.js +1 -1
  58. package/src/synthetizer/audio_engine/engine_methods/render_voice.js +1 -1
  59. package/src/synthetizer/audio_engine/engine_methods/stopping_notes/kill_note.js +1 -1
  60. package/src/synthetizer/audio_engine/engine_methods/system_exclusive.js +2 -1
  61. package/src/utils/README.md +5 -2
  62. package/src/soundfont/basic_soundfont/basic_zones.js +0 -43
@@ -1,4 +1,4 @@
1
- import { getModSourceEnum, Modulator, modulatorCurveTypes } from "../../../soundfont/basic_soundfont/modulator.js";
1
+ import { Modulator, modulatorCurveTypes, modulatorSources } from "../../../soundfont/basic_soundfont/modulator.js";
2
2
  import { NON_CC_INDEX_OFFSET } from "./controller_tables.js";
3
3
 
4
4
  /**
@@ -72,8 +72,16 @@ export class DynamicModulatorSystem
72
72
  isCC = true;
73
73
  }
74
74
  const modulator = new Modulator(
75
- getModSourceEnum(modulatorCurveTypes.linear, isBipolar, 0, isCC, srcNum),
76
- 0x0, // linear no controller
75
+ srcNum,
76
+ modulatorCurveTypes.linear,
77
+ isCC ? 1 : 0,
78
+ isBipolar ? 1 : 0,
79
+ 0,
80
+ modulatorSources.noController,
81
+ modulatorCurveTypes.linear,
82
+ 0,
83
+ 0,
84
+ 0,
77
85
  destination,
78
86
  amount,
79
87
  0
@@ -1,5 +1,5 @@
1
1
  import { absCentsToHz, decibelAttenuationToGain } from "./unit_converter.js";
2
- import { generatorTypes } from "../../../soundfont/basic_soundfont/generator.js";
2
+ import { generatorTypes } from "../../../soundfont/basic_soundfont/generator_types.js";
3
3
 
4
4
  /**
5
5
  * lowpass_filter.js
@@ -32,8 +32,8 @@ import { chooseBank, isSystemXG, parseBankSelect } from "../../../utils/xg_hacks
32
32
  import { DEFAULT_PERCUSSION, GENERATOR_OVERRIDE_NO_CHANGE_VALUE } from "../../synth_constants.js";
33
33
  import { modulatorSources } from "../../../soundfont/basic_soundfont/modulator.js";
34
34
  import { DynamicModulatorSystem } from "./dynamic_modulator_system.js";
35
- import { generatorLimits, GENERATORS_AMOUNT } from "../../../soundfont/basic_soundfont/generator.js";
36
35
  import { computeModulators } from "./compute_modulator.js";
36
+ import { generatorLimits, GENERATORS_AMOUNT } from "../../../soundfont/basic_soundfont/generator_types.js";
37
37
 
38
38
  /**
39
39
  * This class represents a single MIDI Channel within the synthesizer.
@@ -1,7 +1,7 @@
1
1
  import { timecentsToSeconds } from "./unit_converter.js";
2
2
  import { getModulatorCurveValue } from "./modulator_curves.js";
3
- import { generatorTypes } from "../../../soundfont/basic_soundfont/generator.js";
4
3
  import { modulatorCurveTypes } from "../../../soundfont/basic_soundfont/modulator.js";
4
+ import { generatorTypes } from "../../../soundfont/basic_soundfont/generator_types.js";
5
5
 
6
6
  /**
7
7
  * modulation_envelope.js
@@ -1,4 +1,4 @@
1
- import { generatorTypes } from "../../../soundfont/basic_soundfont/generator.js";
1
+ import { generatorTypes } from "../../../soundfont/basic_soundfont/generator_types.js";
2
2
 
3
3
  /**
4
4
  * stereo_panner.js
@@ -7,12 +7,9 @@ import { SpessaSynthWarn } from "../../../utils/loggin.js";
7
7
  import { LowpassFilter } from "./lowpass_filter.js";
8
8
  import { VolumeEnvelope } from "./volume_envelope.js";
9
9
  import { ModulationEnvelope } from "./modulation_envelope.js";
10
- import {
11
- addAndClampGenerator,
12
- GENERATORS_AMOUNT,
13
- generatorTypes
14
- } from "../../../soundfont/basic_soundfont/generator.js";
10
+ import { addAndClampGenerator } from "../../../soundfont/basic_soundfont/generator.js";
15
11
  import { Modulator } from "../../../soundfont/basic_soundfont/modulator.js";
12
+ import { GENERATORS_AMOUNT, generatorTypes } from "../../../soundfont/basic_soundfont/generator_types.js";
16
13
 
17
14
  const EXCLUSIVE_CUTOFF_TIME = -2320;
18
15
  const EXCLUSIVE_MOD_CUTOFF_TIME = -1130; // less because filter shenanigans
@@ -330,7 +327,7 @@ class Voice
330
327
  currentTime,
331
328
  voice.targetKey,
332
329
  realKey,
333
- voice.generators,
330
+ new Int16Array(voice.generators),
334
331
  voice.modulators.map(m => Modulator.copy(m))
335
332
  );
336
333
  }
@@ -401,7 +398,7 @@ export function getVoicesForPreset(preset, bank, program, midiNote, velocity, re
401
398
  }
402
399
 
403
400
  // EMU initial attenuation correction, multiply initial attenuation by 0.4!
404
- // all EMU sound cards have this quirk and all sf2 editors and players emulate it too
401
+ // all EMU sound cards have this quirk, and all sf2 editors and players emulate it too
405
402
  generators[generatorTypes.initialAttenuation] = Math.floor(generators[generatorTypes.initialAttenuation] * 0.4);
406
403
 
407
404
  // key override
@@ -473,9 +470,9 @@ export function getVoicesForPreset(preset, bank, program, midiNote, velocity, re
473
470
  return voices;
474
471
  }, []);
475
472
  // cache the voice
476
- this.setCachedVoice(bank, program, midiNote, velocity, voices.map(v =>
477
- Voice.copy(v, this.currentSynthTime, realKey)));
478
- return voices;
473
+ this.setCachedVoice(bank, program, midiNote, velocity, voices);
474
+ return voices.map(v =>
475
+ Voice.copy(v, this.currentSynthTime, realKey));
479
476
  }
480
477
 
481
478
  /**
@@ -1,6 +1,7 @@
1
1
  import { decibelAttenuationToGain, timecentsToSeconds } from "./unit_converter.js";
2
2
 
3
- import { generatorTypes } from "../../../soundfont/basic_soundfont/generator.js";
3
+
4
+ import { generatorTypes } from "../../../soundfont/basic_soundfont/generator_types.js";
4
5
 
5
6
  /**
6
7
  * volume_envelope.js
@@ -238,8 +238,4 @@ export function resetParameters()
238
238
  this.midiControllers[midiControllers.RPNMsb] = 127 << 7;
239
239
  this.resetGeneratorOverrides();
240
240
  this.resetGeneratorOffsets();
241
- SpessaSynthInfo(
242
- "%cResetting Registered and Non-Registered Parameters!",
243
- consoleColors.info
244
- );
245
241
  }
@@ -1,6 +1,6 @@
1
- import { generatorTypes } from "../../../../soundfont/basic_soundfont/generator.js";
2
1
  import { SpessaSynthWarn } from "../../../../utils/loggin.js";
3
2
  import { consoleColors } from "../../../../utils/other.js";
3
+ import { generatorTypes } from "../../../../soundfont/basic_soundfont/generator_types.js";
4
4
 
5
5
  /**
6
6
  * http://archive.gamedev.net/archive/reference/articles/article445.html
@@ -54,6 +54,13 @@ export function dataEntryCoarse(dataValue)
54
54
  {
55
55
  // store in cc table
56
56
  this.midiControllers[midiControllers.dataEntryMsb] = dataValue << 7;
57
+ /*
58
+ A note on this vibrato.
59
+ This is a completely custom vibrato, with its own oscillator and parameters.
60
+ It is disabled by default,
61
+ only being enabled when one of the NPRN messages changing it is received
62
+ and stays on until the next system-reset.
63
+ */
57
64
  const addDefaultVibrato = () =>
58
65
  {
59
66
  if (this.channelVibrato.delay === 0 && this.channelVibrato.rate === 0 && this.channelVibrato.depth === 0)
@@ -1,9 +1,9 @@
1
- import { generatorTypes } from "../../../soundfont/basic_soundfont/generator.js";
2
1
  import { midiControllers } from "../../../midi/midi_message.js";
3
2
  import { portamentoTimeToSeconds } from "./portamento_time.js";
4
3
  import { customControllers } from "../engine_components/controller_tables.js";
5
4
  import { Modulator } from "../../../soundfont/basic_soundfont/modulator.js";
6
5
  import { GENERATOR_OVERRIDE_NO_CHANGE_VALUE } from "../../synth_constants.js";
6
+ import { generatorTypes } from "../../../soundfont/basic_soundfont/generator_types.js";
7
7
 
8
8
  /**
9
9
  * sends a "MIDI Note on message"
@@ -1,12 +1,12 @@
1
1
  import { VolumeEnvelope } from "../engine_components/volume_envelope.js";
2
2
  import { ModulationEnvelope } from "../engine_components/modulation_envelope.js";
3
- import { generatorTypes } from "../../../soundfont/basic_soundfont/generator.js";
4
3
  import { customControllers } from "../engine_components/controller_tables.js";
5
4
  import { absCentsToHz, timecentsToSeconds } from "../engine_components/unit_converter.js";
6
5
  import { getLFOValue } from "../engine_components/lfo.js";
7
6
  import { WavetableOscillator } from "../engine_components/wavetable_oscillator.js";
8
7
  import { LowpassFilter } from "../engine_components/lowpass_filter.js";
9
8
  import { interpolationTypes } from "../engine_components/enums.js";
9
+ import { generatorTypes } from "../../../soundfont/basic_soundfont/generator_types.js";
10
10
 
11
11
  /**
12
12
  * Renders a voice to the stereo output buffer
@@ -1,5 +1,5 @@
1
- import { generatorTypes } from "../../../../soundfont/basic_soundfont/generator.js";
2
1
  import { customControllers } from "../../engine_components/controller_tables.js";
2
+ import { generatorTypes } from "../../../../soundfont/basic_soundfont/generator_types.js";
3
3
 
4
4
  /**
5
5
  * Stops a note nearly instantly
@@ -8,7 +8,8 @@ import { readBytesAsString } from "../../../utils/byte_functions/string.js";
8
8
  import { synthDisplayTypes } from "../engine_components/enums.js";
9
9
  import { customControllers, NON_CC_INDEX_OFFSET } from "../engine_components/controller_tables.js";
10
10
  import { modulatorSources } from "../../../soundfont/basic_soundfont/modulator.js";
11
- import { generatorTypes } from "../../../soundfont/basic_soundfont/generator.js";
11
+
12
+ import { generatorTypes } from "../../../soundfont/basic_soundfont/generator_types.js";
12
13
 
13
14
  /**
14
15
  * KeyNum: tuning
@@ -1,5 +1,8 @@
1
1
  ## This is the utility folder.
2
2
 
3
- There are various utilites here used by the SpessaSynth library.
3
+ There are various utilities here used by the SpessaSynth library.
4
4
 
5
- ### Note that the stbvorbis_sync.js is licensed under Apache-2.0.
5
+ - `byte_functions` - low-level byte manipulation utilities
6
+ - `buffer_to_wav.js` - converts audio buffer to WAV format
7
+ - `sysex_detector.js` - detects various System Exclusive messages
8
+ - `xg_hacks.js` - XG-specific MIDI handling utilities
@@ -1,43 +0,0 @@
1
- import { BasicZone } from "./basic_zone.js";
2
-
3
- export class BasicInstrumentZone extends BasicZone
4
- {
5
- /**
6
- * Zone's sample. Undefined if global
7
- * @type {BasicSample|undefined}
8
- */
9
- sample = undefined;
10
- /**
11
- * The zone's use count
12
- * @type {number}
13
- */
14
- useCount = 0;
15
-
16
- deleteZone()
17
- {
18
- this.useCount--;
19
- if (this.isGlobal)
20
- {
21
- return;
22
- }
23
- this.sample.useCount--;
24
- }
25
- }
26
-
27
- export class BasicPresetZone extends BasicZone
28
- {
29
- /**
30
- * Zone's instrument. Undefined if global
31
- * @type {BasicInstrument|undefined}
32
- */
33
- instrument = undefined;
34
-
35
- deleteZone()
36
- {
37
- if (this.isGlobal)
38
- {
39
- return;
40
- }
41
- this.instrument.removeUseCount();
42
- }
43
- }