Skip to content

Instantly share code, notes, and snippets.

View amiika's full-sized avatar

Miika Alonen amiika

  • CSC - IT Center for Science
  • Espoo
View GitHub Profile
@xavriley
xavriley / README.md
Last active February 26, 2019 13:56
Designing a DSL for slicing samples in Sonic Pi

Sample slicing DSL in Sonic Pi

I'm stealing/playing around with ideas from the tidal language here.

Tidal is more focussed on creating loop based music and manipulating samples. It has a good (although initially scary looking) DSL for this purpose.

  every 6 (density 2) $ jux (iter 8) $ every 8 rev $ 
  every 5 (0.25 <~) $ sound "[808a/4*16, 808a/2 [808a/3 ~ ~ 808b] [~ 808b/3 808b/3 ~] [~],  [~ ~ ~ [~ 808b/2]]/2]"
 |+| speed "[1 1 1 [1.5 0.8] 1 1 1 [1 0.5]]/8"
@rbnpi
rbnpi / HouseOfTheRisingSunVer2.rb
Created August 18, 2015 06:15
HouseOfTheRisingSun-ver2.rb coded for Sonic Pi. Based on score by M Ludenhoof at http://imslp.org/wiki/House_of_the_Rising_Sun_(Ludenhoff,_Martin). Requires SP 2.6 or later. Hear it at https://soundcloud.com/rbnman/houseoftherisingsun-ver2 This version has a different verse structure and varied instrument mix.
#House of the Rising Sun, coded for Sonic Pi by Robin Newman, August 2015
#Based on version by M Ludenhoof at http://imslp.org/wiki/House_of_the_Rising_Sun_(Ludenhoff,_Martin)
#Creative Commons 3.0 licence. One or two notes modified.
#version 2. Different play structure, and alternative instrument formiddle section
use_debug false
#samples used with their natural pitches
inst0=:bass_woodsy_c
samplepitch0=:c3
@emlyn
emlyn / guitar.rb
Last active May 14, 2024 14:11
Strumming guitar chords in Sonic Pi
# Guitar Strumming - by Emlyn
# This tries to work out the guitar (or ukulele etc.) fingering for arbitrary chords (and tuning).
# It seems to work reasonably well for basic chords, but is quite naive and probably makes many mistakes.
# Ideas, bug reports, fixes etc. gratefully received, just comment below, or tweet @emlyn77.
# Feel free to make use of this code as you like (with attribution if you feel like it, but you don't have to).
# Thanks to @Project_Hell_CK for fixing the tuning, and spotting that it gets chord(:f, :major) not quite right.
# Next note higher or equal to base note n, that is in the chord c
define :next_note do |n, c|
# Make sure n is a number
@mbutz
mbutz / base-clarinet-and-modulo.rb
Created March 2, 2017 20:14
FM sounding like bass clarinet
# Bass Clarinet
master_vol = (line 0, 1, inclusive: true, steps: 50).ramp
bass_vol = 0.5
bass_rhythm = (ring 0.25, 0.75, 1, 0.75, 0.25, 0.5, 0.5).shuffle # makes 4 quarters or one bar on the whole
bass_depth = (line 0, 12, steps: 6) # (ring 0.0, 2.0, 4.0, 6.0, 8.0, 10.0) for fm depth:
bass_room = (ring 100, 150, 200, 300)
bass_cycle = 32 # the complete bassline
bass_phrase = bass_cycle / 4 # One of the four patterns
@xavriley
xavriley / dont_drop_the_bass.rb
Created July 8, 2017 20:38
Don't Drop the Bass - Source code with comments - Brighton Ruby 2017
# ❤️ Brighton Ruby
# This code uses some features from the pre-release of Sonic Pi,
# due out later this month (touch wood!).
# If you just can't wait for the release but want to try it yourself
# you can either build the Sonic Pi master branch from source (pros: free, cons: hard)
# or share some love and contribute to the Patreon page to support Sonic Pi's development
# https://www.patreon.com/samaaron
# That will give to access to the latest pre-release versions
@rbnpi
rbnpi / arpeggios_on_a_tb303_bass.rb
Last active August 13, 2018 11:44
arpeggios using 5 chord progressions on a pedal tb303 note hear it at https://soundcloud.com/user-195236670/arpeggios-on-tb303-bass
#Arpeggios on a tb303 bass by Robin Newman, April 2018
#I first wrote the percussion live loops, liked them, and then thought it would be nice to have a melody on top of this.
#I found a list of chord progressions in :c at https://www.secretsofsongwriting.com/2012/04/10/creating-chord-progressions-that-always-work-in-any-key/
#and started to play with them, ending up with the program below. The triad chords in each progression are played as arpeggios
#with the first note added as a fourth note an octave below throughout the duration of the arpeggio.
#Each progression has a transpose offset applied in a sequence of 0,5,7,-5 and the tonic note of the sequence
#is played an octave lower using :tb303 synth acting as a pedal note. To add interest, the cuttoff value
#is cycled 4 times during the progress of each chord progression.
#The sequence is repeated 5 times with the volume faded up or down in each sequence.
@rbnpi
rbnpi / FibonacciMomentum.rb
Last active August 13, 2018 11:42
FibonacciMomentum is a pice for Sonic Pi which generates binary versions of Fibonacci numbers and uses then to control the notes being played. Further details in the comments. You can hear it on https://soundcloud.com/user-195236670/fibonaccimomentum
#Fibonacci Momentum by Robin Newman May 2018
#This piece generates number in the Fibonacci Sequence where each new number
#is the sum of the previous two. The numbers are converted to binary
#using a recursive function and then these are then used to control the playing of two notes.
#The binary digits are read progressively from each end of the binary number.
#If the digits are the same the first note plays, if they are different the second note plays.
#The pitch of the first note is controlled by its position from the start of the number.
#The pitch of the 2nd note is controlled by its position from the end of the number.
#In each case the pitches are taken from a ring based on notes from either
#the :e2 :minor_pentatonic or :harmonic_minor scales.
@d0lfyn
d0lfyn / 20210213-sections.rb
Last active November 27, 2021 16:27
Sections for Sonic Pi
## sections
# first functions
define :getMirrorRange do |pNum|
return [-pNum, pNum];
end
## constants ===================================================================