summaryrefslogtreecommitdiff
path: root/client/lib/scales.js
blob: f122ba0346c05dace90b24661f414ea607d3e35b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**
 * Scales
 * @module client/lib/scales.js;
 */

import "core-js/stable";
import "regenerator-runtime/runtime";

import {
  Arithmetic,
  Collatz,
  Fibonacci,
  Geometric,
  Power,
  Prime,
  Triangle,
} from "../vendor/number-sequences/dist/index.js";

let a, b;

export const scales = [
  { name: "natural", get: (i, j) => [i + 1, j + 1] },
  { name: "undertone", get: (i, j) => [i + 1, i + j + 2] },
  { name: "overtone", get: (i, j) => [i + j + 2, j + 1] },
  {
    name: "primes",
    reset: (x, y, w, h) => {
      a = Prime().skip(x).take(w).toJS();
      b = Prime().skip(y).take(h).toJS();
    },
    get: (ii, jj, i, j) => [a[i], b[j]],
  },
  {
    name: "arithmetic",
    reset: (x, y, w, h) => {
      a = Arithmetic(x + 1, x + 1)
        .take(w)
        .toJS();
      b = Arithmetic(y + 1, y + 1)
        .take(h)
        .toJS();
      console.log(a);
    },
    get: (ii, jj, i, j) => [a[i], b[j]],
  },
  // {
  //   name: "triangle",
  //   reset: (x, y, w, h) => {
  //     a = Triangle().skip(x).take(w).toJS();
  //     b = Triangle().skip(y).take(h).toJS();
  //   },
  //   get: (ii, jj, i, j) => [a[i], b[j]],
  // },
  {
    name: "collatz",
    reset: (x, y, w, h) => {
      a = Collatz(x + 1)
        .take(w)
        .toJS();
      b = Collatz(y + 1)
        .take(h)
        .toJS();
    },
    get: (ii, jj, i, j) => [a[i], b[j]],
  },
  {
    name: "pythagorean",
    get: (i, j) =>
      i < j
        ? [3 ** (i + 1), 2 ** (j + Math.ceil(Math.max(0, (i * 1.0) / 2)))]
        : [2 ** (i + Math.ceil(Math.max(0, (j * 1.2) / 2))), 3 ** j],
  },
];

export const equal = { name: "equal", get: (i, j) => [i, j + 1] };