summaryrefslogtreecommitdiff
path: root/src/index.jsx
blob: 8c07739c2c3541e289360ad724ff1e9acdf2de14 (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
import * as React from "react";
import { createRoot } from "react-dom/client";
import { requestAudioContext, randrange } from "./lib/util";
import Relabi from "./relabi";
import { Kalimba, Drums } from "./lib/instruments";

document.body.style.backgroundColor = "#111";
document.body.style.color = "#fff";

requestAudioContext(() => {
  document.body.innerHTML = '<div id="app"></div>';

  const relabi = new Relabi({
    waves: [
      { type: "sine", frequency: 0.75 },
      { type: "sine", frequency: 1.0 },
      { type: "sine", frequency: 1.617 },
      { type: "sine", frequency: 3.141 },
    ],
    bounds: [
      {
        level: -0.5,
        sounds: [
          { instrument: Drums, index: 0 },
          { instrument: Drums, index: 1 },
        ],
      },
      {
        level: 0.5,
        sounds: [
          { instrument: Drums, index: 2 },
          { instrument: Drums, index: 3 },
        ],
      },
      {
        level: -0.25,
        sounds: [
          { instrument: Kalimba, frequency: 440 },
          { instrument: Kalimba, frequency: (440 * 3) / 2 },
        ],
      },
      {
        level: 0.25,
        sounds: [
          { instrument: Kalimba, frequency: (440 * 6) / 5 },
          { instrument: Kalimba, frequency: (440 * 6) / 7 },
        ],
      },
    ],
  });
  relabi.start();

  const root = createRoot(document.getElementById("app"));
  root.render(<h1>Relabi generator</h1>);
});