Skip to content

Commit

Permalink
Add the actual sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
mnvr committed Jan 31, 2024
1 parent 8189bac commit 5214364
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ See [x](x) for a longer version with more comments and explanations.
### Cycling with Euclid – A song in E(3, 8)

The prompt for day 31 of Genuary 2024 was to produce a generative piece of
music. I made a neverending song using only HTML/JS/CSS, no dependencies.
music. I made a neverending song using only HTML/JS/CSS without using any
dependencies or libraries. While code size was not a concern, the resulting
files is just 250 lines too.

Live version is at https://mnvr.github.io/gm1k/e.

Source code is in [e/index.html](e/index.html) – a standalone HTML file (you can
just open it in your browser and play directly too). The song it plays is a
just open it in your browser and play it directly too). The song it plays is a
composition using Euclidean rhythms. The bassline and the trill rhythms are
`E(3,8)`, on which totters around the main Euclidean rhythm which cycles through
`E(3,4)` to `E(11, 12)`.
`E(3,8)` and `E(7, 8)`, around which totters around the main Euclidean rhythm
that cycles through `E(3,4)` to `E(11, 12)`.

I also wrote a tutorial about [Euclidean rhythms](https://mrmr.io/mj/euclid)
that explains the code behind the song.
Expand Down
14 changes: 7 additions & 7 deletions e/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,9 @@
return s.flat();
};

/*
Unlike *410*, this song doesn't continue playing in the background
in Safari when you switch tabs (because Safari throttles
setInterval and co).
*/
/* Unlike *410*, this song doesn't continue playing in the
background in Safari when you switch tabs since Safari throttles
setInterval and co) */

let context; /* Audio context */
let intervalID; /* The setInterval ID, set if we're playing */
Expand Down Expand Up @@ -210,17 +208,19 @@

if (seq38[p8]) {
classList(`#b1${p8 + 1}`).add("on");
beep(0.01);
beep(0.01, 0.001, 0.1, 660);
}

if (seq[p]) {
classList(`#b2${p + 1}`).add("on");
beep(0.01);
beep(0.005, 0.001, 0.02, 660);

}

if (seq78[p8]) {
classList(`#b3${p8 + 1}`).add("on");
beep(0.01);
beep(0.1, 0.001, 0.1, 110);
}

p = p + 1;
Expand Down

0 comments on commit 5214364

Please sign in to comment.