Skip to content

Instantly share code, notes, and snippets.

View antonhornquist's full-sized avatar

Anton Hörnquist antonhornquist

  • Linköping, Sweden
View GitHub Profile
(
var root = "C:/my_stuff/newthing/engines"; // ~/dust/code
var enginesToLoad = PathName(root).deepFiles.select { |path|
path.fileName.asString.beginsWith("Engine_") and: (path.extension == "scd")
};
"% norns engines to load.".format(enginesToLoad.size).inform;
enginesToLoad.do { |path|

( var debug = false;

var numChannels = 8;

var buffers; var channelGroups; var channelControlBusses; var samplePlayerSynths; // TODO: not sure this is needed anymore since synths now are self-freeing and communication is made via channelGroups var muteGroups;

(
var nvoices = 7;
var pg;
var effect;
var buffers;
var voices;
var mixBus;
var phases;
var levels;

See examples in the following order (gist files are ordered alphabetically rather than by relevance/how i entered them):

  • testsine - simplest possible engine
  • passersby and glut - real engines with both commands and polls, the latter with polls defined in code
  • r - my modular engine
  • ack - ack, including the support library inline (see below)
  • testsine_pd - possible way to expose a testsine pd engine
  • [co](https://gist.github.
@antonhornquist
antonhornquist / engine_ack.lua
Last active September 7, 2019 21:52
Lua engine metadata examples
local ControlSpec = require 'controlspec'
local Formatters = require 'formatters'
local lib = {}
local specs = {}
specs.send = ControlSpec.DB:copy()
specs.send.default = -60
specs.sample_start = ControlSpec.UNIPOLAR
(
// core
var monomeWidth = 16;
var numKits = 4;
var numDrumsPerKit = 4 * 4;
var numStepsPerPattern = monomeWidth * 4;
var numPatterns = monomeWidth * 4;
var tempoSpec = ControlSpec(10, 800, step: 1, default: 120);
var swingAmountSpec = ControlSpec(0.0, 50.0, step: 0.1, default: 25.0);
@antonhornquist
antonhornquist / dw-howto-fix-led-issues.scd
Last active October 8, 2017 21:01
dw: How to fix led issues

s.latency; // 0.2 is the default s.latency=0.05; // better if possible s.options.hardwareBufferSize; // post default s.options.hardwareBufferSize=64; // great if possible s.reboot; // reboot needed after hardwareBufferSize is changed

@antonhornquist
antonhornquist / dw-howto-load-samples.scd
Last active October 8, 2017 21:23
dw: How to load samples

( // code below loads 16 samples into first kit ~loadKit.value( 0, // kit index. four kits, indexed 0 to 3, are available ( root: "/path/to/samples", // root path for samples samples: [ // an array of up to 16 samples "kick1.wav", "kick2.wav", "snare.wav",

require 'tempfile'
# pure data patching dsl for ruby hack
file = Tempfile.new
begin
my_patch = patch # 1. create patch
my_patch + 'declare -stdpath creb' # 2. add object
mod = my_patch + 'loadbang' >> 'list 200 10000' >> 'line~' >> 'osc~ 2' >> '*~ 800' >> '+~ 1000' # 3. connect
sine = mod >> 'osc~ 429' >> '*~ 0.5'
@antonhornquist
antonhornquist / pd.rb
Last active May 19, 2017 11:39
run and patch pd from ruby
require 'socket'
require 'tempfile'
file = Tempfile.new('foo')
# note: using pd netreceive is unsafe, only do this if you know what you're doing
lines =<<-PATCH
#N canvas 87 360 450 300 10;
#X obj 24 25 netreceive 2000 1;
#X obj 24 51 s pd-#{File.basename(file.path)};