libadlmidi-js 1.2.0 → 2.1.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 (76) hide show
  1. package/README.md +8 -5
  2. package/dist/core.d.ts +191 -4
  3. package/dist/fm_banks/manifest.json +1 -1
  4. package/dist/libadlmidi.d.ts +146 -66
  5. package/dist/libadlmidi.dosbox.browser.js +1 -1
  6. package/dist/libadlmidi.dosbox.browser.wasm +0 -0
  7. package/dist/libadlmidi.dosbox.core.js +1 -1
  8. package/dist/libadlmidi.dosbox.core.wasm +0 -0
  9. package/dist/libadlmidi.dosbox.js +0 -0
  10. package/dist/libadlmidi.dosbox.processor.js +247 -74
  11. package/dist/libadlmidi.dosbox.slim.browser.js +1 -1
  12. package/dist/libadlmidi.dosbox.slim.browser.wasm +0 -0
  13. package/dist/libadlmidi.dosbox.slim.core.js +1 -1
  14. package/dist/libadlmidi.dosbox.slim.core.wasm +0 -0
  15. package/dist/libadlmidi.dosbox.slim.js +0 -0
  16. package/dist/libadlmidi.dosbox.slim.processor.js +247 -74
  17. package/dist/libadlmidi.full.browser.js +1 -1
  18. package/dist/libadlmidi.full.browser.wasm +0 -0
  19. package/dist/libadlmidi.full.core.js +1 -1
  20. package/dist/libadlmidi.full.core.wasm +0 -0
  21. package/dist/libadlmidi.full.js +0 -0
  22. package/dist/libadlmidi.full.processor.js +247 -74
  23. package/dist/libadlmidi.full.slim.browser.js +1 -1
  24. package/dist/libadlmidi.full.slim.browser.wasm +0 -0
  25. package/dist/libadlmidi.full.slim.core.js +1 -1
  26. package/dist/libadlmidi.full.slim.core.wasm +0 -0
  27. package/dist/libadlmidi.full.slim.js +0 -0
  28. package/dist/libadlmidi.full.slim.processor.js +247 -74
  29. package/dist/libadlmidi.js +473 -24
  30. package/dist/libadlmidi.js.map +3 -3
  31. package/dist/libadlmidi.light.browser.js +1 -1
  32. package/dist/libadlmidi.light.browser.wasm +0 -0
  33. package/dist/libadlmidi.light.core.js +1 -1
  34. package/dist/libadlmidi.light.core.wasm +0 -0
  35. package/dist/libadlmidi.light.js +0 -0
  36. package/dist/libadlmidi.light.processor.js +247 -74
  37. package/dist/libadlmidi.light.slim.browser.js +1 -1
  38. package/dist/libadlmidi.light.slim.browser.wasm +0 -0
  39. package/dist/libadlmidi.light.slim.core.js +1 -1
  40. package/dist/libadlmidi.light.slim.core.wasm +0 -0
  41. package/dist/libadlmidi.light.slim.js +0 -0
  42. package/dist/libadlmidi.light.slim.processor.js +247 -74
  43. package/dist/libadlmidi.nuked.browser.js +1 -1
  44. package/dist/libadlmidi.nuked.browser.wasm +0 -0
  45. package/dist/libadlmidi.nuked.core.js +1 -1
  46. package/dist/libadlmidi.nuked.core.wasm +0 -0
  47. package/dist/libadlmidi.nuked.js +0 -0
  48. package/dist/libadlmidi.nuked.processor.js +247 -74
  49. package/dist/libadlmidi.nuked.slim.browser.js +1 -1
  50. package/dist/libadlmidi.nuked.slim.browser.wasm +0 -0
  51. package/dist/libadlmidi.nuked.slim.core.js +1 -1
  52. package/dist/libadlmidi.nuked.slim.core.wasm +0 -0
  53. package/dist/libadlmidi.nuked.slim.js +0 -0
  54. package/dist/libadlmidi.nuked.slim.processor.js +247 -74
  55. package/dist/profiles/dosbox.d.ts +7 -2
  56. package/dist/profiles/dosbox.slim.d.ts +7 -2
  57. package/dist/profiles/full.d.ts +7 -2
  58. package/dist/profiles/full.slim.d.ts +7 -2
  59. package/dist/profiles/light.d.ts +7 -2
  60. package/dist/profiles/light.slim.d.ts +7 -2
  61. package/dist/profiles/nuked.d.ts +7 -2
  62. package/dist/profiles/nuked.slim.d.ts +7 -2
  63. package/dist/utils/constants.d.ts +61 -0
  64. package/package.json +30 -9
  65. package/src/core.js +361 -4
  66. package/src/libadlmidi.js +379 -58
  67. package/src/processor.js +210 -12
  68. package/src/profiles/dosbox.js +20 -10
  69. package/src/profiles/dosbox.slim.js +20 -10
  70. package/src/profiles/full.js +21 -11
  71. package/src/profiles/full.slim.js +21 -11
  72. package/src/profiles/light.js +21 -11
  73. package/src/profiles/light.slim.js +21 -11
  74. package/src/profiles/nuked.js +21 -11
  75. package/src/profiles/nuked.slim.js +21 -11
  76. package/src/utils/constants.js +53 -0
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Zero-config light (slim) profile for libADLMIDI-JS
3
- *
3
+ *
4
4
  * Exports pre-configured AdlMidi and AdlMidiCore with this profile's WASM.
