Skip to content

Instantly share code, notes, and snippets.

View chadochan's full-sized avatar

Chad Langford chadochan

View GitHub Profile
@chadochan
chadochan / Nbit.sc
Created January 29, 2019 11:12
Nbit creates a rhythmic array a specified beatdivision, of length numbeats, with adjustable event density.
// Nbit creates a rhythmic array a specified beatdivision, of length numbeats, with adjustable event density
Nbit {
var beatdiv, numbeats, density;
*new { | beatdiv = 5, numbeats = 2, density = 0.5 |
var pulse = 1 / beatdiv;
var array = Array.fill(beatdiv*numbeats, { (density.coin).binaryValue });
while(
@chadochan
chadochan / PolyPlotter.sc
Created January 29, 2019 11:09
PolyPlotter plots an array of sine waves, superposing them for comparison.
PolyPlotter {
*plot {|limbArray = #[9, 17, 21], phaseoffset = 0, superpose = true|
var sinusplot;
sinusplot = { SinOsc.ar(limbArray, phaseoffset) }.plot(1, bounds: Rect(20, 780, 1370, 70));
sinusplot.superpose = superpose;
}
}
@chadochan
chadochan / Rationalize.sc
Created January 29, 2019 11:04
Rationalize converts a list of decimal representations to their closest possible rational expressions, returning a new 2D list.
// Rationalize converts a list of decimal representations to their closest possible rational expressions,
// returning a new 2D list
Rationalize {
*new { |decimal_list|
var rational_list = List();
decimal_list.do { |item, i|
@chadochan
chadochan / Farey.sc
Created January 29, 2019 11:03
Farey creates an ordered List containing decimal representations of a full Farey sequence up to F(n).
/*
Farey creates an ordered List containing decimal representations of a full Farey sequence up to F(n).
You can use my Rationalize class for conversion to rational list.
(translated from the Python example on Wikipedia)
*/
Farey {
*new { |n = 5|
@chadochan
chadochan / EdgeList.sc
Created January 29, 2019 10:54
EdgeList class takes two rhythm arrays (each comprised of 0 and 1 values) and makes a composite array.
/*
EdgeList takes two rhythm arrays and makes a composite array, returning a 3D array with the unit duration, the composite array,
and the IOI times between events in the composite (in seconds). Can be used as an edge list for a graph.
The array arguments should be comprised of 0 and 1 values, and must each contain at least one value.
*/
EdgeList {
var array1, array2, object;
@chadochan
chadochan / PolyCalc.sc
Last active May 26, 2017 05:01
SuperCollider implementation of Andrew Mead's polyrhythm format calculator (for details http://bit.ly/1PSYIjS). Returns the possible formats for two polyrhythmic limbs.
PolyCalc {
*new { |limb1 = 21, limb2 = 25|
var limb1factors = limb1.factors;
var limb2factors = limb2.factors;
var limb1FirstFactor, limb1SecondFactor, limb2FirstFactor, limb2SecondFactor, temp;
var formatDurations;
if(limb1factors.size == 1, { limb1factors.add(1) });
if(limb2factors.size == 1, { limb2factors.add(1) });
@chadochan
chadochan / snellen.scd
Created February 22, 2016 16:50
SuperCollider 3.6.5: Creates a 12-line text matrix in a 'Snellen' eye-chart configuration.
// SNELLEN by chadochan. 7/12/2015 Durham
// Creates a 12-line 'optotype' eyechart text matrix with text project, random text, and text clearing functions.
(
var font = "Rockwell";
var bold = true;
var backgroundcolor = Color.black;
var lettercolor = Color.grey(1);
var composite1, composite2, composite3, composite4, composite5, composite6, composite7, composite8, composite9, composite10, composite11, composite12;
@chadochan
chadochan / textwall.scd
Last active February 22, 2016 16:47
SuperCollider 3.6.5: create a 25x6 letter matrix for projecting text. Includes project, random letter sprinkle, and text clear functions.
// TEXTWALL by chadochan. 7/12/2015 Durham
// Creates a 25x6 text matrix with text project, random text, and text clearing functions.
(
var font = Font("Luxi Mono", 90);
var backgroundcolor = Color.black;
var lettercolor = Color.white;
var letter1, letter2, letter3, letter4, letter5, letter6, letter7, letter8, letter9, letter10, letter11, letter12, letter13, letter14, letter15, letter16, letter17, letter18, letter19, letter20, letter21, letter22, letter23, letter24, letter25, letter26, letter27, letter28, letter29, letter30, letter31, letter32, letter33, letter34, letter35, letter36, letter37, letter38, letter39, letter40, letter41, letter42, letter43, letter44, letter45, letter46, letter47, letter48, letter49, letter50, letter51, letter52, letter53, letter54, letter55, letter56, letter57, letter58, letter59, letter60, letter61, letter62, letter63, letter64, letter65, letter66, letter67, letter68, letter69, letter70, letter71, letter72, letter73, letter74, letter75, letter76, letter77, letter78, letter79, le