Skip to content

Instantly share code, notes, and snippets.

@amiika
amiika / gist:56d103ca913035104d98c597b3cfdaa2
Created February 10, 2026 06:53
minimalistic bytebeat live coding editor
<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) {
@amiika
amiika / gist:ebf911fe7ee85eb8f13bfc1de6dbcb81
Last active February 10, 2026 23:30
Funcbeat pattern function library
// 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;
@amiika
amiika / gist:64b8a8266bc816d8207b5bec523eb25b
Created January 30, 2026 17:08
Bytebeat in browser console
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 => {
/**
* 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
@amiika
amiika / chain.ts
Created August 17, 2023 12:19
Typescript method chaining example with the automatic evaluation at the end
export class Method {
originalValue: string;
value: string;
constructor(value: string) {
this.originalValue = value;
this.value = value;
}
add(value: string): Method {
@amiika
amiika / linkedlistwithnumbers.ts
Created August 16, 2023 12:10
Typescript linked list with number references for live coding method chaining
// 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();
}
@amiika
amiika / linkedlistchaining.ts
Created August 15, 2023 12:44
Method chaining in typescript example
// 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();
}
# 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
# 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
@amiika
amiika / gist:1c01a48644f2d26d89ad70621599c4b3
Last active April 27, 2021 17:50
integer_sequences.rb
# 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