Skip to content

Instantly share code, notes, and snippets.

View xavriley's full-sized avatar

Xavier Riley xavriley

View GitHub Profile
xavriley /
Last active December 30, 2023 12:17
Original NES Mario Theme for Sonic Pi

Making Chiptune Music using Sonic Pi v2.0

Warning: this might not work on a RaspberryPi yet

I was curious about making retro gaming sounds using Sonic Pi. A couple of months and a lot of Googling later, here's the original Mario Bros theme as it was heard on the NES console.

I'm (just about) old enough to remember rushing home from school to play this game at Philip Boucher's house, sitting cross-legged in front of the TV till my feet got pins and needles. Working out how to recreate it for Sonic Pi was a lot of fun!

Getting the sounds of the NES chip

xavriley /
Created December 1, 2023 13:47
How to run chordino on a batch of audio files

How to run chordino on a batch of audio files

Method 1 - sonic annotator

I'm working on a mac here so I'm assuming you have bash/terminal available. If you're on Windows you could try setting up Windows Subsytem for Linux maybe? (WSL)

  • Open a terminal, get the version of sonic-annotator for your OS from here:
  • Move the downloaded file to your preferred location and extract it (tar -xvf sonic-annotator-1.6-macos.tar.gz was the command I used)
  • Open a terminal, then cd to the sonic-annotator-1.6-macos folder that just got created in the last step
  • find the name of the chordino plugin like so:
xavriley /
Created October 27, 2023 14:15
Add downbeats to midi using PrettyMIDI for use in Logic X
import pretty_midi as pm
import json
def get_syncpoint_downbeat_times(syncpoints):
downbeat_times = []
for syncpoint in syncpoints:
if len(syncpoint) == 2 or syncpoint[2] == 0:
return downbeat_times
xavriley / ambient.rb
Created September 9, 2015 11:28
Ambient piece in Sonic Pi using multiple pentatonic scales
live_loop :foo do
with_fx :echo, mix: 0.3 do
sample :elec_tick if spread(2,7).tick
pattern1 = (knit :a3, 1, :d3, 1, :g3, 1)
pattern2 = (knit :a3, 1, :d3, 1, :g3, 1, :a0, 1)
pattern3 = (knit :a3, 1, :d3, 1, :g3, 1, :a5, 1)
structure = (knit pattern1, 128, pattern2, 32, pattern3, 32).tick(:structure)
xavriley / Example output.txt
Last active May 24, 2023 21:16
Chord Parsing CLI example
$ ./chord-parser -c Cmaj7
input: {
symbol: 'Cmaj7',
rootNote: 'C',
descriptor: 'maj7',
parsableDescriptor: 'maj7',
modifiers: [ 'add7' ],
notationSystem: 'english'
xavriley / auto_dubstep.rb
Created June 10, 2014 21:33
Auto generating dubstep with Sonic Pi
# 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 /
Last active January 8, 2023 12:03
Arpeggiator in Sonic Pi

Arpeggiator in Sonic Pi

This is a work in progress

xavriley /
Last active November 15, 2022 19:34
Using Sonic Pi to practice guitar

Using Sonic Pi to practice guitar

This is an implementation of a scale exercise widely used in jazz teaching. It's sometimes known as the "big scale" exercise.


Let's say you practice the saxophone and you want to make sure you know all your major scales. One way to test this would be to play the scale within the limits of your instrument - saxophones have a lowest note and a highest note (from :Db3 to :A5 at concert pitch in Sonic-Pi speak - see here - assuming you don't get fancy with harmonics!)

Playing an Eb major scale over the whole range of the instrument would mean playing from :D3 to Ab5 (concert) as the lowest and highest notes available don't appear in the scale (:Db3 and :A5 respectively). When you hit the upper or lower limit you just reverse the direction and carry on going.

xavriley /
Created February 5, 2016 21:09
Getting LADSPA plugins working on Sonic Pi

Getting LADSPA plugins working on Sonic Pi

This is an evil experiment at the moment but it works

  • Download and install LMMS from
  • Run the attached SuperCollider file to create the synthdef locally (Overtone doesn't have ladspa yet)
  • patch the named ruby files as per the other attachments
  • start Sonic Pi
xavriley /
Last active May 23, 2022 17:58
Sennheiser VSM201 Vocoder Emulation in SuperCollider