Skip to content

Commit

Permalink
Library reorganization (#19, #20)
Browse files Browse the repository at this point in the history
  • Loading branch information
SthephanShinkufag committed Jan 7, 2022
1 parent 8ca77c3 commit 7763d1a
Show file tree
Hide file tree
Showing 134 changed files with 13,865 additions and 1,256 deletions.
23 changes: 16 additions & 7 deletions bytebeat.css
Original file line number Diff line number Diff line change
Expand Up @@ -153,25 +153,34 @@ code {

.code-date, .code-length, .code-samplerate {
color: gray;
letter-spacing: -1px;
cursor: default;
}

.code-load {
.code-button {
display: inline-block;
margin: 1px 0;
padding: 1px 5px;
margin: 1px 0 1px 6px;
padding: 1px 4px;
border-radius: 3px;
color: #dfe5ee;
background-image: linear-gradient(to bottom, #4f4f4f, #11141a);
color: #ced5e1;
background-image: linear-gradient(to bottom, #424242, #171b22);
white-space: nowrap;
letter-spacing: -1px;
cursor: pointer;
}

.code-load:hover {
.code-button:hover {
color: #c2dfff;
background-image: linear-gradient(to bottom, #364779, #1f2331);
}

.code-button[disabled] {
opacity: 0.7;
color: #ced5e1 !important;
background-image: linear-gradient(to bottom, #424242, #171b22) !important;
cursor: default;
}

.entry {
position: relative;
}
Expand Down Expand Up @@ -208,7 +217,7 @@ code {
}

.entry-top {
padding: 4px 4px 8px 16px;
padding: 6px 4px 8px 16px
}

.entry-top:not(:first-child) {
Expand Down
14 changes: 13 additions & 1 deletion bytebeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,21 @@ const bytebeat = new class {
{ code: xhr.responseText }));
}
};
xhr.open('GET', 'library/' + el.dataset.codeFile, true);
xhr.open('GET', `library/${
el.classList.contains('code-load-formatted') ? 'formatted' :
el.classList.contains('code-load-minified') ? 'minified' :
el.classList.contains('code-load-original') ? 'original' : ''
}/${ el.dataset.codeFile }`, true);
xhr.setRequestHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
xhr.send(null);
} else if(el.classList.contains('code-toggle') && !el.getAttribute('disabled')) {
const parentEl = el.parentNode;
parentEl.classList.toggle('disabled');
if(el.classList.contains('code-toggle-original')) {
parentEl.previousElementSibling.classList.toggle('disabled');
} else if(el.classList.contains('code-toggle-minified')) {
parentEl.nextElementSibling.classList.toggle('disabled');
}
}
};
libraryElem.onmouseover = function(e) {
Expand Down
26 changes: 10 additions & 16 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<title>Bytebeat composer</title>
<link rel="canonical" href="https://dollchan.net/bytebeat/index.html"/>
<link rel="shortcut icon" href="favicon.png">
<link rel="stylesheet" type="text/css" href="bytebeat.css">
<link rel="stylesheet" type="text/css" href="bytebeat.css?version=2022010701">
<script src="bytebeat.js"></script>
<script src="playlist.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pako/1.0.3/pako.min.js"></script>
Expand Down Expand Up @@ -102,28 +102,22 @@
</div>
</div>
<div class="library-content">
<div id="library-header-classic8khz" class="library-header toggle">
[Classic 8kHz] &mdash; code with only one variable (t), no JavaScript, 8kHz sampling rate
<div id="library-header-non-js" class="library-header toggle">
[Non-JS] &mdash; code with only one variable (t), no JavaScript
</div>
<div id="library-classic8khz" class="library-container disabled"></div>
<div id="library-non-js" class="library-container disabled"></div>
</div>
<div class="library-content">
<div id="library-header-js8khz" class="library-header toggle">
[JS 8kHz] &mdash; JavaScript code, 8kHz sampling rate
<div id="library-header-compact-js" class="library-header toggle">
[Compat JS] &mdash; compact JavaScript code
</div>
<div id="library-js8khz" class="library-container disabled"></div>
<div id="library-compact-js" class="library-container disabled"></div>
</div>
<div class="library-content">
<div id="library-header-highrate1k" class="library-header toggle">
[High rate 1k] &mdash; more than 8kHz, compressed size less than 1kB
<div id="library-header-big-js" class="library-header toggle">
[Big JS] &mdash; big JavaScript code files
</div>
<div id="library-highrate1k" class="library-container disabled"></div>
</div>
<div class="library-content">
<div id="library-header-bigcode" class="library-header toggle">
[Big code] &mdash; code with size more than 1kB
</div>
<div id="library-bigcode" class="library-container disabled"></div>
<div id="library-big-js" class="library-container disabled"></div>
</div>
<div class="library-content">
<div id="library-header-floatbeat" class="library-header toggle">
Expand Down
11 changes: 0 additions & 11 deletions library/Romash - weirdo boy.js

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sr = 32000,
sr = 44100,
q = (t + (sr * 128)) / sr,
r = 1.05946309,
a = 880,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sr = 32000,
sr = 44100,
q = (t + (sr * 128)) / sr,
r = 1.05946309,
a = 880,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ o = {
},
h() {
N = int;
k = 11025;
k = 44100;
l = '&)+,,*(&$#%&&%$#';
c = [
"''Wc3333--]]----+`b**bZ&..^..^.^$$Tc3333**ZZ****",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20444,13 +20444,13 @@ bytebeat();

function init() {
// Let's define some constants!!
SAMPLE_RATE = 22050; // change this if there's lag
SAMP_RATE = 22050; // change this if there's lag
BPM = 165;
DETUNE = 1.0028922;
pi = 3.14159;
VIB = 8.0;
KEY = 0;
ticklength = round(SAMPLE_RATE / (BPM * 16 / 60));
ticklength = round(SAMP_RATE / (BPM * 16 / 60));
// Note frequencies!!!
C_ = 261.63;
Db = 277.18;
Expand Down Expand Up @@ -20502,7 +20502,7 @@ function bytebeat() {

function vib_algo(freq, strength) {
return freq * (1 + strength * sin(
(t % (round(freq / VIB) * SAMPLE_RATE / freq)) * 2 * pi * (freq / SAMPLE_RATE) / round(freq / 8)
(t % (round(freq / VIB) * SAMP_RATE / freq)) * 2 * pi * (freq / SAMP_RATE) / round(freq / 8)
));
}

Expand All @@ -20515,7 +20515,7 @@ function instrument(ins, freq, amp) {
const realfreq = freq * pow(1.059463, KEY);
switch(ins) {
case 0: return square(t, realfreq,
amp * 0.75, 18.75 + noise(SAMPLE_RATE / (4 * ticklength), 6.25, 16777216));
amp * 0.75, 18.75 + noise(SAMP_RATE / (4 * ticklength), 6.25, 16777216));
case 1: return square(t, realfreq,
amp * 0.9, 25) + square50(realfreq * 2, amp * 0.9) + sine(realfreq, amp * 0.5);
case 2: return square(t, realfreq, amp * 0.80, 50);
Expand All @@ -20527,16 +20527,16 @@ function instrument(ins, freq, amp) {
case 8: return sweep(freq, amp);
case 9: return noise(freq, amp, 16777216);
case 10: return square(t, realfreq, amp * 0.70, 25);
case 11: return square(int(t % (round(realfreq / VIB) * SAMPLE_RATE / realfreq)),
case 11: return square(int(t % (round(realfreq / VIB) * SAMP_RATE / realfreq)),
vib_algo(realfreq, 0.0023), amp * 0.70, 25);
case 12: return square(t, realfreq, release_algo(amp * 0.75), 25);
case 13: return square(int(t % (round(realfreq / VIB) * SAMPLE_RATE / realfreq)),
case 13: return square(int(t % (round(realfreq / VIB) * SAMP_RATE / realfreq)),
vib_algo(realfreq, 0.0023), amp * 0.75, 50);
case 14: return triangle(t, realfreq, amp * 1.45);
case 15: return square(t, realfreq, amp * 0.75, 75);
case 16: return square(t, realfreq, amp * 0.70, 75);
case 17: return square(t, realfreq, release_algo(amp * 0.75), 75);
case 18: return flute(int(t % (round(realfreq / VIB) * SAMPLE_RATE / realfreq)),
case 18: return flute(int(t % (round(realfreq / VIB) * SAMP_RATE / realfreq)),
vib_algo(realfreq, 0.0023), amp * 2.125);
default: return sine(realfreq, amp);
}
Expand All @@ -20551,19 +20551,19 @@ function square50(freq, amp) {
}

function square(tt, freq, amp, pulse) {
return amp * ((freq * tt / SAMPLE_RATE) % 1.0 <= pulse / 100 ? 1 : -1);
return amp * ((freq * tt / SAMP_RATE) % 1.0 <= pulse / 100 ? 1 : -1);
}

function sine(freq, amp) {
return amp * sin(2 * pi * freq * t / SAMPLE_RATE);
return amp * sin(2 * pi * freq * t / SAMP_RATE);
}

function kick(freq, amp) {
return amp * sin(2 * pi * freq / 10 * pow(1 - (t % (4 * ticklength)) / (4 * ticklength), 3));
}

function noise(freq, amp, modulo) {
const noiseFreq = int((t % modulo) * (freq * 44100 / SAMPLE_RATE) / 44100);
const noiseFreq = int((t % modulo) * (freq * 44100 / SAMP_RATE) / 44100);
return amp / 128 * (int(65536 * sin(noiseFreq * noiseFreq)) & 255) - amp;
}

Expand All @@ -20581,7 +20581,7 @@ function triangle(tt, freq, amp) {
}

function wavetable(tt, index, interpolation, freq, amp) {
const s = 32 * freq * tt / SAMPLE_RATE;
const s = 32 * freq * tt / SAMP_RATE;
if(interpolation) {
const s1 = int(s) % 32;
const s2 = (s1 + 1) % 32;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SAMPLE_RATE = 22050,
SAMP_RATE = 22050,
BPM = 150,
beat = BPM * (t / SAMPLE_RATE) / 60,
beat = BPM * (t / SAMP_RATE) / 60,
tick = int(beat * 48) % 384,

C = 261.63,
Expand Down Expand Up @@ -67,14 +67,14 @@ chan6_pulse = 25,
chan7_freq = A,
chan7_amp = (tick % 12 < 3) * 32 * (6 - ((tick / 12) % 4)) / 6,

noiseFreq = int(t * (chan7_freq * 44100 / SAMPLE_RATE) / 440),
noiseFreq = int(t * (chan7_freq * 44100 / SAMP_RATE) / 440),

128 + chan1_amp * 2 * (int(chan1_freq * t / SAMPLE_RATE * 256) % 256 <= chan1_pulse * 256 / 100) - chan1_amp +
3 / 4 * (chan1_amp / 64) * (abs(((255 * chan1_freq * 2 * t / SAMPLE_RATE + 128) & 255) - 128) - 64) +
chan2_amp * 2 * (int(chan2_freq * t / SAMPLE_RATE * 256) % 256 <= chan2_pulse * 256 / 100) - chan2_amp +
3 / 4 * (chan2_amp / 64) * (abs(((255 * chan2_freq * 2 * t / SAMPLE_RATE + 128) & 255) - 128) - 64) +
(chan3_amp / 128) * (((255 * chan3_freq * t / SAMPLE_RATE) & 255) - 128) +
chan4_amp * 2 * (int(chan4_freq * t / SAMPLE_RATE * 256) % 256 <= chan4_pulse * 256 / 100) - chan4_amp +
chan5_amp * 2 * (int(chan5_freq * t / SAMPLE_RATE * 256) % 256 <= chan5_pulse * 256 / 100) - chan5_amp +
chan6_amp * 2 * (int(chan6_freq * t / SAMPLE_RATE * 256) % 256 <= chan6_pulse * 256 / 100) - chan6_amp +
128 + chan1_amp * 2 * (int(chan1_freq * t / SAMP_RATE * 256) % 256 <= chan1_pulse * 256 / 100) - chan1_amp +
3 / 4 * (chan1_amp / 64) * (abs(((255 * chan1_freq * 2 * t / SAMP_RATE + 128) & 255) - 128) - 64) +
chan2_amp * 2 * (int(chan2_freq * t / SAMP_RATE * 256) % 256 <= chan2_pulse * 256 / 100) - chan2_amp +
3 / 4 * (chan2_amp / 64) * (abs(((255 * chan2_freq * 2 * t / SAMP_RATE + 128) & 255) - 128) - 64) +
(chan3_amp / 128) * (((255 * chan3_freq * t / SAMP_RATE) & 255) - 128) +
chan4_amp * 2 * (int(chan4_freq * t / SAMP_RATE * 256) % 256 <= chan4_pulse * 256 / 100) - chan4_amp +
chan5_amp * 2 * (int(chan5_freq * t / SAMP_RATE * 256) % 256 <= chan5_pulse * 256 / 100) - chan5_amp +
chan6_amp * 2 * (int(chan6_freq * t / SAMP_RATE * 256) % 256 <= chan6_pulse * 256 / 100) - chan6_amp +
(chan7_amp / 128) * (int(65536 * sin(noiseFreq * noiseFreq)) & 255) - chan7_amp;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SAMPRATE = 44000,
SAMPRATE = 44100,
CIRBUFSIZE = int(SAMPRATE * 3),
TEMPOISH = SAMPRATE / 10,
SECOND = t / TEMPOISH,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SAMPLE_RATE = 22050,
SAMPLE_RATE = 44100,
DEBUG = 1,
FEEDBACK_ITERATIONS = 3,
_log = DEBUG ? console.error : () => {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RATE = 22050,
RATE = 44100,
TEMPO = 60 / 600,

S = t => (
Expand Down
59 changes: 59 additions & 0 deletions library/formatted/funute - vgm engine.js

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
time = t / 44000,
time = t / 44100,
fract = function(x) {
return x % 1;
},
Expand All @@ -18,7 +18,7 @@ main = function(time) {
melody_tune = pow(
pow(2, 1 / 12),
(melody_notes[i][floor(time * speed) % melody_notes[i].length] + pitch) - 49
) * 44000;
) * 44100;
melody += puls(time * melody_tune) * (1 - fract(time * speed));
}
return melody / melody_notes.length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ main = function(time) {
melody_tune = pow(
pow(2, 1 / 12),
(melody_notes[i][floor(time * speed) % melody_notes[i].length] + pitch) - 49
) * 44000;
) * 44100;
melody += sin(time * melody_tune) * (1 - fract(time * speed));
}
return melody / melody_notes.length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ main = function(x) {
melody_tune = pow(
pow(2, 1 / 12),
melody_chord[floor(hash((i * 0.24) + floor(time * speed)) * melody_chord.length)] - 49
) * 44000;
) * 44100;
s += sin(time * melody_tune) * (1 - fract(time * speed));
}
return s / loops;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
time = t / 44000,
time = t / 44100,
fract = function(x) {
return x % 1;
},
Expand Down
File renamed without changes.
File renamed without changes.
24 changes: 24 additions & 0 deletions library/formatted/pigdevil2010 - Last Fountain.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
s = (a, b, c) => c / a.charCodeAt(b),
d = a => a & 1 ? -1 : 1,
e = (a, b) => t >> 22 & 1 ? b : a,
b = a => (s(a, r(t) + p * 16, t << 2) * (254 >> (t >> 20 & 7) & 1)) & 20,
p = 178 >> (t >> 19 & 7) & 1,
q = a => 120 >> (a >> 20 & 7) & 1 ? 1 : (-a >> 16 & 1),
r = a => 112 >> (a >> 20 & 7) & 1 ? t >> 14 & 15 : (t >> 17 & 1) * 8,
l = " QQffQQLLLfLLDDQQQfff rrff``UU QQDDQQLLLfLLDD<<f333 r\x98rf`r`U <<<9<LUUU\x80U\x80UL[[rLLL rrff`frr <<<93U999`9U3+--9&&& rrff``UU",
b("rrLr99rrUUrU99rULLyL<<yy``\x80`@@\x80`") * 2 +
b("qqKq88qqTTqT88qTKKxK;;xx__\x7f_??\x7f_") +
(s("rf[<r`L@\x98\x88yQ\x80fUL", (t & 3) + (t >> 17 & 1) * 4 + p * 8, t << 2) & 7) *
(t * d(t >> 16) >> 12 & 15 ^ e(0, 5)) * 3 / 4 +
((s(
"rf[L<9-\x1e&-3&-3-3\xab\x98\x90r`UH0+&9+&\x1d&+\x98\x88yfQL<(3<D3<3-(&09HL`ULU`r`UL@9",
(t >> 13 & 31) + p * 32,
t << 5 - (t >> 11 & 3)
) | t >> 8) * q(t) & 31) +
(((s(l, t >> 14 & 127, t << 6) & s(l, t >> 14 & 127, (t * e(89 / 88, 499 / 498)) << 6)) *
(63486 >> (t >> 15 & 15) & 1) * (102 >> (t >> 20 & 7) & 1)) & e(42, 32)) +
((((253507989 >> (t >> 6 & 31)) * (1 >> (t >> 11 & 3)) * (19593 >> (t >> 13 & 15) & 1) & 1) * 50) +
(
(((t * t / 21 + t & (t >> 3)) | t >> 7 | t >> 8) - 7) *
(3 >> (t >> 11 & 3) & 1) * (2450526224 >> (t >> 13 & 31) & 1) & 31
) * 5 / 2) * (112 >> (t >> 20 & 7) & 1)
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SAMPLE_RATE = 44100,
SAMP_RATE = 44100,
BPM = 140,
ts = t / SAMPLE_RATE,
ts = t / SAMP_RATE,
beat = BPM * ts / 60,
tick = int(beat * 48) % 3072,

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SAMPLE_RATE = 44100,
SAMP_RATE = 22050,
BPM = 150,
ts = t / SAMPLE_RATE,
ts = t / SAMP_RATE,
beat = BPM * ts / 120,
tick = int(beat * 48) % 6656,

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SAMPLE_RATE = 22050,
SAMP_RATE = 44100,
BPM = 130,
ts = t / SAMPLE_RATE,
ts = t / SAMP_RATE,
beat = BPM * ts / 60,
tick = int(beat * 48) % 11520,

Expand Down
Loading

1 comment on commit 7763d1a

@SthephanShinkufag
Copy link
Owner Author

@SthephanShinkufag SthephanShinkufag commented on 7763d1a Jan 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. All songs now sorted by date, from oldest at top to newest at bottom. Groups of songs by one author now placed in list by oldest one..
  2. New library sections structure:
    [Non-JS] — code with only one variable (t), no JavaScript (including high-samplerate formulas)
    [Compat JS] — compact JavaScript code ([JS 8kHz] and [High rate 1k] combined)
    [Big JS] — big JavaScript code files ([Big code] plus all code with files from [High rate 1k] and [JS 8kHz])
  3. All songs now have original versions (I searched and add every single one of it, sic!), and minified versions (even with difference for one character). Minified code shown by default. If it impossible to minify code, then original version shown.
  4. In [Big code] sections, for code migrated from [High rate 1k] and [JS 8kHz] now added original and minimized version of files, with "original" and "minified" buttons.
  5. If the song is a remix, if possible the source is indicated, in the new "remixed" property of json file.

Please sign in to comment.