Bytebeat tunes

Bytebeat is a style of music where a function of time outputs integers, which are taken mod 256, and then the graph of this function becomes the waveform.

Here are some bytebeat tunes I made. You can play these with any bytebeat composer, such as this one or this one. Most of them work best at 8000 bytes/sec.


Here's something pretty simple. The waveform is the graph of 249th powers mod 251 (251 was chosen due to being the largest prime less than 256). Apart from multiples of 251, these are the same as the multiplicative inverses mod 251.

(((((t%251)**4%251 * (t%251)**3%251)**4%251 * (t%251)**3%251)**4%251)**2%251 * t)%251
		

Here's a Stern-Brocot composition that I thought of about 2 years ago. It plays notes with frequencies proportional to the Stern-Brocot sequence, and as such, it goes through every rational interval exactly once.

f = function(n) {
	// stern-brocot sequence
	if (n == 1) return 1;
	if (n % 2 == 0) return f(n / 2);
	return f((n - 1) / 2) + f((n + 1) / 2);
},
t*f((t >> 12) + 1)
		

This is pretty cool. A beat that slowly speeds up until... well, just listen. It's floatbeat, not bytebeat, so you need to select the "floatbeat" option on the site's drop-down menu.

tan(t/(1024 - (t/1024)))%1
		

Waves based on the decimal expansion of 1/n:

powmod = function(b, e, m) {
	if (e == 0) return 1 % m;
	if (e % 2 == 0) return powmod(b, e/2, m)**2 % m;
	else return (powmod(b, (e - 1)/2, m)**2 * b) % m;
},
n = (t>>12),
powmod(10,t%(1<<12),n)*(256/n)
		

Binary repeats of prime powers in order of length:

powmod = function(b, e, m) {
	if (e == 0) return 1 % m;
	if (e % 2 == 0) return powmod(b, e/2, m)**2 % m;
	else return (powmod(b, (e - 1)/2, m)**2 * b) % m;
},
a = [1,3,7,5,31,9,127,17,73,11,23,89,13,8191,43,151,257,131071,19,27,524287,25,41,49,337,683,47,178481,241,601,1801,2731,262657,29,113,233,1103,2089,331,2147483647,65537,599479,43691,71,122921,37,109,223],
n = a[t>>12],
powmod(2,floor(t/3),n)*(256/n)
		

Same thing but for the terms of OEIS sequence A243110:

powmod = function(b, e, m) {
	if (e == 0) return 1 % m;
	if (e % 2 == 0) return powmod(b, e/2, m)**2 % m;
	else return (powmod(b, (e - 1)/2, m)**2 * b) % m;
},
a = [3,11,37,101,239,271,1933,3191,3541,4093,4649,9091,21649,52579,123551,210631,238681,329401,333667,513239,909091,2071723,2906161,5882353,10838689,35121409,52986961,70541929,83251631,99990001,121499449,247629013,265371653],
n = (t>>12),
powmod(10,t%(1<<12),a[n])*(256/a[n])
		

Beginning of a Risset rhythm:

t_prime = t%100000,
u = floor(100000/log(2)*2**(t_prime/100000)),
scale = 2**(t_prime/100000),
((u>>6)^((u>>6) + 1))/scale // *(1/(u%(1<<6)))
		

A demonstration of how suddenly x^^n goes to infinity for high values of n when x passes e^(1/e):

u = t/100000,
u**(u**(u**(u**(u**(u**(u**(u**(u**(u**(u**u))))))))))*100000
		

Another cool bytebeat thing:

t>>(t/((t>>14)%8+1))
		

Goes through the waveforms of b^t mod a (scaled to 0..255), for b = 0..a - 1, where a counts up the odd numbers:

powmod = function(b, e, m) {
	if (e == 0) return 1 % m;
	if (e % 2 == 0) return powmod(b, e/2, m)**2 % m;
	else return (powmod(b, (e - 1)/2, m)**2 * b) % m;
},
n = (t>>12) + 1,
a = 2*floor(sqrt(n)) + 1,
b = n - floor(sqrt(n))**2,
powmod(b,t%(1<<12),a)*(256/a)
		

Found a more efficient way to do Collatz-like sequences. This one iterates 3n + 1, 3n + 3, 3n + 5, etc. maps starting from 1, updating the rule every 2^11 steps.

u = t>>11,
v = t%2**11,
n = (v==0)?1:(n%2==0)?n/2:3*n+2*u+1,
n
		

Improved version of the Stern-Brocot composition, with note decay and different voices fading in and out every few octaves:

