plugin 1.0.1
This commit is contained in:
1 parent
44fce48bb5
commit
018a8c5403
7 files changed
+2681
-26339
No files matched your search
@@ -7,6 +7,7 @@ import { playSample, stopPlayback } from "./pattern_audio.js";
|
||||
import { getTotalSteps } from "../utils.js";
|
||||
import { sendAction } from '../socket.js';
|
||||
import { initializeAudioContext } from '../audio.js';
|
||||
import * as Tone from "https://esm.sh/tone";
|
||||
|
||||
// Função principal de renderização para o editor de patterns
|
||||
export function renderPatternEditor() {
|
||||
@@ -105,7 +106,7 @@ export function redrawSequencer() {
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// LÓGICA DE DECISÃO V2: STEPS OU PIANO ROLL?
|
||||
// LÓGICA DE DECISÃO V2: STEPS OU PIANO ROLL? (MANTIDA)
|
||||
// ============================================================
|
||||
|
||||
const notes = activePattern.notes || [];
|
||||
@@ -117,7 +118,6 @@ export function redrawSequencer() {
|
||||
const isMelodic = notes.some(n => n.key !== firstKey);
|
||||
const hasLongNotes = notes.some(n => n.len > 48);
|
||||
|
||||
// Sobreposição de notas (Acordes)
|
||||
const sortedNotes = [...notes].sort((a, b) => a.pos - b.pos);
|
||||
let hasOverlap = false;
|
||||
for (let i = 0; i < sortedNotes.length - 1; i++) {
|
||||
@@ -153,14 +153,18 @@ export function redrawSequencer() {
|
||||
}
|
||||
});
|
||||
|
||||
// --- CÁLCULO REVERTIDO (VOLTA AO PADRÃO ANTERIOR) ---
|
||||
const barsInput = document.getElementById('bars-input');
|
||||
const barsCount = barsInput ? parseInt(barsInput.value) || 1 : 1;
|
||||
|
||||
// Revertido: Removemos a multiplicação por beatsPerBar que causou o bug visual
|
||||
const totalTicks = 192 * barsCount;
|
||||
// ----------------------------------------------------
|
||||
|
||||
activePattern.notes.forEach(note => {
|
||||
const noteEl = document.createElement('div');
|
||||
noteEl.className = 'mini-note';
|
||||
|
||||
const barsInput = document.getElementById('bars-input');
|
||||
const barsCount = barsInput ? parseInt(barsInput.value) || 1 : 1;
|
||||
const totalTicks = 192 * barsCount;
|
||||
|
||||
const leftPercent = (note.pos / totalTicks) * 100;
|
||||
const widthPercent = (note.len / totalTicks) * 100;
|
||||
|
||||
@@ -200,7 +204,6 @@ export function redrawSequencer() {
|
||||
stepElement.classList.add("active");
|
||||
}
|
||||
|
||||
// --- EVENTO DE CLIQUE (CORRIGIDO PARA PLUGINS) ---
|
||||
stepElement.addEventListener("click", (e) => {
|
||||
e.stopPropagation();
|
||||
initializeAudioContext();
|
||||
@@ -216,18 +219,13 @@ export function redrawSequencer() {
|
||||
isActive: isActive
|
||||
});
|
||||
|
||||
// --- AQUI ESTAVA O PROBLEMA: TOCA O SOM ---
|
||||
if (isActive) {
|
||||
// Caso 1: Sampler (Áudio)
|
||||
if (trackData.type === 'sampler' && trackData.samplePath) {
|
||||
playSample(trackData.samplePath, trackData.id);
|
||||
}
|
||||
// Caso 2: Plugin (Sintetizador)
|
||||
else if (trackData.type === 'plugin' && trackData.instrument) {
|
||||
// Toca um C5 (Dó) curto para feedback visual/sonoro
|
||||
try {
|
||||
// triggerAttackRelease(nota, duração)
|
||||
trackData.instrument.triggerAttackRelease("C5", "16n");
|
||||
trackData.instrument.triggerAttackRelease("C5", "16n", Tone.now());
|
||||
} catch(err) {
|
||||
console.warn("Erro ao tocar preview do synth:", err);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user