Skip to content

Instantly share code, notes, and snippets.

@madgarden
madgarden / life.c
Created June 14, 2021 01:57
Cellular automata with configurable rules
#include <ctype.h>
#include <memory.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define CELLS_W 40
#define CELLS_H 20
#define RULES 9
@madgarden
madgarden / bytebeat_fx.c
Created November 21, 2019 16:05
Arecibo Man bytebeat synthesizer
#include <stdint.h>
#include <memory.h>
#include "bytebeat_fx.h"
#include "mad.h"
static int init_ = 0;
static unsigned int glitch_t = 0;
static float glitch_rate = 8000;
static float glitch_volume = 1;
static int16_t val16 = 0;
@madgarden
madgarden / williams_robotron_synth.c
Last active February 16, 2022 15:12
Williams Robotron sound synth, adapted to C from https://www.lomont.org/software/misc/robotron/
// Williams Robotron sound synth, adapted to C from https://www.lomont.org/software/misc/robotron/
// LICENSE
//
// This software is dual-licensed to the public domain and under the following
// license: you are granted a perpetual, irrevocable license to copy, modify,
// publish, and distribute this file as you see fit.
#define CR_START(n) { int *crptr = (n); switch(*crptr) { case 0:
#define CR_YIELD_VOID do { *crptr =__LINE__; return; case __LINE__:;}while(0);
#define CR_YIELD(x) do { *state =__LINE__; return x; case __LINE__:; }while(0);
@madgarden
madgarden / wav-play.c
Last active May 27, 2016 17:59
wav-play: A WAV loader/player I use for all of my projects, created initially for Saucelifter. Just needs a (sound) buffer for output. Only implemented what I currently need for my games, and for that it works just fine. You can find the unfinished stubs in the code.
// The Madgarden games WAV player
// LICENSE
//
// This software is dual-licensed to the public domain and under the following
// license: you are granted a perpetual, irrevocable license to copy, modify,
// publish, and distribute this file as you see fit.
/*
TODO: Post-process clipping (need 32-bit mix buffer)
// LICENSE
//
// This software is dual-licensed to the public domain and under the following
// license: you are granted a perpetual, irrevocable license to copy, modify,
// publish, and distribute this file as you see fit.
#include "udpnet.h"
#if defined WIN32
typedef int socklen_t;