removed .git from submodule #7

Closed
kieran-mcauliffe wants to merge 1 commits from modenum-nogit into main
11 changed files with 37873 additions and 0 deletions

View File

@ -0,0 +1,62 @@
function isNumeric(str) {
if (typeof str != "string") return false // we only process strings!
return !isNaN(str) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...
!isNaN(parseFloat(str)) // ...and ensure strings of whitespace fail
}
function DropDown(props) {
return e('select', {type: "number", onChange: props.onChange, value: props.value},
...props.options.map((item) => Option(item)));
}
function ListItem(child){
return e('li', null, child);
}
function Label(text){
return e('div', {className: 'label'}, text);
}
function NumberBox(props){
return e('input', {type: "number", onChange: props.onChange, step: props.step, value: props.value, className: props.className}, null);
}
function TextBox(props){
return e('input', {type: "text", value: props.value, onChange: props.onChange, id: props.id});
}
function Option(str, value){
return e("option", {value: value}, str);
}
function Button(props){
return e('button', {onClick: props.onClick}, props.text);
}
function Switch(props){
return e('label', {className: 'switch'},
e('input', {type: 'checkbox', onClick: props.ontoggle}, null),
e('span', {className: 'slider round'}, null))
}
function CreateParamChanger(arr, setArr, index, postCB=() => {}, preCB=(val) => val){
return (event) => {
let newArr = arr.slice();
newArr[index] = preCB(event.target.value);
setArr(newArr);
postCB();
log(`${index} ${event.target.value}`);
}
}
function CreateMatrixParamChanger(matrix, setMatrix, i, j){
return (event) => {
var newMatrix = matrix.map(function(arr) {
return arr.slice();
});
newMatrix[i][j] = event.target.value;
setMatrix(newMatrix);
log(`${i}, ${j} ${event.target.value}`);
}
}

View File

