Skip to content

Instantly share code, notes, and snippets.

@catfact
catfact / ftrack.scd
Last active April 2, 2016 13:54
cmf 4track (sc)
//-- top level sound directory
d = (thisProcess.platform.recordingsDir ++ "/ftrack/").standardizePath;
//-- dictionary associating subdir names to path arrays
p = Dictionary.new;
PathName(d).folders.do({ |f| p.add(f.folderName.asSymbol -> f.files); });
//-- runtime state stored in this Event
e = (
@catfact
catfact / wave_view.scd
Last active June 25, 2016 19:54
supercollider wave view
s = Server.local;
s.waitForBoot {
~bufsize = s.sampleRate;
~graphsize = ~bufsize / 100;
~buf = Buffer.alloc(s, ~bufsize, 1);
~in = { RecordBuf.ar(SoundIn.ar(0), ~buf.bufnum); }.play;
~delta = 0.5;
// testing audible differences between VOsc.ar and Osc.ar under frequency/phase modulation
// press '1' to hear VOsc, '2' to hear Osc
// drag mouse on window to change mod hz and depth
// VOsc is set to interpolate between identical sine buffers
Routine {
SynthDef.new(\vosc_test, {
arg out=0, buf=0, amp=0.25, hz_car=240, hz_mod=60, mod_idx=1.0, fade=0.0;
var mod, car;
@catfact
catfact / aleph-svf-test.scd
Created November 3, 2016 22:58
filter excitation signal generator
Routine {
/* // continuous white noise
~noise = { arg out=1, amp=0.125; Out.ar(out, WhiteNoise.ar * amp) }.play;
~noise.free;
*/
SynthDef.new(\ping_noise_decay, {
arg out=1, amp=0.25, atk=0.0, rel=0.001;
Out.ar(out,
WhiteNoise.ar
@catfact
catfact / gist:95bd414785ded64ce1d008164be2ce18
Created August 24, 2017 18:48
supercollider class for raw monome grid
CfGridRaw {
var <>p; // serial port
var <>q; // rx data queue
var <>r; // rx read loop
// responder functions
var <>keyUp, <>keyDown;
*new { arg port_ = '/dev/ttyUSB0', baud_ = 115200;
^super.new.init(port_, baud_);
@catfact
catfact / sines.scd
Last active October 3, 2017 04:14
simple waveform audio files in supercollider
// function to make a sine
var export_sine = {
arg hz, dur, amp = 0.5, sr = 48000;
var sf, path;
var cycles = dur * hz;
var samplesPerCycle = sr / hz;
// specify some other array of harmonics here for richer waveforms
var signal = Signal.sineFill(samplesPerCycle, [1.0]) * amp;
// outlets: input index, output index, connection value
outlets = 3;
sketch.default2d();
// I/O count, should be an argument
var num_ins = 4;
var num_outs = 4;
// mouse state (world coordinates)
@catfact
catfact / example.lua
Last active May 4, 2019 21:54
module providing "factory preset" functionality for norns scripts
local factory = include('lib/factory')
function init()
--- add parameters here...
-- this will copy .pset and .pmap from dust/code/example/data/*, to dust/data/example/*,
-- (without overwriting existing files)
factory.init()
@catfact
catfact / tanc.g
Last active July 8, 2019 19:06
tanc clipper
function y = tanc(x, a)
g = 1 - a;
y = 1 - g * (1 - tanhx((x - a) / g));
endfunction
@catfact
catfact / bitrot16.c
Last active November 16, 2019 00:16
bitrot16 : demonstration of logical shift-and-rotate on signed integer
#include <stdint.h>
#include <stdio.h>
// perform a logical bit shift with rotation on a signed 16-bit integer
// second argument is number of bits:
// positive to shift right, negative shift left
int16_t bitrot16(int16_t x, int n) {
// use a union with unsigned type,
// so all our bitwise ops ignore sign
union { int16_t si; uint16_t ui; } u;