tetorica-fm2612 0.2.21 → 0.2.23
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 +136 -2
- package/RUNTIME.md +1 -1
- package/ay8910synth.d.ts +148 -0
- package/ay8910synth.js +201 -0
- package/chip_worklet_transport.d.ts +14 -0
- package/chip_worklet_transport.js +8 -0
- package/generated/ymf262_wasm.wasm +0 -0
- package/generated/ymf278b_wasm.wasm +0 -0
- package/native_runtime_synth.d.ts +35 -5
- package/native_runtime_synth.js +85 -13
- package/node/chip_transports.d.mts +89 -0
- package/node/chip_transports.mjs +20 -2
- package/opl_synth.d.ts +200 -0
- package/opl_synth.js +362 -0
- package/package.json +11 -1
- package/playground_audition_guard.d.ts +21 -0
- package/playground_audition_guard.js +39 -0
- package/playground_ay8910.d.ts +10 -0
- package/playground_ay8910.js +32 -0
- package/playground_ay8910_audio.d.ts +17 -0
- package/playground_ay8910_audio.js +61 -0
- package/playground_ay8910_inspector.d.ts +59 -0
- package/playground_ay8910_inspector.js +40 -0
- package/playground_ay8910_worklet.d.ts +1 -0
- package/playground_ay8910_worklet.js +63 -0
- package/playground_chip_clock.d.ts +10 -1
- package/playground_chip_clock.js +13 -4
- package/playground_chip_inspector.d.ts +2 -1
- package/playground_chip_inspector.js +45 -22
- package/playground_chip_inspector_state.d.ts +41 -15
- package/playground_chip_inspector_state.js +53 -12
- package/playground_dx7.d.ts +21 -4
- package/playground_dx7.js +45 -6
- package/playground_dx7_audio.d.ts +2 -2
- package/playground_dx7_audio.js +5 -2
- package/playground_dx7_inspector.d.ts +105 -0
- package/playground_dx7_inspector.js +88 -0
- package/playground_dx7_worklet.js +97 -23
- package/playground_gameboy.d.ts +1 -0
- package/playground_gameboy_audio.js +1 -1
- package/playground_huc6280.d.ts +1 -0
- package/playground_huc6280.js +3 -2
- package/playground_huc6280_audio.js +1 -0
- package/playground_huc6280_worklet.js +9 -1
- package/playground_keyboard_channels.d.ts +22 -0
- package/playground_keyboard_channels.js +52 -0
- package/playground_logic_worker.js +12 -3
- package/playground_native_primary.d.ts +51 -3
- package/playground_native_primary.js +15 -3
- package/playground_nes.d.ts +2 -2
- package/playground_nes.js +8 -9
- package/playground_nes_audio.js +1 -0
- package/playground_okim6258.d.ts +1 -0
- package/playground_okim6258.js +3 -2
- package/playground_okim6258_audio.js +1 -0
- package/playground_okim6258_worklet.js +2 -1
- package/playground_opl.d.ts +14 -0
- package/playground_opl.js +39 -0
- package/playground_opl_audio.d.ts +18 -0
- package/playground_opl_audio.js +63 -0
- package/playground_opl_inspector.d.ts +79 -0
- package/playground_opl_inspector.js +61 -0
- package/playground_opl_worklet.d.ts +1 -0
- package/playground_opl_worklet.js +116 -0
- package/playground_opn.d.ts +1 -0
- package/playground_opn_audio.js +2 -2
- package/playground_opn_inspector.d.ts +49 -0
- package/playground_opn_inspector.js +105 -0
- package/playground_opn_worklet.js +9 -2
- package/playground_performance_processor.d.ts +29 -8
- package/playground_performance_processor.js +141 -14
- package/playground_pwm_audio.js +1 -1
- package/playground_rf5c164.d.ts +1 -0
- package/playground_rf5c164.js +3 -1
- package/playground_rf5c164_audio.js +1 -0
- package/playground_runtime.d.ts +24 -3
- package/playground_runtime.js +133 -26
- package/playground_segapsg.d.ts +1 -0
- package/playground_segapsg.js +8 -4
- package/playground_segapsg_audio.js +1 -0
- package/playground_segapsg_worklet.js +17 -6
- package/playground_snes.d.ts +1 -0
- package/playground_snes.js +1 -0
- package/playground_snes_audio.js +1 -1
- package/playground_snes_inspector.d.ts +61 -0
- package/playground_snes_inspector.js +48 -0
- package/playground_snes_worklet.d.ts +4 -1
- package/playground_snes_worklet.js +19 -1
- package/playground_soundchips.js +1 -1
- package/playground_ym2151.d.ts +3 -1
- package/playground_ym2151.js +2 -1
- package/playground_ym2151_audio.js +1 -1
- package/playground_ym2151_worklet.js +10 -2
- package/playground_ym2413.d.ts +10 -0
- package/playground_ym2413.js +22 -0
- package/playground_ym2413_audio.d.ts +17 -0
- package/playground_ym2413_audio.js +61 -0
- package/playground_ym2413_inspector.d.ts +82 -0
- package/playground_ym2413_inspector.js +59 -0
- package/playground_ym2413_worklet.d.ts +1 -0
- package/playground_ym2413_worklet.js +111 -0
- package/playground_ym2608.d.ts +1 -0
- package/playground_ym2608_audio.js +1 -1
- package/playground_ym2608_worklet.js +11 -2
- package/rf5c164-worklet.js +13 -5
- package/runtime-manifest.json +23 -0
- package/soundchip-output-worklet.js +39 -7
- package/soundchip.d.ts +1 -1
- package/soundchip.js +1 -1
- package/soundchip.md +58 -0
- package/soundchip_worklet.js +1 -1
- package/tetorica_synth.js +2 -2
- package/y8950synth.d.ts +19 -0
- package/y8950synth.js +15 -0
- package/ym2203-worklet.js +6 -1
- package/ym2413synth.d.ts +194 -0
- package/ym2413synth.js +310 -0
- package/ym2608-worklet.js +6 -1
- package/ym2610b-worklet.js +6 -1
- package/ym2612-worklet-nuked.js +15 -3
- package/ym2612-worklet.js +15 -3
- package/ym3526synth.d.ts +19 -0
- package/ym3526synth.js +15 -0
- package/ym3812synth.d.ts +19 -0
- package/ym3812synth.js +15 -0
- package/ymf262synth.d.ts +19 -0
- package/ymf262synth.js +15 -0
package/README.md
CHANGED
|
@@ -32,6 +32,9 @@ entry points, rather than every internal Worker or Worklet module.
|
|
|
32
32
|
| YM2608 FM, SSG, rhythm and ADPCM-B | `tetorica-fm2612/ym2608synth.js` | `YM2608Synth`, `YM2608DirectTransport`, `YM2608WorkletTransport` |
|
|
33
33
|
| YM2610 / YM2610B FM, SSG and ADPCM | `tetorica-fm2612/ym2610bsynth.js` | `YM2610BSynth`, `YM2610BDirectTransport`, `NeoGeoFMSynth`, `NeoGeoSynth` |
|
|
34
34
|
| YM2151 FM | `tetorica-fm2612/ym2151synth.js` | `YM2151Synth`, `YM2151DirectTransport`, `YM2151WorkletTransport` |
|
|
35
|
+
| OPL / OPL2 / Y8950 FM / OPL3 | `tetorica-fm2612/opl_synth.js` | `OPLSynth`, `OPLDirectTransport`, `OPL_PRESETS` |
|
|
36
|
+
| YM2413 OPLL | `tetorica-fm2612/ym2413synth.js` | `YM2413Synth`, `YM2413DirectTransport`, `YM2413_INSTRUMENTS`, `YM2413_USER_PRESETS` |
|
|
37
|
+
| AY-3-8910 PSG | `tetorica-fm2612/ay8910synth.js` | `AY8910Synth`, `AY8910DirectTransport`, `AY8910WorkletTransport` |
|
|
35
38
|
| Game Boy pulse, wave and noise | `tetorica-fm2612/gameboysynth.js` | `GameboySynth`, `GameboyDirectTransport` |
|
|
36
39
|
| NES APU and FDS | `tetorica-fm2612/nesapusynth.js` | `NesApuSynth`, `NesApuDirectTransport`, `NesApuWorkletTransport` |
|
|
37
40
|
| Sega PSG tone and noise | `tetorica-fm2612/segapsgsynth.js` | `SegaPSGSynth`, `SegaPSGDirectTransport`, `psgPeriodFromFrequency`, `psgPeriodFromNote` |
|
|
@@ -88,12 +91,126 @@ Declarations are shipped beside each module, for example
|
|
|
88
91
|
functions/classes, parameter types, options and return types. Plain JavaScript
|
|
89
92
|
projects can use the same editor assistance with JSDoc-aware tooling.
|
|
90
93
|
|
|
94
|
+
### OPL family instruments
|
|
95
|
+
|
|
96
|
+
Available in `tetorica-fm2612@0.2.22` and later.
|
|
97
|
+
|
|
98
|
+
`OPLSynth` shares one API across `ym3526`, `ym3812`, `y8950` (FM only), and
|
|
99
|
+
`ymf262`. Channels are zero-based: 0–8 for the first three, 0–17 for OPL3.
|
|
100
|
+
Operator indices are modulator/carrier 0/1; enabled OPL3 pairs use 0–3.
|
|
101
|
+
`initialize()` explicitly resets the chip and prepares silent voices. Constructing
|
|
102
|
+
a Synth alone never resets or writes to a borrowed chip.
|
|
103
|
+
|
|
104
|
+
```js
|
|
105
|
+
import {createSoundChip, encodeWav} from 'tetorica-fm2612';
|
|
106
|
+
import {OPLSynth, OPLDirectTransport, OPL_PRESETS} from 'tetorica-fm2612/opl_synth.js';
|
|
107
|
+
|
|
108
|
+
const chip = await createSoundChip('ym3812');
|
|
109
|
+
try {
|
|
110
|
+
const opl = new OPLSynth({chip:'ym3812', transport:new OPLDirectTransport(chip)});
|
|
111
|
+
opl.initialize();
|
|
112
|
+
opl.setPreset(0, OPL_PRESETS.sine);
|
|
113
|
+
opl.noteOn(0, 'A4');
|
|
114
|
+
const pcm = chip.generateStereo(Math.round(chip.sampleRate() * 0.5));
|
|
115
|
+
const wav = encodeWav({...pcm, sampleRate:chip.sampleRate()});
|
|
116
|
+
opl.noteOff(0);
|
|
117
|
+
// Save wav to a file, or send pcm to your own output.
|
|
118
|
+
} finally { chip.dispose(); }
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Use `OPLWorkletTransport` from `chip_worklet_transport.js` with a
|
|
122
|
+
`createSoundChip(name, {execution:'worklet'})` endpoint for browser audio.
|
|
123
|
+
`OPLAudifyTransport` from `node/transports` provides optional Node device output.
|
|
124
|
+
The chip-specific `ym3526synth.js`, `ym3812synth.js`, `y8950synth.js` and
|
|
125
|
+
`ymf262synth.js` entry points also export named Synth and DirectTransport wrappers.
|
|
126
|
+
|
|
127
|
+
OPL3 enables stereo with `setPan(ch, left, right)` and pairs with
|
|
128
|
+
`setFourOp(ch, true)` for primary channels 0–2 and 9–11. Each enabled pair owns
|
|
129
|
+
the secondary channel three positions later; address its four operators through
|
|
130
|
+
the primary. `setPreset(0, OPL_PRESETS['four-op-bell'])` configures such a pair.
|
|
131
|
+
Mono chips send the same output to both speakers. Their operators support sine
|
|
132
|
+
only on YM3526/Y8950, four waveforms on YM3812, and eight on YMF262.
|
|
133
|
+
|
|
134
|
+
Playground modes `ym3526`, `ym3812`, `msx-audio` and `ymf262` expose the primary
|
|
135
|
+
instrument as `opl` and provide `OPL_PRESETS`. Use `opl.noteOn()` / `noteOff()`;
|
|
136
|
+
the OPN `fm` and `play()` conveniences are absent. Operators and Keyboard share
|
|
137
|
+
this same primary instrument. OPLL/YM2413 is a separate API and is not included
|
|
138
|
+
in this high-level OPL family implementation.
|
|
139
|
+
|
|
91
140
|
`node_modules/tetorica-fm2612/runtime-manifest.json` lists every shipped runtime
|
|
92
141
|
module and asset. It is a distribution inventory, including internal modules;
|
|
93
142
|
start with the task table above when choosing an application API. See the
|
|
94
143
|
[runnable examples](https://github.com/kyorohiro/tetorica-fm2612-examples) for
|
|
95
144
|
complete setup, playback and cleanup.
|
|
96
145
|
|
|
146
|
+
### Master System: Sega PSG and YM2413 OPLL
|
|
147
|
+
|
|
148
|
+
Available in `tetorica-fm2612@0.2.23` and later.
|
|
149
|
+
|
|
150
|
+
The Master System Playground mode prepares both a mono Sega PSG (`psg`) and
|
|
151
|
+
YM2413 (`opll`). They have separate mixer strips and Keyboard chip/channel
|
|
152
|
+
targets. Game Gear prepares its stereo PSG only.
|
|
153
|
+
|
|
154
|
+
```js
|
|
155
|
+
// Playground script in Master System mode.
|
|
156
|
+
opll.setInstrument(0, 3, 4); // Piano, hardware attenuation 4.
|
|
157
|
+
opll.noteOn(0, 'C4');
|
|
158
|
+
psg.tone(PSG1, {note:'C3', attenuation:10});
|
|
159
|
+
await beat(1);
|
|
160
|
+
opll.noteOff(0);
|
|
161
|
+
psg.off(PSG1);
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
For an embedded Playground, choose
|
|
165
|
+
`Playground({chip:'segapsg', stereoEnabled:false, ym2413:true})`.
|
|
166
|
+
Use `useSoundChip('ym2413')` to borrow the mode's OPLL; `createSoundChip('ym2413')`
|
|
167
|
+
creates an independent instance. `YM2413Synth` also supports Direct, Worklet
|
|
168
|
+
and optional Node Audify transports.
|
|
169
|
+
|
|
170
|
+
YM2413 has nine melody channels, or six melody channels and five rhythm voices.
|
|
171
|
+
Instrument IDs 1–15 select built-in voices; instrument 0 selects the single
|
|
172
|
+
chip-wide user patch. `setUserPatch()` / `setUserOperator()` therefore change
|
|
173
|
+
every channel using instrument 0. Carrier loudness is set by each channel's
|
|
174
|
+
`attenuation` (0 loudest, 15 quietest), rather than a shared carrier TL field.
|
|
175
|
+
The Operators panel keeps built-in voices separate from this shared patch.
|
|
176
|
+
Rhythm levels share CH6–8's instrument/attenuation registers; select those
|
|
177
|
+
channels' melody voices again after changing rhythm levels when needed.
|
|
178
|
+
|
|
179
|
+
### MSX and MSX Audio
|
|
180
|
+
|
|
181
|
+
Available in `tetorica-fm2612@0.2.23` and later.
|
|
182
|
+
|
|
183
|
+
The MSX Playground mode combines `ay` (AY-3-8910 PSG) and `opll` (YM2413
|
|
184
|
+
MSX-MUSIC). MSX Audio adds `opl` (Y8950 MSX-AUDIO FM). Each instrument has
|
|
185
|
+
its own mixer strip, chip tab and Keyboard channel selector in the same audio
|
|
186
|
+
context. These are authoring sound sets. The Y8950 uses the existing OPL FM API; its ADPCM sample player has
|
|
187
|
+
no high-level adapter in this mode.
|
|
188
|
+
|
|
189
|
+
```js
|
|
190
|
+
// Playground script in MSX Audio mode. AY volume: 0 silent .. 15 loudest.
|
|
191
|
+
ay.tone(0, {note:'A4', volume:9});
|
|
192
|
+
opll.setVoice(0, {instrument:3, attenuation:5});
|
|
193
|
+
opll.noteOn(0, 'A4');
|
|
194
|
+
opl.setPreset(0, OPL_PRESETS.sine);
|
|
195
|
+
opl.noteOn(0, 'A4');
|
|
196
|
+
await beat(1);
|
|
197
|
+
ay.keyOff(0); opll.keyOff(0); opl.keyOff(0);
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Embed the two-chip set with `Playground({chip:'msx'})`, or the three-chip set
|
|
201
|
+
with `Playground({chip:'msx-audio'})`. Optional `ayOptions`,
|
|
202
|
+
`opllOptions` and `oplOptions` accept `{fetch, wasmUrl, workletUrl}` for custom
|
|
203
|
+
asset loading. `useSoundChip('ay8910'|'ym2413')` borrows a primary device in
|
|
204
|
+
both modes; `useSoundChip('y8950')` borrows MSX Audio's primary, or adds an
|
|
205
|
+
independent Y8950 in MSX. `createSoundChip()` creates an independent instance.
|
|
206
|
+
|
|
207
|
+
The AY has three channels, each mixing tone and noise. Noise period and
|
|
208
|
+
hardware envelope are shared across those channels. `setMixer()` preserves
|
|
209
|
+
the other channels and I/O bits; `keyOff()` preserves the configured voice,
|
|
210
|
+
and the next `keyOn()` restores its level. `setEnvelope({shape})` explicitly
|
|
211
|
+
retriggers the shared envelope. AY uses a twelve-bit tone period and
|
|
212
|
+
`frequency = clock / (16 * period)`; it is mono, copied to both outputs.
|
|
213
|
+
|
|
97
214
|
## Chip mixer
|
|
98
215
|
|
|
99
216
|
Browser outputs share `SoundChipMixer`: `volume` is a linear multiplier (0–2),
|
|
@@ -699,10 +816,10 @@ FM/PSG/PCM mixing, stop/reset and close/restart. Playwright is a development
|
|
|
699
816
|
dependency; it is not required by users of the sound-chip runtime.
|
|
700
817
|
|
|
701
818
|
The build is staged in `dist/fm2612/`; packing produces
|
|
702
|
-
`tetorica-fm2612-0.2.
|
|
819
|
+
`tetorica-fm2612-0.2.23.tgz`. To install a local build in another project:
|
|
703
820
|
|
|
704
821
|
```sh
|
|
705
|
-
npm install /absolute/path/to/tetorica-fm2612-0.2.
|
|
822
|
+
npm install /absolute/path/to/tetorica-fm2612-0.2.23.tgz
|
|
706
823
|
```
|
|
707
824
|
|
|
708
825
|
The existing `tetorica-vgm` CLI package is built separately. This first package
|
|
@@ -720,6 +837,23 @@ instrument/sample ROMs are not included.
|
|
|
720
837
|
|
|
721
838
|
## Release notes
|
|
722
839
|
|
|
840
|
+
`0.2.23` adds **AY-3-8910 and YM2413 high-level Synth APIs**, direct and Worklet
|
|
841
|
+
transports, native voice inspectors and Keyboard channel adapters. AY exposes
|
|
842
|
+
three tone/noise voices with a shared noise generator and hardware envelope;
|
|
843
|
+
OPLL exposes nine melodic voices or six voices plus five drums, fifteen built-in
|
|
844
|
+
instruments and one shared user patch. Native sound sets include Master System's
|
|
845
|
+
PSG + OPLL, `Playground({chip:'msx'})` with AY + OPLL, and
|
|
846
|
+
`Playground({chip:'msx-audio'})` with AY + OPLL + Y8950 FM. Main/Worker execution,
|
|
847
|
+
independent mixer strips, retained voice settings, Stop and initialization
|
|
848
|
+
cancellation are supported. Keyboard rhythm choices follow the applied audio
|
|
849
|
+
state, without audio polling. The website editor and mode selector remain
|
|
850
|
+
separate from this npm runtime payload.
|
|
851
|
+
|
|
852
|
+
`0.2.22` adds **OPL-family Synth APIs** for YM3526, YM3812, Y8950 FM and YMF262,
|
|
853
|
+
including two-operator voices, rhythm controls, OPL3 four-operator pairs and
|
|
854
|
+
stereo routing. Direct, Worklet and Node output transports share the chip-specific
|
|
855
|
+
register mapping. Y8950 ADPCM remains outside the high-level API.
|
|
856
|
+
|
|
723
857
|
`0.2.21` extends the **shared Playground runtime** with native primary synth
|
|
724
858
|
configurations, applied-state voice inspectors, channel-owned audition,
|
|
725
859
|
`keyboard.bind()`, host-provided `inputAudio()` and sample-instrument adapters.
|
package/RUNTIME.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Full web runtime
|
|
2
2
|
|
|
3
|
-
Includes all
|
|
3
|
+
Includes all 225 top-level web runtime modules and 24 generated chip/engine pairs.
|
|
4
4
|
|
|
5
5
|
ay8910, gameboy_apu, huc6280, k051649, nuked_opn2, okim6258, rf5c164, segapcm, segapsg, spc, y8950, ym2151, ym2203, ym2413, ym2608, ym2610b, ym2612, ym3438, ym3526, ym3812, ymf262, ymf276, ymf278b, ymf288
|
|
6
6
|
|
package/ay8910synth.d.ts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
export { AY8910_CLOCK } from './ay8910.js';
|
|
2
|
+
export { AY8910WorkletTransport } from './chip_worklet_transport.js';
|
|
3
|
+
export type AY8910Voice = {
|
|
4
|
+
tone?: boolean;
|
|
5
|
+
noise?: boolean;
|
|
6
|
+
volume?: number;
|
|
7
|
+
envelope?: boolean;
|
|
8
|
+
period?: number;
|
|
9
|
+
frequency?: number;
|
|
10
|
+
note?: string | number;
|
|
11
|
+
};
|
|
12
|
+
export type AY8910Tone = {
|
|
13
|
+
period?: number;
|
|
14
|
+
frequency?: number;
|
|
15
|
+
note?: string | number;
|
|
16
|
+
volume?: number;
|
|
17
|
+
envelope?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export type AY8910Transport = {
|
|
20
|
+
writeRegister(register: number, value: number): void;
|
|
21
|
+
reset?: () => void;
|
|
22
|
+
dispose?: () => void;
|
|
23
|
+
};
|
|
24
|
+
export type AY8910State = {
|
|
25
|
+
registers: number[] | Uint8Array;
|
|
26
|
+
levels?: number[] | Uint8Array;
|
|
27
|
+
};
|
|
28
|
+
export type RegisterChange = [number, number, number];
|
|
29
|
+
/** AY tone frequency = clock / (16 * period). Raw zero periods behave as one.
|
|
30
|
+
* @param {number} frequency @param {number} [clock] @returns {number} */
|
|
31
|
+
export declare function ay8910PeriodFromHz(frequency: number, clock?: number): number;
|
|
32
|
+
/** Borrow a synchronous AY chip. Its clock was fixed by Ay8910.create(); the
|
|
33
|
+
* Synth's clock must match it. This adapter never owns or disposes the chip.
|
|
34
|
+
* Native normalized DAC output retains a constant DC baseline at volume zero;
|
|
35
|
+
* speaker transports additionally mute silent channels for exact zero PCM. */
|
|
36
|
+
export declare class AY8910DirectTransport {
|
|
37
|
+
chip: import("./ay8910.js").Ay8910;
|
|
38
|
+
/** @param {import('./ay8910.js').Ay8910} chip */
|
|
39
|
+
constructor(chip: import('./ay8910.js').Ay8910);
|
|
40
|
+
/** @param {number} register @param {number} value */
|
|
41
|
+
writeRegister(register: number, value: number): void;
|
|
42
|
+
reset(): void;
|
|
43
|
+
sampleRate(): number;
|
|
44
|
+
/** @param {number} frames */
|
|
45
|
+
generateStereo(frames: number): {
|
|
46
|
+
left: Float32Array;
|
|
47
|
+
right: Float32Array;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/** Three AY-3-8910 physical voices. Each mixes tone and the one shared noise
|
|
51
|
+
* source, then uses fixed volume or the one shared envelope. Volume 0 is silent;
|
|
52
|
+
* 15 is loudest. Construction never resets or writes a borrowed transport.
|
|
53
|
+
*
|
|
54
|
+
* keyOff() silences a voice while retaining its configured level. keyOn()
|
|
55
|
+
* restores that level and preserves tone/noise gates, including noise-only
|
|
56
|
+
* voices. Shared noise/envelope edits affect all voices using those sources.
|
|
57
|
+
*/
|
|
58
|
+
export declare class AY8910Synth {
|
|
59
|
+
#private;
|
|
60
|
+
transport: AY8910Transport;
|
|
61
|
+
clock: any;
|
|
62
|
+
chip: string;
|
|
63
|
+
channels: number;
|
|
64
|
+
/** @type {((register:number,value:number)=>boolean|void)|undefined} */ _beforeWrite: ((register: number, value: number) => boolean | void) | undefined;
|
|
65
|
+
/** @type {((event:{method:string,args:number[],channel?:number})=>void)|undefined} */ _observe: ((event: {
|
|
66
|
+
method: string;
|
|
67
|
+
args: number[];
|
|
68
|
+
channel?: number;
|
|
69
|
+
}) => void) | undefined;
|
|
70
|
+
/** @param {{transport:AY8910Transport,clock?:number}} settings */
|
|
71
|
+
constructor({ transport, clock }?: {
|
|
72
|
+
transport: AY8910Transport;
|
|
73
|
+
clock?: number;
|
|
74
|
+
});
|
|
75
|
+
reset(): void;
|
|
76
|
+
/** Reset to silent A4 tone-only voices. Actual volume registers are zero;
|
|
77
|
+
* keyOn restores configured volume 9. I/O ports are untouched after reset. */
|
|
78
|
+
initialize(): void;
|
|
79
|
+
getRegisterSnapshot(): Uint8Array<ArrayBuffer>;
|
|
80
|
+
/** Adopt raw registers without writes. Zero output levels lack keyOff's
|
|
81
|
+
* retained-voice metadata, so they default to level 9 for a new audition.
|
|
82
|
+
* Use _adoptState() to preserve an intentionally configured zero level.
|
|
83
|
+
* @param {Uint8Array|number[]} snapshot */
|
|
84
|
+
adoptRegisterSnapshot(snapshot: Uint8Array | number[]): void;
|
|
85
|
+
/** Full musical state includes the levels retained by keyOff(). */
|
|
86
|
+
_getState(): {
|
|
87
|
+
registers: number[];
|
|
88
|
+
levels: number[];
|
|
89
|
+
};
|
|
90
|
+
/** No writes; validates the complete state before adoption.
|
|
91
|
+
* @param {AY8910State} state */
|
|
92
|
+
_adoptState(state: AY8910State): void;
|
|
93
|
+
/** @param {number} register @param {number} value */
|
|
94
|
+
writeRegister(register: number, value: number): void;
|
|
95
|
+
/** Atomic partial voice edit. Pitch, mixer and loudness are independent.
|
|
96
|
+
* @param {number} ch @param {AY8910Voice} voice */
|
|
97
|
+
setVoice(ch: number, voice: AY8910Voice): void;
|
|
98
|
+
/** Start a tone-only voice, preserving unspecified volume/envelope settings.
|
|
99
|
+
* @param {number} ch @param {AY8910Tone} [settings] @returns {number} Tone period. */
|
|
100
|
+
tone(ch: number, settings?: AY8910Tone): number;
|
|
101
|
+
/** @param {number} ch @param {AY8910Tone} [settings] */
|
|
102
|
+
setTone(ch: number, settings?: AY8910Tone): number;
|
|
103
|
+
/** Start a noise-only voice. The period belongs to the shared noise source.
|
|
104
|
+
* @param {number} ch @param {{period?:number,volume?:number,envelope?:boolean}} [settings] */
|
|
105
|
+
noise(ch: number, settings?: {
|
|
106
|
+
period?: number;
|
|
107
|
+
volume?: number;
|
|
108
|
+
envelope?: boolean;
|
|
109
|
+
}): void;
|
|
110
|
+
/** Gates are independent; both tone and noise may be enabled on one voice.
|
|
111
|
+
* @param {number} ch @param {{tone?:boolean,noise?:boolean}} gates */
|
|
112
|
+
setMixer(ch: number, gates: {
|
|
113
|
+
tone?: boolean;
|
|
114
|
+
noise?: boolean;
|
|
115
|
+
}): void;
|
|
116
|
+
/** Fixed loudness, 0=silent and 15=loudest; optional envelope selection.
|
|
117
|
+
* Omitted envelope preserves the configured selection even after keyOff().
|
|
118
|
+
* @param {number} ch @param {number} volume @param {boolean} [envelope] */
|
|
119
|
+
setVolume(ch: number, volume: number, envelope?: boolean): void;
|
|
120
|
+
/** @param {number} ch @param {number} period */
|
|
121
|
+
setTonePeriod(ch: number, period: number): void;
|
|
122
|
+
/** @param {number} ch @param {number} frequency */
|
|
123
|
+
setFrequency(ch: number, frequency: number): number;
|
|
124
|
+
/** @param {number} ch @param {string|number} note */
|
|
125
|
+
setNote(ch: number, note: string | number): number;
|
|
126
|
+
/** @param {number} period Shared five-bit noise period. */
|
|
127
|
+
setNoisePeriod(period: number): void;
|
|
128
|
+
/** Shared envelope. Writing shape retriggers it; a period-only edit does not.
|
|
129
|
+
* @param {{period?:number,shape?:number}} envelope */
|
|
130
|
+
setEnvelope(envelope: {
|
|
131
|
+
period?: number;
|
|
132
|
+
shape?: number;
|
|
133
|
+
}): void;
|
|
134
|
+
/** Restore configured level and retain the current tone/noise combination.
|
|
135
|
+
* @param {number} ch */
|
|
136
|
+
keyOn(ch: number): void;
|
|
137
|
+
/** Silence while retaining configured volume/envelope, pitch and mixer.
|
|
138
|
+
* @param {number} ch */
|
|
139
|
+
keyOff(ch: number): void;
|
|
140
|
+
/** MIDI changes tone pitch; noise-only voices retain their noise sound.
|
|
141
|
+
* @param {number} ch @param {string|number} note */
|
|
142
|
+
noteOn(ch: number, note: string | number): void;
|
|
143
|
+
/** @param {number} ch */
|
|
144
|
+
noteOff(ch: number): void;
|
|
145
|
+
/** @param {number} ch */
|
|
146
|
+
off(ch: number): void;
|
|
147
|
+
allNotesOff(): void;
|
|
148
|
+
}
|
package/ay8910synth.js
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import {noteToHz} from './soundchip_pitch.js';
|
|
2
|
+
import {AY8910_CLOCK} from './ay8910.js';
|
|
3
|
+
export {AY8910_CLOCK} from './ay8910.js';
|
|
4
|
+
export {AY8910WorkletTransport} from './chip_worklet_transport.js';
|
|
5
|
+
|
|
6
|
+
/** @typedef {{tone?:boolean,noise?:boolean,volume?:number,envelope?:boolean,
|
|
7
|
+
* period?:number,frequency?:number,note?:string|number}} AY8910Voice
|
|
8
|
+
* @typedef {{period?:number,frequency?:number,note?:string|number,volume?:number,envelope?:boolean}} AY8910Tone
|
|
9
|
+
* @typedef {{writeRegister(register:number,value:number):void,reset?:()=>void,dispose?:()=>void}} AY8910Transport
|
|
10
|
+
* @typedef {{registers:number[]|Uint8Array,levels?:number[]|Uint8Array}} AY8910State
|
|
11
|
+
* @typedef {[number,number,number]} RegisterChange
|
|
12
|
+
*/
|
|
13
|
+
function integer(value,max,label) {
|
|
14
|
+
if (!Number.isInteger(value) || value < 0 || value > max) throw new RangeError(`${label} must be an integer 0..${max}`);
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
function boolean(value,label) {
|
|
18
|
+
if (typeof value !== 'boolean') throw new TypeError(`${label} must be boolean`);
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
function options(value,keys,label) {
|
|
22
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) throw new TypeError(`${label} must be an object`);
|
|
23
|
+
for (const key of Reflect.ownKeys(value)) if (!keys.includes(key)) throw new TypeError(`Unknown ${label} field: ${String(key)}`);
|
|
24
|
+
}
|
|
25
|
+
function masterClock(clock) {
|
|
26
|
+
if (!Number.isInteger(clock) || clock <= 0 || clock > 0x3fffffff) throw new RangeError('AY clock must be positive integer Hz, at most 0x3fffffff');
|
|
27
|
+
return clock;
|
|
28
|
+
}
|
|
29
|
+
/** AY tone frequency = clock / (16 * period). Raw zero periods behave as one.
|
|
30
|
+
* @param {number} frequency @param {number} [clock] @returns {number} */
|
|
31
|
+
export function ay8910PeriodFromHz(frequency,clock = AY8910_CLOCK) {
|
|
32
|
+
masterClock(clock);
|
|
33
|
+
if (!Number.isFinite(frequency) || frequency < clock/(16*4095) || frequency > clock/16) throw new RangeError('Frequency is outside the AY 12-bit tone-period range');
|
|
34
|
+
return Math.max(1,Math.min(4095,Math.round(clock/(16*frequency))));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Borrow a synchronous AY chip. Its clock was fixed by Ay8910.create(); the
|
|
38
|
+
* Synth's clock must match it. This adapter never owns or disposes the chip.
|
|
39
|
+
* Native normalized DAC output retains a constant DC baseline at volume zero;
|
|
40
|
+
* speaker transports additionally mute silent channels for exact zero PCM. */
|
|
41
|
+
export class AY8910DirectTransport {
|
|
42
|
+
/** @param {import('./ay8910.js').Ay8910} chip */
|
|
43
|
+
constructor(chip) {
|
|
44
|
+
if (!chip || typeof chip.writeRegister !== 'function' || typeof chip.reset !== 'function') throw new TypeError('AY8910DirectTransport requires writeRegister() and reset()');
|
|
45
|
+
this.chip = chip;
|
|
46
|
+
}
|
|
47
|
+
/** @param {number} register @param {number} value */
|
|
48
|
+
writeRegister(register,value) {integer(register,15,'Register'); integer(value,255,'Value'); this.chip.writeRegister(register,value);}
|
|
49
|
+
reset() {this.chip.reset();}
|
|
50
|
+
sampleRate() {return this.chip.sampleRate();}
|
|
51
|
+
/** @param {number} frames */
|
|
52
|
+
generateStereo(frames) {return this.chip.generateStereo(frames);}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Three AY-3-8910 physical voices. Each mixes tone and the one shared noise
|
|
56
|
+
* source, then uses fixed volume or the one shared envelope. Volume 0 is silent;
|
|
57
|
+
* 15 is loudest. Construction never resets or writes a borrowed transport.
|
|
58
|
+
*
|
|
59
|
+
* keyOff() silences a voice while retaining its configured level. keyOn()
|
|
60
|
+
* restores that level and preserves tone/noise gates, including noise-only
|
|
61
|
+
* voices. Shared noise/envelope edits affect all voices using those sources.
|
|
62
|
+
*/
|
|
63
|
+
export class AY8910Synth {
|
|
64
|
+
#registers = new Uint8Array(16);
|
|
65
|
+
#levels = new Uint8Array(3).fill(9);
|
|
66
|
+
/** @param {{transport:AY8910Transport,clock?:number}} settings */
|
|
67
|
+
constructor({transport,clock = AY8910_CLOCK} = {}) {
|
|
68
|
+
if (!transport || typeof transport.writeRegister !== 'function') throw new TypeError('AY8910Synth requires writeRegister(register,value)');
|
|
69
|
+
this.transport = transport; this.clock = masterClock(clock); this.chip = 'ay8910'; this.channels = 3;
|
|
70
|
+
/** @type {((register:number,value:number)=>boolean|void)|undefined} */ this._beforeWrite = undefined;
|
|
71
|
+
/** @type {((event:{method:string,args:number[],channel?:number})=>void)|undefined} */ this._observe = undefined;
|
|
72
|
+
}
|
|
73
|
+
reset() {
|
|
74
|
+
this.transport.reset?.(); this.#registers.fill(0); this.#levels.fill(9);
|
|
75
|
+
this._observe?.({method:'reset',args:[]});
|
|
76
|
+
}
|
|
77
|
+
/** Reset to silent A4 tone-only voices. Actual volume registers are zero;
|
|
78
|
+
* keyOn restores configured volume 9. I/O ports are untouched after reset. */
|
|
79
|
+
initialize() {
|
|
80
|
+
this.reset();
|
|
81
|
+
// Disabling both generators with a nonzero volume creates DC on an AY;
|
|
82
|
+
// use volume zero for silence, with the intended tone-only mixer retained.
|
|
83
|
+
this.writeRegister(7,0x38); this.setNoisePeriod(16);
|
|
84
|
+
for (let ch = 0; ch < 3; ch++) {this.setFrequency(ch,440); this.writeRegister(8+ch,0);}
|
|
85
|
+
this.#levels.fill(9);
|
|
86
|
+
}
|
|
87
|
+
getRegisterSnapshot() {return this.#registers.slice();}
|
|
88
|
+
/** Adopt raw registers without writes. Zero output levels lack keyOff's
|
|
89
|
+
* retained-voice metadata, so they default to level 9 for a new audition.
|
|
90
|
+
* Use _adoptState() to preserve an intentionally configured zero level.
|
|
91
|
+
* @param {Uint8Array|number[]} snapshot */
|
|
92
|
+
adoptRegisterSnapshot(snapshot) {
|
|
93
|
+
if (!(snapshot instanceof Uint8Array || Array.isArray(snapshot)) || snapshot.length !== 16) throw new RangeError('Expected sixteen AY register bytes');
|
|
94
|
+
const values = Array.from(snapshot,value => integer(value,255,'Register value'));
|
|
95
|
+
this.#registers.set(values);
|
|
96
|
+
for (let ch = 0; ch < 3; ch++) this.#levels[ch] = (values[8+ch]&31) || 9;
|
|
97
|
+
}
|
|
98
|
+
/** Full musical state includes the levels retained by keyOff(). */
|
|
99
|
+
_getState() {return {registers:Array.from(this.#registers),levels:Array.from(this.#levels)};}
|
|
100
|
+
/** No writes; validates the complete state before adoption.
|
|
101
|
+
* @param {AY8910State} state */
|
|
102
|
+
_adoptState(state) {
|
|
103
|
+
options(state,['registers','levels'],'AY state');
|
|
104
|
+
if (state.levels !== undefined && (!(state.levels instanceof Uint8Array || Array.isArray(state.levels)) || state.levels.length !== 3)) throw new RangeError('Expected three retained AY levels');
|
|
105
|
+
const levels = state.levels === undefined ? undefined : Array.from(state.levels,value => integer(value,31,'Retained level'));
|
|
106
|
+
this.adoptRegisterSnapshot(state.registers);
|
|
107
|
+
if (levels) this.#levels.set(levels);
|
|
108
|
+
}
|
|
109
|
+
/** @param {number} register @param {number} value */
|
|
110
|
+
writeRegister(register,value) {
|
|
111
|
+
integer(register,15,'Register'); integer(value,255,'Value');
|
|
112
|
+
if (this._beforeWrite?.(register,value) === false) return;
|
|
113
|
+
this.transport.writeRegister(register,value); this.#registers[register] = value;
|
|
114
|
+
if (register >= 8 && register <= 10) this.#levels[register-8] = value&31;
|
|
115
|
+
const channel = register < 6 ? Math.floor(register/2) : register >= 8 && register <= 10 ? register-8 : undefined;
|
|
116
|
+
this._observe?.({method:'writeRegister',args:[register,value],channel});
|
|
117
|
+
}
|
|
118
|
+
#channel(ch) {return integer(ch,2,'AY channel');}
|
|
119
|
+
/** @param {RegisterChange[]} changes */
|
|
120
|
+
#apply(changes) {for (const [register,mask,value] of changes) this.writeRegister(register,(this.#registers[register]&~mask)|value);}
|
|
121
|
+
/** @param {number} ch @param {number} period @returns {RegisterChange[]} */
|
|
122
|
+
#pitchChanges(ch,period) {this.#channel(ch); integer(period,4095,'Tone period'); return [[ch*2,255,period&255],[ch*2+1,15,period>>8]];}
|
|
123
|
+
/** @param {number} ch @param {AY8910Voice} voice @returns {RegisterChange[]} */
|
|
124
|
+
#voiceChanges(ch,voice) {
|
|
125
|
+
this.#channel(ch); options(voice,['tone','noise','volume','envelope','period','frequency','note'],'AY voice');
|
|
126
|
+
/** @type {RegisterChange[]} */ const changes = [];
|
|
127
|
+
const pitches = ['period','frequency','note'].filter(name => voice[name] !== undefined);
|
|
128
|
+
if (pitches.length > 1) throw new TypeError('Specify one of period, frequency or note');
|
|
129
|
+
if (pitches.length) {
|
|
130
|
+
const period = voice.period !== undefined ? integer(voice.period,4095,'Tone period') : ay8910PeriodFromHz(voice.frequency ?? noteToHz(voice.note),this.clock);
|
|
131
|
+
changes.push(...this.#pitchChanges(ch,period));
|
|
132
|
+
}
|
|
133
|
+
if (voice.tone !== undefined) changes.push([7,1<<ch,boolean(voice.tone,'Tone gate') ? 0 : 1<<ch]);
|
|
134
|
+
if (voice.noise !== undefined) changes.push([7,8<<ch,boolean(voice.noise,'Noise gate') ? 0 : 8<<ch]);
|
|
135
|
+
if (voice.volume !== undefined || voice.envelope !== undefined) {
|
|
136
|
+
const volume = voice.volume === undefined ? this.#levels[ch]&15 : integer(voice.volume,15,'Volume');
|
|
137
|
+
const envelope = voice.envelope === undefined ? Boolean(this.#levels[ch]&16) : boolean(voice.envelope,'Envelope');
|
|
138
|
+
changes.push([8+ch,31,volume|(envelope?16:0)]);
|
|
139
|
+
}
|
|
140
|
+
return changes;
|
|
141
|
+
}
|
|
142
|
+
/** Atomic partial voice edit. Pitch, mixer and loudness are independent.
|
|
143
|
+
* @param {number} ch @param {AY8910Voice} voice */
|
|
144
|
+
setVoice(ch,voice) {this.#apply(this.#voiceChanges(ch,voice));}
|
|
145
|
+
/** Start a tone-only voice, preserving unspecified volume/envelope settings.
|
|
146
|
+
* @param {number} ch @param {AY8910Tone} [settings] @returns {number} Tone period. */
|
|
147
|
+
tone(ch,settings = {}) {
|
|
148
|
+
this.#channel(ch); options(settings,['period','frequency','note','volume','envelope'],'AY tone');
|
|
149
|
+
const voice = {volume:this.#levels[ch]&15,envelope:Boolean(this.#levels[ch]&16),...settings,tone:true,noise:false};
|
|
150
|
+
const changes = this.#voiceChanges(ch,voice); this.#apply(changes);
|
|
151
|
+
return this.#registers[ch*2]|((this.#registers[ch*2+1]&15)<<8);
|
|
152
|
+
}
|
|
153
|
+
/** @param {number} ch @param {AY8910Tone} [settings] */
|
|
154
|
+
setTone(ch,settings = {}) {return this.tone(ch,settings);}
|
|
155
|
+
/** Start a noise-only voice. The period belongs to the shared noise source.
|
|
156
|
+
* @param {number} ch @param {{period?:number,volume?:number,envelope?:boolean}} [settings] */
|
|
157
|
+
noise(ch,settings = {}) {
|
|
158
|
+
this.#channel(ch); options(settings,['period','volume','envelope'],'AY noise');
|
|
159
|
+
const period = settings.period === undefined ? this.#registers[6]&31 : integer(settings.period,31,'Noise period');
|
|
160
|
+
const voice = {tone:false,noise:true,volume:settings.volume === undefined ? this.#levels[ch]&15 : settings.volume,envelope:settings.envelope === undefined ? Boolean(this.#levels[ch]&16) : settings.envelope};
|
|
161
|
+
const changes = this.#voiceChanges(ch,voice); this.#apply([[6,31,period],...changes]);
|
|
162
|
+
}
|
|
163
|
+
/** Gates are independent; both tone and noise may be enabled on one voice.
|
|
164
|
+
* @param {number} ch @param {{tone?:boolean,noise?:boolean}} gates */
|
|
165
|
+
setMixer(ch,gates) {options(gates,['tone','noise'],'AY mixer'); this.setVoice(ch,gates);}
|
|
166
|
+
/** Fixed loudness, 0=silent and 15=loudest; optional envelope selection.
|
|
167
|
+
* Omitted envelope preserves the configured selection even after keyOff().
|
|
168
|
+
* @param {number} ch @param {number} volume @param {boolean} [envelope] */
|
|
169
|
+
setVolume(ch,volume,envelope = undefined) {integer(volume,15,'Volume'); this.setVoice(ch,{volume,envelope});}
|
|
170
|
+
/** @param {number} ch @param {number} period */
|
|
171
|
+
setTonePeriod(ch,period) {this.#apply(this.#pitchChanges(ch,period));}
|
|
172
|
+
/** @param {number} ch @param {number} frequency */
|
|
173
|
+
setFrequency(ch,frequency) {this.#channel(ch); const period = ay8910PeriodFromHz(frequency,this.clock); this.setTonePeriod(ch,period); return period;}
|
|
174
|
+
/** @param {number} ch @param {string|number} note */
|
|
175
|
+
setNote(ch,note) {return this.setFrequency(ch,noteToHz(note));}
|
|
176
|
+
/** @param {number} period Shared five-bit noise period. */
|
|
177
|
+
setNoisePeriod(period) {integer(period,31,'Noise period'); this.#apply([[6,31,period]]);}
|
|
178
|
+
/** Shared envelope. Writing shape retriggers it; a period-only edit does not.
|
|
179
|
+
* @param {{period?:number,shape?:number}} envelope */
|
|
180
|
+
setEnvelope(envelope) {
|
|
181
|
+
options(envelope,['period','shape'],'AY envelope');
|
|
182
|
+
/** @type {RegisterChange[]} */ const changes = [];
|
|
183
|
+
if (envelope.period !== undefined) {integer(envelope.period,65535,'Envelope period'); changes.push([11,255,envelope.period&255],[12,255,envelope.period>>8]);}
|
|
184
|
+
if (envelope.shape !== undefined) changes.push([13,15,integer(envelope.shape,15,'Envelope shape')]);
|
|
185
|
+
this.#apply(changes);
|
|
186
|
+
}
|
|
187
|
+
/** Restore configured level and retain the current tone/noise combination.
|
|
188
|
+
* @param {number} ch */
|
|
189
|
+
keyOn(ch) {this.#channel(ch); this.#apply([[8+ch,31,this.#levels[ch]]]);}
|
|
190
|
+
/** Silence while retaining configured volume/envelope, pitch and mixer.
|
|
191
|
+
* @param {number} ch */
|
|
192
|
+
keyOff(ch) {this.#channel(ch); const level = this.#levels[ch]; this.#apply([[8+ch,31,0]]); this.#levels[ch] = level;}
|
|
193
|
+
/** MIDI changes tone pitch; noise-only voices retain their noise sound.
|
|
194
|
+
* @param {number} ch @param {string|number} note */
|
|
195
|
+
noteOn(ch,note) {this.#channel(ch); const period = ay8910PeriodFromHz(noteToHz(note),this.clock); this.setTonePeriod(ch,period); this.keyOn(ch);}
|
|
196
|
+
/** @param {number} ch */
|
|
197
|
+
noteOff(ch) {this.keyOff(ch);}
|
|
198
|
+
/** @param {number} ch */
|
|
199
|
+
off(ch) {this.keyOff(ch);}
|
|
200
|
+
allNotesOff() {for (let ch = 0; ch < 3; ch++) this.keyOff(ch);}
|
|
201
|
+
}
|
|
@@ -21,3 +21,17 @@ export declare class SegaPSGWorkletTransport extends ChipWorkletTransport {
|
|
|
21
21
|
}
|
|
22
22
|
export declare class YM2151WorkletTransport extends ChipWorkletTransport {
|
|
23
23
|
}
|
|
24
|
+
export declare class YM2413WorkletTransport extends ChipWorkletTransport {
|
|
25
|
+
}
|
|
26
|
+
export declare class OPLWorkletTransport extends ChipWorkletTransport {
|
|
27
|
+
}
|
|
28
|
+
export declare class YM3526WorkletTransport extends OPLWorkletTransport {
|
|
29
|
+
}
|
|
30
|
+
export declare class YM3812WorkletTransport extends OPLWorkletTransport {
|
|
31
|
+
}
|
|
32
|
+
export declare class Y8950WorkletTransport extends OPLWorkletTransport {
|
|
33
|
+
}
|
|
34
|
+
export declare class YMF262WorkletTransport extends OPLWorkletTransport {
|
|
35
|
+
}
|
|
36
|
+
export declare class AY8910WorkletTransport extends ChipWorkletTransport {
|
|
37
|
+
}
|
|
@@ -20,3 +20,11 @@ export class ChipWorkletTransport {
|
|
|
20
20
|
export class GameboyWorkletTransport extends ChipWorkletTransport {}
|
|
21
21
|
export class SegaPSGWorkletTransport extends ChipWorkletTransport {}
|
|
22
22
|
export class YM2151WorkletTransport extends ChipWorkletTransport {}
|
|
23
|
+
export class YM2413WorkletTransport extends ChipWorkletTransport {}
|
|
24
|
+
export class OPLWorkletTransport extends ChipWorkletTransport {}
|
|
25
|
+
export class YM3526WorkletTransport extends OPLWorkletTransport {}
|
|
26
|
+
export class YM3812WorkletTransport extends OPLWorkletTransport {}
|
|
27
|
+
export class Y8950WorkletTransport extends OPLWorkletTransport {}
|
|
28
|
+
export class YMF262WorkletTransport extends OPLWorkletTransport {}
|
|
29
|
+
|
|
30
|
+
export class AY8910WorkletTransport extends ChipWorkletTransport {}
|
|
Binary file
|
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { createAy8910Client } from './playground_ay8910.js';
|
|
2
2
|
import { TetoricaAudioRuntime } from './tetorica_audio_runtime.js';
|
|
3
3
|
import { createNesClient } from './playground_nes.js';
|
|
4
4
|
import { createSnesClient } from './playground_snes.js';
|
|
@@ -6,14 +6,33 @@ import { createYm2151Client } from './playground_ym2151.js';
|
|
|
6
6
|
import { createOki6258Client } from './playground_okim6258.js';
|
|
7
7
|
import { createHuc6280Client } from './playground_huc6280.js';
|
|
8
8
|
import { createSegaPsgClient } from './playground_segapsg.js';
|
|
9
|
+
import { createYm2413Client } from './playground_ym2413.js';
|
|
10
|
+
import { createOplClient } from './playground_opl.js';
|
|
11
|
+
import { createDx7Client } from './playground_dx7.js';
|
|
9
12
|
export type NativeRuntimeSynthOptions = Pick<import('./megasynth.js').MegaSynthOptions, 'audioContext' | 'outputNode' | 'sampleOutputNode' | 'masterVolume' | 'mixer'> & {
|
|
10
|
-
chip?: 'nes' | 'snes' | 'x68000' | 'huc6280' | 'segapsg';
|
|
13
|
+
chip?: 'nes' | 'snes' | 'x68000' | 'huc6280' | 'segapsg' | 'dx7' | 'ym3526' | 'ym3812' | 'y8950' | 'ymf262' | 'ym2413' | 'ay8910' | 'msx' | 'msx-audio';
|
|
14
|
+
ym2413?: boolean;
|
|
11
15
|
clock?: number;
|
|
12
16
|
stereoEnabled?: boolean;
|
|
13
17
|
fds?: boolean;
|
|
14
18
|
wasmUrl?: string | URL;
|
|
15
19
|
workletUrl?: string | URL;
|
|
16
20
|
fetch?: typeof globalThis.fetch;
|
|
21
|
+
ayOptions?: {
|
|
22
|
+
fetch?: typeof globalThis.fetch;
|
|
23
|
+
wasmUrl?: string | URL;
|
|
24
|
+
workletUrl?: string | URL;
|
|
25
|
+
};
|
|
26
|
+
oplOptions?: {
|
|
27
|
+
fetch?: typeof globalThis.fetch;
|
|
28
|
+
wasmUrl?: string | URL;
|
|
29
|
+
workletUrl?: string | URL;
|
|
30
|
+
};
|
|
31
|
+
opllOptions?: {
|
|
32
|
+
fetch?: typeof globalThis.fetch;
|
|
33
|
+
wasmUrl?: string | URL;
|
|
34
|
+
workletUrl?: string | URL;
|
|
35
|
+
};
|
|
17
36
|
extraOki?: {
|
|
18
37
|
fetch?: typeof globalThis.fetch;
|
|
19
38
|
wasmUrl?: string | URL;
|
|
@@ -21,8 +40,11 @@ export type NativeRuntimeSynthOptions = Pick<import('./megasynth.js').MegaSynthO
|
|
|
21
40
|
};
|
|
22
41
|
};
|
|
23
42
|
/** @typedef {Pick<import('./megasynth.js').MegaSynthOptions,'audioContext'|'outputNode'|'sampleOutputNode'|'masterVolume'|'mixer'> & {
|
|
24
|
-
* chip?:'nes'|'snes'|'x68000'|'huc6280'|'segapsg', clock?:number, stereoEnabled?:boolean, fds?:boolean,
|
|
43
|
+
* chip?:'nes'|'snes'|'x68000'|'huc6280'|'segapsg'|'dx7'|'ym3526'|'ym3812'|'y8950'|'ymf262'|'ym2413'|'ay8910'|'msx'|'msx-audio', ym2413?:boolean, clock?:number, stereoEnabled?:boolean, fds?:boolean,
|
|
25
44
|
* wasmUrl?:string|URL, workletUrl?:string|URL, fetch?:typeof globalThis.fetch,
|
|
45
|
+
* ayOptions?:{fetch?:typeof globalThis.fetch,wasmUrl?:string|URL,workletUrl?:string|URL},
|
|
46
|
+
* oplOptions?:{fetch?:typeof globalThis.fetch,wasmUrl?:string|URL,workletUrl?:string|URL},
|
|
47
|
+
* opllOptions?:{fetch?:typeof globalThis.fetch,wasmUrl?:string|URL,workletUrl?:string|URL},
|
|
26
48
|
* extraOki?:{fetch?:typeof globalThis.fetch,wasmUrl?:string|URL,workletUrl?:string|URL}
|
|
27
49
|
* }} NativeRuntimeSynthOptions */
|
|
28
50
|
/**
|
|
@@ -45,7 +67,7 @@ export declare class NativeRuntimeSynth {
|
|
|
45
67
|
node: any;
|
|
46
68
|
fm: any;
|
|
47
69
|
psg: any;
|
|
48
|
-
/** @type {{nes?:ReturnType<typeof createNesClient>,snes?:ReturnType<typeof createSnesClient>,opm?:ReturnType<typeof createYm2151Client>,adpcm?:ReturnType<typeof createOki6258Client>,pce?:ReturnType<typeof createHuc6280Client>,psg?:ReturnType<typeof createSegaPsgClient>}} */
|
|
70
|
+
/** @type {{nes?:ReturnType<typeof createNesClient>,snes?:ReturnType<typeof createSnesClient>,opm?:ReturnType<typeof createYm2151Client>,adpcm?:ReturnType<typeof createOki6258Client>,pce?:ReturnType<typeof createHuc6280Client>,psg?:ReturnType<typeof createSegaPsgClient>,dx7?:ReturnType<typeof createDx7Client>,opl?:ReturnType<typeof createOplClient>,opll?:ReturnType<typeof createYm2413Client>,ay?:ReturnType<typeof createAy8910Client>}} */
|
|
49
71
|
primaryApis: {
|
|
50
72
|
nes?: ReturnType<typeof createNesClient>;
|
|
51
73
|
snes?: ReturnType<typeof createSnesClient>;
|
|
@@ -53,12 +75,20 @@ export declare class NativeRuntimeSynth {
|
|
|
53
75
|
adpcm?: ReturnType<typeof createOki6258Client>;
|
|
54
76
|
pce?: ReturnType<typeof createHuc6280Client>;
|
|
55
77
|
psg?: ReturnType<typeof createSegaPsgClient>;
|
|
78
|
+
dx7?: ReturnType<typeof createDx7Client>;
|
|
79
|
+
opl?: ReturnType<typeof createOplClient>;
|
|
80
|
+
opll?: ReturnType<typeof createYm2413Client>;
|
|
81
|
+
ay?: ReturnType<typeof createAy8910Client>;
|
|
56
82
|
};
|
|
57
83
|
/** @type {ReturnType<typeof createNesClient>|null} */ nes: ReturnType<typeof createNesClient> | null;
|
|
58
84
|
/** @type {ReturnType<typeof createSnesClient>|null} */ snes: ReturnType<typeof createSnesClient> | null;
|
|
59
85
|
/** @type {ReturnType<typeof createYm2151Client>|null} */ opm: ReturnType<typeof createYm2151Client> | null;
|
|
60
86
|
/** @type {ReturnType<typeof createOki6258Client>|null} */ adpcm: ReturnType<typeof createOki6258Client> | null;
|
|
61
87
|
/** @type {ReturnType<typeof createHuc6280Client>|null} */ pce: ReturnType<typeof createHuc6280Client> | null;
|
|
88
|
+
/** @type {ReturnType<typeof createDx7Client>|null} */ dx7: ReturnType<typeof createDx7Client> | null;
|
|
89
|
+
/** @type {ReturnType<typeof createOplClient>|null} */ opl: ReturnType<typeof createOplClient> | null;
|
|
90
|
+
/** @type {ReturnType<typeof createYm2413Client>|null} */ opll: ReturnType<typeof createYm2413Client> | null;
|
|
91
|
+
/** @type {ReturnType<typeof createAy8910Client>|null} */ ay: ReturnType<typeof createAy8910Client> | null;
|
|
62
92
|
primaryEndpoints: any[];
|
|
63
93
|
listeners: Set<any>;
|
|
64
94
|
readyPromise: Promise<void> | null;
|
|
@@ -92,7 +122,7 @@ export declare class NativeRuntimeSynth {
|
|
|
92
122
|
connect(effect: any): this;
|
|
93
123
|
connectOutput(node?: null): this;
|
|
94
124
|
/** Stop voices while keeping uploaded samples, patches, waveforms and clocks. */
|
|
95
|
-
stopAllNative(): void;
|
|
125
|
+
stopAllNative(): Promise<void> | undefined;
|
|
96
126
|
reset(): void;
|
|
97
127
|
close(): Promise<void>;
|
|
98
128
|
}
|