tau = 2*Math.PI,
v1 = u=>(u%256),
v2 = u=>(128+127*cos(u*tau/256)),
v3 = u=>8*(u%256 - 128)*exp(-(((u/32)%8 - 4)**2)) + 128,
s1 = u=>min(max((log(u/2)/log(2))/5,0),1),
s2 = u=>min(max((log(u/16)/log(2))/5,0),1),
v = (t,u)=>v1(t*u)*(1 - s1(u))+v2(t*u/4)*(s1(u) - s2(u))+v3(t*u/16)*s2(u),
f = function(n) {
    // stern-brocot sequence
    if (n == 1) return 1;
    if (n % 2 == 0) return f(n / 2);
    return f((n - 1) / 2) + f((n + 1) / 2);
},
v(t,f((t >> 12) + 1))/exp(t%(1 << 12)/(1 << 12))
		

Collatz trajectory of 27 with the same voice:

tau = 2*Math.PI,
v1 = u=>(u%256),
v2 = u=>(128+127*cos(u*tau/256)),
v3 = u=>8*(u%256 - 128)*exp(-(((u/32)%8 - 4)**2)) + 128,
s1 = u=>min(max((log(u/2)/log(2))/5,0),1),
s2 = u=>min(max((log(u/16)/log(2))/5,0),1),
v = (t,u)=>v1(t*u)*(1 - s1(u))+v2(t*u/4)*(s1(u) - s2(u))+v3(t*u/16)*s2(u),
n = (t==0)?27:(t%(1<<11)==0)?((n%2==0)?(n/2):(3*n+1)):n,
v(t,n)
		

Old bytebeat tunes

Most of these I made in 2016-2017.

x = 8192, n = int(t / x) + 1, pow((n*t % 512)/200+2,(n*t % 512)/300+2);
        
-(int(t / (1 << 9) + 1/2) % 2) + (2 * (int(t / (1 << 9) + 1/2) % 2) - 1) * (128 - pow(1 - pow(((t + 256) % 512) / 256 - 1, 2), 1/2) * 128)
        
1/4*((2*int(10*t/(1<<8) % 2) - 1) + (2*int(pow(2,7/12)*10*t/(1<<8) % 2) - 1) + (2*int(20*t/(1<<8) % 2) - 1) + (2*int(pow(2,1/3)*20*t/(1<<8) % 2) - 1))
        
c = int(t / (1 << 12)),
d = int(pow(2*c + 9/4, 1/2) - 1/2),
e = pow(d + 1/2, 2)/2 - 9/8,
g = c - e,
h = 1 + g / d,
2 * t * h
        
k = 2000,
c = 2 * int(t / (k << 6)) + 1,
t * (int(t/k) % (1 << 6) & c)
        
n = 4, t % int((-n + sqrt(n*(n + 8*t)))/(2*n))
        
n = 21, t * (t >> 12 ^ n) & (t >> 12) - t * (t >> 12 ^ n)
        
pi = 3.1415926535898, pow(tan(15.9995*t/256*pi), 2)
        
p = function(n) {
	c = t >> 11;
	if (c % n) return 0;
	else return t * n % 256
},
s = function(n) {
	a = 0;
	for (var i = 1; i <= n; i++) {
		a += p(i);
	}
	return a / n;
},
s(20)
        
l = function(n) {
	c = (t >> 11) + 1;
	for (i = n; i >= 1; i--) {
		if (c % i == 0) return i;
	}
},
t*l(20)
        
sum = function (n) {
    var a = 0;
    for (var i = 1; i < n; i++) {
        a = a + sin((t * i) / 32);
    }
    return a / n;
},
sum(1 + (t >> 12)) * 128 + 128
        
(t>>8)*sin(t/10) + 128
        
128*sin((t>>13)*t/60) + 128
        
a = [3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3,8,4],
times37 = function(l) {
	for (var i = 0; i < 20; i++) {
		l[i] = l[i]*37;
	}
	return l;
},
carry = function(l) {
	for (var i = 1; i < 20; i++) {
		l[i - 1] += floor(l[i] / 10);
		l[i] = l[i] % 10;
	}
	return l;
},
b = [0,1,2,3,4,5,0,0,0,0],
doit = function(l) {
	for (var n = 0; n < 10; n++) {
		l[n] = a[0],
		a[0] = 0,
		a = times37(a),
		a = carry(a),
		a = carry(a),
		a = carry(a);
	}
	return l;
},
b = doit(b),
t * pow(2, b[(t>>13) % 10]/12)
        
sum = function(n) {
	s = 0;
	for (var x = 0; x < n; x++) {
		s += (t * pow(2, x / n) / n) % (256 / n);
	}
	return s;
},
sum((t >> 15) + 1)
        
