tetorica-fm2612 0.2.39 → 0.2.40

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/README.md CHANGED
@@ -70,6 +70,7 @@ entry points, rather than every internal Worker or Worklet module.
70
70
  | Experimental PlayStation SPU, low level | `tetorica-fm2612/ps1_spu.js` | `Ps1Spu`: explicit factory initialization, register/RAM access and 44.1 kHz stereo PCM |
71
71
  | PS1 tuned sample instruments / host PCM rate | `tetorica-fm2612/ps1synth.js`, `tetorica-fm2612/ps1_resampler.js` | `Ps1Synth`, `createPs1InitSample`, `Ps1Resampler` |
72
72
  | PS1 named ADSR / reverb parameters | `tetorica-fm2612/ps1_parameters.js` | `decodePs1Envelope`, `encodePs1Envelope`, `patchPs1Envelope`, `PS1_REVERB_PRESETS` |
73
+ | Standard PS1 VAB banks / selected Tone export | `tetorica-fm2612`, `tetorica-fm2612/ps1_vab.js` | `readVab`, `prepareVabTone`, `exportVab`, `MAX_VAB_FILE_BYTES` |
73
74
  | PCM to PS1 SPU ADPCM | `tetorica-fm2612/ps1_adpcm_encoder.js` | `encodePs1Adpcm`, `encodePs1AdpcmCycle` |
74
75
  | PS1 Sample Editor conversion / waveform comparison | `tetorica-fm2612/playground_sample_ps1.js` | `renderPs1Sample`, `renderPs1SampleComparison` |
75
76
  | Isolated offline PS1 sample audition | `tetorica-fm2612/playground_sample_ps1_preview.js` | `renderPs1SamplePreview` with an injected PS1 WASM factory |
@@ -267,6 +268,60 @@ and updated Native hosts accept these controls. A multi-slot Synth voice allocat
267
268
  and patch serialization remain later work. These additions are not in published
268
269
  0.2.36. See the SCSP guide for a two-slot example and scheduling limitations.
269
270
 
