12 Commits

4 changed files with 576 additions and 484 deletions

File diff suppressed because one or more lines are too long

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;
@@ -183,7 +205,15 @@ h5 {
#pulse { #pulse {
animation: pulse-animation 0.2s normal; animation: pulse-animation 0.2s normal;
} }
/* :::::::::::::: SELECTING MODULATORS/ENUMERATORS */
.highlighted-button {
background-color: gray;
}
.unhighlighted-button {
background-color: white;
}
/* :::::::::::::: LOCK CSS */ /* :::::::::::::: LOCK CSS */
.locked-component { .locked-component {
@@ -192,10 +222,10 @@ h5 {
color : white; color : white;
} }
.container { .header {
display: flex; display: flex;
width: 100%; width: 100%;
justify-content: space-between; flex-direction: flex;
} }
/* Locked */ /* Locked */

View File

@@ -9,8 +9,8 @@ else
const e = React.createElement; const e = React.createElement;
let lfos = []; let lfos = [];
const MAXLFOS = 20; const MAXLFOS = 200;
const MAXENUMS = 20; const MAXENUMS = 200;
const MAXENUMPOINTS = 10; const MAXENUMPOINTS = 10;
const MAXUSERDEFINED = 4; const MAXUSERDEFINED = 4;
@@ -30,8 +30,8 @@ const LockModes = Object.freeze({
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) {
@@ -65,14 +65,8 @@ function MasterLfoHandler(){
initVisArr[0] = true; initVisArr[0] = true;
const [viewMode, setViewMode] = React.useState(ViewModes.MOD); const [viewMode, setViewMode] = React.useState(ViewModes.MOD);
const toggleViewMode = () => {
if (viewMode === ViewModes.MOD)
setViewMode(ViewModes.ENUM);
else
setViewMode(ViewModes.MOD);
};
const [lockMode, setLockMode] = React.useState(LockModes.LOCK); const [lockMode, setLockMode] = React.useState(LockModes.UNLOCK);
const toggleLockMode = () => { const toggleLockMode = () => {
if (lockMode === LockModes.UNLOCK) if (lockMode === LockModes.UNLOCK)
setLockMode(LockModes.LOCK); setLockMode(LockModes.LOCK);
@@ -80,6 +74,18 @@ function MasterLfoHandler(){
setLockMode(LockModes.UNLOCK); setLockMode(LockModes.UNLOCK);
}; };
const [enabled, setEnabled] = React.useState(false);
const toggleEnabled = () => {
setEnabled(!enabled);
};
const displayIfEnabled = (content) => {
if (enabled)
return content
}
let toggleEnabledText = enabled ? "Hide" : "Show";
/// MODULATOR ARRAYS /// MODULATOR ARRAYS
let userDefinedWavesBase = []; let userDefinedWavesBase = [];
let userDefinedFunctionsBase = []; let userDefinedFunctionsBase = [];
@@ -96,7 +102,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': {}, '5': {}, '6': {}});
const [ticks, setTicks] = React.useState(0); const [ticks, setTicks] = React.useState(0);
const [beatsInMeasure, setBeatsInMeasure] = React.useState(4); const [beatsInMeasure, setBeatsInMeasure] = React.useState(4);
@@ -534,16 +540,19 @@ function MasterLfoHandler(){
var grid; var grid;
var title; var modButtonClass;
var enumButtonClass;
var labels; var labels;
if (viewMode === ViewModes.MOD) { if (viewMode === ViewModes.MOD) {
grid = modContents; grid = modContents;
title = "MODULATORS"; modButtonClass = "highlighted-button";
enumButtonClass = "unhighlighted-button";
labels = MODULATORLABELS; labels = MODULATORLABELS;
} }
else { else {
grid = enumContents; grid = enumContents;
title = "ENUMERATORS"; modButtonClass = "unhighlighted-button";
enumButtonClass = "highlighted-button";
labels = ENUMERATORLABELS; labels = ENUMERATORLABELS;
} }
@@ -556,13 +565,20 @@ function MasterLfoHandler(){
} }
return e('div', null, return e('div', null,
e('div', {className: 'container'}, e('div', { className: 'header' },
e(Switch, {ontoggle: toggleViewMode}, null), displayIfEnabled(e('button', { onClick: () => setViewMode(ViewModes.MOD), className: modButtonClass}, 'Modulators')),
e('span', {className: lockClass, onClick: toggleLockMode}, null)), displayIfEnabled(e('button', { onClick: () => setViewMode(ViewModes.ENUM), className: enumButtonClass }, 'Enumerators')),
e('button', { onClick: toggleEnabled, }, toggleEnabledText),
e('h5', null, title), //allows lock mode
e('ul', null, ...labels.map(x => ListItem(Label(x)))), //e('span', { className: lockClass, onClick: toggleLockMode }, null)
e('div', {id: 'grid'}, ...grid) ),
displayIfEnabled(
e('table', { id: 'table' },
e('thead', null, e('tr', { id: 'headers' }, ...labels.map(x => e('th', null, x)))),
e('tbody', null, ...grid)
))
); );
} }

View File

@@ -7,7 +7,7 @@ var TYPEOPTIONS = ["LFO", "Noise"];
var SHAPETYPES = ["Sine", "SawUp", "SawDown", "Tri", "Square", "Custom_1", "Custom_2", "Custom_3", "Custom_4"]; var SHAPETYPES = ["Sine", "SawUp", "SawDown", "Tri", "Square", "Custom_1", "Custom_2", "Custom_3", "Custom_4"];
var NOISETYPES = ["Rand", "Line Int.", "Sine Int."] var NOISETYPES = ["Rand", "Line Int.", "Sine Int."]
var INSTANCEOPTIONS = ["1", "2", "3", "4"]; var INSTANCEOPTIONS = ["1", "2", "3", "4", "5", "6"];
const MODPARAMOPTIONS = ["NONE", "stream", "pulse_length", "eventfulness", "event_length", "metriclarity", const MODPARAMOPTIONS = ["NONE", "stream", "pulse_length", "eventfulness", "event_length", "metriclarity",
"harmoniclarity", "melodic_cohesion", "melody_scope", "tonic_pitch", "pitch_center", "pitch_range", "dynamics", "harmoniclarity", "melodic_cohesion", "melody_scope", "tonic_pitch", "pitch_center", "pitch_range", "dynamics",
@@ -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;
@@ -65,7 +67,6 @@ function indexUserWave(phase, index, userDefinedWaves){
return parseFloat(userDefinedWaves[index][Math.floor(phase * 50)]) / 127; return parseFloat(userDefinedWaves[index][Math.floor(phase * 50)]) / 127;
} }
//TODO doesn't work well yet
function indexUserFunction(phase, index, userDefinedFunctions){ function indexUserFunction(phase, index, userDefinedFunctions){
return parseFloat(userDefinedFunctions[index][Math.floor(phase * 101)]) / 127; return parseFloat(userDefinedFunctions[index][Math.floor(phase * 101)]) / 127;
} }