MMPCreator
This commit is contained in:
1 parent
0dda2b1b0c
commit
8395783986
22 files changed
+2883
-460
No files matched your search
@@ -0,0 +1,27 @@
|
||||
// js/utils.js
|
||||
|
||||
export function getTotalSteps() {
|
||||
const compassoAInput = document.getElementById("compasso-a-input");
|
||||
const compassoBInput = document.getElementById("compasso-b-input");
|
||||
const beatsPerBar = parseInt(compassoAInput.value, 10) || 4;
|
||||
const noteValue = parseInt(compassoBInput.value, 10) || 4;
|
||||
const subdivisions = Math.round(16 / noteValue);
|
||||
return beatsPerBar * subdivisions;
|
||||
}
|
||||
|
||||
export function enforceNumericInput(event) {
|
||||
event.target.value = event.target.value.replace(/[^0-9]/g, "");
|
||||
}
|
||||
|
||||
export function adjustValue(inputElement, step) {
|
||||
let currentValue = parseInt(inputElement.value, 10) || 0;
|
||||
let min = parseInt(inputElement.dataset.min, 10);
|
||||
let max = parseInt(inputElement.dataset.max, 10);
|
||||
let newValue = currentValue + step;
|
||||
if (!isNaN(min) && newValue < min) newValue = min;
|
||||
if (!isNaN(max) && newValue > max) newValue = max;
|
||||
inputElement.value = newValue;
|
||||
|
||||
// Dispara um evento 'input' para que outros listeners (como o que redesenha o sequenciador) sejam acionados.
|
||||
inputElement.dispatchEvent(new Event("input", { bubbles: true }));
|
||||
}
|
||||
Reference in new issue
Block a user