@ -0,0 +1,72 @@
/////////////////////////
// ENUMERATORS
/////////////////////////
// NOT A REACT FUNCTIONAL COMPONENT. MERELY RETURNS AN ARRAY WHICH IS UNPACKED
function EnumeratorItems(index, enumBreakPoints, setEnumBreakPoints, enumNames, setEnumNames, djParam){
let items = [];
for (let i = 0; i < MAXENUMPOINTS; i++){
items.push(ListItem(e(TextBox, {onChange: CreateMatrixParamChanger(enumNames, setEnumNames, index, i), value: enumNames[index][i], id:`text-${djParam}-${enumNames[index][i]}`}, null)));
// Add 1 to make up for the lower enum bound
items.push(ListItem(e(NumberBox, {onChange: CreateMatrixParamChanger(enumBreakPoints, setEnumBreakPoints, index, i + 1), value:enumBreakPoints[index][i + 1]}, null)));
}
return items;
}
function EnumeratorRow(props){
let linkedText = props.linked ? "<- mods" : "";
let content = e('ul', {className: 'lfo-item', id: `${props.djParam}-enum-row`},
ListItem(DropDown({onChange: props.setInstanceNum, value:props.instanceNum, options: INSTANCEOPTIONS})),
ListItem(DropDown({onChange: props.setDjParam, value: props.djParam, options: MODPARAMOPTIONS})),
ListItem(e(NumberBox, {onChange: props.setEnumItemCounts, step:1, value:props.enumItems, className: 'enum-count'}, null)),
ListItem(e(NumberBox, {onChange: CreateMatrixParamChanger(props.enumBreakPoints, props.setEnumBreakPoints, props.index, 0), value:props.enumBreakPoints[props.index][0], step:0.1}, null)),
...(EnumeratorItems(props.index, props.enumBreakPoints, props.setEnumBreakPoints, props.enumNames, props.setEnumNames, props.djParam).slice(0, props.enumItems * 2)),
ListItem(e(Button, {text:'+', onClick: props.addEnum}, null)),
ListItem(e(Button, {text:'-', onClick: props.removeEnum}, null)),
ListItem(e("div", {className:"linked"}, linkedText))
);
if (props.visible){
return content;
};
}
function denumerate(inval, count, keys, vals){
let output = inval;
for (let i=0; i < count; i++){
log(vals[i]);
if (inval == vals[i]){
output = (parseFloat(keys[i]) + parseFloat(keys[i+1])) / 2; // linear interpolate
}
}
return output;
}
function enumerate(name, inst, inval, count, keys, vals){
let output = "OUT OF RANGE";
for (let i=0; i < count + 1; i++){
if (inval <= keys[i]){
if (i > 0)
output = vals[i - 1];
break
}
}
let highlightedItem = document.getElementById(`text-${name}-${output}`);
if (highlightedItem){
highlightedItem.style.animation = "pulse-animation 0.5s normal";
highlightedItem.addEventListener('animationend', () => {
highlightedItem.style.animation = "";
});
}
if (name !== "NONE")
window.max.outlet(inst + " " + name + " " + output);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,181 @@
html,
body {
width: 100%;
height: 100%;
margin: 0px;
border: 0;
overflow: hidden; /* Disable scrollbars */
display: block; /* No floating content on sides */
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
}
li {
float: left;
}
input[type=number] {
width: 50px;
margin: 0;
padding: 0;
}
input[type=text] {
width: 60px;
margin: 0;
padding: 0;
font-weight: bold;
}
.timeInput {
width: 80px;
margin: 0;
padding: 0;
}
#matrix {
background-color: aquamarine;
height: 100%;
width: 100%;
}
.numbox-unclicked {
user-select: none;
border: solid;
font-size: 12vw;
}
.numbox-clicked {
user-select: none;
border : solid;
font-size: 12vw;
}
.param-input-label {
width: 93%;
font-size: 5vw;
}
.lfo-input-label {
width: 40%;
font-size: 5vw;
}
/* The switch - the box around the slider */
.switch {
position: relative;
display: inline-block;
width: 30px;
height: 17px;
}
/* Hide default HTML checkbox */
.switch input {
opacity: 0;
width: 0;
height: 0;
}
/* The slider */
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 13px;
width: 13px;
left: 2px;
bottom: 2px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #2196F3;
}
input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked + .slider:before {
-webkit-transform: translateX(13px);
-ms-transform: translateX(13px);
transform: translateX(13px);
}
/* Rounded sliders */
.slider.round {
border-radius: 17px;
}
.slider.round:before {
border-radius: 50%;
}
h5 {
margin: 0;
padding: 0;
}
.enum-count {
background-color: aquamarine;
}
.label {
background-color: aliceblue;
padding: 0 4px 0 4px;
margin: 0 2px 0 2px;
border-color: #333333;
border-width: 1px;
}
.base-val {
background-color: lightgray;
border-color: #333333;
border-width: 1px;
width: 50px;
margin-left: 2px;
margin-top: 1px;
}
.linked {
color: red;
border-width: 1px;
width: 50px;
font-size: small;
margin-left: 2px;
margin-top: 5px;
}
@keyframes pulse-animation {
0% {
color: black;
}
100% {
color: red;
}
}
#pulse {
animation: pulse-animation 0.2s normal;
}

View File

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<!--
We start with a basic html 'page' that is the size of the jweb object,
but has no scrollbars nor floating content.
-->
<head>
<link rel="stylesheet" href="./lfogui.css">
</head>
<body>
<div id="lfo-container"></div>
<script src="./react.js"></script>
<script src="./react-dom.js"></script>
<script src="./moment.js"></script>
<script src="./common.js"></script>
<script src="./enums.js"></script>
<script src="./modulators.js"></script>
<script src="./lfogui.js">
</script>
</body>
</html>

View File

