Skip to content

Instantly share code, notes, and snippets.

View rfl890's full-sized avatar

rfl890

  • St. John's, Newfoundland and Labrador
View GitHub Profile
@rfl890
rfl890 / canon.c
Last active December 8, 2024 23:35 — forked from hypernewbie/canon.c
Pachelbel’s Canon in Dmaj in 73 lines of obfuscated C
/* make canon; ./canon | aplay -r 44100 -f U8 */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define rs (1.0/44100.0)
#define fr(x) (440*pow(2,(x-57)*(1.0/12)))
#define s(x, n) sin((x=(x+fr(n)*rs))*6.2831853)
#define tf (((1.0/rs)*60.)*.25/160.0)
#define gv(c) (c-(c>'9'?('a'-10):'0'))
#define gct(i) (gv(ct[(i)*3]) << 8)+(gv(ct[(i)*3+1]) << 4)+(gv(ct[(i)*3+2]))