summaryrefslogtreecommitdiff
path: root/bundle.js
diff options
context:
space:
mode:
Diffstat (limited to 'bundle.js')
-rw-r--r--bundle.js86
1 files changed, 69 insertions, 17 deletions
diff --git a/bundle.js b/bundle.js
index 9e6a730..a0f2534 100644
--- a/bundle.js
+++ b/bundle.js
@@ -24780,6 +24780,12 @@ nx.onload = function () {
nx.widgets.slideDown.on('*', function (e) {
return e.press && slideDown();
});
+ nx.widgets.slideLeft.on('*', function (e) {
+ return e.press && slideLeft();
+ });
+ nx.widgets.slideRight.on('*', function (e) {
+ return e.press && slideRight();
+ });
nx.widgets.rotateUp.on('*', function (e) {
return e.press && rotateVertical(-1);
});
@@ -24804,8 +24810,48 @@ nx.onload = function () {
_tone2.default.Transport.start();
};
-function shiftUp() {}
-function shiftDown() {}
+function shiftUp() {
+ var scaleCount = _scales2.default.current().scale.length;
+ var originalNotes = findNotes();
+ var subScale = originalNotes.map(function (n) {
+ return noteCount - n;
+ }).reduce(function (acc, n) {
+ var scaleNote = n % scaleCount;
+ if (!acc.includes(scaleNote)) acc.push(scaleNote);
+ return acc;
+ }, []).sort();
+ assignNotes(mapFunction(originalNotes, function (n) {
+ var note = noteCount - n;
+ var scaleIndex = subScale.indexOf(note % scaleCount) + 1;
+ var octave = Math.floor(note / scaleCount);
+ while (scaleIndex >= subScale.length) {
+ scaleIndex -= subScale.length;
+ octave += 1;
+ }
+ return noteCount - (subScale[scaleIndex] + octave * scaleCount);
+ }));
+}
+function shiftDown() {
+ var scaleCount = _scales2.default.current().scale.length;
+ var originalNotes = findNotes();
+ var subScale = originalNotes.map(function (n) {
+ return noteCount - n;
+ }).reduce(function (acc, n) {
+ var scaleNote = n % scaleCount;
+ if (!acc.includes(scaleNote)) acc.push(scaleNote);
+ return acc;
+ }, []).sort();
+ assignNotes(mapFunction(originalNotes, function (n) {
+ var note = noteCount - n;
+ var scaleIndex = subScale.indexOf(note % scaleCount) - 1;
+ var octave = Math.floor(note / scaleCount);
+ while (scaleIndex < 0) {
+ scaleIndex += subScale.length;
+ octave -= 1;
+ }
+ return noteCount - Math.max(0, subScale[scaleIndex] + octave * scaleCount);
+ }));
+}
function slideUp() {
assignNotes(mapFunction(findNotes(), function (n) {
return (n - 1 + noteCount) % noteCount;
@@ -24816,6 +24862,16 @@ function slideDown() {
return (n + 1 + noteCount) % noteCount;
}));
}
+function slideLeft() {
+ assignPositions(mapFunction(findPositions(), function (n) {
+ return (n - 1 + stepCount) % stepCount;
+ }));
+}
+function slideRight() {
+ assignPositions(mapFunction(findPositions(), function (n) {
+ return (n + 1 + stepCount) % stepCount;
+ }));
+}
function flip() {
assignNotes(mapReverse(findNotes()));
}
@@ -24828,25 +24884,25 @@ function rotateHorizontal(n) {
function rotateVertical(n) {
assignNotes(remapArray(findNotes(), n));
}
-function assignPositions(notes) {
- if (!notes) return;
+function assignPositions(positions) {
+ if (!positions) return;
var a = grid.matrix;
var b = iota();
stride(a, function (i, j, v) {
- if (i in notes) {
- b[notes[i]][j] = v;
+ if (i in positions) {
+ b[positions[i]][j] = v;
}
});
assign(grid.matrix, b);
grid.draw();
}
-function assignNotes(positions) {
- if (!positions) return;
+function assignNotes(noteMap) {
+ if (!noteMap) return;
var a = grid.matrix;
var b = iota();
stride(a, function (i, j, v) {
- if (j in positions) {
- b[i][positions[j]] = v;
+ if (j in noteMap) {
+ b[i][noteMap[j]] = v;
}
});
assign(grid.matrix, b);
@@ -24887,11 +24943,9 @@ function iota() {
return a;
}
function findNotes() {
- var a = new Array(grid.matrix[0].length);
- grid.matrix.forEach(function (col, i) {
- col.forEach(function (v, j) {
- if (v) a[j] = 1;
- });
+ var a = new Array(noteCount);
+ stride(grid.matrix, function (i, j, v) {
+ if (v) a[j] = 1;
});
return a.reduce(function (acc, v, i) {
if (v === 1) acc.push(i);
@@ -24918,7 +24972,6 @@ function remapArray(a, n) {
function rotate(a, n) {
var b = a.slice(0);
b.unshift.apply(b, b.splice(-n, b.length));
- console.log(b);
return b;
}
function mapFunction(a, f) {
@@ -24927,7 +24980,6 @@ function mapFunction(a, f) {
for (var i = 0; i < a.length; i++) {
h[a[i]] = f(a[i]);
}
- console.log(h);
return h;
}
function mapReverse(a) {