adicionando instrumentos no editor de patterns
Deploy / Deploy (push) Successful in 1m58s Details

This commit is contained in:
JotaChina 2025-12-27 20:32:22 -03:00
parent cca7ddd398
commit 14c2a3b658
4 changed files with 39 additions and 22 deletions

View File

@ -698,7 +698,11 @@ document.addEventListener("DOMContentLoaded", () => {
(appState.audio.audioEditorSeekTime ?? 0) ||
0;
const patternIndex = appState.pattern.activePatternIndex || 0;
const patternIndex = appState.pattern.activePatternIndex;
if (!Number.isInteger(patternIndex)) {
showToast("Selecione uma pattern antes de enviar.", "error");
return;
}
let posTicks = secondsToSongTicks(sec, bpm);
posTicks = snapSongTicks(posTicks, LMMS_TICKS_PER_BAR); // snap por compasso (fica LMMS-like)
@ -714,10 +718,14 @@ document.addEventListener("DOMContentLoaded", () => {
window.exitPatternFocus = function() {
console.log("Saindo do foco da Bassline");
appState.pattern.focusedBasslineId = null;
renderAll();
}
console.log("Saindo do foco da Bassline");
appState.pattern.focusedBasslineId = null;
// ✅ sem pattern selecionada no Song Editor
appState.pattern.activePatternIndex = null;
renderAll();
}
loadAndRenderSampleBrowser();

View File

@ -26,7 +26,7 @@ export function initializePatternState() {
appState.pattern.tracks = [];
appState.pattern.activeTrackId = null;
appState.pattern.activePatternIndex = 0;
appState.pattern.activePatternIndex = null;
}
export async function loadAudioForTrack(track) {

View File

@ -323,21 +323,30 @@ export function updateGlobalPatternSelector() {
globalPatternSelector.innerHTML = '';
if (referenceTrack && referenceTrack.patterns && referenceTrack.patterns.length > 0) {
referenceTrack.patterns.forEach((pattern, index) => {
const option = document.createElement('option');
option.value = index;
option.textContent = pattern.name;
globalPatternSelector.appendChild(option);
});
const isFocused = !!appState.pattern.focusedBasslineId;
const hasSelection = Number.isInteger(appState.pattern.activePatternIndex);
if (isFocused) {
globalPatternSelector.value = appState.pattern.activePatternIndex || 0;
} else if (activeTrack) {
globalPatternSelector.value = activeTrack.activePatternIndex || 0;
} else {
globalPatternSelector.value = 0;
}
globalPatternSelector.disabled = false;
globalPatternSelector.innerHTML = '';
if (!isFocused && !hasSelection) {
const ph = document.createElement('option');
ph.value = '';
ph.textContent = 'Selecione uma pattern…';
ph.disabled = true;
ph.selected = true;
globalPatternSelector.appendChild(ph);
}
referenceTrack.patterns.forEach((pattern, index) => {
const option = document.createElement('option');
option.value = index;
option.textContent = pattern.name;
globalPatternSelector.appendChild(option);
});
// ✅ em vez de forçar 0
globalPatternSelector.value = hasSelection ? String(appState.pattern.activePatternIndex) : '';
globalPatternSelector.disabled = false;
} else {
const option = document.createElement('option');
option.textContent = 'Sem patterns';

View File

@ -12,7 +12,7 @@ import { DEFAULT_VOLUME, DEFAULT_PAN } from "./config.js";
const patternState = {
tracks: [],
activeTrackId: null,
activePatternIndex: 0,
activePatternIndex: null,
};
const globalState = {
@ -164,7 +164,7 @@ export function resetProjectState() {
Object.assign(appState.pattern, {
tracks: [],
activeTrackId: null,
activePatternIndex: 0,
activePatternIndex: null,
focusedBasslineId: null,
});