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 / apcOSC1.rb
Created November 5, 2018 18:53
Sonic Pi fx parameter control using TouchOSC. index.xml is the TouchOSC template. Donwload and zip it and rename to paramControl.touchosc
#apcOSC1.rb
#Sonic Pi 3 automated parameter control for fx calls controlled by TouchOSC
#developed from an idea by Martin Butz. Code developed by Robin Newman, November 2018
use_osc "192.168.1.240",9000 #address of TouchOSC and input port
#initialise some parameters
#these will be updated further by signals from TouchOSC
set :start,0
set :finish,0.5
set :dur,1
set :type,:fade
@rbnpi
rbnpi / playPurcell-RF.rb
Last active February 18, 2023 11:23
Play Purcell on a Raspberry Pi3 with Sonic Pi. (Run using a run_file command as too long for a sonic pi buffer) Listen to it on https://soundcloud.com/user-195236670/play-purcell
#playPurcell-RF.rb
#run using: run_file "path-to-the-file/playPurcell-RF.rb"
with_fx :reverb,room: 0.8,mix: 0.6 do
use_synth :piano
use_synth_defaults stereo_width: 0.6
a1=[]
b1=[]
a1[0]=[:C3,:B2,:G2,:r,:r,:Bf3,:Ef3,:D3,:B2,:C3,:Ef3,:F3,:G3,:G5,:G5,:r,:D3,:r,:G5,:F5,:G5,:Af5,:G5,:F5,:Ef5,:D5,:C5,:r,:F3,:r,:Bf5,:Af5,:r,:B3,:r,:Af5,:G5,:r,:A3,:r,:G5,:D5,:Ef5,:F5,:G5,:Ef5,:D5,:C5,:C3,:C3,:B2,:G2,:r,:r,:Bf3,:Ef3,:D3,:B2,:r,:Ef4,:r,:r,:C4,:r,:G3,:r,:F3,:r,:Bf3,:r,:C4,:r,:B3,:r,:r,:G3,:Ef4,:D4,:C4,:r,:C3,:r,:r,:G4,:r,:C4,:Ef4,:r,:r,:F4,:Ef3,:D3,:B2,:C3,:Ef3,:F3,:G3,:r,:r,:r,:r,:r,:G3,:r,:C3,:r,:r,:G4,:r,:C4,:Ef4,:r,:r,:F4,:Ef3,:D3,:B2,:r,:r,:G3,:r,:r,:r,:r,:r,:B2,:G2,:r,:r,:Bf3,:Ef3,:D3,:B2,:r,:G5,:G5,:G5,:F5,:F5,:F5,:Ef5,:Af5,:G5,:F5,:Bf5,:Af5,:G5,:Af5,:G5,:F5,:G5,:F5,:Ef5,:D5,:Ef5,:C3,:B2,:G2,:r,:r,:Bf3,:Ef3,:D3,:B2,:C3,:Ef3,:F3,:G3,:r]
b1[0]=[2.0,1.5,0.5,2.0,1.0,1.0,2.0,1.5,0.5,0.5,0.5,0.5,0.5,1.0,1.0,0.5,0.5,0.5,0.5,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.5,0.5,0.5,0.25,0.25,0.5,0.5,0.5,0.25,0.25,0.5,0.5,0.5,
@rbnpi
rbnpi / SonicPiReichLikeDrumsWithHydra.rb
Created January 24, 2023 14:57
Sonic Pi produces a Reich Like drum pattern which controls a Hydra Sketch. Video at https://youtu.be/Tk70Lc2QHJY
#Reich like drumming, by Robin Newman, January 2023
#I use hi and mid tomtoms for the two parts
#or you can set them both the same eg to hard snare
use_debug false
use_midi_logging false
use_midi_defaults channel: 1,port: "iac_driver_bus"
link #lets you adjust tempo as program is running
#set master pattern option with uniform amp or accented amp
#uncomment either the 12 beat or 16 beat patterns
@rbnpi
rbnpi / SPhydraFrere4Pane2.rb
Last active February 6, 2023 16:18
Sonic Pi 4.4dev with built in Hydra plays Frere Jaques displaying the notes. Video at https://youtu.be/J0JbqlScl3Y
#Sonic Pi 4.4dev with built in Hydra
#Hydra sketch shows Frere Jaques 2 part round notes in real time
#coded by Robin enwman February 2023
use_debug false
define :clearPanes do
hydra "
solid(0,0,0).out(o0)
solid(0,0,0).out(o1)
solid(0,0,0).out(o2)
@rbnpi
rbnpi / Hydra Sketch2
Created December 31, 2022 22:30
Sonic Pi and hydra.ojack communicating via midi and audio See it on https://youtu.be/Du0yLoDYHOs
//Sonic Pi controlled code using midi and audio input by Robin Newman
// register WebMIDI
navigator.requestMIDIAccess()
.then(onMIDISuccess, onMIDIFailure);
function onMIDISuccess(midiAccess) {
console.log(midiAccess);
var inputs = midiAccess.inputs;
var outputs = midiAccess.outputs;
for (var input of midiAccess.inputs.values()){
@rbnpi
rbnpi / progressionsBells.rb
Created December 13, 2022 23:29
Progresions of bell like sounds above a bass drone. Based on a toolkit by theibbster on sonic-pi.net Listen on https://soundcloud.com/rbnsonicpi/progressionbells
#This piece is developed from a chord progression tool written by theibbster on sonic-pi.net
#Robin Newman, December 2022
define :chrd do |deg, tonic, sca|
n = 3
if deg.match?('7')
n = 4
deg = deg.slice(0,deg.length-1).to_sym
end
@rbnpi
rbnpi / ReadMe.md
Last active December 3, 2022 17:03
Sonic Pi Loop Controller. Updated for Sonic Pi versions 3.31 and later This program arose out of a question on in-thread.sonic-pi.net inquiring how to control switching a live_loop on and off via a push button see https://in-thread.sonic-pi.net/t/osc-loop-machine-makeymakey/850 See video at https://youtu.be/cEz-fOEF3M0

NOW UPDATED TO INCLUDE CONTROL OF THE BACKGROUND PULSE AND SCREEEN BOTH PROGRAM AND TOUCHOSC TEMPLATE CHANGED

USE SPloopController4.rb for SP versions 3.31, or 4 or greater. YOu can use the new version of TouchOSC see later in the ReadMe file. A SEPARATE VERSION TUNED FOR Pi3 IS ALSO INCLUDED The original question was concerned with using mekey-makey as the "switch input" source. Here I have used a TouchOSC template with 11 pushbuttons on it as the input source. To make it more interesting, I also drive a large "LED" on the TouchOSC screen with OSC commands from the Sonic Pi program. The program has been streamlined to use just ONE live loop to detect the switches being pushed,

@rbnpi
rbnpi / SequencerReadMe.md
Last active November 13, 2022 21:26
Sonic Pi and TouchOSC Sequencer Instructions in readme file. Acompanying article at https://rbnrpi.wordpress.com/sonic-pi-and-touchosc-sequencer/ Video available at https://youtu.be/FrAGd6vbQuQ

UPDATED NOVEMBER 13th 2022 for new format OSC message parsing introduced in Sonic Pi Feb 2020 Use the file Sequencer2.0-RF.rb for Sonic Pi >= 3.2. which uses the new format

The index.xml file will still work, but once you hav it loaded you may like to amend the top label to Sonic Pi Sequencer 2 by Robin Newman, but this is purely cosmetic and not essential

For convenience I have added 4 specimen json files seq1.json to seq4.json which you can use. You can generate your own otherwise using the write commands in the interface. The location of these files is specified in the program. Adjust to suit your own requirements.

orginal ReadMe text follows

@rbnpi
rbnpi / TuningSonicPi.md
Last active November 8, 2022 19:40
Tuning Sonic Pi for best performance

Tuning Sonic Pi for best performance

Several of the programs I write for Sonic Pi push it fairly close to the limit when run on a Raspberry Pi. This note gives some tips on to how to maximise the performance on that platform. Of course, if you run Sonic Pi on Mac OSX,or a Windows PC then the performance is much better on these more powerful platforms and some of the issues may not arise.

Over-clocking your Pi

By increasing the voltage applied to the Pi processor, and running it at a higher clock frequency than normal it is possible to achive significant gains in performance. The down side is that you may reduce the lifetime of your Pi. There are five levels that can be configured: None, Modest, Medium, High and Turbo. I routinely run my Raspberry Pis with Medium Overclocking and have noticed no ill effects on any of them.

If you wish to apply some over-clocking you do so by running the program raspi-config from the command line. Having logged on, from the command line before you start the gra

@rbnpi
rbnpi / GlassArmonicaPlaysMozart.rb
Last active August 27, 2022 18:47
Glass Armonica for Sonic Pi plays Mozart UPDATED to use rpitch: (introduced after this was first written) to calculate sample rate. MUCH simpler
#a Glass Armonica "voice" for Sonic Pi by Robin Newman November 2014
# revised to use rpitch 2018; corrected 2022 for missing tr function
#This simulates the Glass Armonica invented by Benjamin Franklin and for which Mozart
#composed the piece played here
#This version uses rpitch: parameter added to Sonic Pi after the original was written in 2014
##| sample :ambi_glass_rub
##| play :fs5
##| puts note(:fs5)
##| stop
use_debug false