Skip to content

Instantly share code, notes, and snippets.

View xavriley's full-sized avatar

Xavier Riley xavriley

View GitHub Profile
@xavriley
xavriley / README.md
Created May 14, 2014 21:23
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.

http://www.ibtimes.co.uk/take-that-tax-avoidance-how-gary-barlow-howard-donald-mark-owen-dodged-hmrc-1448258

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
xavriley / deep_note.rb
Last active April 21, 2020 02:36
Recreating the THX sound with SonicPi
# THX Deep Note
# Second draft
# see http://www.earslap.com/article/recreating-the-thx-deep-note.html
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
xavriley / auto_dubstep.rb
Created May 26, 2014 20:47
Auto Dubstep example in SonicPi
# 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
xavriley / clyde_stubblefield.rb
Created June 10, 2014 21:15
Funky drummer with Sonic Pi
# 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
xavriley / drum_tab_player.rb
Created June 10, 2014 21:22
Playing ASCII Drum Tabs with Sonic Pi
# 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
# http://en.wikipedia.org/wiki/Amen_break
# Note that %Q{ ... } is just another way
# to define a string in Ruby
@xavriley
xavriley / wobwob.rb
Created June 10, 2014 21:30
Standalone Sonic Pi wobble bass
# Defining standalone wobble
# WOBBLE BASS
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
xavriley / auto_dubstep.rb
Created June 10, 2014 21:33
Auto generating dubstep with Sonic Pi
# DUBSTEP
# Combines ideas from my other gists
current_bpm = 140.0
use_bpm current_bpm
# WOBBLE BASS
define :wob do
use_synth :dsaw
lowcut = note(:E1) # ~ 40Hz
highcut = note(:G8) # ~ 3000Hz
@xavriley
xavriley / beat_slicer.rb
Created June 12, 2014 08:58
Sonic Pi random beat slicer/remixer
# 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
xavriley / beat_slicer_140.rb
Last active August 29, 2015 14:02
Sonic Pi random beat slicer in a tweet (140 chars)
# 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
xavriley / grain_synth_design.md
Created August 14, 2014 13:40
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.

Arguments