Skip to content

Instantly share code, notes, and snippets.

View datramt's full-sized avatar
😎

Dan Tramte datramt

😎
View GitHub Profile
####################################################################
######################## CODE SECTION 1 ############################
####################################################################
# where we define all of our musical patterns
# drum patterns
hhpat1 = (bools 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1)
snpat1 = (bools 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0)
bdpat1 = (bools 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0)
@datramt
datramt / song_structure_example_2.rb
Created June 24, 2019 15:45
song_structure 2 (sonic pi)
define :beat_1 do
in_thread do
16.times do
sample :drum_cymbal_closed if (bools 1, 1, 1, 0, 1, 0, 1, 1).tick(:beat1)
sleep 0.25
end
end
end
define :mel_1 do
@datramt
datramt / control synth.rb
Created June 18, 2019 18:03
control synth example
use_synth :tb303
fitted_duration = 4
my_mel = ((scale :a3, :minor) + (knit :a2, 8)).repeat.shuffle
my_alt_mel = ((scale :e3, :minor) + (knit :e2, 8)).mirror.shuffle
my_current_mel = my_mel
quantity_of_notes = my_current_mel.length
@datramt
datramt / example_c.rb
Created June 17, 2019 22:16
example_c.rb
# Michael Jackson’s Billie Jean basic percussion part in Sonic Pi
100.times do
sample :drum_cymbal_closed
sample :drum_bass_hard
sleep 0.25
sample :drum_cymbal_closed
sleep 0.25
sample :drum_cymbal_closed
sample :drum_snare_hard
sleep 0.25
@datramt
datramt / example_b.rb
Created June 17, 2019 22:15
example_b.rb
# column 1 (hihat cymbal and bass drum play simultaneously and rest for 0.25 seconds)
sample :drum_cymbal_closed
sample :drum_bass_hard
sleep 0.25
# column 2 (hihat cymbal plays and thens rests for 0.25 seconds)
sample :drum_cymbal_closed
sleep 0.25
# column 3 (hihat cymbal and snare drum play simultaneously and rest for 0.25 seconds)
sample :drum_cymbal_closed
sample :drum_snare_hard
@datramt
datramt / example_a.rb
Last active June 17, 2019 22:15
example_a
#Columns (time): 1, 2, 3, 4
Hi-hat cymbal: x, x, x, x
Snare drum: o, o, x, o
Bass drum: x, o, o, o
#(“x” means that the percussion event sounded, while “o” means it rested)
@datramt
datramt / all_samples_simultaneously.rb
Created June 17, 2019 03:37
one-liner to play all Sonic Pi samples simultaneously
sample_groups.each do |g| (sample_names g).each do |n| sample n, sustain: 0, release: 4 end end
@datramt
datramt / project2example.rb
Created June 14, 2019 19:32
Freedom Summer (project 2 example)
##| generate percussion patterns using bools
snpat = (bools 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0)
bdpat = (bools 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0)
##| generate melody using scale (and injecting rests)
use_random_seed 16
mlpat = ((scale :e4, :minor) + (knit :r, 3)).shuffle.take(16)
##| generate bass line using chord (and injecting 1 rest)
use_random_seed 1234
@datramt
datramt / dats_ring_chains.rb
Created June 14, 2019 16:19
datramt's ring chain extensions for sonic pi
class SonicPi::Core::RingVector
#datramt's Ring Chains
def shuffle_times(x)
res = self
x.times do
res = self.shuffle
end
return res
@datramt
datramt / mel_bas_strats.rb
Created June 13, 2019 18:09
strategies for generating melodies and bass lines in sonic pi
# STRATEGIES FOR GENERATING MELODIES & BASS LINES
# scale pattern
##| my_mel = (scale :e, :minor) # returns a ring
# adding rings together will "concatenate" the lists
##| my_mel = (scale :e, :minor) + (ring :r, :r, :r, :r, :r, :r, :r, :r)
# call the "shuffle" method to scramble the scale and mix in rests
##| my_mel = ((scale :e, :minor) + (ring :r, :r, :r, :r, :r, :r, :r, :r)).shuffle