This file contains hidden or 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
| <body style=margin:0;overflow:hidden;background:#000000> | |
| <textarea id=v style="width:100%;height:100%;background:0 0;border:0;color:#4AF262;font:1.4rem monospace;padding:20;" spellcheck=false> | |
| t >> 3 | t & t >> 4 + (t >> 14 & 4) | ((t >> 14 & 2) ? t&t*t>>2 : t&t>>7)</textarea> | |
| <script> | |
| let c,n; | |
| const w = `registerProcessor('a', class extends AudioWorkletProcessor { | |
| constructor() { super(); this.t = 0; this.port.onmessage = e => { | |
| try { let n = new Function('t', 'with(Math) return ' + e.data); n(0); this.f = n; } catch(_) {} | |
| }} | |
| process(_, o) { |
This file contains hidden or 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
| // monkeypatchers pattern library inspired by tidalcycles | |
| const r = t => 0; // Rest | |
| const pitch = (n) => 55 * pow(2, n / 12); | |
| const repeat = (val, n) => Array(n).fill(val); | |
| const speed = (s, pat) => t => { | |
| const rate = typeof s === 'function' ? s(t) : s; |
This file contains hidden or 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
| window.bytebeat = async (f, d=0.2) => { | |
| if (!f) return window.ctx?.close().then(() => { delete window.ctx; delete window.bb; }); | |
| window.ctx = window.ctx || new AudioContext(); | |
| await window.ctx.resume(); | |
| if (!window.bb) { | |
| const c = `registerProcessor('bb', class extends AudioWorkletProcessor { | |
| constructor() { super(); this.t = 0; this.f = t => 0; this.d = 0.2; | |
| this.port.onmessage = e => { |
This file contains hidden or 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
| /** | |
| * Transforms triad intervals into Tonnetz generator vectors. | |
| * | |
| * @param triadIntervals An array [a, b, c] representing the intervals | |
| * around a triad, which must sum to 12. | |
| * @returns An array [u, v] of the two generator vectors, or null if the input is invalid. | |
| */ | |
| function triadIntervalsToGenerators(triadIntervals) { | |
| // Validate the input |
This file contains hidden or 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
| export class Method { | |
| originalValue: string; | |
| value: string; | |
| constructor(value: string) { | |
| this.originalValue = value; | |
| this.value = value; | |
| } | |
| add(value: string): Method { |
This file contains hidden or 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
| // Simple pattern class creating pattern from list of values | |
| export class Pattern { | |
| events: Event[]; | |
| _current : number | undefined = undefined; | |
| constructor(values: number[]) { | |
| this.events = values.map((value, index) => new Event(value)); | |
| this.buildLinks(); | |
| } |
This file contains hidden or 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
| // Simple pattern class creating pattern from list of values | |
| export class Pattern { | |
| events: Event[]; | |
| _current : Event | undefined = undefined; | |
| constructor(values: number[]) { | |
| this.events = values.map((value, index) => new Event(value)); | |
| this.buildLinks(); | |
| } |
This file contains hidden or 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
| # Does the same thing as: https://slonimsky.netlify.app/ | |
| def slonimsky(nodes, interpolations, divisions=1) | |
| return [] if (nodes <= 0) | |
| nodes.times.collect { |i| [i * divisions] + interpolations.map { |x| (i * divisions) + x }}.flatten | |
| end |
This file contains hidden or 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
| # Bresenhams Euclidean algorithm in Ruby | |
| def euclidean_bresenham(pulses, steps) | |
| return Array.new(steps,1) if pulses>=steps | |
| previous = nil | |
| rhythm = [] | |
| steps.times do |i| | |
| div = ((pulses.to_f / steps) * i).to_i | |
| rhythm.push(div == previous ? 0 : 1) | |
| previous = div |
This file contains hidden or 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
| # Number sequence enumerators | |
| define :fibonacci do | |
| Enumerator.new do |y| | |
| a = b = 1 | |
| while true do | |
| y << a | |
| a, b = b, a + b | |
| end | |
| end | |
| end |
NewerOlder