Skip to content

Instantly share code, notes, and snippets.

View rbnpi's full-sized avatar

Robin Newman rbnpi

  • Near Peterborough
View GitHub Profile
@rbnpi
rbnpi / SonicPiConductor.rb
Last active August 29, 2015 14:11
Sonic Pi Conductor. Lets you play a range of workspaces automatically one after the other in a specified order. Video showing operation is on my YouTube channel http://youtu.be/GsbAgU4JdKo
#Sonic Pi Conductor by Robin Newman written for Sonic-Pi 2.1 onwards December 2014
#consists of two functions, slave and conductor, which make extensive use of the :cue and :sync system in Sonic Pi
#The program works becuase these commands can work between workspaces as well as within a single workspace.
#Instructions for use:
#1 In each workspace that you want to control, put as the FIRST LINE slave(ws number)
# eg in workspace two put slave(2), workspace 5 put slave(5) etc.
#2 Put as the LAST LINE of each workspace to be conducted the command cue :wsN where N is the workspace number:
@rbnpi
rbnpi / BachGigueInGMinorSYNTH.rb
Created December 28, 2014 19:59
Plays Bach's Gigue in G Minor on Sonic Pi 2.2 or later. Uses :pulse synth. Also versions for sample based Piano available
#Bach Gigue in G minor from English Suite no 3 Coded by Robion Newman December 2014
#Synth version
set_sched_ahead_time! 3
use_debug false
s=0 #to set global scope
define :setbpm do |n| #set bpm equivalent
s = (1.0 / 8) *(60.0/n.to_f)
end
use_synth :pulse
setbpm(180)
@rbnpi
rbnpi / BachGigueInGMinorSAMPLE1.rb
Last active August 29, 2015 14:12
BachGigueInGMinorSAMPLE1.rb Part 1 of sample based program to play Bach's Gigue in G Minor on Sonic Pi 2.2 or later. (Needs samples and part 2)
#Bach Gigue in G Minor from English Suite 3 (part 1). Coded by Robin Newman December 2014
#sample based version in two parts synced together. Start part 2 then part 1
set_sched_ahead_time! 3
#use_sample_pack '/Users/rbn/Desktop/samples/GrandPiano/' #select and adjust as necessary
use_sample_pack '/home/pi/samples/GrandPiano'
#select loud (f) or soft (p) piano samples
ps="piano_f_"
#ps="piano_p_"
rt=2**(1.0/12) #12th root of 2
@rbnpi
rbnpi / BachGigueInGMinorSAMPLE2.rb
Created December 28, 2014 20:03
Bach Gigue in G Minor sample based version for Sonic Pi 2.2 or later (needs part 1 and samples)
#BachGigueInGMinor (part 2) coded by Robin Newman, December 2014
#sample based version. (two parts synced together: staret this part first, then part 1)
sync :part2
use_sample_pack '/Users/rbn/Desktop/samples/GrandPiano/' #select and adjust as necessary
#use_sample_pack '/home/pi/samples/GrandPiano'
#select loud (f) or soft (p) piano samples
#ps="piano_f_"
ps="piano_p_"
@rbnpi
rbnpi / talk.md
Last active April 13, 2017 15:29
Bett Show 2015 talk

Sonic Pi 2.2 at Bett 2015

This is a summary of a talk given at Bett 2015 on Sonic Pi

I started by playing excerpts from two programs, Scott Joplin Maple Leaf Rag, and a Percussion Generator, to illustrate different things Sonic Pi can do, and gave a brief description of Sonic Pi and the user interface, similar to section 1.2 of the built in tutorial, which is accessed by clicking the Help button.

I also showed how one of the example programs "Idm Breakout" could be copied and played. Then I used the following program sections to develop a code to play the round Frere Jaques

##Making sounds

@rbnpi
rbnpi / BETT-talk.rb
Last active August 29, 2015 14:12
BETT series. Bett talk script. Uncomment successive #nc = lines to play the examples NB also read https://gist.github.com/rbnpi/2c6d2da3246f64f4d97e
@rbnpi
rbnpi / BETT-FrereSliding.rb
Created January 2, 2015 18:01
BETT series. Frere Sliding program illustrates use of control to slide notes
#Frere Jaques using sliding notes
#This piece explores the use of functions generating named args for synths
#by Robin Newman December 12th 2014
#The program explores the use of sliding notes in chord scales and a rendition of Frere Jaques
use_debug false
s=0 #set s here with dummy value so that its scope is global
define :setbpm do |n| #set bpm equivalent
s = (1.0 / 8) *(60.0/n.to_f)
@rbnpi
rbnpi / BETT-FrereAmbiDrone.rb
Created January 2, 2015 18:03
BETT series Frere Ambi-Drone illustrates use of a sample to generate the "voice" used to play the round
#sample based :Ambi-drone voice for Sonic Pi 2.1 over 4 octaves, plays Frere Jaques with drone base, by Robin Newman 5th Dec 2014
set_volume! 2
load_sample :ambi_drone
#sample based voices for :ambi_drone sample over 4 octave range from :c2 to :c6 by Robin Newman December 2014
#use pl(inst,n,d=0.2,pan=0,v=0.8) to play a note where n is note symbol,d duration,v volume
#or plarray(inst,nt,dur,sh=0,vol=0.8,pan=0) to play lists of note symbols and durations
#where inst is samplename,nt and dur are note symbol and duration arrays,sh transpose shift
use_debug false
rm = 2**(1.0/12) #rate multiplier between adjacent semitones (twelth root of 2)
inst = :ambi_drone #to define scope of inst variable set up here. Used as a parameter later
@rbnpi
rbnpi / BETT-LiveCodingExample.rb
Created January 2, 2015 18:10
BETT series Live Coding Example. Successively uncomment commented lines in the program and press play each time
#Live coding example by Robin Newman, December 2014
#uncomment then run each of the five commented lines in the program below
#to add one by one the samples and play commands
#try altering the chords or synths chosen for further effects
#remember to press run to bring changes into effect
set_sched_ahead_time! 0.5
live_loop :d, auto_cue: false do
#sample :bd_zome
@rbnpi
rbnpi / BETT-ScottJoplinMapleLeafRag.rb
Created January 2, 2015 18:12
BETT series Scott Joplin Maple Leaf Rag NB also read https://gist.github.com/rbnpi/2c6d2da3246f64f4d97e
#Scott Joplin Maple Leaf Rag coded by Robin Newman September 2014
#music score http://conquest.imslp.info/files/imglnks/usimg/9/98/IMSLP270188-PMLP06700-Maple_Leaf_Rag.pdf
#on a Raspberry Pi turn OFF Print output in Sonic Pi Prefs
set_sched_ahead_time! 2
use_debug false
s = 1.0 / 12 #makes a crotchet (8) last 0.53s or about 112 crotchets/minute
with_fx :reverb,room: 0.6 do
#first set up synth and note lengths
#not all note lengths used in this piece
use_synth :pretty_bell