adicionando instrumentos no editor de patterns
Deploy / Deploy (push) Successful in 1m58s
Details
Deploy / Deploy (push) Successful in 1m58s
Details
This commit is contained in:
parent
cca7ddd398
commit
14c2a3b658
|
|
@ -698,7 +698,11 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||||
(appState.audio.audioEditorSeekTime ?? 0) ||
|
(appState.audio.audioEditorSeekTime ?? 0) ||
|
||||||
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);
|
let posTicks = secondsToSongTicks(sec, bpm);
|
||||||
posTicks = snapSongTicks(posTicks, LMMS_TICKS_PER_BAR); // snap por compasso (fica LMMS-like)
|
posTicks = snapSongTicks(posTicks, LMMS_TICKS_PER_BAR); // snap por compasso (fica LMMS-like)
|
||||||
|
|
@ -714,10 +718,14 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
|
||||||
|
|
||||||
window.exitPatternFocus = function() {
|
window.exitPatternFocus = function() {
|
||||||
console.log("Saindo do foco da Bassline");
|
console.log("Saindo do foco da Bassline");
|
||||||
appState.pattern.focusedBasslineId = null;
|
appState.pattern.focusedBasslineId = null;
|
||||||
renderAll();
|
|
||||||
}
|
// ✅ sem pattern selecionada no Song Editor
|
||||||
|
appState.pattern.activePatternIndex = null;
|
||||||
|
|
||||||
|
renderAll();
|
||||||
|
}
|
||||||
|
|
||||||
loadAndRenderSampleBrowser();
|
loadAndRenderSampleBrowser();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ export function initializePatternState() {
|
||||||
|
|
||||||
appState.pattern.tracks = [];
|
appState.pattern.tracks = [];
|
||||||
appState.pattern.activeTrackId = null;
|
appState.pattern.activeTrackId = null;
|
||||||
appState.pattern.activePatternIndex = 0;
|
appState.pattern.activePatternIndex = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loadAudioForTrack(track) {
|
export async function loadAudioForTrack(track) {
|
||||||
|
|
|
||||||
|
|
@ -323,21 +323,30 @@ export function updateGlobalPatternSelector() {
|
||||||
globalPatternSelector.innerHTML = '';
|
globalPatternSelector.innerHTML = '';
|
||||||
|
|
||||||
if (referenceTrack && referenceTrack.patterns && referenceTrack.patterns.length > 0) {
|
if (referenceTrack && referenceTrack.patterns && referenceTrack.patterns.length > 0) {
|
||||||
referenceTrack.patterns.forEach((pattern, index) => {
|
const isFocused = !!appState.pattern.focusedBasslineId;
|
||||||
const option = document.createElement('option');
|
const hasSelection = Number.isInteger(appState.pattern.activePatternIndex);
|
||||||
option.value = index;
|
|
||||||
option.textContent = pattern.name;
|
|
||||||
globalPatternSelector.appendChild(option);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (isFocused) {
|
globalPatternSelector.innerHTML = '';
|
||||||
globalPatternSelector.value = appState.pattern.activePatternIndex || 0;
|
|
||||||
} else if (activeTrack) {
|
if (!isFocused && !hasSelection) {
|
||||||
globalPatternSelector.value = activeTrack.activePatternIndex || 0;
|
const ph = document.createElement('option');
|
||||||
} else {
|
ph.value = '';
|
||||||
globalPatternSelector.value = 0;
|
ph.textContent = 'Selecione uma pattern…';
|
||||||
}
|
ph.disabled = true;
|
||||||
globalPatternSelector.disabled = false;
|
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 {
|
} else {
|
||||||
const option = document.createElement('option');
|
const option = document.createElement('option');
|
||||||
option.textContent = 'Sem patterns';
|
option.textContent = 'Sem patterns';
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import { DEFAULT_VOLUME, DEFAULT_PAN } from "./config.js";
|
||||||
const patternState = {
|
const patternState = {
|
||||||
tracks: [],
|
tracks: [],
|
||||||
activeTrackId: null,
|
activeTrackId: null,
|
||||||
activePatternIndex: 0,
|
activePatternIndex: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const globalState = {
|
const globalState = {
|
||||||
|
|
@ -164,7 +164,7 @@ export function resetProjectState() {
|
||||||
Object.assign(appState.pattern, {
|
Object.assign(appState.pattern, {
|
||||||
tracks: [],
|
tracks: [],
|
||||||
activeTrackId: null,
|
activeTrackId: null,
|
||||||
activePatternIndex: 0,
|
activePatternIndex: null,
|
||||||
focusedBasslineId: null,
|
focusedBasslineId: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue