Skip to content

Instantly share code, notes, and snippets.

@rbnpi rbnpi/ringfunctions.rb
Last active Aug 29, 2015

Embed
What would you like to do?
Program demonstrates the power of the ring function added to version 2.2
#example of the use of rings by Robin Newman, December 2014
#the following three rings hold rhythms for three percussion instruments
#they play when the relevant entry is true
k1=(bools 1,0,0,0,1,0,0,0) #drum_bass_hard rhythm
k2=(bools 0,1,1,0,0,0,1,1) #srum_snare_hard rhythm
k3=(bools 0,0,1,1,0,1,1,0) #drum_cymbal_pedal rhythm
#the next two rings, (one generated by the knit function) control the tune and transposition
n1=(ring :c4,:e4,:g4,:a4,:bb4,:a4,:g4,:e4) #basic tune sequence for boogie
#16 notes played with 0 shift, then 16 up 5 semitones, then 16 with zero shift,
#then 8 with 7 semitones shift and 8 with 5 semitones shift
sh= (knit 0,16,5,16,0,16,7,8,5,8) #transpose control to shift boogie line
#the whole point of the rings is that as the index increases the patterns above repeat looping round
live_loop :drums,auto_cue: false do |i| #use index parameter i initialsied to 0
if k1[i]
then
sample :drum_bass_hard #plays when the k1 ring element is true
end
if k2[i]
then
sample :drum_snare_hard,amp: 0.5 #plays when the k2 ring element is true
end
if k3[i]
then
sample :drum_cymbal_pedal #plays when the k3 ring element is true
end
sleep 0.25
inc i #use inc function to increase i by 1
end
with_fx :reverb,room: 0.8 do #add some reverb
live_loop :tune,auto_cue: false do |i| #use index parameter i initialsied to 0
use_synth :fm
with_transpose sh[i] do #the sh ring (set up by knit) controls the transposition of each note
play n1[i],sustain: 0.5*0.6,release: 0.5*0.4 #set 60% sustain 40% release for each note
end
sleep 0.5 #note speed set to half that of the drum rhythm
inc i #use inc function to increase i by 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.