Skip to content

Instantly share code, notes, and snippets.

// each channel has its own trigger stream
// which is a slow Impulse and a faster CombN
// delay threshold is a regular trigger for an envelope
// the source is controlled by a Select (many:1)
// binary math takes triggers on several control channels
// and outputs the index of which channel was last triggered
(Ndef(\spaghettiArp, {|root=45, triggerThreshold=0.08, brightness=1.5, atk=0, dec=2.5|
-- an imaginary verbose REPL
-- ------------------
-- inspired by the ii help in crow/druid
-- most examples based on https://gist.github.com/trentgill/84ec5b68816eb03508566addb5a41dd4
s = sequins
-- comments below are hypothetical log output (via e.g. print() or a REPL)
cs = s"abcd"
@ryanlaws
ryanlaws / crow3-lcg.lua
Created July 11, 2021 18:02
Linear Congruential Generator for Monome Crow 3
-- LCG based on https://github.com/monome/dsp-kit/blob/main/noise/lcg.c by @catfact
-- due to differences in data types, the behavior is not the same.
-- int32_t values were truncated to avoid Lua converting them to inf or -inf.
output[1].action = loop {
to(
dyn{x=1}
:mul(dyn{a=-559})
:step(dyn{c=21032})
:wrap(-32768, 32767)
/ 32768
@ryanlaws
ryanlaws / fc2-working-set.scd
Last active July 11, 2021 00:24
FC2 working set
//JUNK
s.quit;
s.boot;
(~stopwatch = Routine { var ct = 0;
loop { ct.postln; 1.wait; ct = ct + 1 }
}.play;)
~stopwatch.stop;
Ndef.clear
s.options.recHeaderFormat = 'wav'
s.prepareForRecord
@ryanlaws
ryanlaws / fake-wavetable-thing.scd
Created June 15, 2021 04:09
just a really janky wavetable in SuperCollider
// your keycodes may vary
~ctrl = 105;
// recording params - 12 sec for no particular reason
~bufferSeconds = 12;
// do this first and then wait
~buf = Buffer.alloc(s, s.sampleRate * ~bufferSeconds, 2);
(Ndef(\seekWt, { |offset=0,freq=55, gain=1, seekLag=5, curve=0, probability = 1, rate=1|
//////// sunset 2020
(Ndef(\reverb, {|wet=0.85, dry=0.15, size=10|
var input = \in.ar([0, 0]);
var primes = (2..13).nthPrime;
var reverb = Mix.ar(primes.collect({|i|
var delay = SinOsc.ar(0.02.rrand(0.1), 0, 0.02.rand, i/100);
AllpassL.ar(input, 1/2, delay, size, 1/primes.size)
}));
(wet*(reverb + input)) + (dry*input);
});
-- based on @okyeron's hid_demo/hid-events.lua
-- check MIDI Devices list printed below to REPL for which port to choose
-- change these to suit your needs
local midi_port_id = 1 -- especially this one
local midi_channel = 1 -- and probably this one
local midi_velocity = 100
function init()
-- print some device data to REPL
{
const props = ['a', 'b', 'c'];
// Manufacture
const makeObj = (name) => {
const obj = {};
props.forEach(prop =>
Object.defineProperty(obj, prop, {
get: () => `this is ${name}'s ${prop}`
}));
@ryanlaws
ryanlaws / babbys-first-audiobuffer.js
Created April 25, 2019 13:57
Playing around with the web AudioBuffer API
{
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
const sr = audioCtx.sampleRate;
const hzInc = 1 / sr;
const noteToHz = (midiNote) => Math.pow(2, midiNote/12) * 8.17570643783345;
class Accumulator {
constructor() {
this.oscs = [];
@ryanlaws
ryanlaws / partial.js
Created October 2, 2018 13:40
Partial function application
const partial = (f) =>
(...args) =>
(args.length >= f.length)
? f(...args)
: partial(f).bind(this, ...args)