saving and loading
This commit is contained in:
parent
6b8833d457
commit
ff8468792d
@ -19,8 +19,8 @@ function TextBox(props){
|
||||
return e('input', {type: "text", value: props.value, onChange: props.onChange});
|
||||
}
|
||||
|
||||
function Option(str){
|
||||
return e("option", null, str);
|
||||
function Option(str, value){
|
||||
return e("option", {value: value}, str);
|
||||
}
|
||||
|
||||
function Button(props){
|
||||
@ -38,6 +38,7 @@ function CreateParamChanger(arr, setArr, index){
|
||||
let newArr = arr.slice();
|
||||
newArr[index] = event.target.value;
|
||||
setArr(newArr);
|
||||
|
||||
log(`${index} ${event.target.value}`);
|
||||
}
|
||||
}
|
||||
@ -50,5 +51,6 @@ function CreateMatrixParamChanger(matrix, setMatrix, i, j){
|
||||
newMatrix[i][j] = event.target.value;
|
||||
setMatrix(newMatrix);
|
||||
log(`${i}, ${j} ${event.target.value}`);
|
||||
|
||||
}
|
||||
}
|
24
lfogui.js
24
lfogui.js
@ -42,7 +42,7 @@ function MasterLfoHandler(){
|
||||
const [modVisibleArr, setModVisibleArr] = React.useState(initVisArr);
|
||||
|
||||
const [shapeArr, setShapeArr] = React.useState(Array(MAXLFOS).fill('Sine'));
|
||||
const [djParamArr, setDjParamArr] = React.useState(Array(MAXLFOS).fill('djParam'));
|
||||
const [djParamArr, setDjParamArr] = React.useState(Array(MAXLFOS).fill('attenuation'));
|
||||
|
||||
const [freqArr, setFreqArr] = React.useState(Array(MAXLFOS).fill('1'));
|
||||
const [ampArr, setAmpArr] = React.useState(Array(MAXLFOS).fill('1'));
|
||||
@ -50,7 +50,7 @@ function MasterLfoHandler(){
|
||||
|
||||
const allModArrays = [modVisibleArr, shapeArr, djParamArr, freqArr, ampArr, phaseArr];
|
||||
const allModSetters = [setModVisibleArr, setShapeArr, setDjParamArr, setFreqArr, setAmpArr, setPhaseArr];
|
||||
const modBlankVals = [true, PARAMOPTIONS[0], 'Sine', '1', '1', '0'];
|
||||
const modBlankVals = [true, SHAPETYPES[0], PARAMOPTIONS[0], '1', '1', '0'];
|
||||
|
||||
|
||||
/// ENUMERATOR ARRAYS
|
||||
@ -90,16 +90,28 @@ function MasterLfoHandler(){
|
||||
|
||||
|
||||
|
||||
|
||||
React.useEffect(() => {
|
||||
function handleLoad(event) {
|
||||
|
||||
window.max.getDict(event.detail, (dict) => {
|
||||
|
||||
for (let i = 0; i<MAXLFOS; i++) {
|
||||
allModSetters[i](dict.data.modArrays[i]);
|
||||
allEnumArrSetters[i](dict.data.enumArrays[i]);
|
||||
allEnumMatSetters[i](dict.data.enumMats[i]);
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function handleSave(event) {
|
||||
window.max.setDict(event.detail, {"data" : allModArrays});
|
||||
let data = {
|
||||
'modArrays' : allModArrays,
|
||||
'enumArrays' : allEnumArrays,
|
||||
'enumMats' : allEnumMats
|
||||
}
|
||||
window.max.setDict(event.detail, {"data" : data});
|
||||
}
|
||||
|
||||
|
||||
@ -111,7 +123,7 @@ function MasterLfoHandler(){
|
||||
window.removeEventListener('loadDict', handleLoad);
|
||||
window.removeEventListener('saveDict', handleSave);
|
||||
};
|
||||
}, []);
|
||||
}, [...allModArrays, ...allEnumArrays, ...allEnumMats]);
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user