Skip to content

Instantly share code, notes, and snippets.


Xavier Riley xavriley

View GitHub Profile
xavriley /
Created May 14, 2014
Icebreaker Tax Avoidance Scheme

Researching the Icebreaker Tax Avoidance Scheme

This has been in the news recently, with coverage focussing on Gary Barlow and his bandmates in Take That. The following article does a reasonable job of trying to break down what is clearly a complex case.

Looking beyond the media angle of "National Treasure Gary Barlow is a tax dodger", I wanted to see what the extent of this scheme was, and the results were surprising.

The Decision

xavriley / deep_note.rb
Last active Apr 21, 2020
Recreating the THX sound with SonicPi
View deep_note.rb
# THX Deep Note
# Second draft
# see
time = 10
wait_time = (time / 3)
synths = []
rand_note = -> { rrand(note(:A2), note(:A4)) }
with_fx :normaliser, amp: 0.5 do
use_synth :dsaw
xavriley / auto_dubstep.rb
Created May 26, 2014
Auto Dubstep example in SonicPi
View auto_dubstep.rb
# Welcome to Sonic Pi v2.0
# SonicPi ish interpretation of
# Dan Stowells' Dubstep Synth:
# All the usual caveats apply - this is just a first attempt at getting it working
# Refinements to follow
@current_bpm = 120.0 # because current_bpm doesn't work for me
use_bpm @current_bpm
xavriley / clyde_stubblefield.rb
Created Jun 10, 2014
Funky drummer with Sonic Pi
View clyde_stubblefield.rb
# The funky drummer
# The aim here is to experiment with
# a) sequencing drums
# b) playing with 'time feel' which is
# music-speak for how the beat feels,
# ranging from robotic (0.0 swing_time)
# to ultra funky Fresh Prince of Bel Air
# theme tune style (0.2+ swing_time)
current_bpm = 180.0
xavriley / drum_tab_player.rb
Created Jun 10, 2014
Playing ASCII Drum Tabs with Sonic Pi
View drum_tab_player.rb
# Playing ASCII drum tabs with Sonic Pi
# Ruby is an awesome language for String manipulation.
# Lets use that fact to play some drums!
# Tab for the Amen break taken from Wikipedia
# Note that %Q{ ... } is just another way
# to define a string in Ruby
xavriley / wobwob.rb
Created Jun 10, 2014
Standalone Sonic Pi wobble bass
View wobwob.rb
# Defining standalone wobble
define :wob do |note, no_of_wobs, duration|
# using in_thread so we don't block everything
in_thread do
use_synth :dsaw
lowcut = note(:E1) # ~ 40Hz
highcut = note(:G8) # ~ 3000Hz
xavriley / auto_dubstep.rb
Created Jun 10, 2014
Auto generating dubstep with Sonic Pi
View auto_dubstep.rb
# Combines ideas from my other gists
current_bpm = 140.0
use_bpm current_bpm
define :wob do
use_synth :dsaw
lowcut = note(:E1) # ~ 40Hz
highcut = note(:G8) # ~ 3000Hz
xavriley / beat_slicer.rb
Created Jun 12, 2014
Sonic Pi random beat slicer/remixer
View beat_slicer.rb
# Beat slicer
# Taking a sample, we can divide it into n slices
# (in this example we'll use 16). Using the :start
# and :finish parameters for the sample method, we
# can 'remix' the sound by playing the slices in a
# random order
sample_name = :loop_amen
n = 16.0
# start and finish range from 0 to 1
xavriley / beat_slicer_140.rb
Last active Aug 29, 2015
Sonic Pi random beat slicer in a tweet (140 chars)
View beat_slicer_140.rb
# better version that doesn't hard code sleep time - try changing loop_amen to another sample!
s=:loop_amen;n=16;b=(0..1).step(1.0/n).each_cons(2).to_a.shuffle;loop{b.each{|p|sample s,start:p[0],finish:p[1];sleep sample_duration(s)/n}}
xavriley /
Created Aug 14, 2014
API design for SonicPi granular synth

Thinking about a design for a granular synth in SonicPi.

Proposed name - warp_sample

  • based on sample - i.e. takes a symbol or path to sample
  • takes a :rate param which is 1 by default. Default behaviour is to play a granulated version of the sample at normal speed
  • as rate is reduced (to say 0.5) the sample takes twice as long but because it's a granular synth the pitch will stay the same
  • unlike sample, a rate of 0 will just play grains around a :pointer position.