table layout for modulators

This commit is contained in:
Eveline-97 2025-06-29 17:53:12 +02:00
parent 501fca079e
commit 07c4826bd9
3 changed files with 178 additions and 152 deletions

View File

@ -3,12 +3,31 @@
--unlocked-color: #ff5153; --unlocked-color: #ff5153;
} }
:root {
--background: ivory;
--active: royalblue;
--nonactive: lightsteelblue;
--alert: red;
--textcolor: #737373;
}
@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
html {
background-color: var(--background);
}
body {
font-family: "Poppins", sans-serif;
}
html, body { html, body {
width: 100%; width: 100%;
height: 100%; height: 100%;
margin: 0px; margin: 0px;
border: 0; border: 0;
overflow: hidden; /* Disable scrollbars */ overflow-x: hidden; /* no horizontal scrollbar*/
overflow-y: scroll;
display: block; /* No floating content on sides */ display: block; /* No floating content on sides */
} }
@ -24,6 +43,9 @@ li {
float: left; float: left;
} }
table {
overflow: scroll;
}
input[type=number] { input[type=number] {
width: 50px; width: 50px;
@ -192,7 +214,7 @@ h5 {
color : white; color : white;
} }
.container { .header {
display: flex; display: flex;
width: 100%; width: 100%;
justify-content: space-between; justify-content: space-between;

200
lfogui.js
View File

@ -4,7 +4,7 @@ var log;
if (DEBUG) if (DEBUG)
log = console.log; log = console.log;
else else
log = (msg) => {window.max.outlet("debug " + msg)}; log = (msg) => { window.max.outlet("debug " + msg) };
const e = React.createElement; const e = React.createElement;
@ -17,37 +17,37 @@ const MAXUSERDEFINED = 4;
const ViewModes = Object.freeze({ const ViewModes = Object.freeze({
MOD: 0, MOD: 0,
ENUM: 1 ENUM: 1
}); });
const LockModes = Object.freeze({ const LockModes = Object.freeze({
UNLOCK: 0, UNLOCK: 0,
LOCK: 1 LOCK: 1
}); });
var modPhases = Array(MAXLFOS).fill(0); var modPhases = Array(MAXLFOS).fill(0);
var firstUpdateTime = Date.now(); var firstUpdateTime = Date.now();
const MODULATORLABELS = ["inst", "-type-", "---shape---", "-------param-------", "--timebase--", "-min-", "-max", "-phase-", "center"]; const MODULATORLABELS = ["inst", "type", "shape", "param", "timebase", "min", "max", "phase", "center"];
const ENUMERATORLABELS = ["inst", "---parameter---", "-# points-"]; const ENUMERATORLABELS = ["inst", "parameter", "# points"];
function parseLfoTimeNonMusical(lfoTime){ function parseLfoTimeNonMusical(lfoTime) {
if (lfoTime.slice(-2) == "hz"){ if (lfoTime.slice(-2) == "hz") {
return parseFloat(lfoTime.slice(0, -2)); return parseFloat(lfoTime.slice(0, -2));
} }
else if (lfoTime.slice(-2) == "ms"){ else if (lfoTime.slice(-2) == "ms") {
return 1000 / parseFloat(lfoTime.slice(0, -2)); return 1000 / parseFloat(lfoTime.slice(0, -2));
} }
else if (lfoTime.slice(-1) == "s"){ else if (lfoTime.slice(-1) == "s") {
return 1 / parseFloat(lfoTime.slice(0, -1)); return 1 / parseFloat(lfoTime.slice(0, -1));
} }
else if ((lfoTime.match(/:/g) || []).length == 2){ else if ((lfoTime.match(/:/g) || []).length == 2) {
return 1 / moment.duration(lfoTime).asSeconds(); return 1 / moment.duration(lfoTime).asSeconds();
} }
else if ((lfoTime.match(/\./g) || []).length == 2){ else if ((lfoTime.match(/\./g) || []).length == 2) {
return 0; // ignore musical timings return 0; // ignore musical timings
} }
else { else {
@ -55,12 +55,12 @@ function parseLfoTimeNonMusical(lfoTime){
} }
} }
function nnFreqToHzString(num){ function nnFreqToHzString(num) {
return `${num}hz`; return `${num}hz`;
} }
function MasterLfoHandler(){ function MasterLfoHandler() {
let initVisArr = Array(MAXLFOS).fill(false); let initVisArr = Array(MAXLFOS).fill(false);
initVisArr[0] = true; initVisArr[0] = true;
@ -85,7 +85,7 @@ function MasterLfoHandler(){
let userDefinedFunctionsBase = []; let userDefinedFunctionsBase = [];
let userDefinedTypesBase = [0, 0, 0, 0]; //0 = wave, 1 = function let userDefinedTypesBase = [0, 0, 0, 0]; //0 = wave, 1 = function
for (let i=0; i<MAXUSERDEFINED; i++){ for (let i = 0; i < MAXUSERDEFINED; i++) {
userDefinedWavesBase.push(Array(50).fill(0)); userDefinedWavesBase.push(Array(50).fill(0));
userDefinedFunctionsBase.push(Array(101).fill(0)); userDefinedFunctionsBase.push(Array(101).fill(0));
} }
@ -96,7 +96,7 @@ function MasterLfoHandler(){
const [modTypeArr, setModTypeArr] = React.useState(Array(MAXLFOS).fill('LFO')); const [modTypeArr, setModTypeArr] = React.useState(Array(MAXLFOS).fill('LFO'));
const [modInstanceNumArr, setModInstanceNumArr] = React.useState(Array(MAXLFOS).fill('1')); const [modInstanceNumArr, setModInstanceNumArr] = React.useState(Array(MAXLFOS).fill('1'));
const [modCenterVals, setModCenterVals] = React.useState({'1':{}, '2':{}, '3':{}, '4':{}}); const [modCenterVals, setModCenterVals] = React.useState({ '1': {}, '2': {}, '3': {}, '4': {} });
const [ticks, setTicks] = React.useState(0); const [ticks, setTicks] = React.useState(0);
const [beatsInMeasure, setBeatsInMeasure] = React.useState(4); const [beatsInMeasure, setBeatsInMeasure] = React.useState(4);
@ -129,9 +129,9 @@ function MasterLfoHandler(){
const [enumItemCounts, setEnumItemCounts] = React.useState(Array(MAXENUMPOINTS).fill('2')); const [enumItemCounts, setEnumItemCounts] = React.useState(Array(MAXENUMPOINTS).fill('2'));
const [enumDjParamArr, setEnumDjParamArr] = React.useState(Array(MAXENUMPOINTS).fill('NONE')); const [enumDjParamArr, setEnumDjParamArr] = React.useState(Array(MAXENUMPOINTS).fill('NONE'));
let baseEnumBreakpoints = Array(MAXENUMS).fill(0).map(x => Array(MAXENUMPOINTS+ 1).fill(0)); let baseEnumBreakpoints = Array(MAXENUMS).fill(0).map(x => Array(MAXENUMPOINTS + 1).fill(0));
for (let i = 0; i < MAXENUMS; i++){ for (let i = 0; i < MAXENUMS; i++) {
for (let j=0; j < MAXENUMPOINTS + 1; j++){ for (let j = 0; j < MAXENUMPOINTS + 1; j++) {
baseEnumBreakpoints[i][j] = j - 0.5; baseEnumBreakpoints[i][j] = j - 0.5;
} }
} }
@ -139,12 +139,12 @@ function MasterLfoHandler(){
const getBlankEnumBreakPointRow = () => { const getBlankEnumBreakPointRow = () => {
let arr = [] let arr = []
for (let i=0; i< MAXENUMPOINTS + 1; i++) for (let i = 0; i < MAXENUMPOINTS + 1; i++)
arr.push(i - 0.5) arr.push(i - 0.5)
return arr; return arr;
} }
const getBlankEnumNameRow = () => {return Array(MAXENUMPOINTS).fill('param')}; const getBlankEnumNameRow = () => { return Array(MAXENUMPOINTS).fill('param') };
let baseEnumNames = Array(MAXENUMS).fill(0).map(x => Array(MAXENUMPOINTS).fill('param')); let baseEnumNames = Array(MAXENUMS).fill(0).map(x => Array(MAXENUMPOINTS).fill('param'));
const [enumNames, setEnumNames] = React.useState(baseEnumNames); const [enumNames, setEnumNames] = React.useState(baseEnumNames);
@ -166,13 +166,13 @@ function MasterLfoHandler(){
function handleLoad(event) { function handleLoad(event) {
window.max.getDict(event.detail, (dict) => { window.max.getDict(event.detail, (dict) => {
for (let i = 0; i<dict.data.modArrays.length; i++) { for (let i = 0; i < dict.data.modArrays.length; i++) {
allModSetters[i](dict.data.modArrays[i]); allModSetters[i](dict.data.modArrays[i]);
} }
for (let i = 0; i<allEnumArrays.length; i++) { for (let i = 0; i < allEnumArrays.length; i++) {
allEnumArrSetters[i](dict.data.enumArrays[i]); allEnumArrSetters[i](dict.data.enumArrays[i]);
} }
for (let i = 0; i<allEnumMats.length; i++) { for (let i = 0; i < allEnumMats.length; i++) {
allEnumMatSetters[i](dict.data.enumMats[i]); allEnumMatSetters[i](dict.data.enumMats[i]);
} }
}) })
@ -180,29 +180,29 @@ function MasterLfoHandler(){
function handleSave(event) { function handleSave(event) {
let data = { let data = {
'modArrays' : allModArrays, 'modArrays': allModArrays,
'enumArrays' : allEnumArrays, 'enumArrays': allEnumArrays,
'enumMats' : allEnumMats 'enumMats': allEnumMats
} }
window.max.setDict(event.detail, {"data" : data}); window.max.setDict(event.detail, { "data": data });
window.max.outlet("saved"); window.max.outlet("saved");
} }
// only called internally by 1. Handler after modulator processing 2. LFO outputs // only called internally by 1. Handler after modulator processing 2. LFO outputs
function handleEnum(event){ function handleEnum(event) {
let inst = event.detail[0]; let inst = event.detail[0];
let name = event.detail[1]; let name = event.detail[1];
let val = event.detail[2]; let val = event.detail[2];
// if none of the Enums use this param, then we output it // if none of the Enums use this param, then we output it
let i = 0; let i = 0;
while (i < MAXENUMS){ while (i < MAXENUMS) {
if (enumVisibleArr[i] && enumDjParamArr[i] == name && enumInstanceNumArr[i] == inst) if (enumVisibleArr[i] && enumDjParamArr[i] == name && enumInstanceNumArr[i] == inst)
break; break;
i++ i++
} }
if (i == MAXENUMS){ if (i == MAXENUMS) {
window.max.outlet(inst + ' ' + name + ' ' + val); window.max.outlet(inst + ' ' + name + ' ' + val);
} }
else { else {
@ -219,25 +219,25 @@ function MasterLfoHandler(){
let val = event.detail[2]; let val = event.detail[2];
// CHECK FOR INDEX OF THIS NAME IN ENUM MATRIX, AND IF IT IS THERE DENUMERATE // CHECK FOR INDEX OF THIS NAME IN ENUM MATRIX, AND IF IT IS THERE DENUMERATE
let index = -1; let index = -1;
for (let i = 0; i < MAXENUMS; i++){ for (let i = 0; i < MAXENUMS; i++) {
if (enumDjParamArr[i] == name && enumInstanceNumArr[i] == inst) if (enumDjParamArr[i] == name && enumInstanceNumArr[i] == inst)
index = i; index = i;
} }
if (index != -1){ if (index != -1) {
val = denumerate(val, enumItemCounts[index], enumBreakPoints[index], enumNames[index]); val = denumerate(val, enumItemCounts[index], enumBreakPoints[index], enumNames[index]);
} }
// if none of the LFOs use this param, then we send it straight to the enum // if none of the LFOs use this param, then we send it straight to the enum
let i = 0; let i = 0;
while (i < MAXLFOS){ while (i < MAXLFOS) {
if (modVisibleArr[i] && djParamArr[i] == name && modInstanceNumArr[i] == inst) if (modVisibleArr[i] && djParamArr[i] == name && modInstanceNumArr[i] == inst)
break; break;
i++; i++;
} }
if (i == MAXLFOS){ if (i == MAXLFOS) {
window.dispatchEvent(new CustomEvent('enum', {'detail' : [inst, name, val]})); window.dispatchEvent(new CustomEvent('enum', { 'detail': [inst, name, val] }));
} }
modCenterVals[inst][name] = val; modCenterVals[inst][name] = val;
@ -249,15 +249,15 @@ function MasterLfoHandler(){
function handleTick(event) { function handleTick(event) {
let time = (Date.now() - firstUpdateTime) / 1000; let time = (Date.now() - firstUpdateTime) / 1000;
let noiseData = {lastPhaseArr, setLastPhaseArr, cachedNoiseValueArr1, setCachedNoiseValueArr1, cachedNoiseValueArr2, setCachedNoiseValueArr2, noiseTypeArr}; let noiseData = { lastPhaseArr, setLastPhaseArr, cachedNoiseValueArr1, setCachedNoiseValueArr1, cachedNoiseValueArr2, setCachedNoiseValueArr2, noiseTypeArr };
operateModulators(modVisibleArr, modTypeArr, modInstanceNumArr, djParamArr, modCenterVals, freqArr, minArr, maxArr, shapeArr, initPhaseArr, noiseData, userDefinedWaves, userDefinedFunctions, userDefinedTypes, time, beatsInMeasure, ticks); operateModulators(modVisibleArr, modTypeArr, modInstanceNumArr, djParamArr, modCenterVals, freqArr, minArr, maxArr, shapeArr, initPhaseArr, noiseData, userDefinedWaves, userDefinedFunctions, userDefinedTypes, time, beatsInMeasure, ticks);
} }
function handleTimeSig(event) { function handleTimeSig(event) {
setBeatsInMeasure(parseFloat(event.detail[0]) * parseFloat(event.detail[1])/ 4); setBeatsInMeasure(parseFloat(event.detail[0]) * parseFloat(event.detail[1]) / 4);
} }
function handleChangeUserWave(event){ function handleChangeUserWave(event) {
userDefinedWaves[event.detail.index] = event.detail.points; userDefinedWaves[event.detail.index] = event.detail.points;
setUserDefinedWaves(userDefinedWaves); setUserDefinedWaves(userDefinedWaves);
} }
@ -268,39 +268,39 @@ function MasterLfoHandler(){
} }
function handleChangeUserDefinedType(event) { function handleChangeUserDefinedType(event) {
userDefinedTypes[event.detail.index-1] = event.detail.type; userDefinedTypes[event.detail.index - 1] = event.detail.type;
setUserDefinedTypes(userDefinedTypes); setUserDefinedTypes(userDefinedTypes);
} }
function handleMaxTicks(event){ function handleMaxTicks(event) {
setTicks(event.detail); setTicks(event.detail);
} }
function setNN(event){ function setNN(event) {
for (let i=0; i<MAXLFOS; i++){ for (let i = 0; i < MAXLFOS; i++) {
freqArr[i] = nnFreqToHzString(event.detail[i]); freqArr[i] = nnFreqToHzString(event.detail[i]);
} }
setFreqArr(freqArr) setFreqArr(freqArr)
for (let i=MAXLFOS; i<MAXLFOS * 2; i++){ for (let i = MAXLFOS; i < MAXLFOS * 2; i++) {
minArr[i - MAXLFOS] = event.detail[i]; minArr[i - MAXLFOS] = event.detail[i];
} }
setMinArr(minArr); setMinArr(minArr);
for (let i=MAXLFOS*2; i<MAXLFOS * 3; i++){ for (let i = MAXLFOS * 2; i < MAXLFOS * 3; i++) {
maxArr[i - MAXLFOS*2] = event.detail[i]; maxArr[i - MAXLFOS * 2] = event.detail[i];
} }
setMaxArr(maxArr); setMaxArr(maxArr);
for (let i=MAXLFOS*3; i<MAXLFOS * 4; i++){ for (let i = MAXLFOS * 3; i < MAXLFOS * 4; i++) {
initPhaseArr[i - MAXLFOS*3] = parseFloat(event.detail[i]); initPhaseArr[i - MAXLFOS * 3] = parseFloat(event.detail[i]);
} }
setInitPhaseArr(initPhaseArr); setInitPhaseArr(initPhaseArr);
for (let i=MAXLFOS*4; i<MAXLFOS * 5; i++){ for (let i = MAXLFOS * 4; i < MAXLFOS * 5; i++) {
let index = i - MAXLFOS*4; let index = i - MAXLFOS * 4;
let inst = modInstanceNumArr[index]; let inst = modInstanceNumArr[index];
let param = djParamArr[index]; let param = djParamArr[index];
modCenterVals[inst][param] = parseFloat(event.detail[i]); modCenterVals[inst][param] = parseFloat(event.detail[i]);
@ -311,7 +311,7 @@ function MasterLfoHandler(){
rerender(!render); // BAD! SHOULD NOT BE DOING THIS! rerender(!render); // BAD! SHOULD NOT BE DOING THIS!
} }
function dumpNN(event){ function dumpNN(event) {
let allNNData = []; let allNNData = [];
freqArr.forEach(element => { freqArr.forEach(element => {
allNNData.push(parseLfoTimeNonMusical(element)); allNNData.push(parseLfoTimeNonMusical(element));
@ -321,7 +321,7 @@ function MasterLfoHandler(){
allNNData = allNNData.concat(initPhaseArr); allNNData = allNNData.concat(initPhaseArr);
let lfoMatchedCenterVals = []; let lfoMatchedCenterVals = [];
for (let i=0; i<MAXLFOS; i++){ for (let i = 0; i < MAXLFOS; i++) {
let inst = modInstanceNumArr[i]; let inst = modInstanceNumArr[i];
let param = djParamArr[i]; let param = djParamArr[i];
lfoMatchedCenterVals.push(modCenterVals[inst][param]); lfoMatchedCenterVals.push(modCenterVals[inst][param]);
@ -364,8 +364,8 @@ function MasterLfoHandler(){
}, [...allModArrays, ...allEnumArrays, ...allEnumMats, userDefinedWaves, userDefinedFunctions, userDefinedTypes, modCenterVals, render, beatsInMeasure, ticks]); }, [...allModArrays, ...allEnumArrays, ...allEnumMats, userDefinedWaves, userDefinedFunctions, userDefinedTypes, modCenterVals, render, beatsInMeasure, ticks]);
function CheckLinked(inst, param, checkInstArr, checkParamArr){ function CheckLinked(inst, param, checkInstArr, checkParamArr) {
for (let i = 0; i < checkInstArr.length; i++){ for (let i = 0; i < checkInstArr.length; i++) {
if (checkInstArr[i] == inst && checkParamArr[i] == param) if (checkInstArr[i] == inst && checkParamArr[i] == param)
return true; return true;
} }
@ -376,14 +376,14 @@ function MasterLfoHandler(){
// Generate Modulators // Generate Modulators
/////// ///////
let modContents = [] let modContents = []
for (var i = 0; i<MAXLFOS; i++){ for (var i = 0; i < MAXLFOS; i++) {
let id = i; let id = i;
modContents.push( modContents.push(
e(LfoRow, { e(LfoRow, {
locked : lockMode, locked: lockMode,
instanceNum : modInstanceNumArr[i], instanceNum: modInstanceNumArr[i],
setInstanceNum: CreateParamChanger(modInstanceNumArr, setModInstanceNumArr, i), setInstanceNum: CreateParamChanger(modInstanceNumArr, setModInstanceNumArr, i),
type: modTypeArr[i], type: modTypeArr[i],
@ -404,7 +404,7 @@ function MasterLfoHandler(){
//setAmp: CreateParamChanger(ampArr, setAmpArr, i), //setAmp: CreateParamChanger(ampArr, setAmpArr, i),
min: minArr[i], min: minArr[i],
setMin : CreateParamChanger(minArr, setMinArr, i), setMin: CreateParamChanger(minArr, setMinArr, i),
max: maxArr[i], max: maxArr[i],
setMax: CreateParamChanger(maxArr, setMaxArr, i), setMax: CreateParamChanger(maxArr, setMaxArr, i),
@ -415,13 +415,13 @@ function MasterLfoHandler(){
linked: CheckLinked(modInstanceNumArr[i], djParamArr[i], enumInstanceNumArr, enumDjParamArr), linked: CheckLinked(modInstanceNumArr[i], djParamArr[i], enumInstanceNumArr, enumDjParamArr),
addLfo: () => { addLfo: () => {
if (id < MAXLFOS - 1){ if (id < MAXLFOS - 1) {
if (modVisibleArr[id + 1]){ if (modVisibleArr[id + 1]) {
let emptyIndex = modVisibleArr.findIndex((item) => !item); let emptyIndex = modVisibleArr.findIndex((item) => !item);
if (emptyIndex != -1){ if (emptyIndex != -1) {
for (var j = 0; j < allModArrays.length; j++){ for (var j = 0; j < allModArrays.length; j++) {
let array = allModArrays[j]; let array = allModArrays[j];
// remove from all arrays // remove from all arrays
array.splice(emptyIndex, 1); array.splice(emptyIndex, 1);
@ -433,7 +433,7 @@ function MasterLfoHandler(){
} }
else { else {
for (var j = 0; j < allModArrays.length; j++){ // no space below, easy. for (var j = 0; j < allModArrays.length; j++) { // no space below, easy.
let array = allModArrays[j]; let array = allModArrays[j];
array[id + 1] = modBlankVals[j]; array[id + 1] = modBlankVals[j];
allModSetters[j](array); allModSetters[j](array);
@ -444,7 +444,7 @@ function MasterLfoHandler(){
} }
}, },
removeLfo: () => { removeLfo: () => {
if (modVisibleArr.filter(x=>x).length > 1){ if (modVisibleArr.filter(x => x).length > 1) {
let newArr = modVisibleArr.slice(); let newArr = modVisibleArr.slice();
newArr[id] = false; newArr[id] = false;
setModVisibleArr(newArr); setModVisibleArr(newArr);
@ -452,7 +452,7 @@ function MasterLfoHandler(){
} }
}, },
null)); null));
} }
@ -460,13 +460,13 @@ function MasterLfoHandler(){
// Generate Enumerators // Generate Enumerators
/////// ///////
let enumContents = [] let enumContents = []
for (var i = 0; i<MAXLFOS; i++){ for (var i = 0; i < MAXLFOS; i++) {
let id = i; let id = i;
enumContents.push( enumContents.push(
e(EnumeratorRow, { e(EnumeratorRow, {
index: i, index: i,
locked : lockMode, locked: lockMode,
instanceNum : enumInstanceNumArr[i], instanceNum: enumInstanceNumArr[i],
setInstanceNum: CreateParamChanger(enumInstanceNumArr, setEnumInstanceNumArr, i), setInstanceNum: CreateParamChanger(enumInstanceNumArr, setEnumInstanceNumArr, i),
enumItems: enumItemCounts[i], enumItems: enumItemCounts[i],
setEnumItemCounts: CreateParamChanger(enumItemCounts, setEnumItemCounts, i), setEnumItemCounts: CreateParamChanger(enumItemCounts, setEnumItemCounts, i),
@ -479,11 +479,11 @@ function MasterLfoHandler(){
setDjParam: CreateParamChanger(enumDjParamArr, setEnumDjParamArr, i), setDjParam: CreateParamChanger(enumDjParamArr, setEnumDjParamArr, i),
linked: CheckLinked(enumInstanceNumArr[i], enumDjParamArr[i], modInstanceNumArr, djParamArr), linked: CheckLinked(enumInstanceNumArr[i], enumDjParamArr[i], modInstanceNumArr, djParamArr),
addEnum: () => { addEnum: () => {
if (id < MAXLFOS - 1){ if (id < MAXLFOS - 1) {
if (enumVisibleArr[id + 1]){ // if we need to open up space if (enumVisibleArr[id + 1]) { // if we need to open up space
let emptyIndex = enumVisibleArr.findIndex((item) => !item); let emptyIndex = enumVisibleArr.findIndex((item) => !item);
if (emptyIndex != -1){ if (emptyIndex != -1) {
for (var j = 0; j < allEnumArrays.length; j++){ for (var j = 0; j < allEnumArrays.length; j++) {
let array = allEnumArrays[j]; let array = allEnumArrays[j];
// remove from all arrays // remove from all arrays
array.splice(emptyIndex, 1); array.splice(emptyIndex, 1);
@ -494,7 +494,7 @@ function MasterLfoHandler(){
// Now do the same with matrices // Now do the same with matrices
for (var j = 0; j < allEnumMats.length; j++){ for (var j = 0; j < allEnumMats.length; j++) {
let mat = allEnumMats[j]; let mat = allEnumMats[j];
mat.splice(emptyIndex, 1); mat.splice(emptyIndex, 1);
mat.splice(id + 1, 0, 0); mat.splice(id + 1, 0, 0);
@ -504,15 +504,15 @@ function MasterLfoHandler(){
} }
} }
else { else {
for (var j = 0; j < allEnumArrays.length; j++){ for (var j = 0; j < allEnumArrays.length; j++) {
let array = allEnumArrays[j]; let array = allEnumArrays[j];
array[id+1] = enumBlankVals[j]; array[id + 1] = enumBlankVals[j];
allEnumArrSetters[j](array); allEnumArrSetters[j](array);
} }
// Now do the same with matrices // Now do the same with matrices
for (var j = 0; j < allEnumMats.length; j++){ for (var j = 0; j < allEnumMats.length; j++) {
let mat = allEnumMats[j]; let mat = allEnumMats[j];
mat[id + 1] = allGetEnumMatBlankVals[j](); mat[id + 1] = allGetEnumMatBlankVals[j]();
allEnumMatSetters[j](mat); allEnumMatSetters[j](mat);
@ -522,7 +522,7 @@ function MasterLfoHandler(){
} }
}, },
removeEnum: () => { removeEnum: () => {
if (enumVisibleArr.filter(x=>x).length > 1){ if (enumVisibleArr.filter(x => x).length > 1) {
let newArr = enumVisibleArr.slice(); let newArr = enumVisibleArr.slice();
newArr[id] = false; newArr[id] = false;
setEnumVisibleArr(newArr); setEnumVisibleArr(newArr);
@ -536,7 +536,7 @@ function MasterLfoHandler(){
var grid; var grid;
var title; var title;
var labels; var labels;
if (viewMode === ViewModes.MOD){ if (viewMode === ViewModes.MOD) {
grid = modContents; grid = modContents;
title = "MODULATORS"; title = "MODULATORS";
labels = MODULATORLABELS; labels = MODULATORLABELS;
@ -548,7 +548,7 @@ function MasterLfoHandler(){
} }
let lockClass; let lockClass;
if (lockMode == LockModes.LOCK){ if (lockMode == LockModes.LOCK) {
lockClass = 'lock'; lockClass = 'lock';
} }
else { else {
@ -556,23 +556,25 @@ function MasterLfoHandler(){
} }
return e('div', null, return e('div', null,
e('div', {className: 'container'}, e('div', { className: 'header' },
e(Switch, {ontoggle: toggleViewMode}, null), e(Switch, { ontoggle: toggleViewMode }, null),
e('span', {className: lockClass, onClick: toggleLockMode}, null)), e('span', { className: lockClass, onClick: toggleLockMode }, null)),
e('h5', null, title), //e('h5', null, title),
e('ul', null, ...labels.map(x => ListItem(Label(x)))), e('table', { id: 'table' },
e('div', {id: 'grid'}, ...grid) e('thead', null, e('tr', { id: 'headers' }, ...labels.map(x => e('th', null, x)))),
e('tbody', null, ...grid)
)
); );
} }
if (!DEBUG){ if (!DEBUG) {
window.max.bindInlet("load", (dictId) => { window.max.bindInlet("load", (dictId) => {
window.dispatchEvent(new CustomEvent('loadDict', {'detail' : dictId})); window.dispatchEvent(new CustomEvent('loadDict', { 'detail': dictId }));
}); });
window.max.bindInlet("save", (dictId) => { window.max.bindInlet("save", (dictId) => {
window.dispatchEvent(new CustomEvent('saveDict', {'detail' : dictId})); window.dispatchEvent(new CustomEvent('saveDict', { 'detail': dictId }));
}); });
window.max.bindInlet("dumpNN", () => { window.max.bindInlet("dumpNN", () => {
@ -580,35 +582,35 @@ if (!DEBUG){
}); });
window.max.bindInlet("setNN", (...data) => { window.max.bindInlet("setNN", (...data) => {
window.dispatchEvent(new CustomEvent('setNN', {'detail' : data})); window.dispatchEvent(new CustomEvent('setNN', { 'detail': data }));
}); });
window.max.bindInlet("param", (inst, paramName, val) => { window.max.bindInlet("param", (inst, paramName, val) => {
window.dispatchEvent(new CustomEvent('param', {'detail' : [inst, paramName, val]})); window.dispatchEvent(new CustomEvent('param', { 'detail': [inst, paramName, val] }));
}); });
window.max.bindInlet("timesig", (top, bottom) => { window.max.bindInlet("timesig", (top, bottom) => {
window.dispatchEvent(new CustomEvent('timesig', {'detail' : [top, bottom]})); window.dispatchEvent(new CustomEvent('timesig', { 'detail': [top, bottom] }));
}); });
window.max.bindInlet("ticks", (val) => { window.max.bindInlet("ticks", (val) => {
window.dispatchEvent(new CustomEvent('maxTicks', {'detail' : val})); window.dispatchEvent(new CustomEvent('maxTicks', { 'detail': val }));
}); });
window.max.bindInlet("userWave", (index, ...points) => { window.max.bindInlet("userWave", (index, ...points) => {
let data = {points, index}; let data = { points, index };
window.dispatchEvent(new CustomEvent('userWave', {'detail' : data})); window.dispatchEvent(new CustomEvent('userWave', { 'detail': data }));
}); });
window.max.bindInlet("userFunction", (index, ...points) => { window.max.bindInlet("userFunction", (index, ...points) => {
//list of 101 points between 0-100 //list of 101 points between 0-100
let data = {points, index}; let data = { points, index };
window.dispatchEvent(new CustomEvent('userFunction', {'detail': data})); window.dispatchEvent(new CustomEvent('userFunction', { 'detail': data }));
}); });
window.max.bindInlet("userDefinedType", (index, type) => { window.max.bindInlet("userDefinedType", (index, type) => {
let data = {index, type}; let data = { index, type };
window.dispatchEvent(new CustomEvent('userDefinedType', {'detail': data})); window.dispatchEvent(new CustomEvent('userDefinedType', { 'detail': data }));
}) })
setInterval(() => { setInterval(() => {

View File

@ -22,7 +22,9 @@ function ControlType(){
return e('select', {className: 'control-type'}, Option("LFO")); return e('select', {className: 'control-type'}, Option("LFO"));
} }
function DataCell(element) {
return e('td', null, element);
}
function LfoRow(props){ function LfoRow(props){
@ -34,27 +36,27 @@ function LfoRow(props){
let typeOption = null; let typeOption = null;
if (props.type == "LFO"){ if (props.type == "LFO"){
typeOption = ListItem(DropDown({locked:props.locked, onChange: props.setShape, value:props.shape, options: SHAPETYPES})); typeOption = DataCell(DropDown({locked:props.locked, onChange: props.setShape, value:props.shape, options: SHAPETYPES}));
} }
else if (props.type == "Noise"){ else if (props.type == "Noise"){
typeOption = ListItem(DropDown({locked:props.locked, onChange: props.setNoise, value:props.noise, options: NOISETYPES})); typeOption = DataCell(DropDown({locked:props.locked, onChange: props.setNoise, value:props.noise, options: NOISETYPES}));
} }
let content = e('ul', {className: 'lfo-item'}, let content = e('tr', {className: 'lfo-item'},
ListItem(DropDown({locked:props.locked, onChange: props.setInstanceNum, value:props.instanceNum, options: INSTANCEOPTIONS})), DataCell(DropDown({locked:props.locked, onChange: props.setInstanceNum, value:props.instanceNum, options: INSTANCEOPTIONS})),
ListItem(DropDown({locked:props.locked, options: TYPEOPTIONS, onChange: props.setType, value:props.type})), DataCell(DropDown({locked:props.locked, options: TYPEOPTIONS, onChange: props.setType, value:props.type})),
typeOption, typeOption,
ListItem(DropDown({locked:props.locked, onChange: props.setDjParam, value: props.djParam, options: MODPARAMOPTIONS})), DataCell(DropDown({locked:props.locked, onChange: props.setDjParam, value: props.djParam, options: MODPARAMOPTIONS})),
ListItem(e("input", {onChange:props.setFreq, value:props.freq, className:"timeInput"}, null)), DataCell(e("input", {onChange:props.setFreq, value:props.freq, className:"timeInput"}, null)),
ListItem(e(NumberBox, {onChange:props.setMin, value:props.min, step:0.1}, null)), DataCell(e(NumberBox, {onChange:props.setMin, value:props.min, step:0.1}, null)),
ListItem(e(NumberBox, {onChange:props.setMax, value:props.max, step:0.1}, null)), DataCell(e(NumberBox, {onChange:props.setMax, value:props.max, step:0.1}, null)),
//ListItem(e(NumberBox, {onChange:props.setAmp, value:props.amp, step:0.1}, null)), //DataCell(e(NumberBox, {onChange:props.setAmp, value:props.amp, step:0.1}, null)),
ListItem(e(NumberBox, {onChange:props.setPhase, value:props.phase, step:0.1}, null)), DataCell(e(NumberBox, {onChange:props.setPhase, value:props.phase, step:0.1}, null)),
ListItem(e("div", {className:"base-val"}, center.toString())), DataCell(e("div", {className:"base-val"}, center.toString())),
ListItem(e("input", {type: 'range', min: 0, max: 1, step: 0.01, readonly: true, id: `slider-${props.instanceNum}-${props.djParam}`})), DataCell(e("input", {type: 'range', min: 0, max: 1, step: 0.01, readonly: true, id: `slider-${props.instanceNum}-${props.djParam}`})),
ListItem(e(Button, {text:'+', onClick: props.addLfo, locked: props.locked}, null)), DataCell(e(Button, {text:'+', onClick: props.addLfo, locked: props.locked}, null)),
ListItem(e(Button, {text:'-', onClick: props.removeLfo, locked: props.locked}, null)), DataCell(e(Button, {text:'-', onClick: props.removeLfo, locked: props.locked}, null)),
ListItem(e("div", {className:"linked"}, linkedText)), DataCell(e("div", {className:"linked"}, linkedText)),
); );
if (props.visible){ if (props.visible){
return content; return content;