q = 1 << 15, int((t % q)*(2 + int(t / q))/q)*t
        
q = 1 << 15, (1 + int((t % q)*(2 + int(t / q))/q)/(int(t / q) + 1))*t
        
((t*((t >> 12) % 4 + 1) * ((t >> 14) % 4 + 1) ^ 7) & 5*(t >> 14)) ^ (69 * t / 10000)
        
a = t >> 9, c = t >> 12, t*((c + 1 ^ c >> 2) % 16) + 128*sin(t*((a + 1 >> 5) - (a >> 5)))
        
128*sin(t/(t >> 11))*sin(t/10) + 128
        
a = t >> 9, c = t >> 12, t*((c + 1 ^ c >> 2) % 16) + (128 + 128*sin(t)) % (10000 / (t % (1 << 14)))
        
w = function(n) {
	if (n == 0) {
		return 96;
	}
	else {
		return int(7/4*n - 5/4);
	}
},
d = [6,0,2,8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,1,3,2,8,6,1,7,2,0,4,2,7,8,9,8,9,2,7,9,0,4,4,9,4,7,4,3,8,1,4,0,4,3,5,9,7,2,1,8,8,7,4,0,5,5,4,1,0,7,8,4,3,4,3,5,2,5,8,6,3,5,3,5,0,4,7,6,9,3,4,9,6,3,6,9,3,5,3,3,8,8,1,0,2,6,4,0,0,1,1,3,6,2,5,4,2,9,0,5,2,7,1,2,1,6,5,5,5,7,1,5,4,2,6,8,5,5,1,5,5,7,9,2,1,8,3,4,7,2,7,4,3,5,7,4,4,2,9,3,6,8,8,1,8,0,2,4,4,9,9,0,6,8,6,0,2,9,3,0,9,9,1,7,0,7,4,2,1,0,1,5,8,4,5,5,9,3,7,8,5,1,7,8,4,7,0,8,4,0,3,9,9,1,2,2,2,4,2,5,8,0,4,3,9,2,1,7,2,8,0,6,8,8,3,6,3,1,9,6,2,7,2,5,9,5,4,9,5,4,2,6,1,9,9,2,1,0,3,7,4,1,4,4,2,2,6,9,9,9,9,9,9,9,6,7,4,5,9,5,6,0,9,9,9,0,2,1,1,9,4,6,3,4,6,5,6,3,2,1,9,2,6,3,7,1,9][int(t/4096)%1000],
2*t*2**(w(d)/12)
        
tau = 6.283185307179586, c = t >> 13, ((((c & 5) + (c || 2)) % 48)*t % 256) * (2 + cos(tau*t / 2**11))/3
        
( t*((t>>9) & 1+(2*(t>>14))) )*(2^t)
        
a = function(n) {
	if (n > 2 && n % 2 == 0) return 2;
	for (x = 3; x <= sqrt(n); x++) {
		if (n % x == 0) return x;
	}
	return 1;
},
u = (t >> 13) + 1,
u * (t / 2) % 128 + a(u) * (t / 2) % 128
        
(t & (t >> 12)) * 255 / (t >> 12)
        
//This has a new sound.
o = function(x) {
	if (x == 0) return 0;
	if (x % 2 == 0) return o(x / 2);
	else return o((x - 1) / 2) + 1
},
p = function(x) {
	if (x == 0) return 0;
	if (x % 2 == 0) return x / 2 + 2 * p(x / 2);
	else return p(x - 1) + o(x)
},
p(t)
        
s = function(n) {
	if (n == 0) return t;
	return s(n - 1) + (t >> n)
},
s(t >> 11)
        
t * 2 ** ((t >> 10) / 12)
        
u = t >> 12, (256/u)*((t % u) ** 2)
        
p = function(b, e, m) {
	if (e == 0) return 1;
	return b * p(b, e - 1, m) % m;
},
x = 37, (256/x)*p(t >> 3, ((t >> 14) + 1) % 36, x)
        
t & (t * (((t >> 11) ^ 13) & 23))
        
128 + 128*sin(int(t/((t >> 14) + 1)))
        
(128 + 128*sin(int(t/((t >> 13) + 1))))
* ((t >> 12) % 2) +
(128 + 128*sin(t/((t >> 13) + 1)))
* (((t >> 12) + 1) % 2)
        
u = (t >> 10), (((u >> 5) & 3) * t*(2 + (u/2 & 2) + (u/2 & 1)*(1 - (u/2 & 2)))) % 128 + t*(4 + (u & 2) + (u & 1)*(1 - (u/2 & 2))) % 128
        

Back