~amavect/music

e8b9d76bc50289a45b222e35190ba1ff76801781 — amavect 2 years ago 076df55 master
add 13.c
1 files changed, 43 insertions(+), 0 deletions(-)

A bb/13.c
A bb/13.c => bb/13.c +43 -0
@@ 0,0 1,43 @@
/* 44.1 kHz, stereo, signed 16-bit */
/* made by pete */
#include <u.h>
#include <libc.h>
#include <bio.h>

/* unnecessary but whatever */
short
vtos(uvlong v)
{
	return (short)(v&0xFFFF);
}

uvlong
next(uvlong t)
{
	return (((0xe000&((t>>6)|(t>>8)))&(0x50000>>(1+(3&(t>>19)))))&(((("ccggctZZtZglgcZlnglcn_tnngclct"[31&(((((t>>21)*(t>>15)*3)))+((t>>20)&(t>>16))+(0x7&(((t>>14)))))]-(64))*((t)<<2)))))^
	((0xe000&t&(t>>10))|
	(((((t+((((t+(t>>14)))&1)))*("t_tg_ZgtZlntg]_ntZ_g]tgct_tl]t"[31&((t>>15)+((t>>14)&(t>>21))+((t>>14)&(t>>22)))]-64))&(t>>(1+(((t>>(15-((t>>17)&(t>>18)&1)))&1) + ((t>>(17+((t>>19)&1)))&1) + ((t>>20)&1)))))^t) - (t&(((((((t>>17)-(t>>19)-(t>>22))&((t>>16)&((t>>20)^(t>>23))))&1)*-1))|(((t>>16)&(t>>17))&0xff)))));
}

void
main(void)
{
	uvlong t;
	uvlong x, y;
	short s, s2;
	Biobuf bfile;
	
	if(Binit(&bfile, 1, OWRITE) == Beof)
		sysfatal("Binit failed!");
	
	for(t = 1;; t++){
		x = next(t);
		y = x;
		s = vtos(x);
		s2 = vtos(y);
		if(Bwrite(&bfile, &s, sizeof(s)) < 0)
			sysfatal("Bwrite failed!");
		if(Bwrite(&bfile, &s2, sizeof(s)) < 0)
			sysfatal("Bwrite failed!");
	}
}