68 Commits

Author SHA1 Message Date
51420cbd5f how to integrate tab 2025-08-04 16:27:13 +02:00
533de4668a Merge pull request 'initial help patch' (#19) from help-patch into main
Reviewed-on: #19
2025-07-29 14:10:37 +02:00
b850440287 improved text placement 2025-07-29 14:10:14 +02:00
7ac026f35f initial help patch 2025-07-22 15:27:16 +02:00
7cb4180d97 Merge pull request 'setting viewMode directly from Max' (#16) from viewMode-max into main
Reviewed-on: #16
2025-07-21 16:15:52 +02:00
51767ff058 setting viewMode directly from Max 2025-07-21 16:14:12 +02:00
Eveline-97
fe68764e7d fix aligning 2025-07-02 14:29:59 +02:00
Eveline-97
40d0927a0e streamline layout patch 2025-07-02 12:16:30 +02:00
Eveline-97
92b7545e90 match Max layout to jweb 2025-07-02 12:07:53 +02:00
Eveline-97
4912b398dd Merge remote-tracking branch 'refs/remotes/origin/main'
merge
2025-07-01 16:34:50 +02:00
Eveline-97
02d5c6e914 cleanup modulator table 2025-07-01 16:34:27 +02:00
13f3a18c4c Merge pull request 'bpatcher-embed' (#15) from bpatcher-embed into main
Reviewed-on: #15
2025-07-01 16:32:05 +02:00
f21220e7b2 Merge branch 'main' into bpatcher-embed 2025-07-01 16:31:40 +02:00
fe165b77e5 working saving for bpatcher 2025-07-01 16:30:08 +02:00
Eveline-97
a7b0de9e66 navigation bar 2025-07-01 16:15:41 +02:00
43d37f215f Merge branch 'main' into bpatcher-embed 2025-07-01 16:12:51 +02:00
Eveline-97
c1a0a4d919 basic design 2025-07-01 15:04:49 +02:00
e2f33b8ba7 Merge pull request 'properly saving on adding rows, changing enum length, changing enum params' (#14) from hotfix into main
Reviewed-on: #14
2025-07-01 09:54:22 +02:00
a19717a759 properly saving on adding rows, changing enum length, changing enum params 2025-07-01 09:53:39 +02:00
64da80b742 WIP 2025-07-01 09:25:27 +02:00
Eveline-97
34549daf67 also enumerator items as datacells 2025-07-01 09:20:30 +02:00
Eveline-97
dd47c0b030 enumerators as table, jweb bit wider 2025-07-01 09:18:02 +02:00
0b7dbbb775 Merge branch 'main' into bpatcher-embed 2025-06-30 12:00:29 +02:00
290ff73524 Merge pull request 'more instances of DJster' (#13) from more-dj-instances into main
Reviewed-on: #13
2025-06-30 11:59:31 +02:00
9b1a9f2e03 more instances 2025-06-30 11:58:56 +02:00
541ab6d459 created initial bpatcher file and maxhelp 2025-06-30 11:44:03 +02:00
b96f2aa53b Merge pull request 'button for showing and hiding everything' (#12) from showhide-button into main
Reviewed-on: #12
2025-06-30 11:00:09 +02:00
edcddde844 button for showing and hiding everything 2025-06-30 10:58:51 +02:00
e41567c101 Merge pull request 'buttons for switching between modes' (#11) from button-headers into main
Reviewed-on: #11
2025-06-30 10:22:01 +02:00
8002ae8bdb Merge branch 'main' into button-headers 2025-06-30 10:21:44 +02:00
286a43b0b2 buttons for switching between modes 2025-06-30 10:19:42 +02:00
229ddb9c37 Merge pull request 'increased max number of lfos and enums to 200' (#10) from increase-maxlfos into main
Reviewed-on: #10
2025-06-30 09:46:03 +02:00
bbcfd8faab increased max number of lfos and enums to 200 2025-06-30 09:40:14 +02:00
5d092a607c Merge pull request 'removed lock' (#9) from removing-lock into main
Reviewed-on: #9
2025-06-30 09:32:36 +02:00
de28fd87fa removed lock 2025-06-30 09:31:23 +02:00
Eveline-97
07c4826bd9 table layout for modulators 2025-06-29 17:53:12 +02:00
Eveline-97
501fca079e autopattr save and load waves, functions, types 2025-05-15 10:32:39 +02:00
Eveline-97
3507899eb3 debug function waves works now 2025-05-15 10:18:10 +02:00
Eveline-97
dc2daade1b add function functionality for custom shape 2025-05-14 14:42:34 +02:00
149d1a0b8d save on every UI change 2025-05-13 11:24:39 +02:00
4ee8a93791 four user defined waves 2025-02-12 11:02:51 +01:00
c706461443 Merge pull request 'nn-communication' (#8) from nn-communication into main
Reviewed-on: #8
2024-11-29 14:21:11 +01:00
081e33dd07 modulator noise function previous val bug 2024-11-29 14:20:29 +01:00
eb02657b4a center vals included in NN data 2024-10-22 13:27:07 +02:00
d670aefcbd enums start with NONE 2024-10-22 12:32:42 +02:00
68baa3c8de Merge pull request 'nn-communication' (#7) from nn-communication into main
Reviewed-on: #7
2024-10-22 11:00:25 +02:00
a35fecafae NN data receiving 2024-10-22 10:58:46 +02:00
b3ba9b0f2d cachedNoise no longer an array 2024-10-18 15:34:53 +02:00
102a88b242 bugfix - modulators not properly initializing 2024-10-15 14:54:37 +02:00
aebfbe5277 Merge pull request 'main' (#6) from main into nn-communication
Reviewed-on: #6
2024-10-15 12:27:53 +02:00
2d81a832af Merge branch 'nn-communication' into main 2024-10-15 12:27:08 +02:00
cdbcf24dfc Merge pull request 'fixed userwave update' (#5) from lock into main
Reviewed-on: #5
2024-10-15 12:21:08 +02:00
64f1455f69 fixed userwave update 2024-10-14 09:16:05 +02:00
trian-gles
a855d254cd non musical timing to ms value for input from neural net 2024-10-11 15:34:37 +02:00
09a1b5f20f Merge pull request 'lock mode' (#4) from lock into main
Reviewed-on: #4
2024-10-11 13:36:54 +02:00
34e99f09fd lock mode 2024-10-11 12:52:54 +02:00
86a994546e Merge pull request 'noise-functions' (#3) from noise-functions into main
Reviewed-on: #3
2024-10-10 12:25:22 +02:00
d22cdc8401 basic random value noise functions 2024-10-10 12:23:50 +02:00
trian-gles
43e517cc4e added new init values 2024-09-26 12:40:47 +02:00
a608b083f3 working sine interpolation 2024-09-25 15:59:27 +02:00
83cf801ec3 merge conflict 2024-09-24 14:35:37 +02:00
trian-gles
45e168ba11 UI changes 2024-09-24 14:35:01 +02:00
37a65058bc Merge pull request 'musical-timing-phase' (#2) from musical-timing-phase into main
Reviewed-on: #2
2024-09-03 11:37:51 +02:00
trian-gles
45847fbae4 phase calculated from ticks 2024-09-03 11:34:32 +02:00
trian-gles
c794b5bc2f separated phase handling into two options 2024-09-02 16:58:18 +02:00
trian-gles
c8c410a38f UI changes 2024-08-08 15:31:57 +02:00
985b6c832f Merge pull request 'user defined wavetable shape' (#1) from user-defined-table into main
Reviewed-on: #1
2024-08-08 14:32:34 +02:00
trian-gles
ff0e8443fc user defined wavetable shape 2024-08-08 14:31:53 +02:00
12 changed files with 9186 additions and 3355 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.DS_Store

1740
ModEnum.maxhelp Normal file

File diff suppressed because it is too large Load Diff

3345
ModEnum.maxpat Normal file

File diff suppressed because one or more lines are too long

View File

@@ -5,7 +5,8 @@ function isNumeric(str) {
} }
function DropDown(props) { function DropDown(props) {
return e('select', {type: "number", onChange: props.onChange, value: props.value}, let className = props.locked ? 'locked-component' : '';
return e('select', {className, type: "number", onChange: props.onChange, value: props.value},
...props.options.map((item) => Option(item))); ...props.options.map((item) => Option(item)));
} }
@@ -18,11 +19,13 @@ function Label(text){
} }
function NumberBox(props){ function NumberBox(props){
return e('input', {type: "number", onChange: props.onChange, step: props.step, value: props.value, className: props.className}, null); let extraClassName = props.locked ? ' locked-component' : '';
return e('input', {type: "number", onChange: props.onChange, step: props.step, value: props.value, className: props.className + extraClassName}, null);
} }
function TextBox(props){ function TextBox(props){
return e('input', {type: "text", value: props.value, onChange: props.onChange, id: props.id}); let className = props.locked ? 'locked-component' : '';
return e('input', {className, type: "text", value: props.value, onChange: props.onChange, id: props.id});
} }
function Option(str, value){ function Option(str, value){
@@ -30,7 +33,8 @@ function Option(str, value){
} }
function Button(props){ function Button(props){
return e('button', {onClick: props.onClick}, props.text); let className = props.locked ? 'locked-component' : '';
return e('button', {onClick: props.onClick, className}, props.text);
} }
function Switch(props){ function Switch(props){
@@ -39,12 +43,20 @@ function Switch(props){
e('span', {className: 'slider round'}, null)) e('span', {className: 'slider round'}, null))
} }
function SendSaveEvent(){
setTimeout(() => {
window.dispatchEvent(new CustomEvent('saveDict', {'detail' : "localStorage"}));
}, 50)
}
function CreateParamChanger(arr, setArr, index, postCB=() => {}, preCB=(val) => val){ function CreateParamChanger(arr, setArr, index, postCB=() => {}, preCB=(val) => val){
return (event) => { return (event) => {
let newArr = arr.slice(); let newArr = arr.slice();
newArr[index] = preCB(event.target.value); newArr[index] = preCB(event.target.value);
setArr(newArr); setArr(newArr);
postCB(); postCB();
SendSaveEvent();
log(`${index} ${event.target.value}`); log(`${index} ${event.target.value}`);
} }
} }
@@ -56,6 +68,7 @@ function CreateMatrixParamChanger(matrix, setMatrix, i, j){
}); });
newMatrix[i][j] = event.target.value; newMatrix[i][j] = event.target.value;
setMatrix(newMatrix); setMatrix(newMatrix);
SendSaveEvent();
log(`${i}, ${j} ${event.target.value}`); log(`${i}, ${j} ${event.target.value}`);
} }

View File

@@ -4,14 +4,18 @@
function DataCell(element) {
return e('td', null, element);
}
// NOT A REACT FUNCTIONAL COMPONENT. MERELY RETURNS AN ARRAY WHICH IS UNPACKED // NOT A REACT FUNCTIONAL COMPONENT. MERELY RETURNS AN ARRAY WHICH IS UNPACKED
function EnumeratorItems(index, enumBreakPoints, setEnumBreakPoints, enumNames, setEnumNames, djParam){ function EnumeratorItems(index, enumBreakPoints, setEnumBreakPoints, enumNames, setEnumNames, djParam, locked){
let items = []; let items = [];
for (let i = 0; i < MAXENUMPOINTS; i++){ 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))); items.push(DataCell(e(TextBox, {locked, 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 // 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))); items.push(DataCell(e(NumberBox, {locked, onChange: CreateMatrixParamChanger(enumBreakPoints, setEnumBreakPoints, index, i + 1), value:enumBreakPoints[index][i + 1]}, null)));
} }
return items; return items;
} }
@@ -19,15 +23,15 @@ function EnumeratorItems(index, enumBreakPoints, setEnumBreakPoints, enumNames,
function EnumeratorRow(props){ function EnumeratorRow(props){
let linkedText = props.linked ? "<- mods" : ""; let linkedText = props.linked ? "<- mods" : "";
let content = e('ul', {className: 'lfo-item', id: `${props.djParam}-enum-row`}, let content = e('tr', {className: 'lfo-item', id: `${props.djParam}-enum-row`},
ListItem(DropDown({onChange: props.setInstanceNum, value:props.instanceNum, options: INSTANCEOPTIONS})), DataCell(DropDown({locked:props.locked, onChange: props.setInstanceNum, value:props.instanceNum, options: INSTANCEOPTIONS})),
ListItem(DropDown({onChange: props.setDjParam, value: props.djParam, options: MODPARAMOPTIONS})), DataCell(DropDown({locked:props.locked, onChange: props.setDjParam, value: props.djParam, options: MODPARAMOPTIONS})),
ListItem(e(NumberBox, {onChange: props.setEnumItemCounts, step:1, value:props.enumItems, className: 'enum-count'}, null)), DataCell(e(NumberBox, {locked:props.locked, 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)), DataCell(e(NumberBox, {locked:props.locked, 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)), ...(EnumeratorItems(props.index, props.enumBreakPoints, props.setEnumBreakPoints, props.enumNames, props.setEnumNames, props.djParam, props.locked).slice(0, props.enumItems * 2)),
ListItem(e(Button, {text:'+', onClick: props.addEnum}, null)), DataCell(e(Button, {locked:props.locked, text:'+', onClick: props.addEnum}, null)),
ListItem(e(Button, {text:'-', onClick: props.removeEnum}, null)), DataCell(e(Button, {locked:props.locked, text:'-', onClick: props.removeEnum}, null)),
ListItem(e("div", {className:"linked"}, linkedText)) DataCell(e("div", {className:"linked"}, linkedText))
); );
if (props.visible){ if (props.visible){
return content; return content;

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,181 +1,378 @@
* {
--locked-color: #5fadbf;
--unlocked-color: #ff5153;
}
:root {
--background: white;
--active: royalblue;
--nonactive: rgb(205, 205, 205);
--alert: red;
--textcolor: black;
}
@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, html,
body { body {
width: 100%; width: 100%;
height: 100%; height: 100%;
margin: 0px; margin: 0px;
border: 0; border: 0;
overflow: hidden; /* Disable scrollbars */ overflow-x: scroll;
display: block; /* No floating content on sides */ overflow-y: scroll;
} display: block;
/* No floating content on sides */
}
ul { /*navigation*/
list-style-type: none; .header {
margin: 0; display: flex;
padding: 0; flex-flow: row nowrap;
overflow: hidden; justify-content: space-between;
background-color: #333333; align-items: center;
} margin: 1em;
border-bottom: 1px solid var(--active);
}
li { .header button {
float: left; border: 1px solid var(--active);
} color: var(--active);
background-color: white;
padding: 4px;
text-align: center;
display: inline-block;
padding: 0.5em;
margin: 4px;
font-size: 0.9em;
min-width: 4.5em;
}
td button {
input[type=number] { background-color: white;
width: 50px; color: var(--active);
margin: 0; border: 1px solid var(--active);
padding: 0; }
}
input[type=text] { /* :::::::::::::: SELECTING MODULATORS/ENUMERATORS */
width: 60px;
margin: 0;
padding: 0;
font-weight: bold;
}
.timeInput { .header button.highlighted-button {
width: 80px; color: var(--active);
margin: 0; border: 1px solid var(--active);
padding: 0; }
}
#matrix { .header button.unhighlighted-button {
background-color: aquamarine; color: var(--nonactive);
height: 100%; border: 1px solid var(--nonactive);
width: 100%; }
}
.numbox-unclicked { /* table */
user-select: none; table {
border: solid; margin: 1em;
font-size: 12vw; padding: 0em;
} border-collapse: collapse;
background-color: lightsteelblue;
}
.numbox-clicked { /* points datacells should have a min-width*/
user-select: none; .enum-count {
border : solid; min-width: 5.6em;
font-size: 12vw; }
}
.param-input-label { th {
width: 93%; padding: 0.4em 0.3em;
font-size: 5vw; text-align: left;
} }
.lfo-input-label { thead {
width: 40%; color: white;
font-size: 5vw; background-color: var(--active);
} }
/* The switch - the box around the slider */ tr,
.switch { td {
position: relative; margin: 0em;
display: inline-block; }
width: 30px;
height: 17px;
}
/* Hide default HTML checkbox */ td:last-child {
.switch input { white-space: nowrap;
opacity: 0; overflow: hidden;
width: 0; padding: 0;
height: 0; }
}
/* The slider */ /* input types */
.slider { /* dropdown list */
position: absolute; select {
cursor: pointer; width: 100%;
top: 0; }
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before { /*
position: absolute; option, select>* {
content: ""; font-size: 0.8em !important;
height: 13px; padding: 0em !important;
width: 13px; margin: 0em !important;
left: 2px; min-height: 0em !important;
bottom: 2px; }
background-color: white; */
-webkit-transition: .4s; option {
transition: .4s; background-color: var(--active);
} }
input:checked + .slider { option:not(:checked) {
background-color: #2196F3; background-color: white;
} }
input:focus + .slider { /* input */
box-shadow: 0 0 1px #2196F3; input,
} select {
border: 1px solid var(--active);
color: var(--active);
margin: 0;
padding: 0;
line-height: 1.5em;
height: 1.5em;
box-sizing: border-box;
}
input:checked + .slider:before { input {
-webkit-transform: translateX(13px); padding-left: 5px;
-ms-transform: translateX(13px); /*slight padding on left*/
transform: translateX(13px); }
}
/* Rounded sliders */ input[type=number] {
.slider.round { width: 50px;
border-radius: 17px; }
}
.slider.round:before { input[type=text] {
border-radius: 50%; width: 60px;
} font-weight: bold;
}
h5 { .timeInput {
margin: 0; width: 80px;
padding: 0; }
}
.enum-count { #matrix {
background-color: aquamarine; background-color: aquamarine;
} height: 100%;
width: 100%;
}
.label { .numbox-unclicked {
background-color: aliceblue; user-select: none;
padding: 0 4px 0 4px; border: solid;
margin: 0 2px 0 2px; font-size: 12vw;
border-color: #333333; }
border-width: 1px;
}
.base-val { .numbox-clicked {
background-color: lightgray; user-select: none;
border-color: #333333; border: solid;
border-width: 1px; font-size: 12vw;
width: 50px; }
margin-left: 2px;
margin-top: 1px;
}
.linked { .param-input-label {
color: red; width: 93%;
border-width: 1px; font-size: 5vw;
width: 50px; }
font-size: small;
margin-left: 2px;
margin-top: 5px;
}
@keyframes pulse-animation { .lfo-input-label {
0% { 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 */
input[type="range"] {
appearance: none;
-webkit-appearance: none;
height: 8px;
border-radius: 6px;
background-color: white;
outline: none;
opacity: 0.7;
-webkit-transition: .2s;
transition: opacity .2s;
overflow: hidden;
}
/*slider knob*/
input[type="range"]::-webkit-slider-runnable-track {
-webkit-appearance: none;
color: var(--active);
margin-top: -1px;
}
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 20px;
height: 20px;
border-radius: 50%;
background: var(--active);
box-shadow: -80px 0 0 80px var(--active);
}
input[type="range"]::-moz-range-progress {
background-color: var(--active);
}
h5 {
margin: 0;
padding: 0;
}
.label {
background-color: aliceblue;
padding: 0 4px 0 4px;
margin: 0 2px 0 2px;
border-color: #333333;
border-width: 1px;
}
.base-val {
border: none;
color: white;
text-align: center;
font-size: 0.9em;
width: 50px;
margin: 0;
padding: 0;
}
.linked {
color: red;
border-width: 1px;
width: 50px;
font-size: small;
margin-left: 2px;
margin-top: 5px;
display: none;
/*hide*/
}
@keyframes pulse-animation {
0% {
color: black; color: black;
}
100% {
color: red;
}
} }
#pulse { 100% {
animation: pulse-animation 0.2s normal; color: red;
} }
}
#pulse {
animation: pulse-animation 0.2s normal;
}
/* :::::::::::::: LOCK CSS */
.locked-component {
pointer-events: none;
background-color: #333333;
color: white;
}
/* Locked */
.lock {
margin-top: 14px;
width: 24px;
height: 21px;
border: 3px solid var(--locked-color);
border-radius: 5px;
position: relative;
cursor: pointer;
-webkit-transition: all 0.1s ease-in-out;
transition: all 0.1s ease-in-out;
}
.lock:after {
content: "";
display: block;
background: var(--locked-color);
width: 3px;
height: 7px;
position: absolute;
top: 50%;
left: 50%;
margin: -3.5px 0 0 -2px;
-webkit-transition: all 0.1s ease-in-out;
transition: all 0.1s ease-in-out;
}
.lock:before {
content: "";
display: block;
width: 10px;
height: 10px;
bottom: 100%;
position: absolute;
left: 50%;
margin-left: -8px;
border: 3px solid var(--locked-color);
border-top-right-radius: 50%;
border-top-left-radius: 50%;
border-bottom: 0;
-webkit-transition: all 0.1s ease-in-out;
transition: all 0.1s ease-in-out;
}
/* Locked Hover */
.lock:hover:before {
height: 12px;
}
/* Unlocked */
.unlocked {
transform: rotate(10deg);
}
.unlocked:before {
bottom: 130%;
left: 31%;
margin-left: -11.5px;
transform: rotate(-45deg);
}
.unlocked,
.unlocked:before {
border-color: var(--unlocked-color);
}
.unlocked:after {
background: var(--unlocked-color);
}
/* Unlocked Hover */
.unlocked:hover {
transform: rotate(3deg);
}
.unlocked:hover:before {
height: 10px;
left: 40%;
bottom: 124%;
transform: rotate(-30deg);
}

View File

@@ -7,23 +7,21 @@
--> -->
<head> <head>
<link rel="stylesheet" href="./lfogui.css"> <meta charset="utf-8">
<link rel="stylesheet" href="./lfogui.css">
</head> </head>
<body> <body>
<div id="lfo-container"></div> <div id="lfo-container"></div>
<script src="./react.js"></script> <script src="./react.js"></script>
<script src="./react-dom.js"></script> <script src="./react-dom.js"></script>
<script src="./moment.js"></script> <script src="./moment.js"></script>
<script src="./common.js"></script> <script src="./common.js"></script>
<script src="./enums.js"></script> <script src="./enums.js"></script>
<script src="./modulators.js"></script> <script src="./modulators.js"></script>
<script src="./lfogui.js"> <script src="./lfogui.js"></script>
</script>
</body> </body>
</html> </html>

463
lfogui.js
View File

@@ -4,57 +4,112 @@ 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;
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 ViewModes = Object.freeze({ const ViewModes = Object.freeze({
MOD: 0, MOD: 0,
ENUM: 1 ENUM: 1
});
const LockModes = Object.freeze({
UNLOCK: 0,
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", "result", "", ""];
const ENUMERATORLABELS = ["inst", "---parameter---", "-# points-"]; const ENUMERATORLABELS = ["inst", "parameter", "# points"];
function parseLfoTimeNonMusical(lfoTime) {
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 0; // ignore musical timings
}
else {
return 0;
}
}
function nnFreqToHzString(num) {
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;
const [viewMode, setViewMode] = React.useState(ViewModes.MOD); const [viewMode, setViewMode] = React.useState(ViewModes.MOD);
const toggleViewMode = () => {
if (viewMode === ViewModes.MOD) const [lockMode, setLockMode] = React.useState(LockModes.UNLOCK);
setViewMode(ViewModes.ENUM); const toggleLockMode = () => {
if (lockMode === LockModes.UNLOCK)
setLockMode(LockModes.LOCK);
else else
setViewMode(ViewModes.MOD); setLockMode(LockModes.UNLOCK);
}; };
/// MODULATOR ARRAYS const [enabled, setEnabled] = React.useState(false);
const toggleEnabled = () => {
setEnabled(!enabled);
};
const displayIfEnabled = (content) => {
if (enabled)
return content
}
let toggleEnabledText = enabled ? `Hide \u{25BE}` : `Show \u{25B8}`;
/// MODULATOR ARRAYS
let userDefinedWavesBase = [];
let userDefinedFunctionsBase = [];
let userDefinedTypesBase = [0, 0, 0, 0]; //0 = wave, 1 = function
for (let i = 0; i < MAXUSERDEFINED; i++) {
userDefinedWavesBase.push(Array(50).fill(0));
userDefinedFunctionsBase.push(Array(101).fill(0));
}
const [userDefinedWaves, setUserDefinedWaves] = React.useState(userDefinedWavesBase);
const [userDefinedFunctions, setUserDefinedFunctions] = React.useState(userDefinedFunctionsBase);
const [userDefinedTypes, setUserDefinedTypes] = React.useState(userDefinedTypesBase);
const [modVisibleArr, setModVisibleArr] = React.useState(initVisArr); const [modVisibleArr, setModVisibleArr] = React.useState(initVisArr);
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 [bpm, setBpm] = React.useState(100); const [ticks, setTicks] = React.useState(0);
const [beatsInMeasure, setBeatsInMeasure] = React.useState(4); const [beatsInMeasure, setBeatsInMeasure] = React.useState(4);
const [noiseTypeArr, setNoiseTypeArr] = React.useState(Array(MAXLFOS).fill('Sine Int.'));
const [shapeArr, setShapeArr] = React.useState(Array(MAXLFOS).fill('Sine')); const [shapeArr, setShapeArr] = React.useState(Array(MAXLFOS).fill('Sine'));
const [djParamArr, setDjParamArr] = React.useState(Array(MAXLFOS).fill('NONE')); const [djParamArr, setDjParamArr] = React.useState(Array(MAXLFOS).fill('NONE'));
const [freqArr, setFreqArr] = React.useState(Array(MAXLFOS).fill('1hz')); const [freqArr, setFreqArr] = React.useState(Array(MAXLFOS).fill('1hz'));
@@ -62,38 +117,43 @@ function MasterLfoHandler(){
const [minArr, setMinArr] = React.useState(Array(MAXLFOS).fill('0')); const [minArr, setMinArr] = React.useState(Array(MAXLFOS).fill('0'));
const [maxArr, setMaxArr] = React.useState(Array(MAXLFOS).fill('1')); const [maxArr, setMaxArr] = React.useState(Array(MAXLFOS).fill('1'));
const [phaseArr, setPhaseArr] = React.useState(Array(MAXLFOS).fill('0')); const [initPhaseArr, setInitPhaseArr] = React.useState(Array(MAXLFOS).fill('0'));
const [lastPhaseArr, setLastPhaseArr] = React.useState(Array(MAXLFOS).fill(0));
const [cachedNoiseValueArr1, setCachedNoiseValueArr1] = React.useState(Array(MAXLFOS).fill(0));
const [cachedNoiseValueArr2, setCachedNoiseValueArr2] = 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']; const allModArrays = [modVisibleArr, modTypeArr, modInstanceNumArr, shapeArr, noiseTypeArr, djParamArr, freqArr, minArr, maxArr, initPhaseArr, lastPhaseArr, cachedNoiseValueArr1, cachedNoiseValueArr2];
const allModSetters = [setModVisibleArr, setModTypeArr, setModInstanceNumArr, setShapeArr, setNoiseTypeArr, setDjParamArr, setFreqArr, setMinArr, setMaxArr, setInitPhaseArr, setLastPhaseArr, setCachedNoiseValueArr1, setCachedNoiseValueArr2];
const modBlankVals = [true, 'LFO', '1', SHAPETYPES[0], NOISETYPES[0], MODPARAMOPTIONS[0], '1hz', '0', '1', '0', 0, 0, 0];
/// ENUMERATOR ARRAYS /// ENUMERATOR ARRAYS
const [enumVisibleArr, setEnumVisibleArr] = React.useState(initVisArr); const [enumVisibleArr, setEnumVisibleArr] = React.useState(initVisArr);
const [enumInstanceNumArr, setEnumInstanceNumArr] = React.useState(Array(MAXLFOS).fill('1')); const [enumInstanceNumArr, setEnumInstanceNumArr] = React.useState(Array(MAXLFOS).fill('1'));
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('attenuation')); 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; baseEnumBreakpoints[i][j] = j - 0.5;
} }
} }
const [enumBreakPoints, setEnumBreakPoints] = React.useState(baseEnumBreakpoints); const [enumBreakPoints, setEnumBreakPoints] = React.useState(baseEnumBreakpoints);
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) 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);
const allEnumArrays = [enumVisibleArr, enumInstanceNumArr, enumItemCounts, enumDjParamArr]; const allEnumArrays = [enumVisibleArr, enumInstanceNumArr, enumItemCounts, enumDjParamArr];
const allEnumArrSetters = [setEnumVisibleArr, setEnumInstanceNumArr, setEnumItemCounts, setEnumDjParamArr]; const allEnumArrSetters = [setEnumVisibleArr, setEnumInstanceNumArr, setEnumItemCounts, setEnumDjParamArr];
@@ -110,58 +170,52 @@ function MasterLfoHandler(){
React.useEffect(() => { React.useEffect(() => {
function handleLoad(event) { function handleLoad(event) {
window.max.getDict(event.detail, (dict) => { window.max.getDict(event.detail, (dict) => {
for (let i = 0; i<allModArrays.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]);
} }
setModCenterVals(dict.data.modCenters);
}) })
} }
function handleSave(event) { function handleSave(event) {
let data = { let data = {
'modArrays' : allModArrays, 'modArrays': allModArrays,
'enumArrays' : allEnumArrays, 'enumArrays': allEnumArrays,
'enumMats' : allEnumMats, 'enumMats': allEnumMats
'modCenters': modCenterVals
} }
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 {
enumerate(name, inst, val, enumItemCounts[i], enumBreakPoints[i], enumNames[i]); enumerate(name, inst, val, enumItemCounts[i], enumBreakPoints[i], enumNames[i]);
} }
} }
@@ -171,70 +225,160 @@ 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;
setModCenterVals(modCenterVals); setModCenterVals(modCenterVals);
rerender(!render); // BAD! SHOULD NOT BE DOING THIS! rerender(!render); // BAD! SHOULD NOT BE DOING THIS!
} }
function handleTick(event) { function handleTick(event) {
let time = (Date.now() - firstUpdateTime) / 1000; let time = (Date.now() - firstUpdateTime) / 1000;
operateModulators(modVisibleArr, modInstanceNumArr, djParamArr, modCenterVals, freqArr, minArr, maxArr, shapeArr, phaseArr, time, bpm, beatsInMeasure); 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);
function handleBpm(event) {
setBpm(event.detail);
} }
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) {
userDefinedWaves[event.detail.index] = event.detail.points;
setUserDefinedWaves(userDefinedWaves);
}
function handleChangeUserFunction(event) {
userDefinedFunctions[event.detail.index] = event.detail.points;
setUserDefinedFunctions(userDefinedFunctions);
}
function handleChangeUserDefinedType(event) {
userDefinedTypes[event.detail.index - 1] = event.detail.type;
setUserDefinedTypes(userDefinedTypes);
}
function handleMaxTicks(event) {
setTicks(event.detail);
}
function handleChangeViewMode(event){
setEnabled(true);
setViewMode(event.detail);
}
function setNN(event) {
for (let i = 0; i < MAXLFOS; i++) {
freqArr[i] = nnFreqToHzString(event.detail[i]);
}
setFreqArr(freqArr)
for (let i = MAXLFOS; i < MAXLFOS * 2; i++) {
minArr[i - MAXLFOS] = event.detail[i];
}
setMinArr(minArr);
for (let i = MAXLFOS * 2; i < MAXLFOS * 3; i++) {
maxArr[i - MAXLFOS * 2] = event.detail[i];
}
setMaxArr(maxArr);
for (let i = MAXLFOS * 3; i < MAXLFOS * 4; i++) {
initPhaseArr[i - MAXLFOS * 3] = parseFloat(event.detail[i]);
}
setInitPhaseArr(initPhaseArr);
for (let i = MAXLFOS * 4; i < MAXLFOS * 5; i++) {
let index = i - MAXLFOS * 4;
let inst = modInstanceNumArr[index];
let param = djParamArr[index];
modCenterVals[inst][param] = parseFloat(event.detail[i]);
}
setModCenterVals(modCenterVals);
rerender(!render); // BAD! SHOULD NOT BE DOING THIS!
}
function dumpNN(event) {
let allNNData = [];
freqArr.forEach(element => {
allNNData.push(parseLfoTimeNonMusical(element));
});
allNNData = allNNData.concat(minArr);
allNNData = allNNData.concat(maxArr);
allNNData = allNNData.concat(initPhaseArr);
let lfoMatchedCenterVals = [];
for (let i = 0; i < MAXLFOS; i++) {
let inst = modInstanceNumArr[i];
let param = djParamArr[i];
lfoMatchedCenterVals.push(modCenterVals[inst][param]);
if (!lfoMatchedCenterVals[i])
lfoMatchedCenterVals[i] = 0
}
allNNData = allNNData.concat(lfoMatchedCenterVals);
window.max.outlet("NNdata " + allNNData.join(" "));
} }
window.addEventListener('loadDict', handleLoad); window.addEventListener('loadDict', handleLoad);
window.addEventListener('saveDict', handleSave); window.addEventListener('saveDict', handleSave);
window.addEventListener('dumpNN', dumpNN);
window.addEventListener('setNN', setNN);
window.addEventListener('tick', handleTick); window.addEventListener('tick', handleTick);
window.addEventListener('param', handleParam); window.addEventListener('param', handleParam);
window.addEventListener('enum', handleEnum); window.addEventListener('enum', handleEnum);
window.addEventListener('tempo', handleBpm);
window.addEventListener('timesig', handleTimeSig); window.addEventListener('timesig', handleTimeSig);
window.addEventListener('userWave', handleChangeUserWave);
window.addEventListener('userFunction', handleChangeUserFunction);
window.addEventListener('userDefinedType', handleChangeUserDefinedType);
window.addEventListener('maxTicks', handleMaxTicks);
window.addEventListener('viewMode', handleChangeViewMode);
return () => { return () => {
window.removeEventListener('loadDict', handleLoad); window.removeEventListener('loadDict', handleLoad);
window.removeEventListener('saveDict', handleSave); window.removeEventListener('saveDict', handleSave);
window.removeEventListener('dumpNN', dumpNN);
window.removeEventListener('setNN', setNN);
window.removeEventListener('tick', handleTick); window.removeEventListener('tick', handleTick);
window.removeEventListener('param', handleParam); window.removeEventListener('param', handleParam);
window.removeEventListener('enum', handleEnum); window.removeEventListener('enum', handleEnum);
window.removeEventListener('tempo', handleBpm);
window.removeEventListener('timesig', handleTimeSig); window.removeEventListener('timesig', handleTimeSig);
window.removeEventListener('userWave', handleChangeUserWave);
window.removeEventListener('userFunction', handleChangeUserFunction);
window.removeEventListener('userDefinedType', handleChangeUserDefinedType);
window.removeEventListener('maxTicks', handleMaxTicks);
window.removeEventListener('viewMode', handleChangeViewMode);
}; };
}, [...allModArrays, ...allEnumArrays, ...allEnumMats, modCenterVals, render, bpm, beatsInMeasure]); }, [...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;
} }
@@ -245,16 +389,23 @@ 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, {
instanceNum : modInstanceNumArr[i], locked: lockMode,
instanceNum: modInstanceNumArr[i],
setInstanceNum: CreateParamChanger(modInstanceNumArr, setModInstanceNumArr, i), setInstanceNum: CreateParamChanger(modInstanceNumArr, setModInstanceNumArr, i),
type: modTypeArr[i],
setType: CreateParamChanger(modTypeArr, setModTypeArr, i),
shape: shapeArr[i], shape: shapeArr[i],
setShape: CreateParamChanger(shapeArr, setShapeArr, i), setShape: CreateParamChanger(shapeArr, setShapeArr, i),
noise: noiseTypeArr[i],
setNoise: CreateParamChanger(noiseTypeArr, setNoiseTypeArr, i),
djParam: djParamArr[i], djParam: djParamArr[i],
setDjParam: CreateParamChanger(djParamArr, setDjParamArr, i), setDjParam: CreateParamChanger(djParamArr, setDjParamArr, i),
centerVals: modCenterVals, centerVals: modCenterVals,
@@ -266,22 +417,24 @@ 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),
phase: phaseArr[i], phase: initPhaseArr[i],
setPhase: CreateParamChanger(phaseArr, setPhaseArr, i), setPhase: CreateParamChanger(initPhaseArr, setInitPhaseArr, i),
visible: modVisibleArr[i], visible: modVisibleArr[i],
linked: CheckLinked(modInstanceNumArr[i], djParamArr[i], enumInstanceNumArr, enumDjParamArr), linked: CheckLinked(modInstanceNumArr[i], djParamArr[i], enumInstanceNumArr, enumDjParamArr),
addLfo: () => { addLfo: () => {
if (id < MAXLFOS - 1){
if (modVisibleArr[id + 1]){ if (id < MAXLFOS - 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);
@@ -292,25 +445,29 @@ 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);
} }
} }
SendSaveEvent();
rerender(!render); rerender(!render);
} }
}, },
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);
SendSaveEvent();
} }
} }
}, },
null)); null));
} }
@@ -318,30 +475,36 @@ 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,
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),
enumBreakPoints: enumBreakPoints, enumBreakPoints: enumBreakPoints,
setEnumBreakPoints: setEnumBreakPoints, setEnumBreakPoints: (val) => {
setEnumBreakPoints(val);
SendSaveEvent
},
enumNames: enumNames, enumNames: enumNames,
setEnumNames: setEnumNames, setEnumNames: (val) => {
setEnumNames(val);
SendSaveEvent
},
visible: enumVisibleArr[i], visible: enumVisibleArr[i],
djParam: enumDjParamArr[i], djParam: enumDjParamArr[i],
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);
@@ -352,7 +515,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);
@@ -362,28 +525,30 @@ 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);
} }
} }
rerender(!render); rerender(!render);
SendSaveEvent();
} }
}, },
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);
SendSaveEvent();
} }
} }
}, null) }, null)
@@ -392,49 +557,99 @@ 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;
} }
return e('div', null, let lockClass;
e(Switch, {ontoggle: toggleViewMode}, null), if (lockMode == LockModes.LOCK) {
e('h5', null, title), lockClass = 'lock';
e('ul', null, ...labels.map(x => ListItem(Label(x)))), }
e('div', {id: 'grid'}, ...grid) else {
lockClass = 'lock unlocked';
}
return e('div', null,
e('div', { className: 'header' },
e('div', {className: 'nav'},
displayIfEnabled(e('button', { onClick: () => setViewMode(ViewModes.MOD), className: modButtonClass}, 'Modulators')),
displayIfEnabled(e('button', { onClick: () => setViewMode(ViewModes.ENUM), className: enumButtonClass }, 'Enumerators'))
),
e('button', { onClick: toggleEnabled, id: 'hide-button'}, toggleEnabledText),
//allows lock mode
//e('span', { className: lockClass, onClick: toggleLockMode }, null)
),
displayIfEnabled(
e('table', { id: 'table' },
e('thead', null, e('tr', { id: 'headers' }, ...labels.map(x => e('th', {id: x == '# points' ? 'points' : x}, 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.dispatchEvent(new CustomEvent('dumpNN'));
});
window.max.bindInlet("setNN", (...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("tempo", (val) => {
window.dispatchEvent(new CustomEvent('tempo', {'detail' : 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.dispatchEvent(new CustomEvent('maxTicks', { 'detail': val }));
});
window.max.bindInlet("userWave", (index, ...points) => {
let data = { points, index };
window.dispatchEvent(new CustomEvent('userWave', { 'detail': data }));
});
window.max.bindInlet("viewMode", (mode) => {
window.dispatchEvent(new CustomEvent('viewMode', { 'detail': parseInt(mode) }));
});
window.max.bindInlet("userFunction", (index, ...points) => {
//list of 101 points between 0-100
let data = { points, index };
window.dispatchEvent(new CustomEvent('userFunction', { 'detail': data }));
});
window.max.bindInlet("userDefinedType", (index, type) => {
let data = { index, type };
window.dispatchEvent(new CustomEvent('userDefinedType', { 'detail': data }));
})
setInterval(() => { setInterval(() => {
window.dispatchEvent(new CustomEvent('tick')); window.dispatchEvent(new CustomEvent('tick'));
}, 200); }, 200);
@@ -442,4 +657,4 @@ if (!DEBUG){
const root = ReactDOM.createRoot(document.getElementById('lfo-container')); const root = ReactDOM.createRoot(document.getElementById('lfo-container'));
root.render(e(MasterLfoHandler, null, null)); root.render(e(MasterLfoHandler, null, null));

View File

@@ -2,19 +2,29 @@
// MODULATORS // MODULATORS
///////////////////////// /////////////////////////
var SHAPETYPES = ["Sine", "SawUp", "SawDown", "Tri", "Square"];
var INSTANCEOPTIONS = ["1", "2", "3", "4"]; var TYPEOPTIONS = ["LFO", "Noise"];
var SHAPETYPES = ["Sine", "SawUp", "SawDown", "Tri", "Square", "Custom_1", "Custom_2", "Custom_3", "Custom_4"];
var NOISETYPES = ["Rand", "Line Int.", "Sine Int."]
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",
"attenuation", "chordal_weight", "tonality-profile", "ostinato-buffer", "ostinato", "meter", "scale"]; "attenuation", "chordal_weight", "tonality-profile", "ostinato-buffer", "ostinato", "meter", "scale"];
const PhaseTypes = Object.freeze({
MUSICAL: Symbol("musical"),
TIME: Symbol("time")
});
function ControlType(){ 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){
@@ -23,28 +33,45 @@ function LfoRow(props){
if (!center) if (!center)
center = 0; center = 0;
let content = e('ul', {className: 'lfo-item'}, let typeOption = null;
ListItem(DropDown({onChange: props.setInstanceNum, value:props.instanceNum, options: INSTANCEOPTIONS})),
ListItem(ControlType()), if (props.type == "LFO"){
ListItem(DropDown({onChange: props.setShape, value:props.shape, options: SHAPETYPES})), typeOption = DataCell(DropDown({locked:props.locked, 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)), else if (props.type == "Noise"){
ListItem(e(NumberBox, {onChange:props.setMin, value:props.min, step:0.1}, null)), typeOption = DataCell(DropDown({locked:props.locked, onChange: props.setNoise, value:props.noise, options: NOISETYPES}));
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)), let content = e('tr', {className: 'lfo-item'},
ListItem(e("div", {className:"base-val"}, center.toString())), DataCell(DropDown({locked:props.locked, onChange: props.setInstanceNum, value:props.instanceNum, options: INSTANCEOPTIONS})),
ListItem(e("input", {type: 'range', min: 0, max: 1, step: 0.01, readonly: true, id: `slider-${props.instanceNum}-${props.djParam}`})), DataCell(DropDown({locked:props.locked, options: TYPEOPTIONS, onChange: props.setType, value:props.type})),
ListItem(e(Button, {text:'+', onClick: props.addLfo}, null)), typeOption,
ListItem(e(Button, {text:'-', onClick: props.removeLfo}, null)), DataCell(DropDown({locked:props.locked, onChange: props.setDjParam, value: props.djParam, options: MODPARAMOPTIONS})),
ListItem(e("div", {className:"linked"}, linkedText)), DataCell(e("input", {onChange:props.setFreq, value:props.freq, className:"timeInput"}, null)),
DataCell(e(NumberBox, {onChange:props.setMin, value:props.min, step:0.1}, null)),
DataCell(e(NumberBox, {onChange:props.setMax, value:props.max, step:0.1}, null)),
//DataCell(e(NumberBox, {onChange:props.setAmp, value:props.amp, step:0.1}, null)),
DataCell(e(NumberBox, {onChange:props.setPhase, value:props.phase, step:0.1}, null)),
DataCell(e("div", {className:"base-val"}, center.toString())),
DataCell(e("input", {type: 'range', min: 0, max: 1, step: 0.01, readonly: true, id: `slider-${props.instanceNum}-${props.djParam}`})),
DataCell(e(Button, {text:'+', onClick: props.addLfo, locked: props.locked}, null)),
DataCell(e(Button, {text:'-', onClick: props.removeLfo, locked: props.locked}, null)),
DataCell(e("div", {className:"linked"}, linkedText)),
); );
if (props.visible){ if (props.visible){
return content return content;
}; };
} }
function indexWave(type, phase){ function indexUserWave(phase, index, userDefinedWaves){
return parseFloat(userDefinedWaves[index][Math.floor(phase * 50)]) / 127;
}
function indexUserFunction(phase, index, userDefinedFunctions){
return parseFloat(userDefinedFunctions[index][Math.floor(phase * 101)]) / 127;
}
function indexWave(type, phase, userDefinedWaves, userDefinedFunctions, userDefinedTypes){
switch (type){ switch (type){
case "Sine": case "Sine":
return (Math.sin(phase * Math.PI * 2) / 2) + 0.5; return (Math.sin(phase * Math.PI * 2) / 2) + 0.5;
@@ -56,10 +83,18 @@ function indexWave(type, phase){
return phase > 0.5? (1-phase) * 2 : phase * 2; return phase > 0.5? (1-phase) * 2 : phase * 2;
case "Square": case "Square":
return +(phase > 0.5); return +(phase > 0.5);
case "Custom_1":
return userDefinedTypes[0] == 0 ? indexUserWave(phase, 1, userDefinedWaves) : indexUserFunction(phase, 1, userDefinedFunctions);
case "Custom_2":
return userDefinedTypes[1] == 0 ? indexUserWave(phase, 2, userDefinedWaves) : indexUserFunction(phase, 2, userDefinedFunctions);
case "Custom_3":
return userDefinedTypes[2] == 0 ? indexUserWave(phase, 3, userDefinedWaves) : indexUserFunction(phase, 3, userDefinedFunctions);
case "Custom_4":
return userDefinedTypes[3] == 0 ? indexUserWave(phase, 4, userDefinedWaves) : indexUserFunction(phase, 4, userDefinedFunctions);
} }
} }
function operateModulators(visibleArr, instanceNumArr, paramNames, centers, freqs, mins, maxs, waveTypes, phaseArr, currTime, bpm, beatsInMeasure){ function operateModulators(visibleArr, typeArr, instanceNumArr, paramNames, centers, freqs, mins, maxs, waveTypes, phaseArr, noiseData, userDefinedWaves, userDefinedFunctions, userDefinedTypes, currTime, beatsInMeasure, ticks){
for (let i=0; i<paramNames.length; i++){ for (let i=0; i<paramNames.length; i++){
if (visibleArr[i]){ if (visibleArr[i]){
@@ -69,54 +104,121 @@ function operateModulators(visibleArr, instanceNumArr, paramNames, centers, freq
if (centers[inst].hasOwnProperty(name)){ if (centers[inst].hasOwnProperty(name)){
center = centers[inst][name]; center = centers[inst][name];
} }
let output = operateModulator(center, inst, freqs[i], mins[i], maxs[i], waveTypes[i], phaseArr, i, name, currTime, bpm, beatsInMeasure);
let output = 0;
if (typeArr[i] == "LFO")
output = operateLFO(center, inst, freqs[i], mins[i], maxs[i], waveTypes[i], phaseArr, i, userDefinedWaves, userDefinedFunctions, userDefinedTypes, name, currTime, beatsInMeasure, ticks);
else
output = operateNoise(center, inst, freqs[i], mins[i], maxs[i], waveTypes[i], phaseArr, i, name, noiseData, currTime, beatsInMeasure, ticks);
if (name !== "NONE") if (name !== "NONE")
window.dispatchEvent(new CustomEvent('enum', {'detail' : [inst, name, output]})); window.dispatchEvent(new CustomEvent('enum', {'detail' : [inst, name, output]}));
} }
} }
} }
function operateModulator(center, inst, freq, min, max, waveType, phaseArr, phaseI, name, currTime, bpm, beatsInMeasure){ function operateLFO(center, inst, timeBaseStr, min, max, waveType, phaseArr, phaseIndex, userDefinedWaves, userDefinedFunctions, userDefinedTypes, name, currTime, beatsInMeasure, maxTicks){
let amp = parseFloat(max) - parseFloat(min); let amp = parseFloat(max) - parseFloat(min);
let phaseType;
let timeBase;
freq = parseLfoTime(freq, bpm, beatsInMeasure); [timeBase, phaseType] = parseLfoTime(timeBaseStr, beatsInMeasure);
let phase = (currTime * freq + parseFloat(phaseArr[phaseI])) % 1.00; let phase;
let unscaled = indexWave(waveType, phase);
let el = document.getElementById(`slider-${inst}-${name}`);
if (el) if (phaseType === PhaseTypes.TIME)
el.value = unscaled; phase = (currTime * timeBase + parseFloat(phaseArr[phaseIndex])) % 1.00;
else if (phaseType === PhaseTypes.MUSICAL)
phase = (maxTicks % timeBase) / timeBase;
let unscaled = indexWave(waveType, phase, userDefinedWaves, userDefinedFunctions, userDefinedTypes);
syncDisplay(inst, name, unscaled);
return unscaled * amp + center + parseFloat(min); return unscaled * amp + center + parseFloat(min);
} }
function syncDisplay(inst, name, val) {
let el = document.getElementById(`slider-${inst}-${name}`);
if (el)
el.value = val;
}
function parseLfoTime(lfoTime, bpm, beatsInMeasure){ // For now, we're only using sine interpolation
function operateNoise(center, inst, timeBaseStr, min, max, waveType, phaseArr, index, name, noiseData, currTime, beatsInMeasure, maxTicks){
let amp = parseFloat(max) - parseFloat(min);
let phaseType;
let timeBase;
let noiseType = noiseData.noiseTypeArr[index];
[timeBase, phaseType] = parseLfoTime(timeBaseStr, beatsInMeasure);
let phase;
if (phaseType === PhaseTypes.TIME)
phase = (currTime * timeBase + parseFloat(phaseArr[index])) % 1.00;
else if (phaseType === PhaseTypes.MUSICAL)
phase = (maxTicks % timeBase) / timeBase;
if (noiseData.cachedNoiseValueArr1[index] == 0 || noiseData.lastPhaseArr[index] > phase){ // occurs if the phase reset to 0 or at the very start
noiseData.cachedNoiseValueArr2[index] = noiseData.cachedNoiseValueArr1[index];
if (noiseData.cachedNoiseValueArr1[index] == 0)
noiseData.cachedNoiseValueArr2[index] = center;
noiseData.cachedNoiseValueArr1[index] = Math.random();
noiseData.setCachedNoiseValueArr1(noiseData.cachedNoiseValueArr1);
noiseData.setCachedNoiseValueArr2(noiseData.cachedNoiseValueArr2);
}
noiseData.lastPhaseArr[index] = phase;
noiseData.setLastPhaseArr(noiseData.lastPhaseArr);
//let unscaled = (noiseData.cachedNoiseValueArr[index][1] - noiseData.cachedNoiseValueArr[index][0]) * sinePhase + noiseData.cachedNoiseValueArr[index][0];
let unscaled = interpolateNoise(noiseType, noiseData.cachedNoiseValueArr1[index], noiseData.cachedNoiseValueArr2[index], phase);
syncDisplay(inst, name, unscaled);
return unscaled * amp + center + parseFloat(min);
}
function interpolateNoise(type, cachedVal1, cachedVal2, phase){
let interpVal;
switch (type){
case "Sine Int.":
interpVal = (Math.sin(Math.PI + Math.PI * phase) + 1) / 2;
break;
case "Rand":
interpVal = 0;
break;
case "Line Int.":
interpVal = phase;
break;
}
return (cachedVal2 - cachedVal1) * interpVal + cachedVal1;
}
// actual returns the period for musical timing, to avoid floating point errors
function parseLfoTime(lfoTime, beatsInMeasure){
if (lfoTime.slice(-2) == "hz"){ if (lfoTime.slice(-2) == "hz"){
return parseFloat(lfoTime.slice(0, -2)); return [parseFloat(lfoTime.slice(0, -2)), PhaseTypes.TIME];
} }
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)), PhaseTypes.TIME];
} }
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)), PhaseTypes.TIME];
} }
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(), PhaseTypes.TIME];
} }
else if ((lfoTime.match(/\./g) || []).length == 2){ else if ((lfoTime.match(/\./g) || []).length == 2){
return musicalTimingToFreq(...lfoTime.split('.'), bpm, beatsInMeasure) return [musicalTimingToFreq(...lfoTime.split('.'), beatsInMeasure), PhaseTypes.MUSICAL];
} }
else { else {
return 0; return [0, PhaseTypes.TIME];
} }
} }
function musicalTimingToFreq(bars, beats, ticks, bpm, beatsInMeasure){ function musicalTimingToFreq(bars, beats, ticks, beatsInMeasure){
let totalTicks = (parseFloat(bars) * parseFloat(beatsInMeasure) + beats) * 480 + parseFloat(ticks); let totalTicks = (parseFloat(bars) * parseFloat(beatsInMeasure) + parseFloat(beats)) * 480 + parseFloat(ticks);
let tpm = bpm * 480; return totalTicks;
let cyclesPerMinute = tpm / totalTicks;
let hz = cyclesPerMinute / 60;
return hz;
} }

93
myStorage.json Normal file

File diff suppressed because one or more lines are too long