summaryrefslogtreecommitdiff
path: root/bundle.js
diff options
context:
space:
mode:
authorjulian laplace <julescarbon@gmail.com>2025-06-30 23:35:13 +0200
committerjulian laplace <julescarbon@gmail.com>2025-06-30 23:35:13 +0200
commite5ec8893d18aa21f771ab56fc5ded42602125f94 (patch)
treef9b95619cfa86ff6ea72302defbee5367f2d3307 /bundle.js
parentdfcdf790e3879678d8b3a9b729cca03174b32d55 (diff)
fixes
Diffstat (limited to 'bundle.js')
-rw-r--r--bundle.js681
1 files changed, 219 insertions, 462 deletions
diff --git a/bundle.js b/bundle.js
index aaca317..0188920 100644
--- a/bundle.js
+++ b/bundle.js
@@ -63,7 +63,7 @@
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 10);
+/******/ return __webpack_require__(__webpack_require__.s = 11);
/******/ })
/************************************************************************/
/******/ ([
@@ -22526,7 +22526,7 @@ var _tone = __webpack_require__(0);
var _tone2 = _interopRequireDefault(_tone);
-var _startAudioContext = __webpack_require__(11);
+var _startAudioContext = __webpack_require__(12);
var _startAudioContext2 = _interopRequireDefault(_startAudioContext);
@@ -22538,7 +22538,7 @@ var isAndroid = navigator.userAgent.match(/Android/i);
var isMobile = isIphone || isIpad || isAndroid;
var isDesktop = !isMobile;
-document.body.classList.add(isMobile ? 'mobile' : 'desktop');
+document.body.classList.add(isMobile ? "mobile" : "desktop");
var browser = { isIphone: isIphone, isIpad: isIpad, isMobile: isMobile, isDesktop: isDesktop };
@@ -22550,34 +22550,34 @@ function mod(n, m) {
}
function requestAudioContext(fn) {
- if (isMobile) {
- var container = document.createElement('div');
- var button = document.createElement('div');
- button.innerHTML = 'Tap to start - please unmute your phone';
+ if (window.location.protocol !== "https:") {
+ var container = document.createElement("div");
+ var button = document.createElement("div");
+ button.innerHTML = "Tap to start - please unmute your phone";
Object.assign(container.style, {
- display: 'block',
- position: 'absolute',
- width: '100%',
- height: '100%',
- zIndex: '10000',
- top: '0px',
- left: '0px',
- backgroundColor: 'rgba(0, 0, 0, 0.8)'
+ display: "block",
+ position: "absolute",
+ width: "100%",
+ height: "100%",
+ zIndex: "10000",
+ top: "0px",
+ left: "0px",
+ backgroundColor: "rgba(0, 0, 0, 0.8)"
});
Object.assign(button.style, {
- display: 'block',
- position: 'absolute',
- left: '50%',
- top: '50%',
- padding: '20px',
- backgroundColor: '#7F33ED',
- color: 'white',
- fontFamily: 'monospace',
- borderRadius: '3px',
- transform: 'translate3D(-50%,-50%,0)',
- textAlign: 'center',
- lineHeight: '1.5',
- width: '150px'
+ display: "block",
+ position: "absolute",
+ left: "50%",
+ top: "50%",
+ padding: "20px",
+ backgroundColor: "#7F33ED",
+ color: "white",
+ fontFamily: "monospace",
+ borderRadius: "3px",
+ transform: "translate3D(-50%,-50%,0)",
+ textAlign: "center",
+ lineHeight: "1.5",
+ width: "150px"
});
container.appendChild(button);
document.body.appendChild(container);
@@ -22607,6 +22607,7 @@ exports.requestAudioContext = requestAudioContext;
Object.defineProperty(exports, "__esModule", {
value: true
});
+exports.getOutput = getOutput;
var _tone = __webpack_require__(0);
@@ -22614,12 +22615,21 @@ var _tone2 = _interopRequireDefault(_tone);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-var compressor = new _tone2.default.Compressor(-30, 3);
-var gain = new _tone2.default.Gain(0.3);
-compressor.connect(gain);
-gain.toMaster();
+var output = null;
-exports.default = compressor;
+function getOutput() {
+ if (!output) output = makeOutput();
+ return output;
+}
+
+function makeOutput() {
+ var compressor = new _tone2.default.Compressor(-30, 3);
+ var gain = new _tone2.default.Gain(0.3);
+ compressor.connect(gain);
+ gain.toMaster();
+
+ return compressor;
+}
/***/ }),
/* 3 */
@@ -22654,8 +22664,7 @@ module.exports = Array.isArray || isArray;
Object.defineProperty(exports, "__esModule", {
value: true
});
-
-var palettes = [[[0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [1.0, 1.0, 1.0], [0.00, 0.33, 0.67]], [[0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [1.0, 1.0, 1.0], [0.00, 0.10, 0.20]], [[0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [1.0, 1.0, 1.0], [0.30, 0.20, 0.20]], [[0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [1.0, 1.0, 0.5], [0.80, 0.90, 0.30]], [[0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [1.0, 0.7, 0.4], [0.00, 0.15, 0.20]], [[0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [2.0, 1.0, 0.0], [0.50, 0.20, 0.25]], [[0.8, 0.5, 0.4], [0.2, 0.4, 0.2], [2.0, 1.0, 1.0], [0.00, 0.25, 0.25]]];
+var palettes = [[[0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [1.0, 1.0, 1.0], [0.0, 0.33, 0.67]], [[0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [1.0, 1.0, 1.0], [0.0, 0.1, 0.2]], [[0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [1.0, 1.0, 1.0], [0.3, 0.2, 0.2]], [[0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [1.0, 1.0, 0.5], [0.8, 0.9, 0.3]], [[0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [1.0, 0.7, 0.4], [0.0, 0.15, 0.2]], [[0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [2.0, 1.0, 0.0], [0.5, 0.2, 0.25]], [[0.8, 0.5, 0.4], [0.2, 0.4, 0.2], [2.0, 1.0, 1.0], [0.0, 0.25, 0.25]]];
var palette = palettes[0];
@@ -22676,7 +22685,7 @@ function color(t, add, mul) {
d = palette[3][i];
rgb[i] = Math.round(channel(t, a, b, c, d, add, mul) * 255);
}
- return 'rgb(' + rgb + ')';
+ return "rgb(" + rgb + ")";
}
exports.default = color;
@@ -22700,54 +22709,47 @@ var _util = __webpack_require__(1);
var _output = __webpack_require__(2);
-var _output2 = _interopRequireDefault(_output);
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var player_count = 4;
-var samples = [{ root: 226, fn: 'samples/380737__cabled-mess__sansula-01-a-raw.wav' }, { root: 267, fn: 'samples/380736__cabled-mess__sansula-02-c-raw.wav' }, { root: 340, fn: 'samples/380735__cabled-mess__sansula-03-e-raw.wav' }, { root: 452, fn: 'samples/380733__cabled-mess__sansula-06-a-02-raw.wav' }];
+var samples = [{ root: 226, fn: "samples/380737__cabled-mess__sansula-01-a-raw.wav" }];
-samples.forEach(function (sample) {
- sample.players = [];
- sample.index = -1;
- for (var i = 0; i < player_count; i++) {
- var fn = sample.fn;
- if (window.location.href.match(/asdf.us/)) {
- fn = '//asdf.us/kalimba/' + fn.replace('wav', 'mp3');
+function load() {
+ var output = (0, _output.getOutput)();
+ samples.forEach(function (sample) {
+ sample.players = [];
+ sample.index = -1;
+ for (var i = 0; i < player_count; i++) {
+ var fn = sample.fn;
+ if (window.location.href.match(/asdf.us/)) {
+ fn = "//asdf.us/kalimba/" + fn.replace("wav", "mp3");
+ }
+ var player = new _tone2.default.Player({
+ url: fn,
+ retrigger: true,
+ playbackRate: 1
+ });
+ player.connect(output);
+ sample.players.push(player);
}
- var player = new _tone2.default.Player({
- url: fn,
- retrigger: true,
- playbackRate: 1
- });
- player.connect(_output2.default);
- sample.players.push(player);
- }
-});
+ });
+}
function play(freq) {
- /*
- while (freq < 440) {
- freq *= 2
- }
- while (freq > 880) {
- freq /= 2
- }
- freq /= 2
- */
- var best = { sample: (0, _util.choice)(samples) };
- best.sample.index = (best.sample.index + 1) % player_count;
+ var best = (0, _util.choice)(samples);
+ best.index = (best.index + 1) % player_count;
+
+ var player = best.players[best.index];
+ player.playbackRate = freq / best.root;
- var player = best.sample.players[best.sample.index];
- player.playbackRate = freq / best.sample.root;
player.start();
}
function pause() {
// no-op
}
-exports.default = { play: play, pause: pause };
+exports.default = { load: load, play: play, pause: pause };
/***/ }),
/* 6 */
@@ -22799,107 +22801,7 @@ function listen(fn) {
exports.default = { listen: listen };
/***/ }),
-/* 7 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-
-var w = void 0,
- h = void 0,
- a = void 0,
- b = void 0,
- notes = void 0,
- assign = void 0;
-function init(z, fn) {
- // really bad
- notes = z;
- assign = fn;
- build();
- setTempo(50);
-}
-function build() {
- w = notes.length;
- h = notes[0].length;
- a = a || new Array(w);
- b = b || new Array(w);
- for (var i = 0; i < w; i++) {
- a[i] = a[i] || new Array(h);
- b[i] = b[i] || new Array(h);
- for (var j = 0; j < h; j++) {
- a[i][j] = b[i][j] = notes[i][j] && notes[i][j].playing ? 1 : 0;
- }
- }
-}
-var timeout = void 0,
- delay = 1200; // ~120 bpm
-function toggle() {
- build();
- if (timeout) {
- clearTimeout(timeout);
- timeout = null;
- } else {
- step();
- }
-}
-function assign_item(freq, state) {
- b[freq.i][freq.j] = state ? 1 : 0;
-}
-function setTempo(bpm) {
- console.log('bpm:', bpm);
- delay = 60000 / bpm;
-}
-function swap() {
- var tmp = a;
- a = b;
- b = tmp;
-}
-function step() {
- clearTimeout(timeout);
- timeout = setTimeout(step, delay);
- swap();
- var i = void 0,
- j = void 0,
- ni = void 0,
- pi = void 0,
- nj = void 0,
- pj = void 0,
- score = void 0,
- state = void 0;
- for (i = 0; i < w; i++) {
- for (j = 0; j < h; j++) {
- ni = i === 0 ? w - 1 : i - 1;
- pi = i === w - 1 ? 0 : i + 1;
- nj = j === 0 ? h - 1 : j - 1;
- pj = j === h - 1 ? 0 : j + 1;
- score = a[ni][nj] + a[ni][j] + a[ni][pj] + a[i][nj] + a[i][pj] + a[pi][nj] + a[pi][j] + a[pi][pj];
- state = fitness(a[i][j], score);
- b[i][j] = state;
- if (a[i][j] !== state) {
- assign(notes[i][j], state);
- }
- }
- }
-}
-function fitness(old, score) {
- if (old === 1) {
- if (score === 2 || score === 3) return 1;
- } else {
- if (score === 3) return 1;
- }
- return 0;
-}
-function isRunning() {
- return !!timeout;
-}
-
-exports.default = { init: init, step: step, assign_item: assign_item, toggle: toggle, setTempo: setTempo, isRunning: isRunning };
-
-/***/ }),
+/* 7 */,
/* 8 */
/***/ (function(module, exports, __webpack_require__) {
@@ -22951,11 +22853,23 @@ exports.default = { play: play, pause: pause, oscillators: oscillators };
"use strict";
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+var PRIMES = exports.PRIMES = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997];
+
+/***/ }),
+/* 10 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
// MODULES //
var isArray = __webpack_require__( 3 ),
- isIntegerArray = __webpack_require__( 13 ),
- isFunction = __webpack_require__( 12 );
+ isIntegerArray = __webpack_require__( 14 ),
+ isFunction = __webpack_require__( 13 );
// VARIABLES //
@@ -23164,13 +23078,13 @@ module.exports = compute;
/***/ }),
-/* 10 */
+/* 11 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
-var _computeGcd = __webpack_require__(9);
+var _computeGcd = __webpack_require__(10);
var _computeGcd2 = _interopRequireDefault(_computeGcd);
@@ -23186,26 +23100,26 @@ var _kalimba = __webpack_require__(5);
var _kalimba2 = _interopRequireDefault(_kalimba);
-var _life = __webpack_require__(7);
-
-var _life2 = _interopRequireDefault(_life);
-
var _organ = __webpack_require__(8);
var _organ2 = _interopRequireDefault(_organ);
var _util = __webpack_require__(1);
+var _primes = __webpack_require__(9);
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+// import life from "./lib/life";
+
var instrument = _kalimba2.default;
var root = 440;
var s = 50;
-var w = window.innerWidth;
-var h = window.innerHeight;
-var ws = Math.ceil(w / s),
- hs = Math.ceil(h / s);
+var w = void 0,
+ h = void 0,
+ ws = void 0,
+ hs = void 0;
var add_on = 0;
var mul_on = 1.0;
@@ -23216,32 +23130,61 @@ var dragging = false;
var erasing = false;
var lastFreq = 0;
var notes = [];
+var base_x = 0;
+var base_y = 0;
+var is_split = false;
(0, _util.requestAudioContext)(function () {
+ _kalimba2.default.load();
+ build();
+ bind();
+});
+
+function build() {
+ w = window.innerWidth;
+ h = window.innerHeight;
+ ws = Math.ceil(w / s);
+ hs = Math.ceil(h / s);
for (var i = 0; i < ws; i++) {
notes[i] = [];
for (var j = 0; j < hs; j++) {
notes[i][j] = add(i, j);
}
}
- _life2.default.init(notes, assign);
-});
-
+}
+function rebuild() {
+ notes.forEach(function (row) {
+ return row.forEach(function (note) {
+ return note.destroy();
+ });
+ });
+ build();
+}
function play(freq) {
- if (freq.playing) return;
+ if (instrument === _organ2.default && freq.playing) return;
freq.playing = true;
- instrument.play(freq.frequency);
- if (instrument === _organ2.default || hash || _life2.default.isRunning()) {
+ var frequency = freq.frequency;
+
+ // while (frequency < root) {
+ // frequency *= 2;
+ // }
+ // while (frequency > root) {
+ // frequency /= 2;
+ // }
+
+ instrument.play(frequency);
+ if (instrument === _organ2.default || hash) {
+ // || life.isRunning()) {
freq.div.classList.add("playing");
}
- _life2.default.assign_item(freq, true);
+ // life.assign_item(freq, true);
}
function pause(freq) {
if (!freq.playing) return;
freq.playing = false;
instrument.pause(freq.frequency);
freq.div.classList.remove("playing");
- _life2.default.assign_item(freq, false);
+ // life.assign_item(freq, false);
}
function assign(freq, state) {
if (state) {
@@ -23253,102 +23196,17 @@ function assign(freq, state) {
function toggle(freq) {
assign(freq, !freq.playing);
}
-var gliderShape = [[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 0, 0, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]];
-var gliderShapeFlip = gliderShape.map(function (a) {
- return a.slice(0).reverse();
-});
-var gliderShapes = [gliderShape, gliderShapeFlip, gliderShape.slice(0).reverse(), gliderShapeFlip.slice(0).reverse()];
-function glider() {
- var x = Math.floor(Math.random() * ws);
- var y = Math.floor(Math.random() * hs);
- var shape = (0, _util.choice)(gliderShapes);
- weave(x, y, shape);
-}
-function weave(x, y, shape) {
- var xmag = shape.length;
- var ymag = shape[0].length;
- var i = void 0,
- j = void 0,
- px = void 0,
- py = void 0;
- for (i = 0; i < xmag; i++) {
- for (j = 0; j < ymag; j++) {
- px = (x + i) % ws;
- py = (y + j) % hs;
- assign(notes[px][py], shape[i][j]);
- }
- }
-}
-function forEach(f) {
- var i = void 0,
- j = void 0,
- note = void 0,
- s = void 0;
- for (i = 0; i < ws; i++) {
- for (j = 0; j < hs; j++) {
- note = notes[i][j];
- s = f(i, j, note.playing);
- assign(note, s);
- }
- }
-}
-function clone() {
- var i = void 0,
- j = void 0;
- var a = [];
- for (i = 0; i < ws; i++) {
- a[i] = [];
- for (j = 0; j < hs; j++) {
- a[i][j] = notes[i][j].playing;
- }
- }
- return a;
-}
-function move(dx, dy) {
- var a = clone();
- forEach(function (x, y, state) {
- x = (x + dx + ws) % ws;
- y = (y + dy + hs) % hs;
- return a[x][y];
- });
-}
-function clear() {
- forEach(function () {
- return false;
- });
-}
-function stripex(odd) {
- odd = !!odd;
- forEach(function (x) {
- return x % 2 ? odd : !odd;
- });
-}
-function stripey(odd) {
- odd = !!odd;
- forEach(function (x, y) {
- return y % 2 ? odd : !odd;
- });
-}
-function checker(odd, n) {
- odd = !!odd;
- n = n || 1;
- forEach(function (x, y) {
- return Math.floor(x / n) % 2 ^ Math.floor(y / n) % 2 ? odd : !odd;
- });
-}
-function noise(n) {
- n = n || 0.5;
- n = n * n;
- forEach(function () {
- return Math.random() < n;
- });
-}
function add(i, j) {
- var a = i + 1;
- var b = j + 1;
+ var a = i + 1 + base_x;
+ var b = j + 1 + base_y;
+ // const a = i + 1;
+ // const b = i + j + 2;
+ // const a = PRIMES[i];
+ // const b = PRIMES[i + j + 1];
var div = document.createElement("div");
var frequency = root * a / b;
+ // const frequency = root * Math.pow(2, ((b / a) % 1) + 1);
var add = 0;
var frac = void 0;
div.style.left = i * s + "px";
@@ -23360,6 +23218,9 @@ function add(i, j) {
i: i,
j: j,
playing: false,
+ destroy: function destroy() {
+ div.parentNode.removeChild(div);
+ },
recolor: function recolor(numerator, denominator) {
var aa = a / numerator;
var bb = b / denominator;
@@ -23404,24 +23265,30 @@ function add(i, j) {
if (event.button === 2) {
// rightclick
event.preventDefault();
- notes.forEach(function (row) {
- return row.forEach(function (note) {
- return note.recolor(a, b);
- });
- });
+ // notes.forEach((row) => row.forEach((note) => note.recolor(a, b)));
+ is_split = [a, b];
return;
}
div.style.backgroundColor = (0, _color2.default)(frac, add + add_on, mul_on);
- toggle(freq);
- erasing = !freq.playing;
+ dragging = true;
+ if (instrument === _organ2.default) {
+ toggle(freq);
+ erasing = !freq.playing;
+ } else {
+ play(freq);
+ }
});
div.addEventListener("mouseenter", function () {
div.style.backgroundColor = (0, _color2.default)(frac, add + add_on, mul_on);
if (dragging) {
- if (erasing) {
- pause(freq);
+ if (instrument === _organ2.default) {
+ if (erasing) {
+ pause(freq);
+ } else {
+ toggle(freq);
+ }
} else {
- toggle(freq);
+ play(freq);
}
}
});
@@ -23445,186 +23312,85 @@ function add(i, j) {
return freq;
}
-if (_util.browser.isDesktop) {
- document.addEventListener("mousedown", function (event) {
- if (event.button !== 2) {
+function bind() {
+ window.addEventListener("resize", build);
+ if (_util.browser.isDesktop) {
+ document.addEventListener("mousedown", function (event) {
+ if (event.button !== 2) {
+ dragging = true;
+ }
+ });
+ document.addEventListener("mouseup", function () {
+ dragging = false;
+ });
+ } else {
+ document.addEventListener("touchstart", function (e) {
+ e.preventDefault();
dragging = true;
- }
- });
- document.addEventListener("mouseup", function () {
- dragging = false;
- });
-} else {
- document.addEventListener("touchstart", function (e) {
- e.preventDefault();
- dragging = true;
- });
- document.addEventListener("touchmove", function (e) {
- e.preventDefault();
- var x = Math.floor(e.touches[0].pageX / s);
- var y = Math.floor(e.touches[0].pageY / s);
- if (!(x in notes) || !(y in notes[x])) return;
- var freq = notes[x][y];
- if (freq !== lastFreq) {
- if (dragging) {
- if (erasing) {
- pause(freq);
- } else {
- toggle(freq);
+ });
+ document.addEventListener("touchmove", function (e) {
+ e.preventDefault();
+ var x = Math.floor(e.touches[0].pageX / s);
+ var y = Math.floor(e.touches[0].pageY / s);
+ if (!(x in notes) || !(y in notes[x])) return;
+ var freq = notes[x][y];
+ if (freq !== lastFreq) {
+ if (dragging) {
+ if (erasing) {
+ pause(freq);
+ } else {
+ toggle(freq);
+ }
}
+ lastFreq = freq;
}
- lastFreq = freq;
- }
- });
- document.addEventListener("touchend", function () {
- dragging = false;
- });
+ });
+ document.addEventListener("touchend", function () {
+ dragging = false;
+ });
+ }
}
function swap_instrument() {
instrument = instrument === _kalimba2.default ? _organ2.default : _kalimba2.default;
}
-var life_bpm = 50;
window.addEventListener("keydown", keydown, true);
function keydown(e) {
// console.log(e.keyCode)
if (e.altKey || e.ctrlKey || e.metaKey) return;
switch (e.keyCode) {
- case 32:
- // space
- _life2.default.toggle();
- break;
- case 188:
- // comma
- life_bpm += e.shiftKey ? 1 : 5;
- _life2.default.setTempo(life_bpm);
- break;
- case 190:
- // period
- life_bpm -= e.shiftKey ? 1 : 5;
- life_bpm = Math.max(1, life_bpm);
- _life2.default.setTempo(life_bpm);
- break;
case 37:
// left
- move(1, 0);
+ base_x = Math.max(0, base_x - 1);
+ rebuild();
break;
case 38:
// up
- move(0, 1);
+ base_y = Math.max(0, base_y - 1);
+ rebuild();
break;
case 39:
// right
- move(-1, 0);
+ base_x += 1;
+ rebuild();
break;
case 40:
// down
- move(0, -1);
- break;
- case 71:
- // g
- glider();
- break;
- case 83:
- // s
- swap_instrument();
- break;
- case 67:
- // c
- clear();
- break;
- case 87:
- // w
- clear();
- break;
- case 78:
- // n
- noise(0.5);
- break;
- case 69:
- // e
- stripex(Math.random() < 0.5);
- break;
- case 82:
- // r
- stripey(Math.random() < 0.5);
- break;
- case 84:
- // t
- checker(Math.random() < 0.5, 1);
- break;
- case 89:
- // y
- checker(Math.random() < 0.5, 2);
- break;
- case 85:
- // u
- checker(Math.random() < 0.5, 3);
- break;
- case 73:
- // i
- checker(Math.random() < 0.5, 4);
- break;
- case 79:
- // o
- checker(Math.random() < 0.5, 5);
- break;
- case 80:
- // p
- checker(Math.random() < 0.5, 6);
- break;
- case 219:
- // [
- checker(Math.random() < 0.5, 7);
- break;
- case 221:
- // ]
- checker(Math.random() < 0.5, 11);
- break;
- case 49:
- // 1
- noise(0.1);
- break;
- case 50:
- // 2
- noise(0.2);
- break;
- case 51:
- // 3
- noise(0.3);
- break;
- case 52:
- // 4
- noise(0.4);
- break;
- case 53:
- // 5
- noise(0.5);
- break;
- case 54:
- // 6
- noise(0.6);
- break;
- case 55:
- // 7
- noise(0.7);
- break;
- case 56:
- // 8
- noise(0.8);
- break;
- case 57:
- // 9
- noise(0.9);
- break;
- case 48:
- // 0
- noise(1);
+ base_y += 1;
+ rebuild();
break;
}
}
_keys2.default.listen(function (index) {
+ index += 7;
+ var x = index % 7;
+ var y = Math.floor(index / 7);
+ var a = x;
+ var b = y + 1;
+ var freq = notes[a][b];
+ console.log(a, b, freq.frequency);
+ play(freq);
// const freq = scales.current().index(index)
// document.body.style.backgroundColor = color( index / scales.current().scale.length )
// instrument.toggle(freq)
@@ -23634,16 +23400,9 @@ var hash = window.location.hash || window.location.search;
if (hash.match("sin") || hash.match("organ")) {
instrument = _organ2.default;
}
-if (hash.match("glider")) {
- instrument = _organ2.default;
- clear();
- glider();
- _life2.default.setTempo(life_bpm = 120 * 8);
- _life2.default.toggle();
-}
/***/ }),
-/* 11 */
+/* 12 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
@@ -23663,13 +23422,12 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
- } else if ((typeof module === "undefined" ? "undefined" : _typeof(module)) === 'object' && module.exports) {
+ } else if ((typeof module === "undefined" ? "undefined" : _typeof(module)) === "object" && module.exports) {
module.exports = factory();
} else {
root.StartAudioContext = factory();
}
})(undefined, function () {
-
/**
* The StartAudioContext object
*/
@@ -23726,7 +23484,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
};
/**
- * Bind a callback to when the audio context is started.
+ * Bind a callback to when the audio context is started.
* @param {Function} cb
* @return {StartAudioContext}
*/
@@ -23754,7 +23512,6 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
* @internal
*/
var TapListener = function TapListener(element) {
-
this._dragged = false;
this._element = element;
@@ -23798,7 +23555,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
/**
* Invoked the first time of the elements is tapped.
- * Creates a silent oscillator when a non-dragging touchend
+ * Creates a silent oscillator when a non-dragging touchend
* event has been triggered.
*/
function onTap() {
@@ -23834,7 +23591,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
});
/***/ }),
-/* 12 */
+/* 13 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
@@ -23886,7 +23643,7 @@ module.exports = isFunction;
/***/ }),
-/* 13 */
+/* 14 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
@@ -23923,7 +23680,7 @@ module.exports = isFunction;
// MODULES //
var isArray = __webpack_require__( 3 ),
- isInteger = __webpack_require__( 14 );
+ isInteger = __webpack_require__( 15 );
// IS INTEGER ARRAY //
@@ -23959,7 +23716,7 @@ module.exports = isIntegerArray;
/***/ }),
-/* 14 */
+/* 15 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
@@ -23995,7 +23752,7 @@ module.exports = isIntegerArray;
// MODULES //
-var isNumber = __webpack_require__( 15 );
+var isNumber = __webpack_require__( 16 );
// ISINTEGER //
@@ -24018,7 +23775,7 @@ module.exports = isInteger;
/***/ }),
-/* 15 */
+/* 16 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";