tetorica-fm2612 0.2.13 → 0.2.14
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 +89 -4
- package/RUNTIME.md +1 -1
- package/THIRD_PARTY_LICENSES.txt +1 -0
- package/custom_fx.js +1 -0
- package/megasynth.d.ts +25 -0
- package/megasynth.js +62 -3
- package/msfa_dx7/LICENSE +202 -0
- package/msfa_dx7/README.md +193 -0
- package/msfa_dx7/README.vendor.md +16 -0
- package/msfa_dx7/THIRD_PARTY_NOTICES.md +21 -0
- package/msfa_dx7/docs/research.md +193 -0
- package/msfa_dx7/docs/verification.md +69 -0
- package/msfa_dx7/package.json +86 -0
- package/msfa_dx7/src/browser.d.ts +42 -0
- package/msfa_dx7/src/browser.js +161 -0
- package/msfa_dx7/src/dx7-worklet.js +85 -0
- package/msfa_dx7/src/index.d.ts +33 -0
- package/msfa_dx7/src/index.js +177 -0
- package/msfa_dx7/src/sysex.d.ts +40 -0
- package/msfa_dx7/src/sysex.js +209 -0
- package/msfa_dx7/vendor/msfa/COPYING +202 -0
- package/msfa_dx7/vendor/msfa/UPSTREAM.md +15 -0
- package/msfa_dx7/wasm/msfa.wasm +0 -0
- package/native-fx-worklet.d.ts +2 -0
- package/native-fx-worklet.js +2 -1
- package/native_audio_effect.wasm +0 -0
- package/native_fx_engine.d.ts +7 -1
- package/native_fx_engine.js +38 -14
- package/native_sample.d.ts +2 -1
- package/native_sample.js +2 -1
- package/package.json +6 -3
- package/playground_dx7.d.ts +32 -0
- package/playground_dx7.js +131 -0
- package/playground_dx7_audio.d.ts +20 -0
- package/playground_dx7_audio.js +132 -0
- package/playground_dx7_worklet.d.ts +1 -0
- package/playground_dx7_worklet.js +125 -0
- package/playground_execution.d.ts +10 -0
- package/playground_execution.js +65 -4
- package/playground_live.js +5 -4
- package/playground_logic_worker.js +4 -3
- package/playground_runtime.js +20 -14
- package/playground_soundchips.js +1 -1
- package/runtime-manifest.json +9 -1
- package/tetorica_audio_runtime.d.ts +5 -1
- package/tetorica_audio_runtime.js +65 -8
- package/ym2612-worklet-nuked.js +37 -71
- package/ym2612-worklet.js +37 -71
package/README.md
CHANGED
|
@@ -35,6 +35,7 @@ entry points, rather than every internal Worker or Worklet module.
|
|
|
35
35
|
| Real-time chip playback on Node | `tetorica-fm2612/node/transports` | `YM2612AudifyTransport`, `YM2608AudifyTransport`, `YM2151AudifyTransport`, `GameboyAudifyTransport`, `SegaPSGAudifyTransport`, `NesApuAudifyTransport`, `PWM32XAudifyTransport` |
|
|
36
36
|
| Browser synth with FX, recording and looping | `tetorica-fm2612/megasynth.js` | `MegaSynth` |
|
|
37
37
|
| Browser live-code runtime | `tetorica-fm2612/playground_runtime.js` | `Playground`, `createPlaygroundRuntime` |
|
|
38
|
+
| DX7 inside browser Playground scripts | `tetorica-fm2612/playground_runtime.js` | Script globals `useSoundChip('dx7')`, `createSoundChip('dx7')` |
|
|
38
39
|
| Offline FM + native FX rendering | `tetorica-fm2612/megasynth_offline.js` | `createMegaSynthOffline` (experimental) |
|
|
39
40
|
| Offline recording and looping | `tetorica-fm2612/megasynth_session.js` | `createMegaSynthSession` (experimental) |
|
|
40
41
|
| Node synth with Worker audio output | `tetorica-fm2612/node` | `MegaSynthNode` (experimental) |
|
|
@@ -253,6 +254,81 @@ const synth = new MegaSynth({
|
|
|
253
254
|
`moduleFactory`/`moduleOptions` for explicit loader injection. A URL helper does
|
|
254
255
|
not copy assets. Keep dependent files alongside each deployed entry point.
|
|
255
256
|
|
|
257
|
+
Since 0.2.14, an owned `MegaSynth` AudioContext uses the device's
|
|
258
|
+
default sample rate. Set `{outputSampleRate: 48000}` to request a specific output
|
|
259
|
+
frame rate; an explicit legacy `chipSampleRate` request remains supported. An
|
|
260
|
+
injected AudioContext keeps its own rate. Chip clocks and note tuning are
|
|
261
|
+
independent of the output rate.
|
|
262
|
+
|
|
263
|
+
Version 0.2.14 also supports chip-output RMS monitoring:
|
|
264
|
+
|
|
265
|
+
```js
|
|
266
|
+
synth.setOutputEnvelopeOptions({samplesPerPoint: 128, pointsPerMessage: 16});
|
|
267
|
+
// After start(), listen on synth.node.port for:
|
|
268
|
+
// {type: 'output-envelope', rmsValues: Float32Array}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
This measures mixed chip output before browser FX and master volume, separately
|
|
272
|
+
from Playground's final-output waveform analyser. Sample counts are output frames
|
|
273
|
+
at the AudioContext sample rate. Defaults are 512 frames per point and 16 points
|
|
274
|
+
per message; monitoring stays off until requested. Integer ranges are 1–65536 and
|
|
275
|
+
1–1024 respectively. Calls before start and during playback are supported, and
|
|
276
|
+
settings survive close/start. Omitted sizes keep their previous values. Each call
|
|
277
|
+
discards incomplete points and batches and enables monitoring unless
|
|
278
|
+
`{enabled: false}` is supplied. Message intervals are approximately
|
|
279
|
+
`samplesPerPoint * pointsPerMessage / audioContext.sampleRate` seconds.
|
|
280
|
+
|
|
281
|
+
## DX7 in browser Playground (0.2.14)
|
|
282
|
+
|
|
283
|
+
Scripts executed by `Playground` / `createPlaygroundRuntime` can use the MSFA
|
|
284
|
+
DX7-compatible six-operator FM engine. It starts with the self-authored
|
|
285
|
+
`INIT SINE` voice, so no external sound bank is needed:
|
|
286
|
+
|
|
287
|
+
```js
|
|
288
|
+
// Run inside a Playground script; these are runtime-provided globals.
|
|
289
|
+
const dx7 = await useSoundChip('dx7');
|
|
290
|
+
dx7.noteOn(60, 100); // MIDI C4, velocity 100.
|
|
291
|
+
await beat(1);
|
|
292
|
+
dx7.noteOff(60);
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
Read a DX7 single-voice or 32-voice-bank SysEx as binary before loading it.
|
|
296
|
+
The Playground editor provides the virtual-file `file()` helper used below;
|
|
297
|
+
an embedded runtime host supplies its own file access and passes binary data
|
|
298
|
+
to the script:
|
|
299
|
+
|
|
300
|
+
```js
|
|
301
|
+
const bytes = await file('/presets/my-bank.syx', {type: 'arrayBuffer'});
|
|
302
|
+
await dx7.loadSysex(bytes); // Applied in the Worklet before this resolves.
|
|
303
|
+
console.log(dx7.voices); // [{index: 0, name: '...'}, ...]
|
|
304
|
+
dx7.selectVoice(0);
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
`loadSysex` accepts an ArrayBuffer or ArrayBuffer view, validates the complete
|
|
308
|
+
bank before replacing it, and selects voice 0. `noteOn` takes integer MIDI
|
|
309
|
+
notes and velocity values from 0 to 127; velocity 0 is Note Off. There is no
|
|
310
|
+
channel argument. Up to 16 voices can sound simultaneously. `noteOff(note)`
|
|
311
|
+
releases all held voices of that pitch, `allNotesOff()` releases every voice,
|
|
312
|
+
and `panic()` silences release tails and buffered audio immediately.
|
|
313
|
+
|
|
314
|
+
Both Main and Worker script execution use AudioWorklet for audio generation.
|
|
315
|
+
The engine renders mono at a fixed internal 44,100 Hz and supports output
|
|
316
|
+
AudioContexts at 44,100 or 48,000 Hz; 48,000 Hz output is resampled. Its mono
|
|
317
|
+
output feeds Playground's stereo mixer, FX and master volume. Use
|
|
318
|
+
`await mixer.set(dx7.id, {volume: 0.5, pan: -0.25})` for balance. It has no
|
|
319
|
+
chip-clock or raw-register API. STOP disposes the instance; a subsequent call
|
|
320
|
+
to `useSoundChip('dx7')` creates a fresh one. Playground's
|
|
321
|
+
`createSoundChip('dx7', {id: 'dx7-two'})` creates an independent instance and
|
|
322
|
+
bank instead of reusing the cached `useSoundChip` instance.
|
|
323
|
+
|
|
324
|
+
These globals belong to the Playground runtime. Importing `createSoundChip`
|
|
325
|
+
from the **package root** does not add DX7 to that lower-level chip factory.
|
|
326
|
+
For direct PCM generation or DX7 playback outside Playground, use the separate
|
|
327
|
+
[`tetorica-msfa-dx7-wasm`](https://www.npmjs.com/package/tetorica-msfa-dx7-wasm)
|
|
328
|
+
package (`createDX7` in Node/browsers, `createDX7Node` for browser audio).
|
|
329
|
+
The pinned engine, WASM and Apache-2.0 notices are included in this package's
|
|
330
|
+
`msfa_dx7/` directory; no extra runtime dependency or CDN request is required.
|
|
331
|
+
|
|
256
332
|
## Mega CD PCM with MegaSynth
|
|
257
333
|
|
|
258
334
|
Since `0.2.0`, the package includes opt-in RF5C164 support. Enable `megaCD` before
|
|
@@ -425,10 +501,10 @@ FM/PSG/PCM mixing, stop/reset and close/restart. Playwright is a development
|
|
|
425
501
|
dependency; it is not required by users of the sound-chip runtime.
|
|
426
502
|
|
|
427
503
|
The build is staged in `dist/fm2612/`; packing produces
|
|
428
|
-
`tetorica-fm2612-0.2.
|
|
504
|
+
`tetorica-fm2612-0.2.14.tgz`. To install a local build in another project:
|
|
429
505
|
|
|
430
506
|
```sh
|
|
431
|
-
npm install /absolute/path/to/tetorica-fm2612-0.2.
|
|
507
|
+
npm install /absolute/path/to/tetorica-fm2612-0.2.14.tgz
|
|
432
508
|
```
|
|
433
509
|
|
|
434
510
|
The existing `tetorica-vgm` CLI package is built separately. This first package
|
|
@@ -439,11 +515,20 @@ adapter packages can reuse the core later without duplicating it.
|
|
|
439
515
|
|
|
440
516
|
Project code is BSD-3-Clause. Third-party notices and component licenses are
|
|
441
517
|
included; Nuked-OPN2 is LGPL-2.1-or-later, with its source and build script in
|
|
442
|
-
`sources/`. The
|
|
443
|
-
and
|
|
518
|
+
`sources/`. The bundled DX7 engine is Apache-2.0; its license, MSFA provenance
|
|
519
|
+
and third-party notices are in `msfa_dx7/`. The OPNA rhythm data is
|
|
520
|
+
Tetorica-generated and includes its license and generator. External
|
|
521
|
+
instrument/sample ROMs are not included.
|
|
444
522
|
|
|
445
523
|
## Release notes
|
|
446
524
|
|
|
525
|
+
`0.2.14` adds DX7 to browser Playground in Main and Worker modes, including
|
|
526
|
+
single-voice / 32-voice-bank SysEx loading, 16-voice polyphony, mixer/FX routing
|
|
527
|
+
and STOP cleanup. It bundles `tetorica-msfa-dx7-wasm` 0.1.0 and its licenses.
|
|
528
|
+
The lower-level package-root `createSoundChip` API is unchanged. MegaSynth now
|
|
529
|
+
uses the device's default output rate unless explicitly configured and adds
|
|
530
|
+
configurable chip-output RMS monitoring with `setOutputEnvelopeOptions`.
|
|
531
|
+
|
|
447
532
|
`0.2.13` adds common Hz/note/key controls to FM, PSG, Game Boy, NES and SSG
|
|
448
533
|
Synth APIs, with explicit `setBlockFnum` / `noteOnRaw` FM methods. Existing
|
|
449
534
|
three-argument raw FM calls remain supported. Playground's ten SoundChip
|
package/RUNTIME.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Full web runtime
|
|
2
2
|
|
|
3
|
-
Includes all
|
|
3
|
+
Includes all 161 top-level web runtime modules and 23 generated chip/engine pairs.
|
|
4
4
|
|
|
5
5
|
ay8910, gameboy_apu, huc6280, k051649, nuked_opn2, okim6258, rf5c164, segapcm, segapsg, y8950, ym2151, ym2203, ym2413, ym2608, ym2610b, ym2612, ym3438, ym3526, ym3812, ymf262, ymf276, ymf278b, ymf288
|
|
6
6
|
|
package/THIRD_PARTY_LICENSES.txt
CHANGED
|
@@ -11,4 +11,5 @@ mame-segapcm: see licenses/mame-segapcm/LICENSE and README.md.
|
|
|
11
11
|
mame-32x-pwm: see licenses/mame-32x-pwm/LICENSE and README.md.
|
|
12
12
|
Nuked-OPN2 is LGPL-2.1-or-later; the MAME adaptations listed above are BSD-3-Clause.
|
|
13
13
|
NES APU: JSNES (Apache-2.0), FDS: fixNES (MIT); see licenses/jsnes and licenses/fixnes-fds.
|
|
14
|
+
DX7: tetorica-msfa-dx7-wasm 0.1.0 / Google MSFA (Apache-2.0); see msfa_dx7/LICENSE, THIRD_PARTY_NOTICES.md and README.vendor.md.
|
|
14
15
|
No external instrument/sample ROMs are included.
|
package/custom_fx.js
CHANGED
|
@@ -27,6 +27,7 @@ export class LiveFX {
|
|
|
27
27
|
process(channels,report,observe) {
|
|
28
28
|
const n=channels[0].length;
|
|
29
29
|
this.hasProcessed=true;
|
|
30
|
+
if(this.effects.size===0)return;
|
|
30
31
|
if(!this.input||this.input.length!==channels.length||this.input[0].length!==n){
|
|
31
32
|
this.input=channels.map(()=>new Float32Array(n));
|
|
32
33
|
this.output=channels.map(()=>new Float32Array(n));
|
package/megasynth.d.ts
CHANGED
|
@@ -10,6 +10,11 @@ import { createRf5c164Client } from "./playground_rf5c164.js";
|
|
|
10
10
|
export { createFXBranch, createBitcrusherFX, createChorusFX, createFXParallel, createDelayFX, createEqFX, createFilterFX, createGainFX, createLofiFX, createRadioToneFX, createReverbFX, createSlicerFX, createStereoWidthFX, createTapeSaturationFX, } from "./megasynth_fx.js";
|
|
11
11
|
export { MegaSynthLooper } from "./looper.js";
|
|
12
12
|
export { FM_PRESETS, FM_PRESET_ORDER, } from "./megasynth-fm-presets.js";
|
|
13
|
+
export type OutputEnvelopeOptions = {
|
|
14
|
+
samplesPerPoint?: number;
|
|
15
|
+
pointsPerMessage?: number;
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
};
|
|
13
18
|
export type AnyFXUnit = import("./megasynth_fx.js").AnyFXUnit;
|
|
14
19
|
export type YM2612SynthType = import("./ym2612synth.js").YM2612Synth;
|
|
15
20
|
export type YM2612Transport = import("./ym2612synth.js").YM2612Transport;
|
|
@@ -89,6 +94,7 @@ export type MegaSynthOptions = {
|
|
|
89
94
|
rf5c164WasmUrl?: string;
|
|
90
95
|
rf5c164WorkletUrl?: string;
|
|
91
96
|
rf5c164Fetch?: typeof fetch;
|
|
97
|
+
outputSampleRate?: number;
|
|
92
98
|
chipSampleRate?: number;
|
|
93
99
|
mixer?: import('./soundchip_mixer.js').SoundChipMixer;
|
|
94
100
|
masterVolume?: number;
|
|
@@ -232,6 +238,7 @@ export declare class MegaSynth {
|
|
|
232
238
|
bitcrusherWorkletUrl: string;
|
|
233
239
|
ym2612WasmUrl: string;
|
|
234
240
|
chipSampleRate: number;
|
|
241
|
+
outputSampleRate: number | undefined;
|
|
235
242
|
/**
|
|
236
243
|
* Optional. When set, the worklet also loads a Sega PSG core and mixes
|
|
237
244
|
* it with the YM2612 output, exposed on `this.psg`. Left unset by
|
|
@@ -270,6 +277,12 @@ export declare class MegaSynth {
|
|
|
270
277
|
} | null;
|
|
271
278
|
pcmDecodeId: number;
|
|
272
279
|
node: AudioWorkletNode | null;
|
|
280
|
+
/** @type {{samplesPerPoint: number, pointsPerMessage: number, enabled: boolean} | null} */
|
|
281
|
+
outputEnvelopeOptions: {
|
|
282
|
+
samplesPerPoint: number;
|
|
283
|
+
pointsPerMessage: number;
|
|
284
|
+
enabled: boolean;
|
|
285
|
+
} | null;
|
|
273
286
|
recordingManager: MegaSynthRecordingManager | null;
|
|
274
287
|
_recordingHooksInstalled: boolean;
|
|
275
288
|
listeners: Set<any>;
|
|
@@ -360,6 +373,18 @@ export declare class MegaSynth {
|
|
|
360
373
|
* @returns {MegaSynth}
|
|
361
374
|
*/
|
|
362
375
|
connectOutput(node?: AudioNode | null): MegaSynth;
|
|
376
|
+
/**
|
|
377
|
+
* Configure chip-output RMS messages (`output-envelope`, `rmsValues`) on
|
|
378
|
+
* node.port. Calling this enables monitoring unless enabled is false.
|
|
379
|
+
* samplesPerPoint: integer 1..65536 output frames per RMS point (default 512).
|
|
380
|
+
* pointsPerMessage: integer 1..1024 points per message (default 16).
|
|
381
|
+
* Omitted fields retain their previous values. Changes discard partial data.
|
|
382
|
+
* May be called before start() or during playback; settings survive close/start.
|
|
383
|
+
* This does not configure Playground's final-output AnalyserNode.
|
|
384
|
+
* @param {OutputEnvelopeOptions} options
|
|
385
|
+
* @returns {MegaSynth}
|
|
386
|
+
*/
|
|
387
|
+
setOutputEnvelopeOptions(options: OutputEnvelopeOptions): MegaSynth;
|
|
363
388
|
/**
|
|
364
389
|
* Set the final browser-side output gain after the current FX chain.
|
|
365
390
|
*
|
package/megasynth.js
CHANGED
|
@@ -47,6 +47,12 @@ export {
|
|
|
47
47
|
const YM2612_NATIVE_SAMPLE_RATE =
|
|
48
48
|
Math.floor(YM2612_CLOCK / 144);
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Chip-output RMS monitoring before browser FX and master volume, not the final
|
|
52
|
+
* output waveform. All sample counts use the AudioContext output sample rate.
|
|
53
|
+
* @typedef {{samplesPerPoint?: number, pointsPerMessage?: number, enabled?: boolean}} OutputEnvelopeOptions
|
|
54
|
+
*/
|
|
55
|
+
|
|
50
56
|
/**
|
|
51
57
|
* @typedef {import("./megasynth_fx.js").AnyFXUnit} AnyFXUnit
|
|
52
58
|
* @typedef {import("./ym2612synth.js").YM2612Synth} YM2612SynthType
|
|
@@ -66,6 +72,8 @@ const YM2612_NATIVE_SAMPLE_RATE =
|
|
|
66
72
|
* fadeOut?: number,
|
|
67
73
|
* pan?: number,
|
|
68
74
|
* }} MegaSynthSamplePlayOptions
|
|
75
|
+
* Fade times are output seconds. fadeOut also fades the natural end of a
|
|
76
|
+
* one-shot or duration-limited loop; an unbounded loop fades only on stop.
|
|
69
77
|
*/
|
|
70
78
|
|
|
71
79
|
/**
|
|
@@ -130,6 +138,10 @@ const YM2612_NATIVE_SAMPLE_RATE =
|
|
|
130
138
|
*/
|
|
131
139
|
|
|
132
140
|
/**
|
|
141
|
+
* Browser output uses the AudioContext/device rate by default. outputSampleRate
|
|
142
|
+
* explicitly requests an output frame rate; an explicitly supplied legacy
|
|
143
|
+
* chipSampleRate still requests that rate. An injected audioContext owns its
|
|
144
|
+
* rate. None of these options change the chip master clock or note tuning.
|
|
133
145
|
* @typedef {{
|
|
134
146
|
* audioContext?: AudioContext | null,
|
|
135
147
|
* outputNode?: AudioNode | null,
|
|
@@ -144,6 +156,7 @@ const YM2612_NATIVE_SAMPLE_RATE =
|
|
|
144
156
|
* rf5c164WasmUrl?: string,
|
|
145
157
|
* rf5c164WorkletUrl?: string,
|
|
146
158
|
* rf5c164Fetch?: typeof fetch,
|
|
159
|
+
* outputSampleRate?: number,
|
|
147
160
|
* chipSampleRate?: number,
|
|
148
161
|
* mixer?: import('./soundchip_mixer.js').SoundChipMixer,
|
|
149
162
|
* masterVolume?: number,
|
|
@@ -312,6 +325,16 @@ export class MegaSynth {
|
|
|
312
325
|
options.chipSampleRate ??
|
|
313
326
|
YM2612_NATIVE_SAMPLE_RATE
|
|
314
327
|
);
|
|
328
|
+
// The worklet already converts chip frames to the output clock. Let Web
|
|
329
|
+
// Audio use the device rate instead of requesting the unusual FM rate
|
|
330
|
+
// (53,267 Hz), which adds another resampling stage on the device path.
|
|
331
|
+
// Preserve an explicitly requested legacy chipSampleRate as output rate.
|
|
332
|
+
this.outputSampleRate = options.outputSampleRate ??
|
|
333
|
+
(options.chipSampleRate == null ? undefined : this.chipSampleRate);
|
|
334
|
+
if (options.outputSampleRate != null &&
|
|
335
|
+
(!Number.isInteger(this.outputSampleRate) || this.outputSampleRate < 8000 || this.outputSampleRate > 384000)) {
|
|
336
|
+
throw new RangeError('outputSampleRate must be an integer from 8000 to 384000');
|
|
337
|
+
}
|
|
315
338
|
|
|
316
339
|
/**
|
|
317
340
|
* Optional. When set, the worklet also loads a Sega PSG core and mixes
|
|
@@ -338,6 +361,8 @@ export class MegaSynth {
|
|
|
338
361
|
this.pcmDecodeId = 0;
|
|
339
362
|
|
|
340
363
|
this.node = null;
|
|
364
|
+
/** @type {{samplesPerPoint: number, pointsPerMessage: number, enabled: boolean} | null} */
|
|
365
|
+
this.outputEnvelopeOptions = null;
|
|
341
366
|
this.recordingManager = null;
|
|
342
367
|
this._recordingHooksInstalled =
|
|
343
368
|
false;
|
|
@@ -537,6 +562,37 @@ export class MegaSynth {
|
|
|
537
562
|
return this;
|
|
538
563
|
}
|
|
539
564
|
|
|
565
|
+
/**
|
|
566
|
+
* Configure chip-output RMS messages (`output-envelope`, `rmsValues`) on
|
|
567
|
+
* node.port. Calling this enables monitoring unless enabled is false.
|
|
568
|
+
* samplesPerPoint: integer 1..65536 output frames per RMS point (default 512).
|
|
569
|
+
* pointsPerMessage: integer 1..1024 points per message (default 16).
|
|
570
|
+
* Omitted fields retain their previous values. Changes discard partial data.
|
|
571
|
+
* May be called before start() or during playback; settings survive close/start.
|
|
572
|
+
* This does not configure Playground's final-output AnalyserNode.
|
|
573
|
+
* @param {OutputEnvelopeOptions} options
|
|
574
|
+
* @returns {MegaSynth}
|
|
575
|
+
*/
|
|
576
|
+
setOutputEnvelopeOptions(options) {
|
|
577
|
+
if (!options || typeof options !== 'object' || Array.isArray(options)) {
|
|
578
|
+
throw new TypeError('Output envelope options must be an object');
|
|
579
|
+
}
|
|
580
|
+
const previous = this.outputEnvelopeOptions;
|
|
581
|
+
const samplesPerPoint = options.samplesPerPoint === undefined ? previous?.samplesPerPoint ?? 512 : options.samplesPerPoint;
|
|
582
|
+
const pointsPerMessage = options.pointsPerMessage === undefined ? previous?.pointsPerMessage ?? 16 : options.pointsPerMessage;
|
|
583
|
+
const enabled = options.enabled === undefined ? true : options.enabled;
|
|
584
|
+
if (!Number.isInteger(samplesPerPoint) || samplesPerPoint < 1 || samplesPerPoint > 65536) {
|
|
585
|
+
throw new RangeError('samplesPerPoint must be an integer from 1 to 65536');
|
|
586
|
+
}
|
|
587
|
+
if (!Number.isInteger(pointsPerMessage) || pointsPerMessage < 1 || pointsPerMessage > 1024) {
|
|
588
|
+
throw new RangeError('pointsPerMessage must be an integer from 1 to 1024');
|
|
589
|
+
}
|
|
590
|
+
if (typeof enabled !== 'boolean') throw new TypeError('enabled must be a boolean');
|
|
591
|
+
this.outputEnvelopeOptions = {samplesPerPoint, pointsPerMessage, enabled};
|
|
592
|
+
this.node?.port.postMessage({type: 'set-output-envelope', ...this.outputEnvelopeOptions});
|
|
593
|
+
return this;
|
|
594
|
+
}
|
|
595
|
+
|
|
540
596
|
/**
|
|
541
597
|
* Set the final browser-side output gain after the current FX chain.
|
|
542
598
|
*
|
|
@@ -709,9 +765,8 @@ export class MegaSynth {
|
|
|
709
765
|
}
|
|
710
766
|
|
|
711
767
|
#createAudioContext() {
|
|
712
|
-
return new AudioContext(
|
|
713
|
-
sampleRate: this.
|
|
714
|
-
});
|
|
768
|
+
return new AudioContext(this.outputSampleRate === undefined
|
|
769
|
+
? undefined : {sampleRate: this.outputSampleRate});
|
|
715
770
|
}
|
|
716
771
|
|
|
717
772
|
async #initialize(signal) {
|
|
@@ -824,6 +879,10 @@ export class MegaSynth {
|
|
|
824
879
|
await workletReady;
|
|
825
880
|
signal.throwIfAborted();
|
|
826
881
|
|
|
882
|
+
if (this.outputEnvelopeOptions) {
|
|
883
|
+
this.node.port.postMessage({type: 'set-output-envelope', ...this.outputEnvelopeOptions});
|
|
884
|
+
}
|
|
885
|
+
|
|
827
886
|
const transport =
|
|
828
887
|
new YM2612WorkletTransport(
|
|
829
888
|
this.node
|
package/msfa_dx7/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|