@grame/faustwasm 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/standalone/create-node.js +46 -9
- package/assets/standalone/faust-ui/index.js +2 -2
- package/assets/standalone/faust-ui/index.js.map +1 -1
- package/assets/standalone/faustwasm/index.d.ts +42 -2
- package/assets/standalone/faustwasm/index.js +117 -66
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/assets/standalone/index-pwa.js +125 -90
- package/assets/standalone/index-template.js +43 -22
- package/assets/standalone/index.js +36 -19
- package/assets/standalone/service-worker.js +58 -5
- package/dist/cjs/index.d.ts +42 -2
- package/dist/cjs/index.js +117 -66
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.d.ts +42 -2
- package/dist/cjs-bundle/index.js +117 -66
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.d.ts +42 -2
- package/dist/esm/index.js +117 -66
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.d.ts +42 -2
- package/dist/esm-bundle/index.js +117 -66
- package/dist/esm-bundle/index.js.map +2 -2
- package/package.json +2 -2
- package/src/FaustAudioWorkletNode.ts +14 -30
- package/src/FaustAudioWorkletProcessor.ts +16 -0
- package/src/FaustOfflineProcessor.ts +2 -0
- package/src/FaustScriptProcessorNode.ts +6 -30
- package/src/FaustWebAudioDsp.ts +88 -0
- package/src/copyWebStandaloneAssets.js +14 -0
- package/test/faustlive-wasm/faust-ui/index.js +2 -2
- package/test/faustlive-wasm/faust-ui/index.js.map +1 -1
- package/test/faustlive-wasm/faustwasm/index.d.ts +42 -2
- package/test/faustlive-wasm/faustwasm/index.js +117 -66
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
- package/test/midi/create-node.js +177 -0
- package/test/midi/dsp-meta.json +133 -0
- package/test/midi/dsp-module.wasm +0 -0
- package/test/midi/faust-ui/index.css +442 -0
- package/test/midi/faust-ui/index.css.map +1 -0
- package/test/midi/faust-ui/index.d.ts +1 -0
- package/test/midi/faust-ui/index.js +3729 -0
- package/test/midi/faust-ui/index.js.map +1 -0
- package/test/midi/faustwasm/index.d.ts +1680 -0
- package/test/midi/faustwasm/index.js +4884 -0
- package/test/midi/faustwasm/index.js.map +7 -0
- package/test/midi/icon.png +0 -0
- package/test/midi/index.html +76 -0
- package/test/midi/index.js +183 -0
- package/test/midi/manifest.json +17 -0
- package/test/midi/service-worker.js +165 -0
- package/test/midi.dsp +8 -1
- package/test/organ1/create-node.js +177 -0
- package/test/organ1/dsp-meta.json +126 -0
- package/test/organ1/dsp-module.wasm +0 -0
- package/test/organ1/faust-ui/index.css +442 -0
- package/test/organ1/faust-ui/index.css.map +1 -0
- package/test/organ1/faust-ui/index.d.ts +1 -0
- package/test/organ1/faust-ui/index.js +3729 -0
- package/test/organ1/faust-ui/index.js.map +1 -0
- package/test/organ1/faustwasm/index.d.ts +1656 -0
- package/test/organ1/faustwasm/index.js +4783 -0
- package/test/organ1/faustwasm/index.js.map +7 -0
- package/test/organ1/icon.png +0 -0
- package/test/organ1/index.html +76 -0
- package/test/organ1/index.js +203 -0
- package/test/organ1/manifest.json +17 -0
- package/test/organ1/service-worker.js +181 -0
|
@@ -618,6 +618,20 @@ export interface IFaustBaseWebAudioDsp {
|
|
|
618
618
|
* @param value - the MIDI controller value (0..16383)
|
|
619
619
|
*/
|
|
620
620
|
pitchWheel(chan: number, value: number): void;
|
|
621
|
+
/**
|
|
622
|
+
* Handle MIDI keyOn messages.
|
|
623
|
+
* @param channel
|
|
624
|
+
* @param pitch
|
|
625
|
+
* @param velocity
|
|
626
|
+
*/
|
|
627
|
+
keyOn(channel: number, pitch: number, velocity: number): void;
|
|
628
|
+
/**
|
|
629
|
+
* Handle MIDI keyOn messages.
|
|
630
|
+
* @param channel
|
|
631
|
+
* @param pitch
|
|
632
|
+
* @param velocity
|
|
633
|
+
*/
|
|
634
|
+
keyOff(channel: number, pitch: number, velocity: number): void;
|
|
621
635
|
/**
|
|
622
636
|
* Set parameter value.
|
|
623
637
|
*
|
|
@@ -767,6 +781,24 @@ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
|
767
781
|
min: number;
|
|
768
782
|
max: number;
|
|
769
783
|
}[][];
|
|
784
|
+
protected fMidiKeyLabel: {
|
|
785
|
+
path: string;
|
|
786
|
+
chan: number;
|
|
787
|
+
min: number;
|
|
788
|
+
max: number;
|
|
789
|
+
}[][];
|
|
790
|
+
protected fMidiKeyOnLabel: {
|
|
791
|
+
path: string;
|
|
792
|
+
chan: number;
|
|
793
|
+
min: number;
|
|
794
|
+
max: number;
|
|
795
|
+
}[][];
|
|
796
|
+
protected fMidiKeyOffLabel: {
|
|
797
|
+
path: string;
|
|
798
|
+
chan: number;
|
|
799
|
+
min: number;
|
|
800
|
+
max: number;
|
|
801
|
+
}[][];
|
|
770
802
|
protected fPathTable: {
|
|
771
803
|
[address: string]: number;
|
|
772
804
|
};
|
|
@@ -826,6 +858,8 @@ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
|
826
858
|
getNumOutputs(): number;
|
|
827
859
|
midiMessage(data: number[] | Uint8Array): void;
|
|
828
860
|
ctrlChange(channel: number, ctrl: number, value: number): void;
|
|
861
|
+
keyOn(channel: number, pitch: number, velocity: number): void;
|
|
862
|
+
keyOff(channel: number, pitch: number, velocity: number): void;
|
|
829
863
|
pitchWheel(channel: number, wheel: number): void;
|
|
830
864
|
setParamValue(path: string, value: number): void;
|
|
831
865
|
getParamValue(path: string): number;
|
|
@@ -835,11 +869,11 @@ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
|
835
869
|
getUI(): FaustUIDescriptor;
|
|
836
870
|
getDescriptors(): FaustUIInputItem[];
|
|
837
871
|
hasSoundfiles(): boolean;
|
|
872
|
+
startSensors(): void;
|
|
873
|
+
stopSensors(): void;
|
|
838
874
|
start(): void;
|
|
839
875
|
stop(): void;
|
|
840
876
|
destroy(): void;
|
|
841
|
-
startSensors(): void;
|
|
842
|
-
stopSensors(): void;
|
|
843
877
|
}
|
|
844
878
|
export declare class FaustMonoWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustMonoWebAudioDsp {
|
|
845
879
|
private fInstance;
|
|
@@ -1180,6 +1214,8 @@ export declare class FaustOfflineProcessor<Poly extends boolean = false> {
|
|
|
1180
1214
|
midiMessage(data: number[] | Uint8Array): void;
|
|
1181
1215
|
ctrlChange(chan: number, ctrl: number, value: number): void;
|
|
1182
1216
|
pitchWheel(chan: number, value: number): void;
|
|
1217
|
+
keyOn(channel: number, pitch: number, velocity: number): void;
|
|
1218
|
+
keyOff(channel: number, pitch: number, velocity: number): void;
|
|
1183
1219
|
setParamValue(path: string, value: number): void;
|
|
1184
1220
|
getParamValue(path: string): number;
|
|
1185
1221
|
getParams(): string[];
|
|
@@ -1374,6 +1410,8 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
|
|
|
1374
1410
|
midiMessage(data: number[] | Uint8Array): void;
|
|
1375
1411
|
ctrlChange(channel: number, ctrl: number, value: number): void;
|
|
1376
1412
|
pitchWheel(channel: number, wheel: number): void;
|
|
1413
|
+
keyOn(channel: number, pitch: number, velocity: number): void;
|
|
1414
|
+
keyOff(channel: number, pitch: number, velocity: number): void;
|
|
1377
1415
|
get hasAccInput(): boolean;
|
|
1378
1416
|
propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert?: boolean): void;
|
|
1379
1417
|
get hasGyrInput(): boolean;
|
|
@@ -1441,6 +1479,8 @@ export declare class FaustScriptProcessorNode<Poly extends boolean = false> exte
|
|
|
1441
1479
|
midiMessage(data: number[] | Uint8Array): void;
|
|
1442
1480
|
ctrlChange(chan: number, ctrl: number, value: number): void;
|
|
1443
1481
|
pitchWheel(chan: number, value: number): void;
|
|
1482
|
+
keyOn(channel: number, pitch: number, velocity: number): void;
|
|
1483
|
+
keyOff(channel: number, pitch: number, velocity: number): void;
|
|
1444
1484
|
setParamValue(path: string, value: number): void;
|
|
1445
1485
|
getParamValue(path: string): number;
|
|
1446
1486
|
getParams(): string[];
|
|
@@ -186,6 +186,14 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
186
186
|
this.pitchWheel(msg.data[0], msg.data[1]);
|
|
187
187
|
break;
|
|
188
188
|
}
|
|
189
|
+
case "keyOn": {
|
|
190
|
+
this.keyOn(msg.data[0], msg.data[1], msg.data[2]);
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
case "keyOff": {
|
|
194
|
+
this.keyOff(msg.data[0], msg.data[1], msg.data[2]);
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
189
197
|
case "param": {
|
|
190
198
|
this.setParamValue(msg.data.path, msg.data.value);
|
|
191
199
|
break;
|
|
@@ -232,6 +240,12 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
232
240
|
pitchWheel(channel, wheel) {
|
|
233
241
|
this.fDSPCode.pitchWheel(channel, wheel);
|
|
234
242
|
}
|
|
243
|
+
keyOn(channel, pitch, velocity) {
|
|
244
|
+
this.fDSPCode.keyOn(channel, pitch, velocity);
|
|
245
|
+
}
|
|
246
|
+
keyOff(channel, pitch, velocity) {
|
|
247
|
+
this.fDSPCode.keyOff(channel, pitch, velocity);
|
|
248
|
+
}
|
|
235
249
|
propagateAcc(accelerationIncludingGravity, invert = false) {
|
|
236
250
|
this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);
|
|
237
251
|
}
|
|
@@ -2112,6 +2126,10 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
|
2112
2126
|
// MIDI handling
|
|
2113
2127
|
this.fPitchwheelLabel = [];
|
|
2114
2128
|
this.fCtrlLabel = new Array(128).fill(null).map(() => []);
|
|
2129
|
+
// array of MIDI key handlers; array index is the MIDI note number
|
|
2130
|
+
this.fMidiKeyLabel = new Array(128).fill(null).map(() => []);
|
|
2131
|
+
this.fMidiKeyOnLabel = new Array(128).fill(null).map(() => []);
|
|
2132
|
+
this.fMidiKeyOffLabel = new Array(128).fill(null).map(() => []);
|
|
2115
2133
|
this.fPathTable = {};
|
|
2116
2134
|
this.fUICallback = (item) => {
|
|
2117
2135
|
if (item.type === "hbargraph" || item.type === "vbargraph") {
|
|
@@ -2124,6 +2142,7 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
|
2124
2142
|
if (!item.meta)
|
|
2125
2143
|
return;
|
|
2126
2144
|
item.meta.forEach((meta) => {
|
|
2145
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2127
2146
|
const { midi, acc, gyr } = meta;
|
|
2128
2147
|
if (midi) {
|
|
2129
2148
|
const strMidi = midi.trim();
|
|
@@ -2137,10 +2156,25 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
|
2137
2156
|
} else {
|
|
2138
2157
|
const matched2 = strMidi.match(/^ctrl\s(\d+)\s(\d+)/);
|
|
2139
2158
|
const matched1 = strMidi.match(/^ctrl\s(\d+)/);
|
|
2159
|
+
const matchedKey = strMidi.match(/^key\s+(\d+)(?:\s+(\d+))?$/);
|
|
2160
|
+
const matchedKeyOn = strMidi.match(/^keyon\s+(\d+)(?:\s+(\d+))?$/);
|
|
2161
|
+
const matchedKeyOff = strMidi.match(/^keyoff\s+(\d+)(?:\s+(\d+))?$/);
|
|
2140
2162
|
if (matched2) {
|
|
2141
2163
|
this.fCtrlLabel[parseInt(matched2[1])].push({ path: item.address, chan: parseInt(matched2[2]), min: item.min, max: item.max });
|
|
2142
2164
|
} else if (matched1) {
|
|
2143
2165
|
this.fCtrlLabel[parseInt(matched1[1])].push({ path: item.address, chan: 0, min: item.min, max: item.max });
|
|
2166
|
+
} else if (matchedKey) {
|
|
2167
|
+
const note = parseInt(matchedKey[1]);
|
|
2168
|
+
const channel = matchedKey[2] ? parseInt(matchedKey[2]) : 0;
|
|
2169
|
+
this.fMidiKeyLabel[note].push({ path: item.address, chan: channel, min: (_a = item.min) != null ? _a : 0, max: (_b = item.max) != null ? _b : 1 });
|
|
2170
|
+
} else if (matchedKeyOn) {
|
|
2171
|
+
const note = parseInt(matchedKeyOn[1]);
|
|
2172
|
+
const channel = matchedKeyOn[2] ? parseInt(matchedKeyOn[2]) : 0;
|
|
2173
|
+
this.fMidiKeyOnLabel[note].push({ path: item.address, chan: channel, min: (_c = item.min) != null ? _c : 0, max: (_d = item.max) != null ? _d : 1 });
|
|
2174
|
+
} else if (matchedKeyOff) {
|
|
2175
|
+
const note = parseInt(matchedKeyOff[1]);
|
|
2176
|
+
const channel = matchedKeyOff[2] ? parseInt(matchedKeyOff[2]) : 0;
|
|
2177
|
+
this.fMidiKeyOffLabel[note].push({ path: item.address, chan: channel, min: (_e = item.min) != null ? _e : 0, max: (_f = item.max) != null ? _f : 1 });
|
|
2144
2178
|
}
|
|
2145
2179
|
}
|
|
2146
2180
|
}
|
|
@@ -2402,6 +2436,15 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
|
2402
2436
|
return this.ctrlChange(channel, data1, data2);
|
|
2403
2437
|
if (cmd === 14)
|
|
2404
2438
|
return this.pitchWheel(channel, data2 * 128 + data1);
|
|
2439
|
+
if (cmd === 9) {
|
|
2440
|
+
if (data2 > 0)
|
|
2441
|
+
return this.keyOn(channel, data1, data2);
|
|
2442
|
+
else
|
|
2443
|
+
return this.keyOff(channel, data1, data2);
|
|
2444
|
+
}
|
|
2445
|
+
if (cmd === 8) {
|
|
2446
|
+
return this.keyOff(channel, data1, data2);
|
|
2447
|
+
}
|
|
2405
2448
|
}
|
|
2406
2449
|
ctrlChange(channel, ctrl, value) {
|
|
2407
2450
|
if (this.fPlotHandler)
|
|
@@ -2417,6 +2460,46 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
|
2417
2460
|
});
|
|
2418
2461
|
}
|
|
2419
2462
|
}
|
|
2463
|
+
keyOn(channel, pitch, velocity) {
|
|
2464
|
+
if (this.fPlotHandler)
|
|
2465
|
+
this.fCachedEvents.push({ type: "keyOn", data: [channel, pitch, velocity] });
|
|
2466
|
+
this.fMidiKeyOnLabel[pitch].forEach((key) => {
|
|
2467
|
+
const { path, chan } = key;
|
|
2468
|
+
if (chan === 0 || channel === chan - 1) {
|
|
2469
|
+
this.setParamValue(path, _FaustBaseWebAudioDsp.remap(velocity, 0, 127, key.min, key.max));
|
|
2470
|
+
if (this.fOutputHandler)
|
|
2471
|
+
this.fOutputHandler(path, this.getParamValue(path));
|
|
2472
|
+
}
|
|
2473
|
+
});
|
|
2474
|
+
this.fMidiKeyLabel[pitch].forEach((key) => {
|
|
2475
|
+
const { path, chan } = key;
|
|
2476
|
+
if (chan === 0 || channel === chan - 1) {
|
|
2477
|
+
this.setParamValue(path, _FaustBaseWebAudioDsp.remap(velocity, 0, 127, key.min, key.max));
|
|
2478
|
+
if (this.fOutputHandler)
|
|
2479
|
+
this.fOutputHandler(path, this.getParamValue(path));
|
|
2480
|
+
}
|
|
2481
|
+
});
|
|
2482
|
+
}
|
|
2483
|
+
keyOff(channel, pitch, velocity) {
|
|
2484
|
+
if (this.fPlotHandler)
|
|
2485
|
+
this.fCachedEvents.push({ type: "keyOff", data: [channel, pitch, velocity] });
|
|
2486
|
+
this.fMidiKeyOffLabel[pitch].forEach((key) => {
|
|
2487
|
+
const { path, chan } = key;
|
|
2488
|
+
if (chan === 0 || channel === chan - 1) {
|
|
2489
|
+
this.setParamValue(path, _FaustBaseWebAudioDsp.remap(velocity, 0, 127, key.min, key.max));
|
|
2490
|
+
if (this.fOutputHandler)
|
|
2491
|
+
this.fOutputHandler(path, this.getParamValue(path));
|
|
2492
|
+
}
|
|
2493
|
+
});
|
|
2494
|
+
this.fMidiKeyLabel[pitch].forEach((key) => {
|
|
2495
|
+
const { path, chan } = key;
|
|
2496
|
+
if (chan === 0 || channel === chan - 1) {
|
|
2497
|
+
this.setParamValue(path, 0);
|
|
2498
|
+
if (this.fOutputHandler)
|
|
2499
|
+
this.fOutputHandler(path, this.getParamValue(path));
|
|
2500
|
+
}
|
|
2501
|
+
});
|
|
2502
|
+
}
|
|
2420
2503
|
pitchWheel(channel, wheel) {
|
|
2421
2504
|
if (this.fPlotHandler)
|
|
2422
2505
|
this.fCachedEvents.push({ type: "pitchWheel", data: [channel, wheel] });
|
|
@@ -2452,6 +2535,12 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
|
2452
2535
|
hasSoundfiles() {
|
|
2453
2536
|
return this.fSoundfiles.length > 0;
|
|
2454
2537
|
}
|
|
2538
|
+
startSensors() {
|
|
2539
|
+
this.startSensors();
|
|
2540
|
+
}
|
|
2541
|
+
stopSensors() {
|
|
2542
|
+
this.stopSensors();
|
|
2543
|
+
}
|
|
2455
2544
|
start() {
|
|
2456
2545
|
this.fProcessing = true;
|
|
2457
2546
|
}
|
|
@@ -2464,12 +2553,6 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
|
2464
2553
|
this.fComputeHandler = null;
|
|
2465
2554
|
this.fPlotHandler = null;
|
|
2466
2555
|
}
|
|
2467
|
-
startSensors() {
|
|
2468
|
-
this.startSensors();
|
|
2469
|
-
}
|
|
2470
|
-
stopSensors() {
|
|
2471
|
-
this.stopSensors();
|
|
2472
|
-
}
|
|
2473
2556
|
};
|
|
2474
2557
|
var FaustMonoWebAudioDsp = class extends FaustBaseWebAudioDsp {
|
|
2475
2558
|
constructor(instance, sampleRate, sampleSize, bufferSize, soundfiles) {
|
|
@@ -3053,6 +3136,12 @@ var FaustOfflineProcessor = class {
|
|
|
3053
3136
|
pitchWheel(chan, value) {
|
|
3054
3137
|
this.fDSPCode.pitchWheel(chan, value);
|
|
3055
3138
|
}
|
|
3139
|
+
keyOn(channel, pitch, velocity) {
|
|
3140
|
+
this.fDSPCode.keyOn(channel, pitch, velocity);
|
|
3141
|
+
}
|
|
3142
|
+
keyOff(channel, pitch, velocity) {
|
|
3143
|
+
this.fDSPCode.keyOff(channel, pitch, velocity);
|
|
3144
|
+
}
|
|
3056
3145
|
setParamValue(path, value) {
|
|
3057
3146
|
this.fDSPCode.setParamValue(path, value);
|
|
3058
3147
|
}
|
|
@@ -3918,42 +4007,14 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
3918
4007
|
async startSensors() {
|
|
3919
4008
|
if (this.hasAccInput) {
|
|
3920
4009
|
if (window.DeviceMotionEvent) {
|
|
3921
|
-
|
|
3922
|
-
try {
|
|
3923
|
-
const response = await window.DeviceMotionEvent.requestPermission();
|
|
3924
|
-
if (response === "granted") {
|
|
3925
|
-
window.addEventListener("devicemotion", this.handleDeviceMotion, true);
|
|
3926
|
-
} else if (response === "denied") {
|
|
3927
|
-
alert("You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access.");
|
|
3928
|
-
throw new Error("Unable to access the accelerometer.");
|
|
3929
|
-
}
|
|
3930
|
-
} catch (error) {
|
|
3931
|
-
console.error(error);
|
|
3932
|
-
}
|
|
3933
|
-
} else {
|
|
3934
|
-
window.addEventListener("devicemotion", this.handleDeviceMotion, true);
|
|
3935
|
-
}
|
|
4010
|
+
window.addEventListener("devicemotion", this.handleDeviceMotion, true);
|
|
3936
4011
|
} else {
|
|
3937
4012
|
console.log("Cannot set the accelerometer handler.");
|
|
3938
4013
|
}
|
|
3939
4014
|
}
|
|
3940
4015
|
if (this.hasGyrInput) {
|
|
3941
4016
|
if (window.DeviceMotionEvent) {
|
|
3942
|
-
|
|
3943
|
-
try {
|
|
3944
|
-
const response = await window.DeviceOrientationEvent.requestPermission();
|
|
3945
|
-
if (response === "granted") {
|
|
3946
|
-
window.addEventListener("deviceorientation", this.handleDeviceOrientation, true);
|
|
3947
|
-
} else if (response === "denied") {
|
|
3948
|
-
alert("You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access.");
|
|
3949
|
-
throw new Error("Unable to access the gyroscope.");
|
|
3950
|
-
}
|
|
3951
|
-
} catch (error) {
|
|
3952
|
-
console.error(error);
|
|
3953
|
-
}
|
|
3954
|
-
} else {
|
|
3955
|
-
window.addEventListener("deviceorientation", this.handleDeviceOrientation, true);
|
|
3956
|
-
}
|
|
4017
|
+
window.addEventListener("deviceorientation", this.handleDeviceOrientation, true);
|
|
3957
4018
|
} else {
|
|
3958
4019
|
console.log("Cannot set the gyroscope handler.");
|
|
3959
4020
|
}
|
|
@@ -4017,6 +4078,10 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
4017
4078
|
this.ctrlChange(channel, data1, data2);
|
|
4018
4079
|
else if (cmd === 14)
|
|
4019
4080
|
this.pitchWheel(channel, data2 * 128 + data1);
|
|
4081
|
+
if (cmd === 8 || cmd === 9 && data2 === 0)
|
|
4082
|
+
this.keyOff(channel, data1, data2);
|
|
4083
|
+
else if (cmd === 9)
|
|
4084
|
+
this.keyOn(channel, data1, data2);
|
|
4020
4085
|
else
|
|
4021
4086
|
this.port.postMessage({ type: "midi", data });
|
|
4022
4087
|
}
|
|
@@ -4028,6 +4093,14 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
4028
4093
|
const e = { type: "pitchWheel", data: [channel, wheel] };
|
|
4029
4094
|
this.port.postMessage(e);
|
|
4030
4095
|
}
|
|
4096
|
+
keyOn(channel, pitch, velocity) {
|
|
4097
|
+
const e = { type: "keyOn", data: [channel, pitch, velocity] };
|
|
4098
|
+
this.port.postMessage(e);
|
|
4099
|
+
}
|
|
4100
|
+
keyOff(channel, pitch, velocity) {
|
|
4101
|
+
const e = { type: "keyOff", data: [channel, pitch, velocity] };
|
|
4102
|
+
this.port.postMessage(e);
|
|
4103
|
+
}
|
|
4031
4104
|
get hasAccInput() {
|
|
4032
4105
|
return __privateGet(this, _hasAccInput);
|
|
4033
4106
|
}
|
|
@@ -4191,42 +4264,14 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode ||
|
|
|
4191
4264
|
async startSensors() {
|
|
4192
4265
|
if (this.hasAccInput) {
|
|
4193
4266
|
if (window.DeviceMotionEvent) {
|
|
4194
|
-
|
|
4195
|
-
try {
|
|
4196
|
-
const response = await window.DeviceMotionEvent.requestPermission();
|
|
4197
|
-
if (response === "granted") {
|
|
4198
|
-
window.addEventListener("devicemotion", this.handleDeviceMotion, true);
|
|
4199
|
-
} else if (response === "denied") {
|
|
4200
|
-
alert("You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access.");
|
|
4201
|
-
throw new Error("Unable to access the accelerometer.");
|
|
4202
|
-
}
|
|
4203
|
-
} catch (error) {
|
|
4204
|
-
console.error(error);
|
|
4205
|
-
}
|
|
4206
|
-
} else {
|
|
4207
|
-
window.addEventListener("devicemotion", this.handleDeviceMotion, true);
|
|
4208
|
-
}
|
|
4267
|
+
window.addEventListener("devicemotion", this.handleDeviceMotion, true);
|
|
4209
4268
|
} else {
|
|
4210
4269
|
console.log("Cannot set the accelerometer handler.");
|
|
4211
4270
|
}
|
|
4212
4271
|
}
|
|
4213
4272
|
if (this.hasGyrInput) {
|
|
4214
4273
|
if (window.DeviceMotionEvent) {
|
|
4215
|
-
|
|
4216
|
-
try {
|
|
4217
|
-
const response = await window.DeviceOrientationEvent.requestPermission();
|
|
4218
|
-
if (response === "granted") {
|
|
4219
|
-
window.addEventListener("deviceorientation", this.handleDeviceOrientation, true);
|
|
4220
|
-
} else if (response === "denied") {
|
|
4221
|
-
alert("You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access.");
|
|
4222
|
-
throw new Error("Unable to access the gyroscope.");
|
|
4223
|
-
}
|
|
4224
|
-
} catch (error) {
|
|
4225
|
-
console.error(error);
|
|
4226
|
-
}
|
|
4227
|
-
} else {
|
|
4228
|
-
window.addEventListener("deviceorientation", this.handleDeviceOrientation, true);
|
|
4229
|
-
}
|
|
4274
|
+
window.addEventListener("deviceorientation", this.handleDeviceOrientation, true);
|
|
4230
4275
|
} else {
|
|
4231
4276
|
console.log("Cannot set the gyroscope handler.");
|
|
4232
4277
|
}
|
|
@@ -4279,6 +4324,12 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode ||
|
|
|
4279
4324
|
pitchWheel(chan, value) {
|
|
4280
4325
|
this.fDSPCode.pitchWheel(chan, value);
|
|
4281
4326
|
}
|
|
4327
|
+
keyOn(channel, pitch, velocity) {
|
|
4328
|
+
this.fDSPCode.keyOn(channel, pitch, velocity);
|
|
4329
|
+
}
|
|
4330
|
+
keyOff(channel, pitch, velocity) {
|
|
4331
|
+
this.fDSPCode.keyOff(channel, pitch, velocity);
|
|
4332
|
+
}
|
|
4282
4333
|
setParamValue(path, value) {
|
|
4283
4334
|
this.fDSPCode.setParamValue(path, value);
|
|
4284
4335
|
}
|