@grame/faustwasm 0.9.5 → 0.10.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 +76 -1
- package/assets/standalone/index copie.js +171 -0
- package/assets/standalone/index-pwa.js +18 -0
- package/assets/standalone/index.js +38 -5
- package/dist/cjs-bundle/index.js +1 -1
- package/dist/esm-bundle/index.js +1 -1
- package/libfaust-wasm/libfaust-wasm.wasm +0 -0
- package/package.json +1 -1
- package/test/{organ1 → organ}/create-node.js +77 -2
- package/test/{organ1 → organ}/dsp-meta.json +18 -12
- package/test/organ/dsp-module.wasm +0 -0
- package/test/{organ1 → organ}/index.js +21 -3
- package/test/{organ1 → organ}/manifest.json +3 -3
- package/test/{organ1 → organ}/service-worker.js +3 -3
- package/test/organ1/dsp-module.wasm +0 -0
- package/test/organ1/effect-meta.json +0 -118
- package/test/organ1/effect-module.wasm +0 -0
- /package/test/{organ1 → organ}/faust-ui/index.css +0 -0
- /package/test/{organ1 → organ}/faust-ui/index.css.map +0 -0
- /package/test/{organ1 → organ}/faust-ui/index.d.ts +0 -0
- /package/test/{organ1 → organ}/faust-ui/index.js +0 -0
- /package/test/{organ1 → organ}/faust-ui/index.js.map +0 -0
- /package/test/{organ1 → organ}/faustwasm/index.d.ts +0 -0
- /package/test/{organ1 → organ}/faustwasm/index.js +0 -0
- /package/test/{organ1 → organ}/faustwasm/index.js.map +0 -0
- /package/test/{organ1 → organ}/icon.png +0 -0
- /package/test/{organ1 → organ}/index.html +0 -0
- /package/test/{organ1 → organ}/mixer-module.wasm +0 -0
|
Binary file
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
const createFaustNode = async (audioContext, dspName = "template", voices = 0, sp = false, bufferSize = 512) => {
|
|
23
23
|
// Set to true if the DSP has an effect
|
|
24
|
-
const FAUST_DSP_HAS_EFFECT =
|
|
24
|
+
const FAUST_DSP_HAS_EFFECT = false;
|
|
25
25
|
|
|
26
26
|
// Import necessary Faust modules and data
|
|
27
27
|
const { FaustMonoDspGenerator, FaustPolyDspGenerator } = await import("./faustwasm/index.js");
|
|
@@ -172,6 +172,81 @@ async function requestPermissions() {
|
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Key2Midi: maps keyboard input to MIDI messages.
|
|
177
|
+
*/
|
|
178
|
+
class Key2Midi {
|
|
179
|
+
static KEY_MAP = {
|
|
180
|
+
a: 0, w: 1, s: 2, e: 3, d: 4, f: 5, t: 6, g: 7,
|
|
181
|
+
y: 8, h: 9, u: 10, j: 11, k: 12, o: 13, l: 14, p: 15, ";": 16,
|
|
182
|
+
z: "PREV", x: "NEXT", c: "VELDOWN", v: "VELUP"
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
constructor({ keyMap = Key2Midi.KEY_MAP, offset = 60, velocity = 100, handler = console.log } = {}) {
|
|
186
|
+
this.keyMap = keyMap;
|
|
187
|
+
this.offset = offset;
|
|
188
|
+
this.velocity = velocity;
|
|
189
|
+
this.velMap = [20, 40, 60, 80, 100, 127];
|
|
190
|
+
this.handler = handler;
|
|
191
|
+
this.pressed = {};
|
|
192
|
+
|
|
193
|
+
this.onKeyDown = this.onKeyDown.bind(this);
|
|
194
|
+
this.onKeyUp = this.onKeyUp.bind(this);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
start() {
|
|
198
|
+
window.addEventListener("keydown", this.onKeyDown);
|
|
199
|
+
window.addEventListener("keyup", this.onKeyUp);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
stop() {
|
|
203
|
+
window.removeEventListener("keydown", this.onKeyDown);
|
|
204
|
+
window.removeEventListener("keyup", this.onKeyUp);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
onKeyDown(e) {
|
|
208
|
+
const key = e.key.toLowerCase();
|
|
209
|
+
if (this.pressed[key]) return;
|
|
210
|
+
this.pressed[key] = true;
|
|
211
|
+
|
|
212
|
+
const val = this.keyMap[key];
|
|
213
|
+
if (typeof val === "number") {
|
|
214
|
+
const note = val + this.offset;
|
|
215
|
+
this.handler([0x90, note, this.velocity]);
|
|
216
|
+
} else if (val === "PREV") {
|
|
217
|
+
this.offset -= 1;
|
|
218
|
+
} else if (val === "NEXT") {
|
|
219
|
+
this.offset += 1;
|
|
220
|
+
} else if (val === "VELDOWN") {
|
|
221
|
+
const idx = Math.max(0, this.velMap.indexOf(this.velocity) - 1);
|
|
222
|
+
this.velocity = this.velMap[idx];
|
|
223
|
+
} else if (val === "VELUP") {
|
|
224
|
+
const idx = Math.min(this.velMap.length - 1, this.velMap.indexOf(this.velocity) + 1);
|
|
225
|
+
this.velocity = this.velMap[idx];
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
onKeyUp(e) {
|
|
230
|
+
const key = e.key.toLowerCase();
|
|
231
|
+
const val = this.keyMap[key];
|
|
232
|
+
if (typeof val === "number") {
|
|
233
|
+
const note = val + this.offset;
|
|
234
|
+
this.handler([0x80, note, this.velocity]);
|
|
235
|
+
}
|
|
236
|
+
delete this.pressed[key];
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Creates a Key2Midi instance.
|
|
242
|
+
*
|
|
243
|
+
* @param {function} handler - The function to handle MIDI messages.
|
|
244
|
+
* @returns {Key2Midi} - The Key2Midi instance.
|
|
245
|
+
*/
|
|
246
|
+
function createKey2MIDI(handler) {
|
|
247
|
+
return new Key2Midi({ handler: handler });
|
|
248
|
+
}
|
|
249
|
+
|
|
175
250
|
// Export the functions
|
|
176
|
-
export { createFaustNode, createFaustUI, connectToAudioInput, requestPermissions };
|
|
251
|
+
export { createFaustNode, createFaustUI, createKey2MIDI, connectToAudioInput, requestPermissions };
|
|
177
252
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "
|
|
3
|
-
"filename": "
|
|
4
|
-
"version": "2.80.
|
|
5
|
-
"compile_options": "-lang wasm-
|
|
2
|
+
"name": "organ",
|
|
3
|
+
"filename": "organ",
|
|
4
|
+
"version": "2.80.4",
|
|
5
|
+
"compile_options": "-lang wasm-i -ct 1 -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 2",
|
|
6
6
|
"library_list": [
|
|
7
7
|
"/usr/share/faust/stdfaust.lib",
|
|
8
8
|
"/usr/share/faust/oscillators.lib",
|
|
@@ -18,8 +18,9 @@
|
|
|
18
18
|
"."
|
|
19
19
|
],
|
|
20
20
|
"size": 262264,
|
|
21
|
+
"code": "aFrT",
|
|
21
22
|
"inputs": 0,
|
|
22
|
-
"outputs":
|
|
23
|
+
"outputs": 1,
|
|
23
24
|
"meta": [
|
|
24
25
|
{
|
|
25
26
|
"basics.lib/name": "Faust Basic Element Library"
|
|
@@ -28,7 +29,7 @@
|
|
|
28
29
|
"basics.lib/version": "1.21.0"
|
|
29
30
|
},
|
|
30
31
|
{
|
|
31
|
-
"compile_options": "-lang wasm-
|
|
32
|
+
"compile_options": "-lang wasm-i -ct 1 -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 2"
|
|
32
33
|
},
|
|
33
34
|
{
|
|
34
35
|
"envelopes.lib/adsr:author": "Yann Orlarey and Andrey Bundin"
|
|
@@ -49,7 +50,7 @@
|
|
|
49
50
|
"envelopes.lib/version": "1.3.0"
|
|
50
51
|
},
|
|
51
52
|
{
|
|
52
|
-
"filename": "
|
|
53
|
+
"filename": "organ"
|
|
53
54
|
},
|
|
54
55
|
{
|
|
55
56
|
"maths.lib/author": "GRAME"
|
|
@@ -67,7 +68,7 @@
|
|
|
67
68
|
"maths.lib/version": "2.8.1"
|
|
68
69
|
},
|
|
69
70
|
{
|
|
70
|
-
"name": "
|
|
71
|
+
"name": "organ"
|
|
71
72
|
},
|
|
72
73
|
{
|
|
73
74
|
"oscillators.lib/name": "Faust Oscillator Library"
|
|
@@ -85,15 +86,20 @@
|
|
|
85
86
|
"ui": [
|
|
86
87
|
{
|
|
87
88
|
"type": "vgroup",
|
|
88
|
-
"label": "
|
|
89
|
+
"label": "organ",
|
|
89
90
|
"items": [
|
|
90
91
|
{
|
|
91
92
|
"type": "hslider",
|
|
92
93
|
"label": "freq",
|
|
93
94
|
"varname": "fHslider1",
|
|
94
95
|
"shortname": "freq",
|
|
95
|
-
"address": "/
|
|
96
|
+
"address": "/organ/freq",
|
|
96
97
|
"index": 262168,
|
|
98
|
+
"meta": [
|
|
99
|
+
{
|
|
100
|
+
"midi": "ctrl 7"
|
|
101
|
+
}
|
|
102
|
+
],
|
|
97
103
|
"init": 440,
|
|
98
104
|
"min": 20,
|
|
99
105
|
"max": 3000,
|
|
@@ -104,7 +110,7 @@
|
|
|
104
110
|
"label": "gain",
|
|
105
111
|
"varname": "fHslider0",
|
|
106
112
|
"shortname": "gain",
|
|
107
|
-
"address": "/
|
|
113
|
+
"address": "/organ/gain",
|
|
108
114
|
"index": 262144,
|
|
109
115
|
"init": 0.5,
|
|
110
116
|
"min": 0,
|
|
@@ -116,7 +122,7 @@
|
|
|
116
122
|
"label": "gate",
|
|
117
123
|
"varname": "fButton0",
|
|
118
124
|
"shortname": "gate",
|
|
119
|
-
"address": "/
|
|
125
|
+
"address": "/organ/gate",
|
|
120
126
|
"index": 262212
|
|
121
127
|
}
|
|
122
128
|
]
|
|
Binary file
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Set to > 0 if the DSP is polyphonic
|
|
2
|
-
const FAUST_DSP_VOICES =
|
|
2
|
+
const FAUST_DSP_VOICES = 0;
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @typedef {import("./faustwasm").FaustAudioWorkletNode} FaustAudioWorkletNode
|
|
@@ -39,8 +39,8 @@ let faustNode;
|
|
|
39
39
|
const { createFaustNode, createFaustUI } = await import("./create-node.js");
|
|
40
40
|
|
|
41
41
|
// To test the ScriptProcessorNode mode
|
|
42
|
-
// const result = await createFaustNode(audioContext, "
|
|
43
|
-
const result = await createFaustNode(audioContext, "
|
|
42
|
+
// const result = await createFaustNode(audioContext, "organ", FAUST_DSP_VOICES, true, 512);
|
|
43
|
+
const result = await createFaustNode(audioContext, "organ", FAUST_DSP_VOICES);
|
|
44
44
|
faustNode = result.faustNode; // Assign to the global variable
|
|
45
45
|
if (!faustNode) throw new Error("Faust DSP not compiled");
|
|
46
46
|
|
|
@@ -101,6 +101,22 @@ function stopMIDI() {
|
|
|
101
101
|
let sensorHandlersBound = false;
|
|
102
102
|
let midiHandlersBound = false;
|
|
103
103
|
|
|
104
|
+
// Keyboard to MIDI handing
|
|
105
|
+
let keyboard2MIDI = null;
|
|
106
|
+
|
|
107
|
+
async function startKeyboard2MIDI() {
|
|
108
|
+
// Import the create-node module
|
|
109
|
+
const { createKey2MIDI } = await import("./create-node.js");
|
|
110
|
+
|
|
111
|
+
keyboard2MIDI = createKey2MIDI((event) => faustNode.midiMessage(event));
|
|
112
|
+
keyboard2MIDI.start();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function stopKeyboard2MIDI() {
|
|
116
|
+
keyboard2MIDI.stop();
|
|
117
|
+
keyboard2MIDI = null;
|
|
118
|
+
}
|
|
119
|
+
|
|
104
120
|
// Function to activate MIDI and Sensors on user interaction
|
|
105
121
|
async function activateMIDISensors() {
|
|
106
122
|
|
|
@@ -119,6 +135,7 @@ async function activateMIDISensors() {
|
|
|
119
135
|
// Initialize the MIDI setup
|
|
120
136
|
if (!midiHandlersBound) {
|
|
121
137
|
startMIDI();
|
|
138
|
+
await startKeyboard2MIDI();
|
|
122
139
|
midiHandlersBound = true;
|
|
123
140
|
}
|
|
124
141
|
|
|
@@ -153,6 +170,7 @@ async function deactivateAudioMIDISensors() {
|
|
|
153
170
|
// Deactivate the MIDI setup
|
|
154
171
|
if (midiHandlersBound && FAUST_DSP_VOICES > 0) {
|
|
155
172
|
stopMIDI();
|
|
173
|
+
stopKeyboard2MIDI();
|
|
156
174
|
midiHandlersBound = false;
|
|
157
175
|
}
|
|
158
176
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "Faust
|
|
3
|
-
"short_name": "
|
|
2
|
+
"name": "Faust organ",
|
|
3
|
+
"short_name": "organ",
|
|
4
4
|
"start_url": "./index.html",
|
|
5
|
-
"description": "Progressive Web App for
|
|
5
|
+
"description": "Progressive Web App for organ",
|
|
6
6
|
"display": "standalone",
|
|
7
7
|
"background_color": "#ffffff",
|
|
8
8
|
"theme_color": "#000000",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference lib="webworker" />
|
|
2
2
|
|
|
3
3
|
// Set to > 0 if the DSP is polyphonic
|
|
4
|
-
const FAUST_DSP_VOICES =
|
|
4
|
+
const FAUST_DSP_VOICES = 0;
|
|
5
5
|
// Set to true if the DSP has an effect
|
|
6
|
-
const FAUST_DSP_HAS_EFFECT =
|
|
6
|
+
const FAUST_DSP_HAS_EFFECT = false;
|
|
7
7
|
|
|
8
|
-
const CACHE_NAME = "
|
|
8
|
+
const CACHE_NAME = "organ_20250522-1139"; // Cache name with versioning
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* List of essential resources required for the **Mono DSP** version of the application.
|
|
Binary file
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "organ1",
|
|
3
|
-
"filename": "organ1",
|
|
4
|
-
"version": "2.80.3",
|
|
5
|
-
"compile_options": "-lang wasm-e -inpl -ct 1 -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 2",
|
|
6
|
-
"library_list": [
|
|
7
|
-
"/usr/share/faust/stdfaust.lib",
|
|
8
|
-
"/usr/share/faust/oscillators.lib",
|
|
9
|
-
"/usr/share/faust/platform.lib",
|
|
10
|
-
"/usr/share/faust/maths.lib",
|
|
11
|
-
"/usr/share/faust/basics.lib",
|
|
12
|
-
"/usr/share/faust/envelopes.lib"
|
|
13
|
-
],
|
|
14
|
-
"include_pathnames": [
|
|
15
|
-
"/share/faust",
|
|
16
|
-
"/usr/local/share/faust",
|
|
17
|
-
"/usr/share/faust",
|
|
18
|
-
"."
|
|
19
|
-
],
|
|
20
|
-
"size": 12,
|
|
21
|
-
"code": "qO/O",
|
|
22
|
-
"inputs": 2,
|
|
23
|
-
"outputs": 2,
|
|
24
|
-
"meta": [
|
|
25
|
-
{
|
|
26
|
-
"basics.lib/name": "Faust Basic Element Library"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"basics.lib/version": "1.21.0"
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
"compile_options": "-lang wasm-e -inpl -ct 1 -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 2"
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"envelopes.lib/adsr:author": "Yann Orlarey and Andrey Bundin"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"envelopes.lib/author": "GRAME"
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
"envelopes.lib/copyright": "GRAME"
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"envelopes.lib/license": "LGPL with exception"
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"envelopes.lib/name": "Faust Envelope Library"
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
"envelopes.lib/version": "1.3.0"
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
"filename": "organ1"
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
"maths.lib/author": "GRAME"
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
"maths.lib/copyright": "GRAME"
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
"maths.lib/license": "LGPL with exception"
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
"maths.lib/name": "Faust Math Library"
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
"maths.lib/version": "2.8.1"
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
"name": "organ1"
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
"oscillators.lib/name": "Faust Oscillator Library"
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
"oscillators.lib/version": "1.6.0"
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
"platform.lib/name": "Generic Platform Library"
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
"platform.lib/version": "1.3.0"
|
|
84
|
-
}
|
|
85
|
-
],
|
|
86
|
-
"ui": [
|
|
87
|
-
{
|
|
88
|
-
"type": "vgroup",
|
|
89
|
-
"label": "organ1",
|
|
90
|
-
"items": [
|
|
91
|
-
{
|
|
92
|
-
"type": "hslider",
|
|
93
|
-
"label": "Left",
|
|
94
|
-
"varname": "fHslider0",
|
|
95
|
-
"shortname": "Left",
|
|
96
|
-
"address": "/organ1/Left",
|
|
97
|
-
"index": 0,
|
|
98
|
-
"init": 0.1,
|
|
99
|
-
"min": 0,
|
|
100
|
-
"max": 1,
|
|
101
|
-
"step": 0.01
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
"type": "hslider",
|
|
105
|
-
"label": "Right",
|
|
106
|
-
"varname": "fHslider1",
|
|
107
|
-
"shortname": "Right",
|
|
108
|
-
"address": "/organ1/Right",
|
|
109
|
-
"index": 4,
|
|
110
|
-
"init": 0.1,
|
|
111
|
-
"min": 0,
|
|
112
|
-
"max": 1,
|
|
113
|
-
"step": 0.01
|
|
114
|
-
}
|
|
115
|
-
]
|
|
116
|
-
}
|
|
117
|
-
]
|
|
118
|
-
}
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|