Add MP3 download to UX test page.

Installs lamejs and adds an MP3 downloader that records the Motif synth output in real time via an output tap, then encodes and downloads as .mp3.
This commit is contained in:
b1rdmania
2025-12-29 09:59:56 +00:00
parent 134867cf93
commit b48fb4b7de
5 changed files with 171 additions and 0 deletions
+19
View File
@@ -138,6 +138,25 @@ export class MotifEngine {
}
}
/**
* Connect an additional output tap node to the synthesis output.
* Useful for recording/export without changing the audible output.
*/
connectOutput(node: AudioNode): void {
if (this.synthesisEngine) {
this.synthesisEngine.connectOutput(node);
}
}
/**
* Disconnect a previously connected output tap node.
*/
disconnectOutput(node: AudioNode): void {
if (this.synthesisEngine) {
this.synthesisEngine.disconnectOutput(node);
}
}
seek(progress: number): void {
if (this.synthesisEngine) {
this.synthesisEngine.seek(progress);
+19
View File
@@ -19,6 +19,25 @@ export class SynthesisEngine {
this.masterGain.gain.value = 0.3;
}
/**
* Connect the master output to an additional node (e.g. recorder tap).
* This does not change the default destination routing.
*/
connectOutput(node: AudioNode): void {
this.masterGain.connect(node);
}
/**
* Disconnect a previously connected output tap.
*/
disconnectOutput(node: AudioNode): void {
try {
this.masterGain.disconnect(node);
} catch {
// ignore (node might not be connected)
}
}
setupLayers(assignments: RoleAssignment[]): void {
// Clean up existing layers
this.cleanupLayers();