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 / 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

@xavriley
xavriley / avishai.rb
Created February 5, 2015 10:32
Avishai Cohen's Pinzin Kinzin in Sonic Pi 2.3-dev
use_bpm 130
use_synth :saw
use_synth_defaults release: 0.4
bassline = (knit :a3, 4,
:e3, 5,
:f3, 4,
:d3, 5,
:b2, 4,
:c3, 5,
@xavriley
xavriley / texture_fx.rb
Created February 18, 2015 16:37
Ring mod, bitcrusher, reverb, compression - oh my!
use_bpm 110
live_loop(:dr) do
with_fx :compressor, pre_amp: 10 do
with_fx :reverb, mix: 0.1, room: 1 do
with_fx :ring, freq: scale(:eb4, :minor_pentatonic).choose, mix: 0.4 do
"100100101110".chars.map(&:to_i).each.with_index do |beat, i|
sample :bd_808 if beat == 1
sample :bd_808 if beat != 1 and one_in(12)
with_fx :bitcrusher, bits: 8 do
sample :elec_blip, pan: -> {rrand(0,1)}.call, amp: 5 if [4,13].include? i
@xavriley
xavriley / drop_2.rb
Last active August 29, 2015 14:15
Prototype drop-ii harmoniser in Sonic Pi
c_bebop = [60,62,64,65,67,68,69,71]
current_scale = (c_bebop.map {|x| x - 12 } + \
c_bebop + \
c_bebop.map {|x| x + 12 } + \
c_bebop.map {|x| x + 24 }).flatten
def chord_tones(n, scale)
return n if n.nil?
idx = scale.to_a.index(note(n).to_i)
@xavriley
xavriley / pad_times.rb
Created March 12, 2015 18:24
Melody maker in sonic pi
uncomment do
define :pad_times do |target_length, time_values|
if time_values.reduce(:+) < target_length
return time_values << (target_length - time_values.reduce(:+))
else
truncated_times = time_values.take_while.with_index {|x,i|
time_values[0..i].reduce(:+) < target_length
}
return truncated_times << (target_length - truncated_times.reduce(:+))
end
@xavriley
xavriley / bath_ruby_piece.rb
Created March 14, 2015 01:19
Bath Ruby piece
live_loop :dr do |c|
with_fx :reverb do
synth :zawa, note: (knit :c2, 32, :a1, 8)[c], release: 3, phase: 0.25, wave: 1, phase_offset: 0.5 if factor?(c, 16)
end
with_fx :echo, mix: 0.3 do
synth :pulse, pan: Math.sin(vt), note: (scale :a3, :minor_pentatonic).choose, release: 0.1 if spread(7,16)[c]
end
sample :bd_haus if spread(5,8)[c]
@xavriley
xavriley / README.md
Created April 19, 2015 11:46
degrade effect in Sonic Pi

Degrade effect for Sonic Pi

Our old friend Tidal has a function I quite like - degrade

Tidal is a pattern based language and degrade simply drops an event from a pattern 50% of the time.

input: [1,1,1,1,1,1,1,1]

-&gt; degrade(input)