@grame/faustwasm 0.12.2 → 0.13.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/.prettierrc +5 -0
- package/README.md +21 -3
- package/assets/standalone/faustwasm/index.d.ts +38 -16
- package/assets/standalone/faustwasm/index.js +1574 -404
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/dist/cjs/index.d.ts +38 -16
- package/dist/cjs/index.js +1573 -404
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.d.ts +38 -16
- package/dist/cjs-bundle/index.js +1576 -406
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.d.ts +38 -16
- package/dist/esm/index.js +1574 -404
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.d.ts +38 -16
- package/dist/esm-bundle/index.js +1576 -406
- package/dist/esm-bundle/index.js.map +2 -2
- package/eslint.config.js +11 -0
- package/package.json +57 -51
- package/sound.cpp +163 -0
- package/sound.dsp +4 -0
- package/sound.json +1 -0
- package/sound.wasm +0 -0
- package/src/FaustAudioWorkletCommunicator.ts +150 -143
- package/src/FaustAudioWorkletNode.ts +173 -75
- package/src/FaustAudioWorkletProcessor.ts +218 -90
- package/src/FaustCmajor.ts +9 -3
- package/src/FaustCompiler.ts +112 -35
- package/src/FaustDspGenerator.ts +561 -117
- package/src/FaustDspInstance.ts +58 -24
- package/src/FaustFFTAudioWorkletProcessor.ts +822 -612
- package/src/FaustOfflineProcessor.ts +187 -56
- package/src/FaustScriptProcessorNode.ts +156 -49
- package/src/FaustSensors.ts +426 -96
- package/src/FaustSvgDiagrams.ts +18 -5
- package/src/FaustWasmInstantiator.ts +224 -70
- package/src/FaustWebAudioDsp.ts +1060 -349
- package/src/LibFaust.ts +13 -4
- package/src/SoundfileReader.ts +175 -131
- package/src/WavDecoder.ts +42 -20
- package/src/WavEncoder.ts +35 -21
- package/src/copyWebStandaloneAssets.d.ts +20 -5
- package/src/copyWebStandaloneAssets.js +203 -75
- package/src/exports-bundle.ts +5 -5
- package/src/exports.ts +24 -24
- package/src/faust2CmajorFiles.d.ts +7 -3
- package/src/faust2cmajorFiles.js +10 -8
- package/src/faust2svgFiles.d.ts +7 -3
- package/src/faust2svgFiles.js +9 -7
- package/src/faust2wasmFiles.d.ts +10 -5
- package/src/faust2wasmFiles.js +34 -17
- package/src/faust2wavFiles.d.ts +12 -3
- package/src/faust2wavFiles.js +25 -12
- package/src/index-bundle-iife.ts +2 -2
- package/src/index-bundle.ts +1 -1
- package/src/index.ts +1 -1
- package/src/instantiateFaustModule.ts +43 -36
- package/src/instantiateFaustModuleFromFile.ts +30 -14
- package/src/types.ts +101 -25
- package/test/faustlive-wasm/faustwasm/index.d.ts +38 -16
- package/test/faustlive-wasm/faustwasm/index.js +1574 -404
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
- package/test/web/create-faust-node.html +53 -0
- package/test/web/create-faust-node.js +186 -0
- package/test/organ/create-node.js +0 -252
- package/test/organ/dsp-meta.json +0 -131
- package/test/organ/dsp-module.wasm +0 -0
- package/test/organ/faust-pwa.js +0 -344
- package/test/organ/faust-ui/index.css +0 -442
- package/test/organ/faust-ui/index.css.map +0 -1
- package/test/organ/faust-ui/index.d.ts +0 -1
- package/test/organ/faust-ui/index.js +0 -3756
- package/test/organ/faust-ui/index.js.map +0 -1
- package/test/organ/faustwasm/index.d.ts +0 -1705
- package/test/organ/faustwasm/index.js +0 -4773
- package/test/organ/faustwasm/index.js.map +0 -7
- package/test/organ/icon.png +0 -0
- package/test/organ/index.html +0 -76
- package/test/organ/index.js +0 -69
- package/test/organ/manifest.json +0 -17
- package/test/organ/service-worker.js +0 -165
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
//@ts-check
|
|
2
|
-
import * as fs from
|
|
3
|
-
import * as path from
|
|
4
|
-
import { cpSync, cpSyncModify } from
|
|
5
|
-
import { fileURLToPath } from
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import { cpSync, cpSyncModify } from '../fileutils.js';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
6
|
|
|
7
7
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -13,39 +13,86 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
13
13
|
* @param {boolean} [poly] - Whether the DSP is polyphonic.
|
|
14
14
|
* @param {boolean} [effect] - Whether the DSP has an effect module.
|
|
15
15
|
*/
|
|
16
|
-
const copyWebStandaloneAssets = (
|
|
17
|
-
|
|
16
|
+
const copyWebStandaloneAssets = (
|
|
17
|
+
outputDir,
|
|
18
|
+
dspName,
|
|
19
|
+
poly = false,
|
|
20
|
+
effect = false
|
|
21
|
+
) => {
|
|
22
|
+
console.log(`Writing assets files.`);
|
|
18
23
|
if (!fs.existsSync(outputDir)) fs.mkdirSync(outputDir);
|
|
19
24
|
|
|
20
25
|
// Define find and replace patterns
|
|
21
|
-
const findAndReplace = [
|
|
22
|
-
if (poly)
|
|
23
|
-
|
|
26
|
+
const findAndReplace = ['FAUST_DSP_NAME', dspName];
|
|
27
|
+
if (poly)
|
|
28
|
+
findAndReplace.push('FAUST_DSP_VOICES = 0', 'FAUST_DSP_VOICES = 16');
|
|
29
|
+
if (poly && effect)
|
|
30
|
+
findAndReplace.push(
|
|
31
|
+
'FAUST_DSP_HAS_EFFECT = false',
|
|
32
|
+
'FAUST_DSP_HAS_EFFECT = true'
|
|
33
|
+
);
|
|
24
34
|
|
|
25
35
|
// Copy some files
|
|
26
|
-
const createNodeJSPath = path.join(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
const createNodeJSPath = path.join(
|
|
37
|
+
__dirname,
|
|
38
|
+
'../assets/standalone/create-node.js'
|
|
39
|
+
);
|
|
40
|
+
cpSyncModify(
|
|
41
|
+
createNodeJSPath,
|
|
42
|
+
outputDir + `/create-node.js`,
|
|
43
|
+
...findAndReplace
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const templateJSPath = path.join(
|
|
47
|
+
__dirname,
|
|
48
|
+
'../assets/standalone/index.js'
|
|
49
|
+
);
|
|
30
50
|
cpSyncModify(templateJSPath, outputDir + `/index.js`, ...findAndReplace);
|
|
31
51
|
|
|
32
|
-
const templateHTMLPath = path.join(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
cpSyncModify(
|
|
37
|
-
|
|
38
|
-
|
|
52
|
+
const templateHTMLPath = path.join(
|
|
53
|
+
__dirname,
|
|
54
|
+
'../assets/standalone/index.html'
|
|
55
|
+
);
|
|
56
|
+
cpSyncModify(
|
|
57
|
+
templateHTMLPath,
|
|
58
|
+
outputDir + `/index.html`,
|
|
59
|
+
...findAndReplace
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const templateWorkerPath = path.join(
|
|
63
|
+
__dirname,
|
|
64
|
+
'../assets/standalone/service-worker.js'
|
|
65
|
+
);
|
|
66
|
+
cpSyncModify(
|
|
67
|
+
templateWorkerPath,
|
|
68
|
+
outputDir + `/service-worker.js`,
|
|
69
|
+
...findAndReplace
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
const templateIconPath = path.join(
|
|
73
|
+
__dirname,
|
|
74
|
+
'../assets/standalone/icon.png'
|
|
75
|
+
);
|
|
39
76
|
cpSync(templateIconPath, outputDir + `/icon.png`);
|
|
40
77
|
|
|
41
|
-
const faustwasmPath = path.join(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
cpSync(
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
78
|
+
const faustwasmPath = path.join(
|
|
79
|
+
__dirname,
|
|
80
|
+
'../assets/standalone/faustwasm'
|
|
81
|
+
);
|
|
82
|
+
cpSync(faustwasmPath, outputDir + '/faustwasm');
|
|
83
|
+
|
|
84
|
+
const faustuiPath = path.join(__dirname, '../assets/standalone/faust-ui');
|
|
85
|
+
cpSync(faustuiPath, outputDir + '/faust-ui');
|
|
86
|
+
|
|
87
|
+
const templateManifestPath = path.join(
|
|
88
|
+
__dirname,
|
|
89
|
+
'../assets/standalone/manifest.json'
|
|
90
|
+
);
|
|
91
|
+
cpSyncModify(
|
|
92
|
+
templateManifestPath,
|
|
93
|
+
outputDir + `/manifest.json`,
|
|
94
|
+
...findAndReplace
|
|
95
|
+
);
|
|
49
96
|
};
|
|
50
97
|
|
|
51
98
|
/**
|
|
@@ -55,51 +102,102 @@ const copyWebStandaloneAssets = (outputDir, dspName, poly = false, effect = fals
|
|
|
55
102
|
* @param {boolean} [effect] - Whether the DSP has an effect module.
|
|
56
103
|
*/
|
|
57
104
|
const copyWebPWAAssets = (outputDir, dspName, poly = false, effect = false) => {
|
|
58
|
-
console.log(`Writing assets files.`)
|
|
105
|
+
console.log(`Writing assets files.`);
|
|
59
106
|
if (!fs.existsSync(outputDir)) fs.mkdirSync(outputDir);
|
|
60
107
|
|
|
61
108
|
// Generate VERSION_DATE
|
|
62
109
|
const now = new Date();
|
|
63
|
-
const VERSION_DATE =
|
|
64
|
-
|
|
65
|
-
(
|
|
66
|
-
(
|
|
67
|
-
|
|
110
|
+
const VERSION_DATE =
|
|
111
|
+
now.getFullYear().toString() +
|
|
112
|
+
('0' + (now.getMonth() + 1)).slice(-2) +
|
|
113
|
+
('0' + now.getDate()).slice(-2) +
|
|
114
|
+
'-' +
|
|
115
|
+
('0' + now.getHours()).slice(-2) +
|
|
116
|
+
('0' + now.getMinutes()).slice(-2);
|
|
68
117
|
|
|
69
118
|
// Define find and replace patterns
|
|
70
|
-
const findAndReplace = [
|
|
71
|
-
findAndReplace.push(
|
|
119
|
+
const findAndReplace = ['FAUST_DSP_NAME', dspName];
|
|
120
|
+
findAndReplace.push('VERSION_DATE', VERSION_DATE);
|
|
72
121
|
|
|
73
|
-
if (poly)
|
|
74
|
-
|
|
122
|
+
if (poly)
|
|
123
|
+
findAndReplace.push('FAUST_DSP_VOICES = 0', 'FAUST_DSP_VOICES = 16');
|
|
124
|
+
if (poly && effect)
|
|
125
|
+
findAndReplace.push(
|
|
126
|
+
'FAUST_DSP_HAS_EFFECT = false',
|
|
127
|
+
'FAUST_DSP_HAS_EFFECT = true'
|
|
128
|
+
);
|
|
75
129
|
|
|
76
130
|
// Copy some files
|
|
77
|
-
const createNodeJSPath = path.join(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
131
|
+
const createNodeJSPath = path.join(
|
|
132
|
+
__dirname,
|
|
133
|
+
'../assets/standalone/create-node.js'
|
|
134
|
+
);
|
|
135
|
+
cpSyncModify(
|
|
136
|
+
createNodeJSPath,
|
|
137
|
+
outputDir + `/create-node.js`,
|
|
138
|
+
...findAndReplace
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
const templateJSPath = path.join(
|
|
142
|
+
__dirname,
|
|
143
|
+
'../assets/standalone/index-pwa.js'
|
|
144
|
+
);
|
|
81
145
|
cpSyncModify(templateJSPath, outputDir + `/index.js`, ...findAndReplace);
|
|
82
146
|
|
|
83
|
-
const templatePWAJSPath = path.join(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
cpSyncModify(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
147
|
+
const templatePWAJSPath = path.join(
|
|
148
|
+
__dirname,
|
|
149
|
+
'../assets/standalone/faust-pwa.js'
|
|
150
|
+
);
|
|
151
|
+
cpSyncModify(
|
|
152
|
+
templatePWAJSPath,
|
|
153
|
+
outputDir + `/faust-pwa.js`,
|
|
154
|
+
...findAndReplace
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
const templateHTMLPath = path.join(
|
|
158
|
+
__dirname,
|
|
159
|
+
'../assets/standalone/index-pwa.html'
|
|
160
|
+
);
|
|
161
|
+
cpSyncModify(
|
|
162
|
+
templateHTMLPath,
|
|
163
|
+
outputDir + `/index.html`,
|
|
164
|
+
...findAndReplace
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
const templateWorkerPath = path.join(
|
|
168
|
+
__dirname,
|
|
169
|
+
'../assets/standalone/service-worker.js'
|
|
170
|
+
);
|
|
171
|
+
cpSyncModify(
|
|
172
|
+
templateWorkerPath,
|
|
173
|
+
outputDir + `/service-worker.js`,
|
|
174
|
+
...findAndReplace
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
const templateIconPath = path.join(
|
|
178
|
+
__dirname,
|
|
179
|
+
'../assets/standalone/icon.png'
|
|
180
|
+
);
|
|
93
181
|
cpSync(templateIconPath, outputDir + `/icon.png`);
|
|
94
182
|
|
|
95
|
-
const faustwasmPath = path.join(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
cpSync(
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
|
|
183
|
+
const faustwasmPath = path.join(
|
|
184
|
+
__dirname,
|
|
185
|
+
'../assets/standalone/faustwasm'
|
|
186
|
+
);
|
|
187
|
+
cpSync(faustwasmPath, outputDir + '/faustwasm');
|
|
188
|
+
|
|
189
|
+
const faustuiPath = path.join(__dirname, '../assets/standalone/faust-ui');
|
|
190
|
+
cpSync(faustuiPath, outputDir + '/faust-ui');
|
|
191
|
+
|
|
192
|
+
const templateManifestPath = path.join(
|
|
193
|
+
__dirname,
|
|
194
|
+
'../assets/standalone/manifest.json'
|
|
195
|
+
);
|
|
196
|
+
cpSyncModify(
|
|
197
|
+
templateManifestPath,
|
|
198
|
+
outputDir + `/manifest.json`,
|
|
199
|
+
...findAndReplace
|
|
200
|
+
);
|
|
103
201
|
};
|
|
104
202
|
/**
|
|
105
203
|
* @param {string} outputDir - The output directory.
|
|
@@ -107,30 +205,60 @@ const copyWebPWAAssets = (outputDir, dspName, poly = false, effect = false) => {
|
|
|
107
205
|
* @param {boolean} [poly] - Whether the DSP is polyphonic.
|
|
108
206
|
* @param {boolean} [effect] - Whether the DSP has an effect module.
|
|
109
207
|
*/
|
|
110
|
-
const copyWebTemplateAssets = (
|
|
111
|
-
|
|
208
|
+
const copyWebTemplateAssets = (
|
|
209
|
+
outputDir,
|
|
210
|
+
dspName,
|
|
211
|
+
poly = false,
|
|
212
|
+
effect = false
|
|
213
|
+
) => {
|
|
112
214
|
// Create output directory if it doesn't exist
|
|
113
215
|
if (!fs.existsSync(outputDir)) fs.mkdirSync(outputDir);
|
|
114
216
|
|
|
115
217
|
// Define find and replace patterns
|
|
116
|
-
const findAndReplace = [
|
|
218
|
+
const findAndReplace = ['FAUST_DSP_NAME', dspName];
|
|
117
219
|
|
|
118
|
-
if (poly)
|
|
119
|
-
|
|
220
|
+
if (poly)
|
|
221
|
+
findAndReplace.push('FAUST_DSP_VOICES = 0', 'FAUST_DSP_VOICES = 16');
|
|
222
|
+
if (poly && effect)
|
|
223
|
+
findAndReplace.push(
|
|
224
|
+
'FAUST_DSP_HAS_EFFECT = false',
|
|
225
|
+
'FAUST_DSP_HAS_EFFECT = true'
|
|
226
|
+
);
|
|
120
227
|
|
|
121
228
|
// Copy some files
|
|
122
|
-
const createNodeJSPath = path.join(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
229
|
+
const createNodeJSPath = path.join(
|
|
230
|
+
__dirname,
|
|
231
|
+
'../assets/standalone/create-node.js'
|
|
232
|
+
);
|
|
233
|
+
cpSyncModify(
|
|
234
|
+
createNodeJSPath,
|
|
235
|
+
outputDir + `/create-node.js`,
|
|
236
|
+
...findAndReplace
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
const templateJSPath = path.join(
|
|
240
|
+
__dirname,
|
|
241
|
+
'../assets/standalone/index-template.js'
|
|
242
|
+
);
|
|
126
243
|
cpSyncModify(templateJSPath, outputDir + `/index.js`, ...findAndReplace);
|
|
127
244
|
|
|
128
|
-
const templateHTMLPath = path.join(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
245
|
+
const templateHTMLPath = path.join(
|
|
246
|
+
__dirname,
|
|
247
|
+
'../assets/standalone/index-template.html'
|
|
248
|
+
);
|
|
249
|
+
cpSyncModify(
|
|
250
|
+
templateHTMLPath,
|
|
251
|
+
outputDir + `/index.html`,
|
|
252
|
+
'index-template.js',
|
|
253
|
+
'index.js',
|
|
254
|
+
...findAndReplace
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
const faustwasmPath = path.join(
|
|
258
|
+
__dirname,
|
|
259
|
+
'../assets/standalone/faustwasm'
|
|
260
|
+
);
|
|
261
|
+
cpSync(faustwasmPath, outputDir + '/faustwasm');
|
|
133
262
|
};
|
|
134
263
|
|
|
135
264
|
export { copyWebStandaloneAssets, copyWebPWAAssets, copyWebTemplateAssets };
|
|
136
|
-
|
package/src/exports-bundle.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { default as instantiateFaustModule } from
|
|
2
|
-
|
|
3
|
-
export * from
|
|
4
|
-
|
|
5
|
-
export * from
|
|
1
|
+
export { default as instantiateFaustModule } from './instantiateFaustModule';
|
|
2
|
+
|
|
3
|
+
export * from './instantiateFaustModule';
|
|
4
|
+
|
|
5
|
+
export * from './exports';
|
package/src/exports.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
export { default as instantiateFaustModuleFromFile } from
|
|
2
|
-
export { default as getFaustAudioWorkletProcessor } from
|
|
3
|
-
export { default as getFaustFFTAudioWorkletProcessor } from
|
|
4
|
-
export { default as FaustCompiler } from
|
|
5
|
-
export { FaustDspInstance } from
|
|
6
|
-
export { default as FaustWasmInstantiator } from
|
|
7
|
-
export { default as FaustOfflineProcessor } from
|
|
8
|
-
export { default as FaustSvgDiagrams } from
|
|
9
|
-
export { default as FaustCmajor } from
|
|
10
|
-
export { default as LibFaust } from
|
|
11
|
-
export { default as WavEncoder } from
|
|
12
|
-
export { default as WavDecoder } from
|
|
13
|
-
export { default as SoundfileReader } from
|
|
1
|
+
export { default as instantiateFaustModuleFromFile } from './instantiateFaustModuleFromFile';
|
|
2
|
+
export { default as getFaustAudioWorkletProcessor } from './FaustAudioWorkletProcessor';
|
|
3
|
+
export { default as getFaustFFTAudioWorkletProcessor } from './FaustFFTAudioWorkletProcessor';
|
|
4
|
+
export { default as FaustCompiler } from './FaustCompiler';
|
|
5
|
+
export { FaustDspInstance } from './FaustDspInstance';
|
|
6
|
+
export { default as FaustWasmInstantiator } from './FaustWasmInstantiator';
|
|
7
|
+
export { default as FaustOfflineProcessor } from './FaustOfflineProcessor';
|
|
8
|
+
export { default as FaustSvgDiagrams } from './FaustSvgDiagrams';
|
|
9
|
+
export { default as FaustCmajor } from './FaustCmajor';
|
|
10
|
+
export { default as LibFaust } from './LibFaust';
|
|
11
|
+
export { default as WavEncoder } from './WavEncoder';
|
|
12
|
+
export { default as WavDecoder } from './WavDecoder';
|
|
13
|
+
export { default as SoundfileReader } from './SoundfileReader';
|
|
14
14
|
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
17
|
-
export * from
|
|
18
|
-
export * from
|
|
19
|
-
export * from
|
|
20
|
-
export * from
|
|
21
|
-
export * from
|
|
22
|
-
export * from
|
|
23
|
-
export * from
|
|
24
|
-
export * from
|
|
15
|
+
export * from './FaustAudioWorkletNode';
|
|
16
|
+
export * from './FaustAudioWorkletProcessor';
|
|
17
|
+
export * from './FaustFFTAudioWorkletProcessor';
|
|
18
|
+
export * from './FaustCompiler';
|
|
19
|
+
export * from './FaustDspInstance';
|
|
20
|
+
export * from './FaustOfflineProcessor';
|
|
21
|
+
export * from './FaustScriptProcessorNode';
|
|
22
|
+
export * from './FaustWebAudioDsp';
|
|
23
|
+
export * from './FaustDspGenerator';
|
|
24
|
+
export * from './LibFaust';
|
|
25
25
|
|
|
26
|
-
export * from
|
|
26
|
+
export * from './types';
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
declare const faust2CmajorFiles: (
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
declare const faust2CmajorFiles: (
|
|
2
|
+
inputFile: string,
|
|
3
|
+
outputDir: string,
|
|
4
|
+
argv?: string[]
|
|
5
|
+
) => Promise<string>;
|
|
6
|
+
|
|
7
|
+
export default faust2CmajorFiles;
|
package/src/faust2cmajorFiles.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
//@ts-check
|
|
2
|
-
import * as fs from
|
|
3
|
-
import * as path from
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import * as path from 'path';
|
|
4
4
|
import {
|
|
5
5
|
instantiateFaustModuleFromFile,
|
|
6
6
|
LibFaust,
|
|
7
7
|
FaustCompiler,
|
|
8
8
|
FaustCmajor
|
|
9
|
-
} from
|
|
10
|
-
import { fileURLToPath } from
|
|
9
|
+
} from '../dist/esm/index.js';
|
|
10
|
+
import { fileURLToPath } from 'url';
|
|
11
11
|
|
|
12
12
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
13
13
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -18,16 +18,18 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
18
18
|
* @param {string[]} [argv]
|
|
19
19
|
*/
|
|
20
20
|
const faust2CmajorFiles = async (inputFile, outputDir, argv = []) => {
|
|
21
|
-
const faustModule = await instantiateFaustModuleFromFile(
|
|
21
|
+
const faustModule = await instantiateFaustModuleFromFile(
|
|
22
|
+
path.join(__dirname, '../libfaust-wasm/libfaust-wasm.js')
|
|
23
|
+
);
|
|
22
24
|
const libFaust = new LibFaust(faustModule);
|
|
23
25
|
const compiler = new FaustCompiler(libFaust);
|
|
24
26
|
console.log(`Faust Compiler version: ${compiler.version()}`);
|
|
25
27
|
console.log(`Reading file ${inputFile}`);
|
|
26
|
-
const code = fs.readFileSync(inputFile, { encoding:
|
|
28
|
+
const code = fs.readFileSync(inputFile, { encoding: 'utf8' });
|
|
27
29
|
const { name } = path.parse(inputFile);
|
|
28
30
|
const cmajor = new FaustCmajor(compiler);
|
|
29
|
-
if (!argv.find(a => a ===
|
|
30
|
-
const cmajor_file = cmajor.compile(name, code, argv.join(
|
|
31
|
+
if (!argv.find((a) => a === '-I')) argv.push('-I', 'libraries/');
|
|
32
|
+
const cmajor_file = cmajor.compile(name, code, argv.join(' '));
|
|
31
33
|
console.log(`Writing files to ${outputDir}`);
|
|
32
34
|
if (!fs.existsSync(outputDir)) fs.mkdirSync(outputDir);
|
|
33
35
|
const cmajorPath = path.join(outputDir, `${name}.cmajor`);
|
package/src/faust2svgFiles.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
declare const faust2svgFiles: (
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
declare const faust2svgFiles: (
|
|
2
|
+
inputFile: string,
|
|
3
|
+
outputDir: string,
|
|
4
|
+
argv?: string[]
|
|
5
|
+
) => Promise<Record<string, string>>;
|
|
6
|
+
|
|
7
|
+
export default faust2svgFiles;
|
package/src/faust2svgFiles.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
//@ts-check
|
|
2
|
-
import * as fs from
|
|
3
|
-
import * as path from
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import * as path from 'path';
|
|
4
4
|
import {
|
|
5
5
|
instantiateFaustModuleFromFile,
|
|
6
6
|
LibFaust,
|
|
7
7
|
FaustCompiler,
|
|
8
8
|
FaustSvgDiagrams
|
|
9
|
-
} from
|
|
10
|
-
import { fileURLToPath } from
|
|
9
|
+
} from '../dist/esm/index.js';
|
|
10
|
+
import { fileURLToPath } from 'url';
|
|
11
11
|
|
|
12
12
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
13
13
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -18,15 +18,17 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
18
18
|
* @param {string[]} [argv]
|
|
19
19
|
*/
|
|
20
20
|
const faust2svgFiles = async (inputFile, outputDir, argv = []) => {
|
|
21
|
-
const faustModule = await instantiateFaustModuleFromFile(
|
|
21
|
+
const faustModule = await instantiateFaustModuleFromFile(
|
|
22
|
+
path.join(__dirname, '../libfaust-wasm/libfaust-wasm.js')
|
|
23
|
+
);
|
|
22
24
|
const libFaust = new LibFaust(faustModule);
|
|
23
25
|
const compiler = new FaustCompiler(libFaust);
|
|
24
26
|
console.log(`Faust Compiler version: ${compiler.version()}`);
|
|
25
27
|
console.log(`Reading file ${inputFile}`);
|
|
26
|
-
const code = fs.readFileSync(inputFile, { encoding:
|
|
28
|
+
const code = fs.readFileSync(inputFile, { encoding: 'utf8' });
|
|
27
29
|
const { name } = path.parse(inputFile);
|
|
28
30
|
const diagram = new FaustSvgDiagrams(compiler);
|
|
29
|
-
const svgs = diagram.from(name, code, argv.join(
|
|
31
|
+
const svgs = diagram.from(name, code, argv.join(' '));
|
|
30
32
|
console.log(`Generated ${Object.keys(svgs).length} files.`);
|
|
31
33
|
console.log(`Writing files to ${outputDir}`);
|
|
32
34
|
if (!fs.existsSync(outputDir)) fs.mkdirSync(outputDir);
|
package/src/faust2wasmFiles.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import { FaustDspMeta } from
|
|
2
|
-
|
|
3
|
-
declare const faust2wasmFiles: (
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { FaustDspMeta } from './types';
|
|
2
|
+
|
|
3
|
+
declare const faust2wasmFiles: (
|
|
4
|
+
inputFile: string,
|
|
5
|
+
outputDir: string,
|
|
6
|
+
argv?: string[],
|
|
7
|
+
poly?: boolean
|
|
8
|
+
) => Promise<{ dspMeta: FaustDspMeta; effectMeta: FaustDspMeta | null }>;
|
|
9
|
+
|
|
10
|
+
export default faust2wasmFiles;
|
package/src/faust2wasmFiles.js
CHANGED
|
@@ -1,43 +1,50 @@
|
|
|
1
1
|
//@ts-check
|
|
2
|
-
import * as fs from
|
|
3
|
-
import * as path from
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import * as path from 'path';
|
|
4
4
|
import {
|
|
5
5
|
instantiateFaustModuleFromFile,
|
|
6
6
|
LibFaust,
|
|
7
7
|
FaustCompiler,
|
|
8
8
|
FaustMonoDspGenerator,
|
|
9
9
|
FaustPolyDspGenerator
|
|
10
|
-
} from
|
|
11
|
-
import { fileURLToPath } from
|
|
10
|
+
} from '../dist/esm/index.js';
|
|
11
|
+
import { fileURLToPath } from 'url';
|
|
12
12
|
|
|
13
13
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
14
14
|
const __filename = fileURLToPath(import.meta.url);
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Script to compile a Faust DSP file to WebAssembly and write the output to files.
|
|
18
|
-
*
|
|
18
|
+
*
|
|
19
19
|
* @param {string} inputFile : The path to the Faust DSP file.
|
|
20
20
|
* @param {string} outputDir : The path to the output directory.
|
|
21
21
|
* @param {string[]} [argv] : An array of command-line arguments to pass to the Faust compiler.
|
|
22
22
|
* @param {boolean} [poly] : Whether to compile the DSP as a polyphonic instrument.
|
|
23
23
|
*/
|
|
24
|
-
const faust2wasmFiles = async (
|
|
25
|
-
|
|
24
|
+
const faust2wasmFiles = async (
|
|
25
|
+
inputFile,
|
|
26
|
+
outputDir,
|
|
27
|
+
argv = [],
|
|
28
|
+
poly = false
|
|
29
|
+
) => {
|
|
30
|
+
const faustModule = await instantiateFaustModuleFromFile(
|
|
31
|
+
path.join(__dirname, '../libfaust-wasm/libfaust-wasm.js')
|
|
32
|
+
);
|
|
26
33
|
const libFaust = new LibFaust(faustModule);
|
|
27
34
|
const compiler = new FaustCompiler(libFaust);
|
|
28
35
|
console.log(`Faust Compiler version: ${compiler.version()}`);
|
|
29
36
|
console.log(`Reading file ${inputFile}`);
|
|
30
|
-
const code = fs.readFileSync(inputFile, { encoding:
|
|
37
|
+
const code = fs.readFileSync(inputFile, { encoding: 'utf8' });
|
|
31
38
|
|
|
32
|
-
const fileName = /** @type {string} */(inputFile.split('/').pop());
|
|
39
|
+
const fileName = /** @type {string} */ (inputFile.split('/').pop());
|
|
33
40
|
const dspName = fileName.replace(/\.dsp$/, '');
|
|
34
41
|
// Flush to zero to avoid costly denormalized numbers
|
|
35
|
-
argv.push(
|
|
42
|
+
argv.push('-ftz', '2');
|
|
36
43
|
const dspModulePath = path.join(outputDir, `dsp-module.wasm`);
|
|
37
44
|
const dspMetaPath = path.join(outputDir, `dsp-meta.json`);
|
|
38
45
|
const effectModulePath = path.join(outputDir, `effect-module.wasm`);
|
|
39
46
|
const effectMetaPath = path.join(outputDir, `effect-meta.json`);
|
|
40
|
-
const mixerModulePath = path.join(outputDir,
|
|
47
|
+
const mixerModulePath = path.join(outputDir, 'mixer-module.wasm');
|
|
41
48
|
/** @type {Uint8Array} */
|
|
42
49
|
let dspModule;
|
|
43
50
|
/** @type {import("./types").FaustDspMeta} */
|
|
@@ -52,10 +59,15 @@ const faust2wasmFiles = async (inputFile, outputDir, argv = [], poly = false) =>
|
|
|
52
59
|
if (poly) {
|
|
53
60
|
const generator = new FaustPolyDspGenerator();
|
|
54
61
|
const t1 = Date.now();
|
|
55
|
-
const dsp = await generator.compile(
|
|
56
|
-
|
|
62
|
+
const dsp = await generator.compile(
|
|
63
|
+
compiler,
|
|
64
|
+
name,
|
|
65
|
+
code,
|
|
66
|
+
argv.join(' ')
|
|
67
|
+
);
|
|
68
|
+
if (!dsp) throw new Error('Faust DSP not compiled');
|
|
57
69
|
const { voiceFactory, effectFactory, mixerBuffer } = dsp;
|
|
58
|
-
if (!voiceFactory) throw new Error(
|
|
70
|
+
if (!voiceFactory) throw new Error('Faust DSP Factory not compiled');
|
|
59
71
|
console.log(`Compilation successful (${Date.now() - t1} ms).`);
|
|
60
72
|
dspModule = voiceFactory.code;
|
|
61
73
|
dspMeta = JSON.parse(voiceFactory.json);
|
|
@@ -67,10 +79,15 @@ const faust2wasmFiles = async (inputFile, outputDir, argv = [], poly = false) =>
|
|
|
67
79
|
} else {
|
|
68
80
|
const generator = new FaustMonoDspGenerator();
|
|
69
81
|
const t1 = Date.now();
|
|
70
|
-
const dsp = await generator.compile(
|
|
71
|
-
|
|
82
|
+
const dsp = await generator.compile(
|
|
83
|
+
compiler,
|
|
84
|
+
name,
|
|
85
|
+
code,
|
|
86
|
+
argv.join(' ')
|
|
87
|
+
);
|
|
88
|
+
if (!dsp) throw new Error('Faust DSP not compiled');
|
|
72
89
|
const { factory } = dsp;
|
|
73
|
-
if (!factory) throw new Error(
|
|
90
|
+
if (!factory) throw new Error('Faust DSP Factory not compiled');
|
|
74
91
|
console.log(`Compilation successful (${Date.now() - t1} ms).`);
|
|
75
92
|
dspModule = factory.code;
|
|
76
93
|
dspMeta = JSON.parse(factory.json);
|
package/src/faust2wavFiles.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
-
declare const faust2wavFiles: (
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
declare const faust2wavFiles: (
|
|
2
|
+
inputFile: string,
|
|
3
|
+
inputWav: string,
|
|
4
|
+
outputWav: string,
|
|
5
|
+
bufferSize?: number,
|
|
6
|
+
sampleRate?: number,
|
|
7
|
+
samples?: number,
|
|
8
|
+
bitDepth?: number,
|
|
9
|
+
argv?: string[]
|
|
10
|
+
) => Promise<void>;
|
|
11
|
+
|
|
12
|
+
export default faust2wavFiles;
|