adicionando instrumentos no editor de patterns

This commit is contained in:
JotaChina committed 2025-12-27 20:32:22 -03:00
1 parent 2393533c69
commit 1c3938abdd
4 files changed
+39 -22

No files matched your search

+1 -1
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) {
+23 -14
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';