Skip to content

Instantly share code, notes, and snippets.

View wrl's full-sized avatar

william light wrl

View GitHub Profile
@wrl
wrl / style.c
Created September 28, 2013 15:13
a compiled rutabaga stylesheet
/**
* rutabaga: an OpenGL widget toolkit
* Copyright (c) 2013 William Light.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
@wrl
wrl / gc_map.c
Last active December 24, 2015 12:59
/*
** keeping track of objects that exist in both C and mruby is tricky! in
** situations where you're binding to a library which maintains its own
** internal lists of child objects (say, in a UI toolkit, a container
** object with a list of contained widgets), you want to do the least
** amount of bookkeeping possible, lest you do your bookkeeping wrong.
**
** here's a simple solution. it works by mapping a cptr to a ruby object,
** which preferably you'd use to wrap around said cptr with a MRB_TT_DATA
** object. the way you use it is simple: whenever you get a pointer back
class LameError < RuntimeError
end
ShibeTest::Suite.new('ShibeTest') do
should_pass 'assert true' do |assert|
assert.true { true }
end
should_fail 'fail assert true' do |assert|
assert.true { false }
@wrl
wrl / iso8601.c
Created February 10, 2014 21:34
generating ISO 8601 dates on win32 vs on anything else
/**
* released under http://unlicense.org/
*/
#include <time.h>
#ifdef _WIN32
#include <windows.h>
static void
@wrl
wrl / jprng.h
Created March 2, 2014 21:40
approximating gaussian white noise with equal-distribution random numbers
/**
* code from http://burtleburtle.net/bob/rand/smallprng.html
* "I wrote this PRNG. I place it in the public domain."
*/
#pragma once
#include <stdint.h>
#define JPRNG_RAND_MAX UINT32_MAX
/**
* rutabaga: an OpenGL widget toolkit
* Copyright (c) 2013 William Light.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
@wrl
wrl / sine_lut.c
Created April 1, 2014 12:42
sine lookup table
/**
* lut.c: quadrature-optimized sine lookup table
* written in 2014 by william light <[email protected]>
*
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
@wrl
wrl / libedcast.cpp
Created June 27, 2014 13:00
edcast with better float -> int conversion
#define HAVE_FLAC TRUE
/* it doesn't detect I got flac atleast on my system -drr */
#include <math.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
class VstFxProgram
STRUCT_FORMAT = [
'l>', # int32 size
'a4', # int32 fx magic
'l>', # format version
'a4', # vst fx unique id
'l>', # vst fx version
'l>', # nparams
{"version":20140811,"exported":{"from":"0.2.0-bc918a1","on":"2014-10-14T16:12:51+0200"},"programs":[{"level":-6.0,"note_logic":"poly","glide_time":50.0,"pitch_bend_range":2.0,"uncertainty":0.0,"env":{"amp":{"attack":0.002,"decay":0.3,"sustain":-6.0,"release":0.05},"filter":{"attack":0.001,"decay":0.18,"sustain":-90.0,"release":0.001}},"osc":[{"level":0.0,"octave":0.0,"coarse":0.0,"fine":0.0,"phase_shift":0.0,"stereo_separation":0.0,"lsj_amount":0.5,"lsj_y_mult":1.0},{"level":-90.0,"octave":0.0,"coarse":0.0,"fine":0.0,"phase_shift":0.0,"stereo_separation":0.0,"lsj_amount":0.0,"lsj_y_mult":1.0},{"level":-90.0,"octave":0.0,"coarse":0.0,"fine":0.0,"phase_shift":0.0,"stereo_separation":0.0,"lsj_amount":0.0,"lsj_y_mult":1.0}],"lissajous":{"phase_multiplier":1.0,"theta":2.0,"a":1.0,"b":1.0,"osc":{"x":{"octave":0.0,"coarse":0.0,"fine":0.0,"phase_shift":0.0},"y":{"octave":0.0,"coarse":0.0,"fine":0.0,"phase_shift":0.0}},"smoothing":0.0},"filter":{"type":"LP24","cutoff":24000.0,"resonance":0.0,"drive":1.0,"env_mod":0.0}