This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getClassesAndIds(parent, memo) { | |
if (typeof memo === 'undefined') | |
memo = {classes: [], ids: []}; | |
if (parent.className) | |
parent.className.split(' ').forEach(function (className) { | |
if (className && !~memo.classes.indexOf(className)) | |
memo.classes.push(className) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// No error checking or anything! Use with caution! | |
function addCombos(list, combos=[], dict={}) { | |
if (!list.length) | |
return combos.concat(dict); | |
let item = list[0]; | |
let possibilities = getPossibilities(item); | |
possibilities.forEach(possibility => { | |
let subDict = addKvp(dict, item, possibility); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage: | |
// ----- | |
// import html from './html-tagged-temp-lit.js' | |
// html`<div>${"Hello World"}</div>` | |
const joinIfArray = (maybeArray) => | |
Array.isArray(maybeArray) ? maybeArray.join('') : maybeArray | |
const html = (literals, ...vars) => { | |
return Array.from(literals).reduce((output, literal, i) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const partial = (f) => | |
(...args) => | |
(args.length >= f.length) | |
? f(...args) | |
: partial(f).bind(this, ...args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
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 = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
const props = ['a', 'b', 'c']; | |
// Manufacture | |
const makeObj = (name) => { | |
const obj = {}; | |
props.forEach(prop => | |
Object.defineProperty(obj, prop, { | |
get: () => `this is ${name}'s ${prop}` | |
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//////// 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); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 |
OlderNewer