Skip to content

Instantly share code, notes, and snippets.

@alyssa
alyssa / sonic_pi_feeling_blue.rb
Last active July 9, 2022 15:58
Standard 12 bar blues (bass line + comping) for sonic pi (sonic-pi.net)
# Standard 12 bar blues
# I7 | IV7 | I7 | I7
# IV7 | IV7 | I7 | I7
# V7 | IV7 | I7 | I7
# Choose a root note (one) and everything else will fall into place.
one = :G2
four = one + 5
five = one + 7
@darinwilson
darinwilson / ambient1
Created August 14, 2015 19:46
Ambient experiment using Sonic Pi
# Ambient experiment for Sonic Pi (http://sonic-pi.net/)
#
# The piece consists of three long loops, each of which plays one of
# two randomly selected pitches. Each note has different attack,
# release and sleep values, so that they move in and out of phase
# with each other. This can play for quite awhile without
# repeating itself :)
live_loop :note1 do
use_synth :hollow
@samaaron
samaaron / dnb.rb
Last active August 23, 2020 08:10
Derivative Drum and Bass
# Super simple drum and bass
# Coded by Sam Aaron w/ Sonic Pi
# To play: download Sonic Pi from the link below, paste the code in and hit Run
# http://sonic-pi.net
use_bpm 100
live_loop :amen_break do
#samples = Dir.glob("/path/to/samples/*.wav")
#samples = [:loop_amen_full, :ambi_choir]
#samples = [:ambi_choir]
samples = [:guit_harmonics]
#starts = (ring 0, 0.25, 0.5, 0.75)
#starts = range(0, 0.875, 0.125)
starts = range(0, 0.875, 0.0625)
#starts = (0..10).collect{rand(1)}
live_loop :drums do
with_fx :level, amp:1.0 do
sample :bd_ada, attack:0, sustain_level:0, decay: 0.1, start: 0, amp:2, rate:0.5
sleep 0.125
with_fx :reverb, mix:0.2, room:0.5 do
sample :perc_snap, attack:0, sustain_level:0, decay: (ring 0.1, 0.1, 0.1, 0.5).tick(:t1), start: 0, amp:1, rate:(ring -2, -3, -4, -5).tick(:t1b)
sleep 0.125
with_fx :krush, mix:0.7 do
sample :misc_burp, attack:0, sustain_level:0, decay: 0.4, start: 0.5, amp:(ring 0.4, 0.6, 0.8, 0).tick(:t2), rate:0.9
end
@rbnpi
rbnpi / scaletypecontrolledarpeggios.rb
Last active August 29, 2015 14:25
scaletypecontrolledarpeggios.rb An exercise in composing a piece based on scale types, three chords and arpeggios. Fully commented to explain how it works. Needs SP 2.6. Audio on https://soundcloud.com/rbnman/scaletypecontrolledarpeggios
#loading...#scaletypecontrolledarpeggios.rb by Robin Newman, July 2015. Requires sp2.6
#A study using arpeggios with different scale formats. Also utilising rings and ticks
#This was a great exercise to explore different Sonic Pi (and Ruby) commands
#eg tick, look, ring, note_range for SP and string manipulation commands and eval for Ruby to mention some.
#First of all in the defined procedures which enable you to extract info about different scale types
#and to generate the rings required for the piece to work.
#Basically the code generates a pool of notes for three separate chords and then transposes those notes
#using notes 0,3,4 and 4 (down an octave) for each of the distinct 8 note scales supported in Sonic Pi
@kindohm
kindohm / timing.rb
Created July 22, 2015 17:45
timing
live_loop :thing do
sample :drum_bass_hard
sleep 0.75
4.times do
sample :drum_cymbal_soft, rate: rrand(2,4)
sleep 0.125
end
end
live_loop :snare do
@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|
@cassiel
cassiel / forbidden-piano.rb
Created May 2, 2015 17:17
Forbidden Piano, for Sonic Pi.
theNotes = [:a2, :a3, :e3, :a4, :g4, :e4]
define :foo do |samp, n|
sample samp,
rate: pitch_ratio(note(n) - note(:a3)),
sustain: 0.05,
release: 0.1,
amp:3
end
@hamin
hamin / the_suburbs.rb
Last active October 26, 2019 08:50
Arcade Fire's 'The Suburbs' in Sonic PI ;) Download http://sonic-pi.net and copy paste this Grammy Winning gem ;)
in_thread do
loop do
sample :drum_bass_hard, amp: 2
sleep 2
end
end
in_thread do
loop do
sleep 1