@ -0,0 +1,445 @@
// const { createElement } = require("./react");
const DEBUG = false;
var log;
if (DEBUG)
log = console.log;
else
log = (msg) => {window.max.outlet("debug " + msg)};
const e = React.createElement;
let lfos = [];
const MAXLFOS = 20;
const MAXENUMS = 20;
const MAXENUMPOINTS = 10;
const ViewModes = Object.freeze({
MOD: 0,
ENUM: 1
});
var modPhases = Array(MAXLFOS).fill(0);
var firstUpdateTime = Date.now();
const MODULATORLABELS = ["inst", "-type-", "---shape---", "-------param-------", "--timebase--", "-min-", "-max", "-phase-", "center"];
const ENUMERATORLABELS = ["inst", "---parameter---", "-# points-"];
function MasterLfoHandler(){
let initVisArr = Array(MAXLFOS).fill(false);
initVisArr[0] = true;
const [viewMode, setViewMode] = React.useState(ViewModes.MOD);
const toggleViewMode = () => {
if (viewMode === ViewModes.MOD)
setViewMode(ViewModes.ENUM);
else
setViewMode(ViewModes.MOD);
};
/// MODULATOR ARRAYS
const [modVisibleArr, setModVisibleArr] = React.useState(initVisArr);
const [modInstanceNumArr, setModInstanceNumArr] = React.useState(Array(MAXLFOS).fill('1'));
const [modCenterVals, setModCenterVals] = React.useState({'1':{}, '2':{}, '3':{}, '4':{}});
const [bpm, setBpm] = React.useState(100);
const [beatsInMeasure, setBeatsInMeasure] = React.useState(4);
const [shapeArr, setShapeArr] = React.useState(Array(MAXLFOS).fill('Sine'));
const [djParamArr, setDjParamArr] = React.useState(Array(MAXLFOS).fill('NONE'));
const [freqArr, setFreqArr] = React.useState(Array(MAXLFOS).fill('1hz'));
// const [ampArr, setAmpArr] = React.useState(Array(MAXLFOS).fill('1'));
const [minArr, setMinArr] = React.useState(Array(MAXLFOS).fill('0'));
const [maxArr, setMaxArr] = React.useState(Array(MAXLFOS).fill('1'));
const [phaseArr, setPhaseArr] = React.useState(Array(MAXLFOS).fill('0'));
const allModArrays = [modVisibleArr, modInstanceNumArr, shapeArr, djParamArr, freqArr, minArr, maxArr, phaseArr];
const allModSetters = [setModVisibleArr, setModInstanceNumArr, setShapeArr, setDjParamArr, setFreqArr, setMinArr, setMaxArr, setPhaseArr];
const modBlankVals = [true, '1', SHAPETYPES[0], MODPARAMOPTIONS[0], '1hz', '0', '1', '0'];
/// ENUMERATOR ARRAYS
const [enumVisibleArr, setEnumVisibleArr] = React.useState(initVisArr);
const [enumInstanceNumArr, setEnumInstanceNumArr] = React.useState(Array(MAXLFOS).fill('1'));
const [enumItemCounts, setEnumItemCounts] = React.useState(Array(MAXENUMPOINTS).fill('2'));
const [enumDjParamArr, setEnumDjParamArr] = React.useState(Array(MAXENUMPOINTS).fill('attenuation'));
let baseEnumBreakpoints = Array(MAXENUMS).fill(0).map(x => Array(MAXENUMPOINTS+ 1).fill(0));
for (let i = 0; i < MAXENUMS; i++){
for (let j=0; j < MAXENUMPOINTS + 1; j++){
baseEnumBreakpoints[i][j] = j;
}
}
const [enumBreakPoints, setEnumBreakPoints] = React.useState(baseEnumBreakpoints);
const getBlankEnumBreakPointRow = () => {
let arr = []
for (let i=0; i< MAXENUMPOINTS + 1; i++)
arr.push(i)
return arr;
}
const getBlankEnumNameRow = () => {return Array(MAXENUMPOINTS).fill('param')};
let baseEnumNames = Array(MAXENUMS).fill(0).map(x => Array(MAXENUMPOINTS).fill('param'));
const [enumNames, setEnumNames] = React.useState(baseEnumNames);
const allEnumArrays = [enumVisibleArr, enumInstanceNumArr, enumItemCounts, enumDjParamArr];
const allEnumArrSetters = [setEnumVisibleArr, setEnumInstanceNumArr, setEnumItemCounts, setEnumDjParamArr];
const allEnumMats = [enumBreakPoints, enumNames];
const allEnumMatSetters = [setEnumBreakPoints, setEnumNames];
const allGetEnumMatBlankVals = [getBlankEnumBreakPointRow, getBlankEnumNameRow]
const enumBlankVals = [true, '1', 2, MODPARAMOPTIONS[0]];
const [render, rerender] = React.useState(false); // BAD. I SHOULDN'T BE DOING THIS
React.useEffect(() => {
function handleLoad(event) {
window.max.getDict(event.detail, (dict) => {
for (let i = 0; i<allModArrays.length; i++) {
allModSetters[i](dict.data.modArrays[i]);
}
for (let i = 0; i<allEnumArrays.length; i++) {
allEnumArrSetters[i](dict.data.enumArrays[i]);
}
for (let i = 0; i<allEnumMats.length; i++) {
allEnumMatSetters[i](dict.data.enumMats[i]);
}
setModCenterVals(dict.data.modCenters);
})
}
function handleSave(event) {
let data = {
'modArrays' : allModArrays,
'enumArrays' : allEnumArrays,
'enumMats' : allEnumMats,
'modCenters': modCenterVals
}
window.max.setDict(event.detail, {"data" : data});
window.max.outlet("saved");
}
// only called internally by 1. Handler after modulator processing 2. LFO outputs
function handleEnum(event){
let inst = event.detail[0];
let name = event.detail[1];
let val = event.detail[2];
// if none of the Enums use this param, then we output it
let i = 0;
while (i < MAXENUMS){
if (enumVisibleArr[i] && enumDjParamArr[i] == name && enumInstanceNumArr[i] == inst)
break;
i++
}
if (i == MAXENUMS){
window.max.outlet(inst + ' ' + name + ' ' + val);
}
else {
enumerate(name, inst, val, enumItemCounts[i], enumBreakPoints[i], enumNames[i]);
}
}
function handleParam(event) {
let inst = event.detail[0]; // djster instance
let name = event.detail[1];
let val = event.detail[2];
// CHECK FOR INDEX OF THIS NAME IN ENUM MATRIX, AND IF IT IS THERE DENUMERATE
let index = -1;
for (let i = 0; i < MAXENUMS; i++){
if (enumDjParamArr[i] == name && enumInstanceNumArr[i] == inst)
index = i;
}
if (index != -1){
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
let i = 0;
while (i < MAXLFOS){
if (modVisibleArr[i] && djParamArr[i] == name && modInstanceNumArr[i] == inst)
break;
i++;
}
if (i == MAXLFOS){
window.dispatchEvent(new CustomEvent('enum', {'detail' : [inst, name, val]}));
}
modCenterVals[inst][name] = val;
setModCenterVals(modCenterVals);
rerender(!render); // BAD! SHOULD NOT BE DOING THIS!
}
function handleTick(event) {
let time = (Date.now() - firstUpdateTime) / 1000;
operateModulators(modVisibleArr, modInstanceNumArr, djParamArr, modCenterVals, freqArr, minArr, maxArr, shapeArr, phaseArr, time, bpm, beatsInMeasure);
}
function handleBpm(event) {
setBpm(event.detail);
}
function handleTimeSig(event) {
setBeatsInMeasure(parseFloat(event.detail[0]) * parseFloat(event.detail[1])/ 4);
}
window.addEventListener('loadDict', handleLoad);
window.addEventListener('saveDict', handleSave);
window.addEventListener('tick', handleTick);
window.addEventListener('param', handleParam);
window.addEventListener('enum', handleEnum);
window.addEventListener('tempo', handleBpm);
window.addEventListener('timesig', handleTimeSig);
return () => {
window.removeEventListener('loadDict', handleLoad);
window.removeEventListener('saveDict', handleSave);
window.removeEventListener('tick', handleTick);
window.removeEventListener('param', handleParam);
window.removeEventListener('enum', handleEnum);
window.removeEventListener('tempo', handleBpm);
window.removeEventListener('timesig', handleTimeSig);
};
}, [...allModArrays, ...allEnumArrays, ...allEnumMats, modCenterVals, render, bpm, beatsInMeasure]);
function CheckLinked(inst, param, checkInstArr, checkParamArr){
for (let i = 0; i < checkInstArr.length; i++){
if (checkInstArr[i] == inst && checkParamArr[i] == param)
return true;
}
return false;
}
///////
// Generate Modulators
///////
let modContents = []
for (var i = 0; i<MAXLFOS; i++){
let id = i;
modContents.push(
e(LfoRow, {
instanceNum : modInstanceNumArr[i],
setInstanceNum: CreateParamChanger(modInstanceNumArr, setModInstanceNumArr, i),
shape: shapeArr[i],
setShape: CreateParamChanger(shapeArr, setShapeArr, i),
djParam: djParamArr[i],
setDjParam: CreateParamChanger(djParamArr, setDjParamArr, i),
centerVals: modCenterVals,
freq: freqArr[i],
setFreq: CreateParamChanger(freqArr, setFreqArr, i),
//amp: ampArr[i],
//setAmp: CreateParamChanger(ampArr, setAmpArr, i),
min: minArr[i],
setMin : CreateParamChanger(minArr, setMinArr, i),
max: maxArr[i],
setMax: CreateParamChanger(maxArr, setMaxArr, i),
phase: phaseArr[i],
setPhase: CreateParamChanger(phaseArr, setPhaseArr, i),
visible: modVisibleArr[i],
linked: CheckLinked(modInstanceNumArr[i], djParamArr[i], enumInstanceNumArr, enumDjParamArr),
addLfo: () => {
if (id < MAXLFOS - 1){
if (modVisibleArr[id + 1]){
let emptyIndex = modVisibleArr.findIndex((item) => !item);
if (emptyIndex != -1){
for (var j = 0; j < allModArrays.length; j++){
let array = allModArrays[j];
// remove from all arrays
array.splice(emptyIndex, 1);
// add empty item at opened index
array.splice(id + 1, 0, modBlankVals[j]);
allModSetters[j](array);
}
}
}
else {
for (var j = 0; j < allModArrays.length; j++){ // no space below, easy.
let array = allModArrays[j];
array[id + 1] = modBlankVals[j];
allModSetters[j](array);
}
}
rerender(!render);
}
},
removeLfo: () => {
if (modVisibleArr.filter(x=>x).length > 1){
let newArr = modVisibleArr.slice();
newArr[id] = false;
setModVisibleArr(newArr);
}
}
},
null));
}
///////
// Generate Enumerators
///////
let enumContents = []
for (var i = 0; i<MAXLFOS; i++){
let id = i;
enumContents.push(
e(EnumeratorRow, {
index: i,
instanceNum : enumInstanceNumArr[i],
setInstanceNum: CreateParamChanger(enumInstanceNumArr, setEnumInstanceNumArr, i),
enumItems: enumItemCounts[i],
setEnumItemCounts: CreateParamChanger(enumItemCounts, setEnumItemCounts, i),
enumBreakPoints: enumBreakPoints,
setEnumBreakPoints: setEnumBreakPoints,
enumNames: enumNames,
setEnumNames: setEnumNames,
visible: enumVisibleArr[i],
djParam: enumDjParamArr[i],
setDjParam: CreateParamChanger(enumDjParamArr, setEnumDjParamArr, i),
linked: CheckLinked(enumInstanceNumArr[i], enumDjParamArr[i], modInstanceNumArr, djParamArr),
addEnum: () => {
if (id < MAXLFOS - 1){
if (enumVisibleArr[id + 1]){ // if we need to open up space
let emptyIndex = enumVisibleArr.findIndex((item) => !item);
if (emptyIndex != -1){
for (var j = 0; j < allEnumArrays.length; j++){
let array = allEnumArrays[j];
// remove from all arrays
array.splice(emptyIndex, 1);
// add empty item at opened index
array.splice(id + 1, 0, enumBlankVals[j]);
allEnumArrSetters[j](array);
}
// Now do the same with matrices
for (var j = 0; j < allEnumMats.length; j++){
let mat = allEnumMats[j];
mat.splice(emptyIndex, 1);
mat.splice(id + 1, 0, 0);
mat[id + 1] = allGetEnumMatBlankVals[j]();
allEnumMatSetters[j](mat);
}
}
}
else {
for (var j = 0; j < allEnumArrays.length; j++){
let array = allEnumArrays[j];
array[id+1] = enumBlankVals[j];
allEnumArrSetters[j](array);
}
// Now do the same with matrices
for (var j = 0; j < allEnumMats.length; j++){
let mat = allEnumMats[j];
mat[id + 1] = allGetEnumMatBlankVals[j]();
allEnumMatSetters[j](mat);
}
}
rerender(!render);
}
},
removeEnum: () => {
if (enumVisibleArr.filter(x=>x).length > 1){
let newArr = enumVisibleArr.slice();
newArr[id] = false;
setEnumVisibleArr(newArr);
}
}
}, null)
);
}
var grid;
var title;
var labels;
if (viewMode === ViewModes.MOD){
grid = modContents;
title = "MODULATORS";
labels = MODULATORLABELS;
}
else {
grid = enumContents;
title = "ENUMERATORS";
labels = ENUMERATORLABELS;
}
return e('div', null,
e(Switch, {ontoggle: toggleViewMode}, null),
e('h5', null, title),
e('ul', null, ...labels.map(x => ListItem(Label(x)))),
e('div', {id: 'grid'}, ...grid)
);
}
if (!DEBUG){
window.max.bindInlet("load", (dictId) => {
window.dispatchEvent(new CustomEvent('loadDict', {'detail' : dictId}));
});
window.max.bindInlet("save", (dictId) => {
window.dispatchEvent(new CustomEvent('saveDict', {'detail' : dictId}));
});
window.max.bindInlet("param", (inst, paramName, val) => {
window.dispatchEvent(new CustomEvent('param', {'detail' : [inst, paramName, val]}));
});
window.max.bindInlet("tempo", (val) => {
window.dispatchEvent(new CustomEvent('tempo', {'detail' : val}));
});
window.max.bindInlet("timesig", (top, bottom) => {
window.dispatchEvent(new CustomEvent('timesig', {'detail' : [top, bottom]}));
});
setInterval(() => {
window.dispatchEvent(new CustomEvent('tick'));
}, 200);
}
const root = ReactDOM.createRoot(document.getElementById('lfo-container'));
root.render(e(MasterLfoHandler, null, null));

View File

@ -0,0 +1,122 @@
/////////////////////////
// MODULATORS
/////////////////////////
var SHAPETYPES = ["Sine", "SawUp", "SawDown", "Tri", "Square"];
var INSTANCEOPTIONS = ["1", "2", "3", "4"];
const MODPARAMOPTIONS = ["NONE", "stream", "pulse_length", "eventfulness", "event_length", "metriclarity",
"harmoniclarity", "melodic_cohesion", "melody_scope", "tonic_pitch", "pitch_center", "pitch_range", "dynamics",
"attenuation", "chordal_weight", "tonality-profile", "ostinato-buffer", "ostinato", "meter", "scale"];
function ControlType(){
return e('select', {className: 'control-type'}, Option("LFO"));
}
function LfoRow(props){
let linkedText = props.linked ? "-> enums" : "";
let center = props.centerVals[props.instanceNum][props.djParam];
if (!center)
center = 0;
let content = e('ul', {className: 'lfo-item'},
ListItem(DropDown({onChange: props.setInstanceNum, value:props.instanceNum, options: INSTANCEOPTIONS})),
ListItem(ControlType()),
ListItem(DropDown({onChange: props.setShape, value:props.shape, options: SHAPETYPES})),
ListItem(DropDown({onChange: props.setDjParam, value: props.djParam, options: MODPARAMOPTIONS})),
ListItem(e("input", {onChange:props.setFreq, value:props.freq, className:"timeInput"}, null)),
ListItem(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)),
//ListItem(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)),
ListItem(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}`})),
ListItem(e(Button, {text:'+', onClick: props.addLfo}, null)),
ListItem(e(Button, {text:'-', onClick: props.removeLfo}, null)),
ListItem(e("div", {className:"linked"}, linkedText)),
);
if (props.visible){
return content
};
}
function indexWave(type, phase){
switch (type){
case "Sine":
return (Math.sin(phase * Math.PI * 2) / 2) + 0.5;
case "SawUp":
return phase;
case "SawDown":
return 1 - phase;
case "Tri":
return phase > 0.5? (1-phase) * 2 : phase * 2;
case "Square":
return +(phase > 0.5);
}
}
function operateModulators(visibleArr, instanceNumArr, paramNames, centers, freqs, mins, maxs, waveTypes, phaseArr, currTime, bpm, beatsInMeasure){
for (let i=0; i<paramNames.length; i++){
if (visibleArr[i]){
let name = paramNames[i];
let inst = instanceNumArr[i];
let center = 0;
if (centers[inst].hasOwnProperty(name)){
center = centers[inst][name];
}
let output = operateModulator(center, inst, freqs[i], mins[i], maxs[i], waveTypes[i], phaseArr, i, name, currTime, bpm, beatsInMeasure);
if (name !== "NONE")
window.dispatchEvent(new CustomEvent('enum', {'detail' : [inst, name, output]}));
}
}
}
function operateModulator(center, inst, freq, min, max, waveType, phaseArr, phaseI, name, currTime, bpm, beatsInMeasure){
let amp = parseFloat(max) - parseFloat(min);
freq = parseLfoTime(freq, bpm, beatsInMeasure);
let phase = (currTime * freq + parseFloat(phaseArr[phaseI])) % 1.00;
let unscaled = indexWave(waveType, phase);
let el = document.getElementById(`slider-${inst}-${name}`);
if (el)
el.value = unscaled;
return unscaled * amp + center + parseFloat(min);
}
function parseLfoTime(lfoTime, bpm, beatsInMeasure){
if (lfoTime.slice(-2) == "hz"){
return parseFloat(lfoTime.slice(0, -2));
}
else if (lfoTime.slice(-2) == "ms"){
return 1000 / parseFloat(lfoTime.slice(0, -2));
}
else if (lfoTime.slice(-1) == "s"){
return 1 / parseFloat(lfoTime.slice(0, -1));
}
else if ((lfoTime.match(/:/g) || []).length == 2){
return 1 / moment.duration(lfoTime).asSeconds();
}
else if ((lfoTime.match(/\./g) || []).length == 2){
return musicalTimingToFreq(...lfoTime.split('.'), bpm, beatsInMeasure)
}
else {
return 0;
}
}
function musicalTimingToFreq(bars, beats, ticks, bpm, beatsInMeasure){
let totalTicks = (parseFloat(bars) * parseFloat(beatsInMeasure) + beats) * 480 + parseFloat(ticks);
let tpm = bpm * 480;
let cyclesPerMinute = tpm / totalTicks;
let hz = cyclesPerMinute / 60;
return hz;
}

File diff suppressed because one or more lines are too long

29924
max-lfo-table-nogit/react-dom.js vendored Normal file

File diff suppressed because it is too large Load Diff

3343
max-lfo-table-nogit/react.js vendored Normal file

File diff suppressed because it is too large Load Diff