Skip to content

Instantly share code, notes, and snippets.

Avatar

Robin Newman rbnpi

  • Near Peterborough
View GitHub Profile
@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
View SonicPiReichLikeDrumsWithHydra.rb
#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 / 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
View Hydra Sketch2
//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
View progressionsBells.rb
#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
View ReadMe.md

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
View SequencerReadMe.md

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
View TuningSonicPi.md

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
View GlassArmonicaPlaysMozart.rb
#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
@rbnpi
rbnpi / BeatusVirControlled-RFAuto.rb
Created January 27, 2017 17:16
Sonic Pi processing remote control GUI
View BeatusVirControlled-RFAuto.rb
#!/usr/bin/ruby
`/usr/local/bin/sonic_pi stop`
`/usr/local/bin/sonic_pi "run_file '~/Documents/SPfromXML/BeatusVirControlled-RF.rb'"`
@rbnpi
rbnpi / MarenzioMadrigal1.rb
Last active August 4, 2022 21:11
Sonic Pi plays 3 16th Century madrigals by Luca Marenzio, arranged for 5 trumpets. uses sample based voices, and features dynamic level variation. Requires SP 2.5 or later. Sample download at http://r.newman.ch/rpi/Marenzio.zip
View MarenzioMadrigal1.rb
# Luca Marenzio Madrigal 1553-1599 "Togli dolce ben mio" arranged for 5 trumpets coded for by Robin Newman, April 2015
#uses sample based voice, and also has variable dynamic settings for each part and final rit.
#requires version >=2.9
#Sample requires can be downloaded from http://r.newman.ch/rpi/Marenzio.zip
#This version altered for syntax changes. Wrosk with later versions of SP
use_debug false
path= '~/Desktop/samples/Marenzio/' #path to sample folder
#first deal with selecting and setting up the sample
inst0 = 0 #first (in fact only) sample in folder
@rbnpi
rbnpi / SonicPiTocAndFugue-RF.rb
Last active July 27, 2022 22:08
Bach Toccata and Fugue played by Sonic Pi. Use run_file "/path/to/SonicPiTocAndFugue-RF.rb" to play. Hear it on https://soundcloud.com/rbnsonicpi/bachtoccataandfugue-1
View SonicPiTocAndFugue-RF.rb
#BachTocAndFugue-RFrb (latest version)
#coded by Robin Newman from an arrangement by Guillaume Bentaieb https://musescore.com/user/2953356/scores/7328486
start = 0 #section to start playing from (fugue stats at 6)
#note data part0 (a few extra notes from part 1 which required this to play on Sonic Pi)
a0=[]
b0=[]
a0[0]=[:A6,:A6,:r,:G6,:F6,:E6,:D6,:Cs6,:D6,:A5,:A5,:r,:E5,:F5,:Cs5,:D5,:r,:r,:r,:r,:r,:r]
b0[0]=[0.16666667,0.33333334,0.125,0.0625,0.0625,0.0625,0.0625,0.125,1.0,0.16666667,0.33333334,0.125,0.125,0.125,0.125,1.0,2.0,4.0,2.0,1.0,0.5,0.25]
a0[1]=[:r,:r,:r,:r,:r,:r,:r,:E5,:r,:r,:r,:A4,:r,:r]
b0[1]=[0.25,4.0,4.0,4.0,4.0,2.0,0.5,0.5,1.0,2.0,0.5,0.5,1.0,4.0]