teste
This commit is contained in:
1 parent
42da68afa0
commit
12c5b55bce
29 files changed
+162410
-343433
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import { TripleOscillator } from "./plugins/TripleOscillator.js";
|
||||
import { PLUGINS } from "utils.js";
|
||||
|
||||
export class InstrumentFactory {
|
||||
constructor() {
|
||||
// Cria um contexto de áudio único para a página
|
||||
this.audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
||||
}
|
||||
|
||||
play(instrumentData) {
|
||||
// Pega o nome do plugin (que vem do python em minúsculo)
|
||||
// O parser as vezes bota o nome na raiz ou dentro de tags.
|
||||
// Vamos assumir que o "instrument_name" é a chave principal.
|
||||
|
||||
// Normalização de nome (ex: "TripleOscillator" -> "tripleoscillator")
|
||||
const pluginName = (
|
||||
instrumentData.instrument_name ||
|
||||
instrumentData.name ||
|
||||
""
|
||||
).toLowerCase();
|
||||
|
||||
if (PLUGINS[pluginName]) {
|
||||
const InstrumentClass = PLUGINS[pluginName];
|
||||
const instr = new InstrumentClass(this.audioCtx, instrumentData);
|
||||
|
||||
// Toca uma nota de teste (Dó central - MIDI 60)
|
||||
instr.playNote(60, this.audioCtx.currentTime, 0.5);
|
||||
} else {
|
||||
console.warn(`Plugin não implementado no JS: ${pluginName}`);
|
||||
alert(`O plugin ${pluginName} ainda não tem implementação Web Audio.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user