Skip to content

Instantly share code, notes, and snippets.

Gerasene {
classvar fft_bufsize;
var <buf;
var <out_bus;
var <syn;
var <out_syn;
*initClass {
@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 / Engine_TestNoise.sc
Last active February 1, 2025 20:43
norns engine switching test
// CroneEngine_TestNoise
// variante of TestSine, for switching
// Inherit methods from CroneEngine
Engine_TestNoise : CroneEngine {
var <synth;
*new { arg context, doneCallback;
^super.new(context, doneCallback);
}
@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 / Engine_Drumf.sc
Last active December 7, 2019 22:26
norns hackalong drumf
Engine_Drumf : CroneEngine {
classvar <numVoices = 4;
var <trig_bus;
var <drum_synth;
var <drum_def;
*new { arg context, doneCallback;
@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;
@catfact
catfact / solinish.scd
Last active January 21, 2020 04:48
solinish
// 8-voice paraphonic synth,
// _very loosely_ inspired by ARP Solina architecture
Routine {
// first element is an oscillator.
// classically this is a sawtooth, with some nonlinear lowpass filtering
// we'll expand on it with:
// - triangle->saw width control
@catfact
catfact / sc_synth_to_midi.scd
Created March 2, 2020 02:18
supercollider synth to midi / control bus demo
MIDIClient.init; // initialize MIDI
m = MIDIOut(0); // get the first output device
Routine { // use a Routine (aka a thread) for synchronization with the server
s = Server.default;
s.boot;
s.sync; // wait for the server to be ready
// a control-rate bus which our synth will write to
~lfo_out_bus = Bus.control(s, 1);
@catfact
catfact / PolyLevelTest.sc
Created April 23, 2020 06:04
supercollider level control for polyphonic synths
PolyLevelTest {
// homework: experiment with this value
var <>estimatedGainPerVoiceDb = 3;
var <activeVoiceCount = 0;
var outputBus;
var <outputSynth;
init { arg server;
SynthDef.new(\fm_noise_1shot, {
arg out=0, amp=0.5, pan=0.0,
// utility func to "wrap: a value to a range, by octave division
var geoWrap = { arg x, max=2, min=1;
var y = x;
while ({y>max}, {y=y/2});
while ({y<min}, {y=y*2});
y
};
var synthFunc = {
arg hz=110, amp=0.125, out=0,