271
+ ### Standard PS1 VAB banks
272
+
273
+ Available from **0.2.40**.
274
+
275
+ `readVab`, `prepareVabTone` and `exportVab` are pure synchronous APIs for
276
+ standard Sony VAB v6/v7. Import them from the package root or
277
+ `tetorica-fm2612/ps1_vab.js` (the extensionless `ps1_vab` path also works).
278
+ They do not create an audio device, require WASM, or convert through JSON.
279
+
280
+ ```js
281
+ import {readVab,prepareVabTone,exportVab} from 'tetorica-fm2612';
282
+
283
+ // Browser: bytes = await (await fetch(yourBankUrl)).arrayBuffer().
284
+ // Node: bytes = await readFile(yourBankPath).
285
+ const bank=readVab(bytes);
286
+ // For split banks instead: readVab(vhBytes, vbBytes).
287
+ console.table(bank.tones.map((tone,toneNumber)=>({toneNumber,...tone})));
288
+
289
+ const toneNumber=0; // Global bank.tones index, not an original Program ID.
290
+ const prepared=prepareVabTone(bank,toneNumber);
291
+ // ps1 is an initialized Ps1Synth, or the Playground's PS1 client.
292
+ const instrument=await ps1.loadADPCM(prepared.adpcm,prepared.options);
293
+ await ps1.setPreset(0,{...prepared.preset,sample:instrument});
294
+ await ps1.noteOn(0,'C4');
295
+ // Later: await ps1.keyOff(0).
296
+
297
+ const originalBankBytes=exportVab(bank);
298
+ const selectedToneBytes=exportVab(bank,{toneNumber});
299
+ ```
300
+
301
+ Inputs may be an `ArrayBuffer` or any `ArrayBufferView`, including `DataView`
302
+ and Node `Buffer`. Parsed banks retain original sparse Program IDs and Tone
303
+ metadata. Preparation returns owned ADPCM through the first END packet,
304
+ explicit `baseFrequencyHz`, an optional loop start, and ADSR/volume/pan/send
305
+ settings compatible with `Ps1Synth` and its asynchronous client. The bytes
306
+ are not decoded or re-encoded. Static volume/pan approximate libsnd;
307
+ shared reverb, key-zone layering, vibrato, portamento and song-driver logic
308
+ remain host responsibilities. Unassigned samples, libsnd Noise Tones and
309
+ unsupported ADPCM forms fail with an explanation.
310
+
311
+ Full-bank export preserves the original combined VH + VB bytes, including
312
+ padding. Selected export produces a standard one-Tone VAB, retaining its
313
+ original Program ID while packing the Tone as index 0 and its sample as 1.
314
+ Export requires the unchanged bank returned by `readVab`; it does not serialize
315
+ an arbitrary edited Synth instrument. Returned buffers are independent copies.
316
+ The exported types are `Ps1VabBank`, `Ps1VabProgram`, `Ps1VabTone`,
317
+ `Ps1VabSample`, `Ps1VabPreparedTone` and `Ps1VabExportOptions`.
318
+
319
+ In SPU Synth, **Save bank to presets** and **Save selected Tone to preset**
320
+ keep standard `.vab` files alongside portable Tone JSON. The Preset picker can
321
+ load a Program/Tone directly from a saved VAB, even with no JSON files present.
322
+ For an offline WAV example using the original demo bank, see
323
+ [main_ps1_vab.js](https://github.com/kyorohiro/hello_ymfm_wasm/blob/main/tetorica_examples/nodejs/main_ps1_vab.js).
324
+
270
325
  ### Experimental standalone PlayStation SPU
271
326
 
272
327
  `Ps1Spu` is a CPU-free MAME-derived instrument core with 24 voices and 512 KiB
@@ -1528,10 +1583,10 @@ FM/PSG/PCM mixing, stop/reset and close/restart. Playwright is a development
1528
1583
  dependency; it is not required by users of the sound-chip runtime.
1529
1584
 
1530
1585
  The build is staged in `dist/fm2612/`; packing produces
1531
- `tetorica-fm2612-0.2.39.tgz`. To install a local build in another project:
1586
+ `tetorica-fm2612-0.2.40.tgz`. To install a local build in another project:
1532
1587
 
1533
1588
  ```sh
1534
- npm install /absolute/path/to/tetorica-fm2612-0.2.39.tgz
1589
+ npm install /absolute/path/to/tetorica-fm2612-0.2.40.tgz
1535
1590
  ```
1536
1591
 
1537
1592
  The build pins an unpublished `tetorica-soundchip-native` SDK **0.1.7** source
@@ -1560,6 +1615,20 @@ notices. They are packaged alongside the unchanged fixed SDK snapshot.
1560
1615
 
1561
1616
  ## Release notes
1562
1617
 
1618
+ `0.2.40` exposes standard PS1 VAB v6/v7 helpers at the package root and
1619
+ `ps1_vab.js` / `ps1_vab` subpaths: `readVab()`, `prepareVabTone()` and
1620
+ `exportVab()`, with six public metadata and result types. Read combined VAB
1621
+ or split VH/VB, prepare tuned ADPCM for `Ps1Synth` / its asynchronous client,
1622
+ and preserve a complete source bank or extract a one-Tone standard VAB.
1623
+ The same pure helpers are available in Playground Main/Worker and Synth Code.
1624
+ They do not create an audio device or require intermediate Tetorica JSON.
1625
+ Export requires the original unchanged bank; shared effects and song-driver
1626
+ behavior remain separate. The existing SPU client declarations also retain
1627
+ valid method-return types when inferred through the generic runtime.
1628
+ SPU ADPCM preparation also accepts a LOOP START marker in a one-shot sample
1629
+ when the final END packet has Repeat disabled. Original bytes and flags are
1630
+ preserved; that marker alone does not make the sample loop.
1631
+
1563
1632
  `0.2.39` adds SID to the package-root `createSoundChip()` factory. Select
1564
1633
  6581 or PAL 8580 Preview, generate raw mono PCM directly, or use the generic
1565
1634
  browser AudioWorklet endpoint with explicit start/stop/dispose. It retains the
package/RUNTIME.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Full web runtime
2
2
 
3
- Includes all 359 top-level web runtime modules and 28 generated chip/engine pairs.
3
+ Includes all 360 top-level web runtime modules and 28 generated chip/engine pairs.
4
4
 
5
5
  ay8910, gameboy_apu, huc6280, wonderswan, pokey, k051649, nesapu, pwm32x, nuked_opn2, okim6258, rf5c164, segapcm, segapsg, spc, y8950, ym2151, ym2203, ym2413, ym2608, ym2610b, ym2612, ym3438, ym3526, ym3812, ymf262, ymf276, ymf278b, ymf288
6
6
 
@@ -38,7 +38,21 @@ export declare class GameboyRuntimeSynth {
38
38
  initializationController: AbortController | null;
39
39
  state: string;
40
40
  noise: {
41
- create: (options?: {}) => any;
41
+ create: (options?: {}) => {
42
+ type: any;
43
+ gain: any;
44
+ pan: any;
45
+ attack: any;
46
+ release: any;
47
+ filter: {
48
+ cutoff: any;
49
+ q: any;
50
+ set(mode: any, frequency: any, q?: any): void;
51
+ };
52
+ start: () => void;
53
+ stop: () => void;
54
+ dispose(): void;
55
+ };
42
56
  stopAll: () => void;
43
57
  };
44
58
  /** @param {GameboyRuntimeSynthOptions|undefined} options */
@@ -61,9 +75,9 @@ export declare class GameboyRuntimeSynth {
61
75
  /** @param {number} volume */
62
76
  setMasterVolume(volume: number): number;
63
77
  getMasterVolume(): number;
64
- setFXChain(effects?: any[], options?: {}): any;
65
- getFXChain(): any;
66
- clearFXChain(options?: {}): any;
78
+ setFXChain(effects?: any[], options?: {}): any[] | undefined;
79
+ getFXChain(): any[];
80
+ clearFXChain(options?: {}): any[];
67
81
  connect(effect: any): this;
68
82
  connectOutput(node?: null): this;
69
83
  close(): Promise<void>;
package/megasynth.d.ts CHANGED
@@ -296,7 +296,21 @@ export declare class MegaSynth {
296
296
  readonly id: string;
297
297
  }) | null;
298
298
  noise: {
299
- create: (options?: {}) => any;
299
+ create: (options?: {}) => {
300
+ type: any;
301
+ gain: any;
302
+ pan: any;
303
+ attack: any;
304
+ release: any;
305
+ filter: {
306
+ cutoff: any;
307
+ q: any;
308
+ set(mode: any, frequency: any, q?: any): void;
309
+ };
310
+ start: () => void;
311
+ stop: () => void;
312
+ dispose(): void;
313
+ };
300
314
  stopAll: () => void;
301
315
  };
302
316
  /** @type {Promise<void> | null} */
@@ -2,7 +2,34 @@
2
2
  * @returns Native rack node, FX/sample/noise controllers and Main/Worker ownership/lifecycle methods. */
3
3
  export declare function createNativeFXRack(context: AudioContext): Promise<{
4
4
  node: AudioWorkletNode;
5
- controller: any;
5
+ controller: {
6
+ liveFx(name: string, { process, context, resetState }?: {
7
+ process: (input: Float32Array[], output: Float32Array[], state: Record<string, unknown>, context: Record<string, unknown>) => void;
8
+ context?: Record<string, unknown>;
9
+ resetState?: boolean;
10
+ }): void;
11
+ updateContext(name: any, context: any): void;
12
+ removeLiveFx(name: any): void;
13
+ branch: (...children: any[]) => {
14
+ type: string;
15
+ children: any[];
16
+ owner: /*elided*/ any;
17
+ dispose(): void;
18
+ };
19
+ parallel: (...children: any[]) => {
20
+ type: string;
21
+ children: any[];
22
+ owner: /*elided*/ any;
23
+ dispose(): void;
24
+ };
25
+ setChain(effects?: any[]): any[];
26
+ clear({ dispose }?: {
27
+ dispose?: boolean | undefined;
28
+ }): any[];
29
+ dispose(): void;
30
+ getChain(): any[];
31
+ syncTempo(): void;
32
+ };
6
33
  mainActive: boolean;
7
34
  sample: {
8
35
  accept(d: any): void;
@@ -39,8 +39,8 @@ export declare function createNativeGenesisExtraSnesEndpoint(synth: any): {
39
39
  value: boolean;
40
40
  deferred?: undefined;
41
41
  } | {
42
- value?: undefined;
43
42
  id?: undefined;
43
+ value?: undefined;
44
44
  deferred: Promise<{
45
45
  id: any;
46
46
  value: any;
@@ -37,10 +37,10 @@ export declare function createNativeGenesisMedia(synth: any, { fetch: fetcher, d
37
37
  value: number | undefined;
38
38
  error?: undefined;
39
39
  } | {
40
- value?: undefined;
41
40
  op: string;
42
41
  id: any;
43
42
  error: string;
43
+ value?: undefined;
44
44
  }>;
45
45
  loadDacBank(name: any, bytes: any): Promise<any>;
46
46
  playDacBank(name: any, time: any, timing?: {}): Promise<void>;
@@ -185,10 +185,10 @@ export declare class NativeGenesisSynth {
185
185
  value: number | undefined;
186
186
  error?: undefined;
187
187
  } | {
188
+ value?: undefined;
188
189
  op: string;
189
190
  id: any;
190
191
  error: string;
191
- value?: undefined;
192
192
  }>;
193
193
  loadDacBank(name: any, bytes: any): Promise<any>;
194
194
  playDacBank(name: any, time: any, timing?: {}): Promise<void>;
@@ -114,7 +114,21 @@ export declare class NativeRuntimeSynth {
114
114
  initializationController: AbortController | null;
115
115
  state: string;
116
116
  noise: {
117
- create: (options?: {}) => any;
117
+ create: (options?: {}) => {
118
+ type: any;
119
+ gain: any;
120
+ pan: any;
121
+ attack: any;
122
+ release: any;
123
+ filter: {
124
+ cutoff: any;
125
+ q: any;
126
+ set(mode: any, frequency: any, q?: any): void;
127
+ };
128
+ start: () => void;
129
+ stop: () => void;
130
+ dispose(): void;
131
+ };
118
132
  stopAll: () => void;
119
133
  };
120
134
  /** @param {NativeRuntimeSynthOptions} [options] */
@@ -134,9 +148,9 @@ export declare class NativeRuntimeSynth {
134
148
  removeListener(listener: any): void;
135
149
  setMasterVolume(volume: any): number;
136
150
  getMasterVolume(): number;
137
- setFXChain(effects?: any[], options?: {}): any;
138
- getFXChain(): any;
139
- clearFXChain(options?: {}): any;
151
+ setFXChain(effects?: any[], options?: {}): any[] | undefined;
152
+ getFXChain(): any[];
153
+ clearFXChain(options?: {}): any[];
140
154
  connect(effect: any): this;
141
155
  connectOutput(node?: null): this;
142
156
  /** Stop voices while keeping uploaded samples, patches, waveforms and clocks. */
@@ -43,7 +43,21 @@ export declare class OPNRuntimeSynth {
43
43
  initializationController: AbortController | null;
44
44
  state: string;
45
45
  noise: {
46
- create: (options?: {}) => any;
46
+ create: (options?: {}) => {
47
+ type: any;
48
+ gain: any;
49
+ pan: any;
50
+ attack: any;
51
+ release: any;
52
+ filter: {
53
+ cutoff: any;
54
+ q: any;
55
+ set(mode: any, frequency: any, q?: any): void;
56
+ };
57
+ start: () => void;
58
+ stop: () => void;
59
+ dispose(): void;
60
+ };
47
61
  stopAll: () => void;
48
62
  };
49
63
  /** @param {OPNRuntimeSynthOptions|undefined} options */
@@ -66,9 +80,9 @@ export declare class OPNRuntimeSynth {
66
80
  /** @param {number} volume */
67
81
  setMasterVolume(volume: number): number;
68
82
  getMasterVolume(): number;
69
- setFXChain(effects?: any[], options?: {}): any;
70
- getFXChain(): any;
71
- clearFXChain(options?: {}): any;
83
+ setFXChain(effects?: any[], options?: {}): any[] | undefined;
84
+ getFXChain(): any[];
85
+ clearFXChain(options?: {}): any[];
72
86
  connect(effect: any): this;
73
87
  connectOutput(node?: null): this;
74
88
  close(): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tetorica-fm2612",
3
- "version": "0.2.39",
3
+ "version": "0.2.40",
4
4
  "description": "Tetorica sound chip WASM cores, Synth helpers and browser audio runtime",
5
5
  "type": "module",
6
6
  "license": "BSD-3-Clause",
@@ -10,6 +10,7 @@ import {executeWithPlaygroundGuards} from './playground_execution.js';
10
10
  import {midiToOpnPitch,opnPitchFromHz} from './soundchip_pitch.js';
11
11
  import {FM_PRESETS} from './megasynth-fm-presets.js';
12
12
  import {formatLogArgs} from './playground_log.js';
13
+ import {readVab,prepareVabTone,exportVab,MAX_VAB_FILE_BYTES} from './ps1_vab.js';
13
14
 
14
15
  /** @typedef {'ym2612'|'segapsg'|'rf5c164'|'pwm'} DefaultCodeSoundChip */
15
16
  /** @type {readonly DefaultCodeSoundChip[]} */
@@ -254,6 +255,7 @@ export function createPlaygroundCodeRuntime({ensureReady,now,useSoundChip,suppor
254
255
  waitBeats:beats=>{ensure();return clock.waitForBeat(clock.currentBeat()+beats,scope.epoch);}});
255
256
  const log=(...args)=>{ensure();onLog(formatLogArgs(args));};
256
257
  const globals={context:runtime.context,fm:fm(),fx:guarded(effectApi,scope),FM_PRESETS,CH1:0,CH2:1,CH3:2,CH4:3,CH5:4,CH6:5,
258
+ readVab,prepareVabTone,exportVab,MAX_VAB_FILE_BYTES,
257
259
  PSG1:0,PSG2:1,PSG3:2,OP1:0,OP2:1,OP3:2,OP4:3,
258
260
  console:{log,warn:(...args)=>log('[warn]',...args),error:(...args)=>log('[error]',...args)},log,
259
261
  async useSoundChip(name) {
@@ -3,6 +3,7 @@ import {createSnesClient} from './playground_snes.js';
3
3
  import {encodeBrr} from './snes_brr_encoder.js';
4
4
  import {encodeAdpcmA} from './adpcm_a_sample.js';
5
5
  import {encodePs1Adpcm} from './ps1_adpcm_encoder.js';
6
+ import {readVab,prepareVabTone,exportVab,MAX_VAB_FILE_BYTES} from './ps1_vab.js';
6
7
  import {createPerformanceSender} from './playground_performance_sender.js';
7
8
  import {midiToOpnPitch, opnPitchFromHz} from './soundchip_pitch.js';
8
9
  import {CHIP_CLOCKS} from './playground_chip_clock.js';
@@ -747,6 +748,7 @@ function createRun(sourceCode, presets, scaleIntervals, capabilities = {}, timin
747
748
  encodeBrr,
748
749
  encodeAdpcmA,
749
750
  encodePs1Adpcm,
751
+ readVab,prepareVabTone,exportVab,MAX_VAB_FILE_BYTES,
750
752
  trackAsync: promise => loopTasks.track(promise),
751
753
  createSampleInstrument: (audio,options={}) => createSampleInstrumentFactory({pg:globals,audio,chip:capabilities.chip,...options}),
752
754
  keyboard: {bind(name,handlers) {
@@ -158,9 +158,9 @@ export declare function createNativePrimaryClient(name: any, port: any, options?
158
158
  reset(options?: {
159
159
  clearRam?: boolean;
160
160
  }): void;
161
- getState(): Promise<ReturnType<import("./ps1synth.js").Ps1Synth['getState']>>;
162
- getPreset(ch: number): Promise<ReturnType<import("./ps1synth.js").Ps1Synth['getPreset']>>;
163
- snapshot(): Promise<ReturnType<import("./ps1synth.js").Ps1Synth['snapshot']>>;
161
+ getState(): Promise<ReturnType<import('./ps1synth.js').Ps1Synth['getState']>>;
162
+ getPreset(ch: number): Promise<ReturnType<import('./ps1synth.js').Ps1Synth['getPreset']>>;
163
+ snapshot(): Promise<ReturnType<import('./ps1synth.js').Ps1Synth['snapshot']>>;
164
164
  dispose(): void;
165
165
  } | {
166
166
  sampleRate: number;
@@ -1,5 +1,3 @@
1
- /** Ordered Browser/logic-Worker controls for the experimental PS1 SPU. */
2
- import { Ps1Synth } from './ps1synth.js';
3
1
  /** @param {MessagePort} port @param {{sampleRate?:number,state?:any}} [initial] */
4
2
  export declare function createPs1Client(port: MessagePort, initial?: {
5
3
  sampleRate?: number;
@@ -78,8 +76,8 @@ export declare function createPs1Client(port: MessagePort, initial?: {
78
76
  * @param {{clearRam?:boolean}} [options] */ reset(options?: {
79
77
  clearRam?: boolean;
80
78
  }): void;
81
- /** @returns {Promise<ReturnType<Ps1Synth['getState']>>} */ getState(): Promise<ReturnType<Ps1Synth['getState']>>;
82
- /** @param {number} ch @returns {Promise<ReturnType<Ps1Synth['getPreset']>>} */ getPreset(ch: number): Promise<ReturnType<Ps1Synth['getPreset']>>;
83
- /** @returns {Promise<ReturnType<Ps1Synth['snapshot']>>} */ snapshot(): Promise<ReturnType<Ps1Synth['snapshot']>>;
79
+ /** @returns {Promise<ReturnType<import('./ps1synth.js').Ps1Synth['getState']>>} */ getState(): Promise<ReturnType<import('./ps1synth.js').Ps1Synth['getState']>>;
80
+ /** @param {number} ch @returns {Promise<ReturnType<import('./ps1synth.js').Ps1Synth['getPreset']>>} */ getPreset(ch: number): Promise<ReturnType<import('./ps1synth.js').Ps1Synth['getPreset']>>;
81
+ /** @returns {Promise<ReturnType<import('./ps1synth.js').Ps1Synth['snapshot']>>} */ snapshot(): Promise<ReturnType<import('./ps1synth.js').Ps1Synth['snapshot']>>;
84
82
  dispose(): void;
85
83
  };
package/playground_ps1.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /** Ordered Browser/logic-Worker controls for the experimental PS1 SPU. */
2
- import {Ps1Synth,preparePs1ADPCM} from './ps1synth.js';
2
+ import {Ps1Synth,preparePs1ADPCM} from './ps1synth.js?v=ps1-oneshot-marker-1';
3
3
  const TIMEOUT_MS=15000;
4
4
  /** @param {MessagePort} port @param {{sampleRate?:number,state?:any}} [initial] */
5
5
  export function createPs1Client(port,initial={},lifecycle={}) {
@@ -54,9 +54,9 @@ export function createPs1Client(port,initial={},lifecycle={}) {
54
54
  /** Immediate preparation barrier, including in Worker mode. Clears prior
55
55
  * reserved notes; later voice controls retain their normal lookahead.
56
56
  * @param {{clearRam?:boolean}} [options] */ reset(options){control('reset',options===undefined?[]:[options]);},
57
- /** @returns {Promise<ReturnType<Ps1Synth['getState']>>} */ getState(){return request('getState');},
58
- /** @param {number} ch @returns {Promise<ReturnType<Ps1Synth['getPreset']>>} */ getPreset(ch){validation.getPreset(ch);return request('getPreset',[ch]);},
59
- /** @returns {Promise<ReturnType<Ps1Synth['snapshot']>>} */ snapshot(){return request('snapshot');},
57
+ /** @returns {Promise<ReturnType<import('./ps1synth.js').Ps1Synth['getState']>>} */ getState(){return request('getState');},
58
+ /** @param {number} ch @returns {Promise<ReturnType<import('./ps1synth.js').Ps1Synth['getPreset']>>} */ getPreset(ch){validation.getPreset(ch);return request('getPreset',[ch]);},
59
+ /** @returns {Promise<ReturnType<import('./ps1synth.js').Ps1Synth['snapshot']>>} */ snapshot(){return request('snapshot');},
60
60
  dispose(){if(disposed)return;disposed=true;revision++;try{port.postMessage({method:'dispose',args:[]});}catch{}finally{for(const p of pending.values()){clearTimeout(p.timer);p.reject(abort('PS1 SPU instance is disposed'));}pending.clear();port.onmessage=null;port.onmessageerror=null;port.close();}},
61
61
  };
62
62
  {
@@ -1,6 +1,6 @@
1
1
  import {noteToHz} from './soundchip_pitch.js';
2
2
  import {patchPs1Envelope} from './ps1_parameters.js';
3
- import {preparePs1ADPCM} from './ps1synth.js';
3
+ import {preparePs1ADPCM} from './ps1synth.js?v=ps1-oneshot-marker-1';
4
4
  const channel=value=>{if(!Number.isInteger(value)||value<0||value>23)throw new RangeError('PS1 SPU channel must be 0..23');return value;};
5
5
  function identity(value){if(typeof value!=='string'||!value.length||value.length>128)throw new TypeError('Audition identity must contain 1..128 characters');return `voice-editor:${value}`;}
6
6
  function retriggerOption(value={}){
@@ -1,6 +1,6 @@
1
1
  import factory from './generated/ps1_spu_wasm.js';
2
2
  import {Ps1Spu} from './ps1_spu.js';
3
- import {Ps1Synth,createPs1InitSample} from './ps1synth.js';
3
+ import {Ps1Synth,createPs1InitSample} from './ps1synth.js?v=ps1-oneshot-marker-1';
4
4
  import {Ps1Resampler} from './ps1_resampler.js';
5
5
  import {createProcessorPerformance} from './playground_performance_processor.js';
6
6
  import {Ps1VoiceInspector} from './playground_ps1_inspector.js';
@@ -8,6 +8,7 @@ import {createPs1Client} from './playground_ps1.js';
8
8
  import {encodeBrr} from './snes_brr_encoder.js';
9
9
  import {encodeAdpcmA} from './adpcm_a_sample.js';
10
10
  import {encodePs1Adpcm} from './ps1_adpcm_encoder.js';
11
+ import {readVab,prepareVabTone,exportVab,MAX_VAB_FILE_BYTES} from './ps1_vab.js';
11
12
  import {createChipInspector} from './playground_chip_inspector.js';
12
13
  import {createPerformanceHost} from './playground_performance_host.js';
13
14
  import {createNativeGenesisWorkerBridge} from './native_genesis_worker.js';
@@ -2541,6 +2542,7 @@ export function createPlaygroundRuntime(
2541
2542
  encodeBrr,
2542
2543
  encodeAdpcmA,
2543
2544
  encodePs1Adpcm,
2545
+ readVab,prepareVabTone,exportVab,MAX_VAB_FILE_BYTES,
2544
2546
  mixer: megaDrive.mixer,
2545
2547
  trackAsync: promise => loopTasks.track(promise),
2546
2548
  inputAudio: inputOptions => inputAudio(inputOptions, runToken),
@@ -2772,6 +2774,10 @@ export function createPlaygroundRuntime(
2772
2774
  encodeBrr: pg.encodeBrr,
2773
2775
  encodeAdpcmA: pg.encodeAdpcmA,
2774
2776
  encodePs1Adpcm: pg.encodePs1Adpcm,
2777
+ readVab: pg.readVab,
2778
+ prepareVabTone: pg.prepareVabTone,
2779
+ exportVab: pg.exportVab,
2780
+ MAX_VAB_FILE_BYTES: pg.MAX_VAB_FILE_BYTES,
2775
2781
  mixer: pg.mixer,
2776
2782
  createSoundChip: pg.createSoundChip,
2777
2783
  useSoundChip: pg.useSoundChip,
package/ps1_vab.d.ts ADDED
@@ -0,0 +1,195 @@
1
+ export declare const MAX_VAB_FILE_BYTES: number;
2
+ export type Ps1VabSample = {
3
+ /**
4
+ * Original one-based VAB sample number.
5
+ */
6
+ index: number;
7
+ /**
8
+ * Owned raw sample bytes; no decoding or encoding.
9
+ */
10
+ bytes: Uint8Array;
11
+ };
12
+ export type Ps1VabTone = {
13
+ /**
14
+ * Original Program number, 0..127.
15
+ */
16
+ program: number;
17
+ /**
18
+ * Tone index within that Program, 0..15.
19
+ */
20
+ index: number;
21
+ /**
22
+ * One-based sample number; 0 is unassigned and 255 is libsnd Noise.
23
+ */
24
+ sample: number;
25
+ /**
26
+ * Raw Tone mode flags, including bit 2 reverb send.
27
+ */
28
+ mode: number;
29
+ /**
30
+ * Tone volume code, 0..127.
31
+ */
32
+ volume: number;
33
+ /**
34
+ * Tone pan code, 0..127.
35
+ */
36
+ pan: number;
37
+ /**
38
+ * Center MIDI note, 0..127.
39
+ */
40
+ center: number;
41
+ /**
42
+ * Positive playback fine tuning in 1/128 semitone units.
43
+ */
44
+ shift: number;
45
+ /**
46
+ * Minimum key code, 0..127.
47
+ */
48
+ keyLow: number;
49
+ /**
50
+ * Maximum key code, 0..127.
51
+ */
52
+ keyHigh: number;
53
+ /**
54
+ * Raw ADSR1 register.
55
+ */
56
+ adsr1: number;
57
+ /**
58
+ * Raw ADSR2 register.
59
+ */
60
+ adsr2: number;
61
+ /**
62
+ * Recorded vibrato width code.
63
+ */
64
+ vibratoWidth: number;
65
+ /**
66
+ * Recorded vibrato time code.
67
+ */
68
+ vibratoTime: number;
69
+ /**
70
+ * Recorded portamento width code.
71
+ */
72
+ portamentoWidth: number;
73
+ /**
74
+ * Recorded portamento time code.
75
+ */
76
+ portamentoTime: number;
77
+ /**
78
+ * Recorded downward pitch bend range.
79
+ */
80
+ bendMin: number;
81
+ /**
82
+ * Recorded upward pitch bend range.
83
+ */
84
+ bendMax: number;
85
+ };
86
+ export type Ps1VabProgram = {
87
+ /**
88
+ * Original Program number, 0..127; sparse numbers are retained.
89
+ */
90
+ index: number;
91
+ /**
92
+ * Program volume code, 0..127.
93
+ */
94
+ volume: number;
95
+ /**
96
+ * Program pan code, 0..127.
97
+ */
98
+ pan: number;
99
+ /**
100
+ * Tones in their original Program order.
101
+ */
102
+ tones: Ps1VabTone[];
103
+ };
104
+ export type Ps1VabBank = {
105
+ /**
106
+ * Supported standard VAB version.
107
+ */
108
+ version: 6 | 7;
109
+ /**
110
+ * Original VAB identifier.
111
+ */
112
+ id: number;
113
+ /**
114
+ * Bank volume code, 0..127.
115
+ */
116
+ masterVolume: number;
117
+ /**
118
+ * Bank pan code, 0..127.
119
+ */
120
+ masterPan: number;
121
+ /**
122
+ * Nonempty Programs in table order.
123
+ */
124
+ programs: Ps1VabProgram[];
125
+ /**
126
+ * All Tones in packed Program/Tone order.
127
+ */
128
+ tones: Ps1VabTone[];
129
+ /**
130
+ * Samples in one-based VAB number order.
131
+ */
132
+ samples: Ps1VabSample[];
133
+ };
134
+ export type Ps1VabPreparedTone = {
135
+ /**
136
+ * Owned original bytes through the first END packet.
137
+ */
138
+ adpcm: Uint8Array;
139
+ /**
140
+ * Explicit sample tuning and optional packet-aligned loop start.
141
+ */
142
+ options: {
143
+ baseFrequencyHz: number;
144
+ loopStartSamples?: number;
145
+ };
146
+ /**
147
+ * Voice settings, excluding the uploaded sample ID.
148
+ */
149
+ preset: {
150
+ adsr1: number;
151
+ adsr2: number;
152
+ pitch: number;
153
+ reverb: boolean;
154
+ volumeLeft: number;
155
+ volumeRight: number;
156
+ };
157
+ /**
158
+ * The selected source Tone metadata.
159
+ */
160
+ tone: Ps1VabTone;
161
+ /**
162
+ * Original bounded bytes omitted after END.
163
+ */
164
+ trimmedBytes: number;
165
+ };
166
+ export type Ps1VabExportOptions = {
167
+ /**
168
+ * Index in bank.tones. Omit for a byte-exact full source bank.
169
+ */
170
+ toneNumber?: number;
171
+ };
172
+ /** Parse a complete VAB, or a VH header plus its explicitly supplied VB body.
173
+ * Counts are actual counts (not count minus one). Tone tables are packed by
174
+ * nonempty program, while the 128-entry program table may have holes.
175
+ * No file names, code execution, AudioContext or live RAM are involved.
176
+ * @param {ArrayBuffer|ArrayBufferView} headerInput Complete VAB or VH bytes.
177
+ * @param {ArrayBuffer|ArrayBufferView} [bodyInput] Matching VB bytes for split input.
178
+ * @returns {Ps1VabBank} */
179
+ export declare function readVab(headerInput: ArrayBuffer | ArrayBufferView, bodyInput?: ArrayBuffer | ArrayBufferView): Ps1VabBank;
180
+ /** Export an opened, unchanged standard VAB without an audio core or encoder.
181
+ * Full-bank output preserves the original VH + VB bytes, including padding.
182
+ * A selected Tone keeps its original Program number and raw attributes, but
183
+ * becomes the only Tone (index 0) and references the only sample (number 1).
184
+ * This exports source banks, not arbitrary edited Synth instruments.
185
+ * @param {Ps1VabBank} bank
186
+ * @param {Ps1VabExportOptions} [options]
187
+ * @returns {Uint8Array} */
188
+ export declare function exportVab(bank: Ps1VabBank, options?: Ps1VabExportOptions): Uint8Array;
189
+ /** Prepare one Tone for the existing Synth/preset API. ADPCM payload is never
190
+ * decoded or re-encoded. Trim only bytes after the first hardware END packet.
191
+ * Unsupported flag patterns fail instead of silently rewriting game data.
192
+ * @param {Ps1VabBank} bank
193
+ * @param {number} toneNumber Index in bank.tones, not a Program number.
194
+ * @returns {Ps1VabPreparedTone} */
195
+ export declare function prepareVabTone(bank: Ps1VabBank, toneNumber: number): Ps1VabPreparedTone;