@grame/faustwasm 0.5.2 → 0.5.3
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 +2 -2
- package/assets/standalone/create-node.js +35 -2
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/assets/standalone/index-pwa.js +16 -56
- package/assets/standalone/index.js +17 -30
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.js.map +2 -2
- package/foo.cpp +3312 -0
- package/package.json +1 -1
- package/src/FaustSensors.ts +0 -2
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
|
@@ -29,50 +29,23 @@ const audioContext = new AudioCtx({ latencyHint: 0.00001 });
|
|
|
29
29
|
audioContext.destination.channelInterpretation = "discrete";
|
|
30
30
|
audioContext.suspend();
|
|
31
31
|
|
|
32
|
-
/**
|
|
33
|
-
* @param {FaustAudioWorkletNode} faustNode
|
|
34
|
-
*/
|
|
35
|
-
const createFaustUI = async (faustNode) => {
|
|
36
|
-
const { FaustUI } = await import("./faust-ui/index.js");
|
|
37
|
-
const $container = document.createElement("div");
|
|
38
|
-
$container.style.margin = "0";
|
|
39
|
-
$container.style.position = "absolute";
|
|
40
|
-
$container.style.overflow = "auto";
|
|
41
|
-
$container.style.display = "flex";
|
|
42
|
-
$container.style.flexDirection = "column";
|
|
43
|
-
$container.style.width = "100%";
|
|
44
|
-
$container.style.height = "100%";
|
|
45
|
-
$divFaustUI.appendChild($container);
|
|
46
|
-
const faustUI = new FaustUI({
|
|
47
|
-
ui: faustNode.getUI(),
|
|
48
|
-
root: $container,
|
|
49
|
-
listenWindowMessage: false,
|
|
50
|
-
listenWindowResize: true,
|
|
51
|
-
});
|
|
52
|
-
faustUI.paramChangeByUI = (path, value) => faustNode.setParamValue(path, value);
|
|
53
|
-
faustNode.setOutputParamHandler((path, value) => faustUI.paramChangeByDSP(path, value));
|
|
54
|
-
$container.style.minWidth = `${faustUI.minWidth}px`;
|
|
55
|
-
$container.style.minHeight = `${faustUI.minHeight}px`;
|
|
56
|
-
faustUI.resize();
|
|
57
|
-
};
|
|
58
|
-
|
|
59
32
|
(async () => {
|
|
60
33
|
|
|
61
|
-
const { createFaustNode } = await import("./create-node.js");
|
|
62
|
-
|
|
63
34
|
// To test the ScriptProcessorNode mode
|
|
64
35
|
// const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "osc", FAUST_DSP_VOICES, true);
|
|
36
|
+
const { createFaustNode } = await import("./create-node.js");
|
|
65
37
|
const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "osc", FAUST_DSP_VOICES);
|
|
66
38
|
if (!faustNode) throw new Error("Faust DSP not compiled");
|
|
67
39
|
|
|
68
40
|
// Create the Faust UI
|
|
69
|
-
await
|
|
41
|
+
const { createFaustUI } = await import("./create-node.js");
|
|
42
|
+
await createFaustUI($divFaustUI, faustNode);
|
|
70
43
|
|
|
71
44
|
// Connect the Faust node to the audio output
|
|
72
45
|
faustNode.connect(audioContext.destination);
|
|
73
46
|
|
|
74
47
|
// Connect the Faust node to the audio input
|
|
75
|
-
if (faustNode.
|
|
48
|
+
if (faustNode.numberOfInputs > 0) {
|
|
76
49
|
const { connectToAudioInput } = await import("./create-node.js");
|
|
77
50
|
await connectToAudioInput(audioContext, null, faustNode, null);
|
|
78
51
|
}
|
|
@@ -81,40 +54,27 @@ const createFaustUI = async (faustNode) => {
|
|
|
81
54
|
await faustNode.listenSensors();
|
|
82
55
|
|
|
83
56
|
// Function to initialize MIDI
|
|
84
|
-
function initMIDI() {
|
|
57
|
+
function initMIDI(faustNode) {
|
|
85
58
|
// Check if the browser supports the Web MIDI API
|
|
86
59
|
if (navigator.requestMIDIAccess) {
|
|
87
|
-
navigator.requestMIDIAccess()
|
|
88
|
-
|
|
60
|
+
navigator.requestMIDIAccess().then(
|
|
61
|
+
midiAccess => {
|
|
62
|
+
console.log("MIDI Access obtained.");
|
|
63
|
+
for (let input of midiAccess.inputs.values()) {
|
|
64
|
+
input.onmidimessage = (event) => faustNode.midiMessage(event.data);
|
|
65
|
+
console.log(`Connected to input: ${input.name}`);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
() => console.error("Failed to access MIDI devices.")
|
|
69
|
+
);
|
|
89
70
|
} else {
|
|
90
71
|
console.log("Web MIDI API is not supported in this browser.");
|
|
91
72
|
}
|
|
92
73
|
}
|
|
93
74
|
|
|
94
|
-
// Success callback for requesting MIDI access
|
|
95
|
-
function onMIDISuccess(midiAccess) {
|
|
96
|
-
console.log("MIDI Access obtained.");
|
|
97
|
-
// Iterate through all available MIDI inputs
|
|
98
|
-
for (let input of midiAccess.inputs.values()) {
|
|
99
|
-
// Attach the event listener to each input
|
|
100
|
-
input.onmidimessage = handleMIDIMessage;
|
|
101
|
-
console.log(`Connected to input: ${input.name}`);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// Failure callback for requesting MIDI access
|
|
106
|
-
function onMIDIFailure() {
|
|
107
|
-
console.error("Failed to access MIDI devices.");
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Dummy event handler for MIDI messages
|
|
111
|
-
function handleMIDIMessage(event) {
|
|
112
|
-
faustNode.midiMessage(event.data);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
75
|
// Initialize the MIDI setup
|
|
116
76
|
if (FAUST_DSP_VOICES > 0) {
|
|
117
|
-
initMIDI();
|
|
77
|
+
initMIDI(faustNode);
|
|
118
78
|
}
|
|
119
79
|
|
|
120
80
|
})();
|
|
@@ -38,6 +38,7 @@ const AudioCtx = window.AudioContext || window.webkitAudioContext;
|
|
|
38
38
|
const audioContext = new AudioCtx({ latencyHint: 0.00001 });
|
|
39
39
|
audioContext.destination.channelInterpretation = "discrete";
|
|
40
40
|
audioContext.suspend();
|
|
41
|
+
|
|
41
42
|
$buttonDsp.disabled = true;
|
|
42
43
|
|
|
43
44
|
/**
|
|
@@ -106,49 +107,35 @@ const buildMidiDeviceMenu = async (faustNode) => {
|
|
|
106
107
|
};
|
|
107
108
|
};
|
|
108
109
|
|
|
109
|
-
/**
|
|
110
|
-
* @param {FaustAudioWorkletNode} faustNode
|
|
111
|
-
*/
|
|
112
|
-
const createFaustUI = async (faustNode) => {
|
|
113
|
-
const { FaustUI } = await import("./faust-ui/index.js");
|
|
114
|
-
const $container = document.createElement("div");
|
|
115
|
-
$container.style.margin = "0";
|
|
116
|
-
$container.style.position = "absolute";
|
|
117
|
-
$container.style.overflow = "auto";
|
|
118
|
-
$container.style.display = "flex";
|
|
119
|
-
$container.style.flexDirection = "column";
|
|
120
|
-
$container.style.width = "100%";
|
|
121
|
-
$container.style.height = "100%";
|
|
122
|
-
$divFaustUI.appendChild($container);
|
|
123
|
-
const faustUI = new FaustUI({
|
|
124
|
-
ui: faustNode.getUI(),
|
|
125
|
-
root: $container,
|
|
126
|
-
listenWindowMessage: false,
|
|
127
|
-
listenWindowResize: true,
|
|
128
|
-
});
|
|
129
|
-
faustUI.paramChangeByUI = (path, value) => faustNode.setParamValue(path, value);
|
|
130
|
-
faustNode.setOutputParamHandler((path, value) => faustUI.paramChangeByDSP(path, value));
|
|
131
|
-
$container.style.minWidth = `${faustUI.minWidth}px`;
|
|
132
|
-
$container.style.minHeight = `${faustUI.minHeight}px`;
|
|
133
|
-
faustUI.resize();
|
|
134
|
-
};
|
|
135
|
-
|
|
136
110
|
(async () => {
|
|
137
|
-
|
|
111
|
+
|
|
138
112
|
// To test the ScriptProcessorNode mode
|
|
139
113
|
// const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "FAUST_DSP_NAME", FAUST_DSP_VOICES, true);
|
|
114
|
+
const { createFaustNode } = await import("./create-node.js");
|
|
140
115
|
const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "FAUST_DSP_NAME", FAUST_DSP_VOICES);
|
|
141
116
|
if (!faustNode) throw new Error("Faust DSP not compiled");
|
|
142
|
-
|
|
117
|
+
|
|
118
|
+
// Create the Faust UI
|
|
119
|
+
const { createFaustUI } = await import("./create-node.js");
|
|
120
|
+
await createFaustUI($divFaustUI, faustNode);
|
|
121
|
+
|
|
122
|
+
// Connect the Faust node to the audio output
|
|
143
123
|
faustNode.connect(audioContext.destination);
|
|
144
|
-
|
|
124
|
+
|
|
125
|
+
// Build the audio device menu
|
|
126
|
+
if (faustNode.numberOfInputs > 0) await buildAudioDeviceMenu(faustNode);
|
|
145
127
|
else $spanAudioInput.hidden = true;
|
|
128
|
+
|
|
129
|
+
// Build the MIDI device menu
|
|
146
130
|
if (navigator.requestMIDIAccess) await buildMidiDeviceMenu(faustNode);
|
|
147
131
|
else $spanMidiInput.hidden = true;
|
|
132
|
+
|
|
133
|
+
// Set the title and enable the DSP button
|
|
148
134
|
$buttonDsp.disabled = false;
|
|
149
135
|
document.title = name;
|
|
150
136
|
let motionHandlersBound = false;
|
|
151
137
|
$buttonDsp.onclick = async () => {
|
|
138
|
+
// Activate sensor listeners
|
|
152
139
|
if (!motionHandlersBound) {
|
|
153
140
|
await faustNode.listenSensors();
|
|
154
141
|
motionHandlersBound = true;
|