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 |
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
| Moved to https://github.com/amiika/novation_games |
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
| # Markov chain player for novation mini launchpad | |
| # Tested only on novation mini mk3 model but probably works on any novaion launchpad | |
| use_debug false | |
| use_midi_logging false | |
| # Midi ports for the launchpad | |
| launchpad_in = "/midi:midiin2_(lpminimk3_midi)_1:1/*" | |
| launchpad_out = "midiout2_(lpminimk3_midi)_2" |
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
| # https://in-thread.sonic-pi.net/t/self-modifying-algorithms/5360/21 | |
| use_debug false | |
| generations = { | |
| :gen1=>{:cells=>[0, 0, 1, 0, 0, 0, 0, 1, 1]}, | |
| :gen2=>{:cells=>[1, 0, 0, 0, 1, 0, 0, 0, 0]} | |
| } | |
| define :create_ruleset do |n| |
NewerOlder