Instantly share code, notes, and snippets.

Xavier Riley xavriley

View GitHub Profile

Working with Carabiner (Ableton Link) from Ruby

This script currently requires Ruby >= 2.4 and Mac OS 10.12 or higher

Download Carabiner from here (releases page has builds for OSX and Windows)

Run it in a terminal somewhere.

Download the Link repo and build the examples:


Prototype of vocoder on Sonic Pi

Demo here: Original voice input here:

This is a demo of a simple effects synth using the UGen from SuperCollider. This is a fairly primitive vocoder implementation made of a bunch of bandpass filters which are "tuned" to various frequencies.

The results are mixed, but it's difficult to get a decent reproduction of the words from this.

To get T-Pain/Imogen Heap style auto-tune it would be necessary to write a different algorithm probably using a technique called PSOLA which is described at the following links:


Gossip protocol with XBee and Arduino - Personal Report

Early on in the project we decided to divide some of the requirements from the specification between ourselves. Mirela and I looked at implementing the Gossip algorithm in parallel to the work that Luis was doing on wiring the sensors and transferring the sensor data.

The first stage was to write some pseudo-code outlining the stages of the gossip algorithm. This was done in discussion with Mirela while looking over the paper and other resources we had available. This was important to gain understanding of the key steps.

Initially we decided to try implementing half of the algorithm each with me taking the broadcasting phase and Mirela implementing the receiving phase. Given that I had marginally more experience working with C we later revised these so that I handled both parts of the implementation to allow Mirela to focus on other deliverables.

The Code



developer@5b0666c5c640:~$ jackd -r -t 100000  -d dummy -r 44100
jackd 0.124.1
Copyright 2001-2009 Paul Davis, Stephane Letz, Jack O'Quinn, Torben Hohn and others.
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
// BEGIN code to convert AKWF wavetables from 600 samples in length to 1024
// because VOsc3 needs a buffer which is a power of two to work properly
// this pipes in stdout from ls
var p, l;
p ="find ~/Projects/sonic-pi/etc/wavetables/AKWF/AKWF_0001 -iname *.wav", "r"); // list directory contents in long format
l = p.getLine; // get the first line
View dont_drop_the_bass.rb
# ❤️ Brighton Ruby
# This code uses some features from the pre-release of Sonic Pi,
# due out later this month (touch wood!).
# If you just can't wait for the release but want to try it yourself
# you can either build the Sonic Pi master branch from source (pros: free, cons: hard)
# or share some love and contribute to the Patreon page to support Sonic Pi's development
# That will give to access to the latest pre-release versions
View live_sample.rb
# place in ~/.sonic-pi/init.rb to autoload
def live_sample(name=nil, *args)
raise ArgumentError, "live_sample needs to have a unique name. For example: live_sample :foo" unless name
raise ArgumentError, "live_sample's name needs to be a string or symbol, got: #{name.inspect}. Example usage: live_sample :foo" unless (name.is_a?(Symbol) || name.is_a?(String))
ls_name = "live_sample_#{name}".to_sym
args_h = resolve_synth_opts_hash_or_array(args)
click = args_h[:click] || 4
dur = args_h[:dur]
View harmonizer_idea.rb
s = scale(:c5, :blues_major, num_octaves: 1)
live_loop :foo do
n = s.choose
c = Array(s.index(n)).flat_map {|x|
[x-6, x-4, x-2, x]
play s.values_at(*c), release: 0.1
sleep 0.25
View rhythm_ladder.rb
use_bpm 100
live_loop :ladder do
bars = 2
no_of_beats = [1, 1.5, 2, 3, 4].map {|x|
[x, (4 * x.to_f)*bars]
count = (knit *no_of_beats).tick
sample :elec_tick