Skip to content

Commit

Permalink
Make build has to be used.
Browse files Browse the repository at this point in the history
  • Loading branch information
sletz committed Oct 5, 2024
1 parent 778682f commit a7a1088
Show file tree
Hide file tree
Showing 125 changed files with 13,965 additions and 878 deletions.
6 changes: 3 additions & 3 deletions docs/gamelan/atomicro/dsp-meta.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "atomicro",
"filename": "atomicro.dsp",
"version": "2.75.3",
"version": "2.75.7",
"compile_options": "-lang wasm-i -ct 1 -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 2",
"include_pathnames": [
"/share/faust",
Expand All @@ -10,7 +10,7 @@
"."
],
"size": 5041144,
"code": "wJa+",
"code": "8Ia+",
"inputs": 1,
"outputs": 1,
"meta": [
Expand Down Expand Up @@ -87,7 +87,7 @@
"signals_lib_version": "1.6.0"
},
{
"version": "2.75.7"
"version": "2.75.10"
}
],
"ui": [
Expand Down
Binary file modified docs/gamelan/atomicro/dsp-module.wasm
Binary file not shown.
10 changes: 8 additions & 2 deletions docs/gamelan/atomicro/faustwasm/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1289,8 +1289,11 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
protected fUICallback: UIHandler;
protected fDescriptor: FaustUIInputItem[];
constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options?: Partial<FaustAudioWorkletNodeOptions<Poly>>);
private handleDeviceMotion;
private handleDeviceOrientation;
/** Setup accelerometer and gyroscope handlers */
listenSensors(): Promise<void>;
startSensors(): Promise<void>;
stopSensors(): void;
setOutputParamHandler(handler: OutputParamHandler | null): void;
getOutputParamHandler(): OutputParamHandler | null;
setComputeHandler(handler: ComputeHandler | null): void;
Expand Down Expand Up @@ -1353,8 +1356,11 @@ export declare class FaustScriptProcessorNode<Poly extends boolean = false> exte
protected fInputs: Float32Array[];
protected fOutputs: Float32Array[];
init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp): void;
private handleDeviceMotion;
private handleDeviceOrientation;
/** Setup accelerometer and gyroscope handlers */
listenSensors(): Promise<void>;
startSensors(): Promise<void>;
stopSensors(): void;
compute(input: Float32Array[], output: Float32Array[]): boolean;
setOutputParamHandler(handler: OutputParamHandler): void;
getOutputParamHandler(): OutputParamHandler | null;
Expand Down
99 changes: 63 additions & 36 deletions docs/gamelan/atomicro/faustwasm/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/gamelan/atomicro/faustwasm/index.js.map

Large diffs are not rendered by default.

72 changes: 64 additions & 8 deletions docs/gamelan/atomicro/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ audioContext.suspend();

(async () => {

const { createFaustNode } = await import("./create-node.js");
// To test the ScriptProcessorNode mode
// const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "osc", FAUST_DSP_VOICES, true);
const { createFaustNode } = await import("./create-node.js");
const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "osc", FAUST_DSP_VOICES);
if (!faustNode) throw new Error("Faust DSP not compiled");

Expand All @@ -50,8 +50,8 @@ audioContext.suspend();
await connectToAudioInput(audioContext, null, faustNode, null);
}

// Function to initialize MIDI
function initMIDI() {
// Function to start MIDI
function startMIDI() {
// Check if the browser supports the Web MIDI API
if (navigator.requestMIDIAccess) {
navigator.requestMIDIAccess().then(
Expand All @@ -69,25 +69,81 @@ audioContext.suspend();
}
}

// Function to stop MIDI
function stopMIDI() {
// Check if the browser supports the Web MIDI API
if (navigator.requestMIDIAccess) {
navigator.requestMIDIAccess().then(
midiAccess => {
console.log("MIDI Access obtained.");
for (let input of midiAccess.inputs.values()) {
input.onmidimessage = null;
console.log(`Disconnected from input: ${input.name}`);
}
},
() => console.error("Failed to access MIDI devices.")
);
} else {
console.log("Web MIDI API is not supported in this browser.");
}
}

let sensorHandlersBound = false;
let midiHandlersBound = false;

// Function to resume AudioContext, activate MIDI and Sensors on user interaction
function activateAudioMIDISensors() {
async function activateAudioMIDISensors() {

// Resume the AudioContext
if (audioContext.state === 'suspended') {
audioContext.resume();
await audioContext.resume();
}

// Activate sensor listeners
faustNode.listenSensors();
if (!sensorHandlersBound) {
await faustNode.startSensors();
sensorHandlersBound = true;
}

// Initialize the MIDI setup
if (FAUST_DSP_VOICES > 0) {
initMIDI();
if (!midiHandlersBound && FAUST_DSP_VOICES > 0) {
startMIDI();
midiHandlersBound = true;
}
}

// Function to suspend AudioContext, deactivate MIDI and Sensors on user interaction
async function deactivateAudioMIDISensors() {

// Suspend the AudioContext
if (audioContext.state === 'running') {
await audioContext.suspend();
}

// Deactivate sensor listeners
if (sensorHandlersBound) {
faustNode.stopSensors();
sensorHandlersBound = false;
}

// Deactivate the MIDI setup
if (midiHandlersBound && FAUST_DSP_VOICES > 0) {
stopMIDI();
midiHandlersBound = false;
}
}

// Add event listeners for user interactions

// Activate AudioContext, MIDI and Sensors on user interaction
window.addEventListener('click', activateAudioMIDISensors);
window.addEventListener('touchstart', activateAudioMIDISensors);

// Deactivate AudioContext, MIDI and Sensors on user interaction
window.addEventListener('visibilitychange', function () {
if (window.visibilityState === 'hidden') {
deactivateAudioMIDISensors();
}
});

})();
5 changes: 3 additions & 2 deletions docs/gamelan/attackey/dsp-meta.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "attackey",
"filename": "attackey.dsp",
"version": "2.75.3",
"version": "2.75.7",
"compile_options": "-lang wasm-i -ct 1 -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 2",
"include_pathnames": [
"/share/faust",
Expand All @@ -10,6 +10,7 @@
"."
],
"size": 844636,
"code": "MPs0AZQTHw==",
"inputs": 0,
"outputs": 2,
"meta": [
Expand Down Expand Up @@ -185,7 +186,7 @@
"soundfiles": "https://raw.githubusercontent.com/grame-cncm/GameLAN/master/attacKey"
},
{
"version": "2.75.7"
"version": "2.75.10"
}
],
"ui": [
Expand Down
Binary file modified docs/gamelan/attackey/dsp-module.wasm
Binary file not shown.
Loading

0 comments on commit a7a1088

Please sign in to comment.