Skip to content

Instantly share code, notes, and snippets.

View xavriley's full-sized avatar

Xavier Riley xavriley

View GitHub Profile
@xavriley
xavriley / just_tuning.rb
Created April 21, 2015 16:00
Example of Just Temperament in Sonic Pi
# ratios from http://algoart.com/help/artwonk4/MicroTone/microtone.htm
JUST = [1, #c
16.0/15.0, #cs
9.0/8.0, #d
6.0/5.0, #ds
5.0/4.0, #e
4.0/3.0, #f
45.0/32.0, #fs
3.0/2.0, #g
@xavriley
xavriley / README.md
Created April 30, 2015 10:04
Super fast low memory OCR on a Mac

In OCR, everything seems to be using tesseract which is a huge, complex library with lots of dependencies.

Here's an alternative toolchain that shows potential and is much quicker to use

brew install pdfimages
brew install gocr
brew install ocrad

pdfimages path_to_pdf.pdf /tmp/out
@xavriley
xavriley / README.md
Created May 12, 2015 08:21
Stroke width transform with Docker on OSX
@xavriley
xavriley / voice_leading.rb
Last active August 29, 2015 14:21
Smooth voice leading between chords in Sonic Pi
# work out taxicab metric
def octave_transform(chord)
chord.map {|x| 60 + (x%12) }.sort
end
def t_matrix(chord_a, chord_b)
z = octave_transform(chord_a).zip(octave_transform(chord_b))
z.map {|a,b| b - a }
end
@xavriley
xavriley / phasing.rb
Last active August 29, 2015 14:21
Sonic Pi phasing a la Steve Reich
# There are lots of different ways to code this
# This is just one variation that uses one live_loop
use_synth :fm
use_synth_defaults release: 0.2
live_loop :phase, auto_cue: false do
# start the second loop as if 10k notes had elapsed
# c = 10000 if c == 0
# because the pattern is groups of 3, offsets which are
@xavriley
xavriley / Dockerfile
Last active August 29, 2015 14:22
Sonic Pi Dockerfile (experimental)
FROM ubuntu:14.04
RUN apt-get update && \
apt-get -y install \
build-essential \
curl \
git-core \
libcurl4-openssl-dev \
libreadline-dev \
libssl-dev \
@xavriley
xavriley / VirtualBoc Docker Audio Sonic Pi session
Created June 5, 2015 11:21
VirtualBoc Docker Audio Sonic Pi session
xavriley@debian:~$ sudo /etc/init.d/docker start
[sudo] password for xavriley:
[ ok ] Starting docker (via systemctl): docker.service.
xavriley@debian:~$ ps aux | grep pulse
xavriley 1013 0.2 4.3 650772 89280 ? S<Ll 11:30 0:00 /usr/bin/pulseaudio --start
xavriley 1095 0.0 0.0 4328 108 ? S 11:30 0:00 /bin/sh /usr/bin/start-pulseaudio-x11
xavriley 1583 0.0 0.0 12724 2032 pts/0 S+ 11:31 0:00 grep pulse
xavriley@debian:~$ sudo pasuspender -- docker run --privileged -v /dev/snd:/dev/snd:rw -i -t sonic-pi "/bin/bash"
developer@210826e8c96d:/$ dbus-launch --auto-syntax
DBUS_SESSION_BUS_ADDRESS='unix:abstract=/tmp/dbus-KzCjqtFQYC,guid=e507ce7eea08da0b4d21671e556d863b';
@xavriley
xavriley / arpeggiator.rb
Last active August 29, 2015 14:23
Sonic Pi note_range function
def note_range_demo(low_note, high_note, options={})
low_note = Note.resolve_midi_note(low_note)
high_note = Note.resolve_midi_note(high_note)
potential_note_range = Range.new(low_note, high_note)
if options[:pitches]
pitch_classes = options[:pitches].map {|x| Note.resolve_note_name(x) }
note_pool = potential_note_range.select {|n|
@xavriley
xavriley / tesseract_libtiff_homebrew.patch
Created July 1, 2015 10:47
Installing tesseract with libtiff support using homebrew
diff --git a/Library/Formula/tesseract.rb b/Library/Formula/tesseract.rb
index b7903dc..0c4b705 100644
--- a/Library/Formula/tesseract.rb
+++ b/Library/Formula/tesseract.rb
@@ -135,7 +135,7 @@ class Tesseract < Formula
ENV.cxx11 if build.devel?
system "./autogen.sh" if build.head?
- system "./configure", "--disable-dependency-tracking", "--prefix=#{prefix}"
+ system "./configure", "--with-libtiff=/usr/local/Cellar/libtiff/4.0.3/", "--disable-dependency-tracking", "--prefix=#{prefix}"