5
5
  * Slim builds require loading a WOPL bank at runtime.
6
- *
6
+ *
7
7
  * @module profiles/light.slim
8
8
  */
9
9
 
@@ -15,6 +15,10 @@ const PROCESSOR_URL = new URL('../../dist/libadlmidi.light.slim.processor.js', i
15
15
  const WASM_URL = new URL('../../dist/libadlmidi.light.slim.core.wasm', import.meta.url).href;
16
16
  const CORE_PATH = new URL('../../dist/libadlmidi.light.slim.core.js', import.meta.url).href;
17
17
 
18
+ // Default synth settings injected at init. NUKED_FAST is preferred when the
19
+ // profile bundles it (bit-exact vs Nuked 1.8, roughly 1.5x faster).
20
+ const DEFAULT_SETTINGS = { emulator: 1 };
21
+
18
22
  /**
19
23
  * Pre-configured AdlMidi for light slim profile.
20
24
  *
@@ -30,15 +34,17 @@ const CORE_PATH = new URL('../../dist/libadlmidi.light.slim.core.js', import.met
30
34
  export class AdlMidi extends BaseAdlMidi {
31
35
  /**
32
36
  * Initialize the synthesizer with this profile's WASM.
33
- *
37
+ *
34
38
  * @param {string} [processorUrl] - Override processor URL (optional)
35
39
  * @param {string} [wasmUrl] - Override WASM URL (optional)
40
+ * @param {object} [defaultSettings] - Override profile's default synth settings
36
41
  * @returns {Promise<void>}
37
42
  */
38
- async init(processorUrl, wasmUrl) {
43
+ async init(processorUrl, wasmUrl, defaultSettings) {
39
44
  return super.init(
40
45
  processorUrl || PROCESSOR_URL,
41
- wasmUrl || WASM_URL
46
+ wasmUrl || WASM_URL,
47
+ defaultSettings || DEFAULT_SETTINGS
42
48
  );
43
49
  }
44
50
  }
@@ -60,23 +66,27 @@ export class AdlMidiCore {
60
66
  /**
61
67
  * Create a new AdlMidiCore instance with this profile's WASM.
62
68
  *
63
- * @param {{corePath?: string}} [options] - Options (corePath is pre-configured)
69
+ * @param {{corePath?: string, defaultEmulator?: number, wasmBinary?: ArrayBuffer}} [options]
70
+ * Override profile defaults. corePath and defaultEmulator are pre-configured.
64
71
  * @returns {Promise<BaseAdlMidiCore>}
65
72
  */
66
73
  static async create(options = {}) {
67
74
  return BaseAdlMidiCore.create({
68
75
  ...options,
69
- corePath: options.corePath || CORE_PATH
76
+ corePath: options.corePath || CORE_PATH, defaultEmulator: options.defaultEmulator !== undefined ? options.defaultEmulator : 1
70
77
  });
71
78
  }
72
79
  }
73
80
 
74
81
  // Re-export struct utilities for convenience
75
- export {
76
- encodeInstrument,
77
- decodeInstrument,
82
+ export {
83
+ encodeInstrument,
84
+ decodeInstrument,
78
85
  defaultInstrument,
79
86
  encodeOperator,
80
87
  decodeOperator,
81
- defaultOperator
88
+ defaultOperator
82
89
  } from '../utils/struct.js';
90
+
91
+ // Re-export enums
92
+ export { Emulator, TrackOption } from '../utils/constants.js';
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Zero-config nuked profile for libADLMIDI-JS
3
- *
3
+ *
4
4
  * Exports pre-configured AdlMidi and AdlMidiCore with this profile's WASM.
5
5
  *
6
- *
6
+ *
7
7
  * @module profiles/nuked
8
8
  */
9
9
 
@@ -15,6 +15,10 @@ const PROCESSOR_URL = new URL('../../dist/libadlmidi.nuked.processor.js', import
15
15
  const WASM_URL = new URL('../../dist/libadlmidi.nuked.core.wasm', import.meta.url).href;
16
16
  const CORE_PATH = new URL('../../dist/libadlmidi.nuked.core.js', import.meta.url).href;
17
17
 
18
+ // Default synth settings injected at init. NUKED_FAST is preferred when the
19
+ // profile bundles it (bit-exact vs Nuked 1.8, roughly 1.5x faster).
20
+ const DEFAULT_SETTINGS = { emulator: 1 };
21
+
18
22
  /**
19
23
  * Pre-configured AdlMidi for nuked profile.
20
24
  *
@@ -30,15 +34,17 @@ const CORE_PATH = new URL('../../dist/libadlmidi.nuked.core.js', import.meta.url
30
34
  export class AdlMidi extends BaseAdlMidi {
31
35
  /**
32
36
  * Initialize the synthesizer with this profile's WASM.
33
- *
37
+ *
34
38
  * @param {string} [processorUrl] - Override processor URL (optional)
35
39
  * @param {string} [wasmUrl] - Override WASM URL (optional)
40
+ * @param {object} [defaultSettings] - Override profile's default synth settings
36
41
  * @returns {Promise<void>}
37
42
  */
38
- async init(processorUrl, wasmUrl) {
43
+ async init(processorUrl, wasmUrl, defaultSettings) {
39
44
  return super.init(
40
45
  processorUrl || PROCESSOR_URL,
41
- wasmUrl || WASM_URL
46
+ wasmUrl || WASM_URL,
47
+ defaultSettings || DEFAULT_SETTINGS
42
48
  );
43
49
  }
44
50
  }
@@ -60,23 +66,27 @@ export class AdlMidiCore {
60
66
  /**
61
67
  * Create a new AdlMidiCore instance with this profile's WASM.
62
68
  *
63
- * @param {{corePath?: string}} [options] - Options (corePath is pre-configured)
69
+ * @param {{corePath?: string, defaultEmulator?: number, wasmBinary?: ArrayBuffer}} [options]
70
+ * Override profile defaults. corePath and defaultEmulator are pre-configured.
64
71
  * @returns {Promise<BaseAdlMidiCore>}
65
72
  */
66
73
  static async create(options = {}) {
67
74
  return BaseAdlMidiCore.create({
68
75
  ...options,
69
- corePath: options.corePath || CORE_PATH
76
+ corePath: options.corePath || CORE_PATH, defaultEmulator: options.defaultEmulator !== undefined ? options.defaultEmulator : 1
70
77
  });
71
78
  }
72
79
  }
73
80
 
74
81
  // Re-export struct utilities for convenience
75
- export {
76
- encodeInstrument,
77
- decodeInstrument,
82
+ export {
83
+ encodeInstrument,
84
+ decodeInstrument,
78
85
  defaultInstrument,
79
86
  encodeOperator,
80
87
  decodeOperator,
81
- defaultOperator
88
+ defaultOperator
82
89
  } from '../utils/struct.js';
90
+
91
+ // Re-export enums
92
+ export { Emulator, TrackOption } from '../utils/constants.js';
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Zero-config nuked (slim) profile for libADLMIDI-JS
3
- *
3
+ *
4
4
  * Exports pre-configured AdlMidi and AdlMidiCore with this profile's WASM.
5
5
  * Slim builds require loading a WOPL bank at runtime.
6
- *
6
+ *
7
7
  * @module profiles/nuked.slim
8
8
  */
9
9
 
@@ -15,6 +15,10 @@ const PROCESSOR_URL = new URL('../../dist/libadlmidi.nuked.slim.processor.js', i
15
15
  const WASM_URL = new URL('../../dist/libadlmidi.nuked.slim.core.wasm', import.meta.url).href;
16
16
  const CORE_PATH = new URL('../../dist/libadlmidi.nuked.slim.core.js', import.meta.url).href;
17
17
 
18
+ // Default synth settings injected at init. NUKED_FAST is preferred when the
19
+ // profile bundles it (bit-exact vs Nuked 1.8, roughly 1.5x faster).
20
+ const DEFAULT_SETTINGS = { emulator: 1 };
21
+
18
22
  /**
19
23
  * Pre-configured AdlMidi for nuked slim profile.
20
24
  *
@@ -30,15 +34,17 @@ const CORE_PATH = new URL('../../dist/libadlmidi.nuked.slim.core.js', import.met
30
34
  export class AdlMidi extends BaseAdlMidi {
31
35
  /**
32
36
  * Initialize the synthesizer with this profile's WASM.
33
- *
37
+ *
34
38
  * @param {string} [processorUrl] - Override processor URL (optional)
35
39
  * @param {string} [wasmUrl] - Override WASM URL (optional)
40
+ * @param {object} [defaultSettings] - Override profile's default synth settings
36
41
  * @returns {Promise<void>}
37
42
  */
38
- async init(processorUrl, wasmUrl) {
43
+ async init(processorUrl, wasmUrl, defaultSettings) {
39
44
  return super.init(
40
45
  processorUrl || PROCESSOR_URL,
41
- wasmUrl || WASM_URL
46
+ wasmUrl || WASM_URL,
47
+ defaultSettings || DEFAULT_SETTINGS
42
48
  );
43
49
  }
44
50
  }
@@ -60,23 +66,27 @@ export class AdlMidiCore {
60
66
  /**
61
67
  * Create a new AdlMidiCore instance with this profile's WASM.
62
68
  *
63
- * @param {{corePath?: string}} [options] - Options (corePath is pre-configured)
69
+ * @param {{corePath?: string, defaultEmulator?: number, wasmBinary?: ArrayBuffer}} [options]
70
+ * Override profile defaults. corePath and defaultEmulator are pre-configured.
64
71
  * @returns {Promise<BaseAdlMidiCore>}
65
72
  */
66
73
  static async create(options = {}) {
67
74
  return BaseAdlMidiCore.create({
68
75
  ...options,
69
- corePath: options.corePath || CORE_PATH
76
+ corePath: options.corePath || CORE_PATH, defaultEmulator: options.defaultEmulator !== undefined ? options.defaultEmulator : 1
70
77
  });
71
78
  }
72
79
  }
73
80
 
74
81
  // Re-export struct utilities for convenience
75
- export {
76
- encodeInstrument,
77
- decodeInstrument,
82
+ export {
83
+ encodeInstrument,
84
+ decodeInstrument,
78
85
  defaultInstrument,
79
86
  encodeOperator,
80
87
  decodeOperator,
81
- defaultOperator
88
+ defaultOperator
82
89
  } from '../utils/struct.js';
90
+
91
+ // Re-export enums
92
+ export { Emulator, TrackOption } from '../utils/constants.js';
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Shared constants for libADLMIDI-JS
3
+ */
4
+
5
+ /**
6
+ * Available OPL2/OPL3 emulator cores.
7
+ * Use with switchEmulator() to change the synthesis engine at runtime.
8
+ * Note: Only emulators compiled into the current profile are available.
9
+ * @readonly
10
+ * @enum {number}
11
+ */
12
+ export const Emulator = Object.freeze({
13
+ /** Nuked OPL3 v1.8 - Most accurate, higher CPU usage */
14
+ NUKED: 0,
15
+ /** Optimized Nuked 1.8 fork by tgies with identical output */
16
+ NUKED_FAST: 1,
17
+ /** @deprecated Use NUKED_FAST */
18
+ NUKED_174: 1,
19
+ /** DosBox OPL3 - Good accuracy, lower CPU usage */
20
+ DOSBOX: 2,
21
+ /** Opal - Reality Adlib Tracker emulator */
22
+ OPAL: 3,
23
+ /** Java OPL3 - Port of emu8950 */
24
+ JAVA: 4,
25
+ /** ESFMu - ESFM chip emulator */
26
+ ESFMu: 5,
27
+ /** MAME OPL2 */
28
+ MAME_OPL2: 6,
29
+ /** YMFM OPL2 */
30
+ YMFM_OPL2: 7,
31
+ /** YMFM OPL3 */
32
+ YMFM_OPL3: 8,
33
+ /** Nuked OPL2 LLE - Transistor-level emulation */
34
+ NUKED_OPL2_LLE: 9,
35
+ /** Nuked OPL3 LLE - Transistor-level emulation */
36
+ NUKED_OPL3_LLE: 10,
37
+ /** Nuked OPL2 Lite - Lightweight OPL2 emulation for AdLib-era music */
38
+ NUKED_OPL2_LITE: 11,
39
+ });
40
+
41
+ /**
42
+ * Track option flags for use with setTrackOptions().
43
+ * @readonly
44
+ * @enum {number}
45
+ */
46
+ export const TrackOption = Object.freeze({
47
+ /** Enable the track (default state) */
48
+ ON: 1,
49
+ /** Mute/disable the track */
50
+ OFF: 2,
51
+ /** Solo the track (mute all others) */
52
+ SOLO: 3,
53
+ });