Skip to content

Instantly share code, notes, and snippets.

View datramt's full-sized avatar
😎

Dan Tramte datramt

😎
View GitHub Profile
@datramt
datramt / sonicPIANOphase.rb
Created December 24, 2018 14:49
Piano Phase implementation in sonic pi
#piano phase by Steve Reich
#implemented by dan tramte
use_synth :piano
for i in 120..121 do
use_bpm i
in_thread do
loop do
play (ring 64, 66, 71, 73, 74, 66, 64, 73, 71, 66, 74, 73).tick, pan: 120.5-i
sleep 0.25
@datramt
datramt / songStructure_v1.rb
Created February 2, 2019 20:30
structuring song version 1
use_bpm 140
define :bassThread do
in_thread do
16.times do
tick
sample :bd_boom, amp: 3, rate: (ring, 1, 1, 1, 0.9, 1.19, 1.19, 1.06, 1.03).look
sleep 1
end
end
@datramt
datramt / live_hiss.rb
Created April 10, 2019 22:02
live hiss
define :live_hiss do
in_thread do
loop do
adjusted_stretch_2_bpm = current_bpm/7.5
sample :vinyl_hiss, beat_stretch: adjusted_stretch_2_bpm
sleep adjusted_stretch_2_bpm
end
end
end
@datramt
datramt / pick_a_perm.rb
Last active April 13, 2019 02:19
generates a list of binary numbers and outputs one permutation as array of 1's & 0's
define :genBinaryList do |n|
if n < 10 then
bl = []
(0..(2**n -1)).each do |i|
bn = "%0#{n}b" % i
bl.push(bn)
end
return bl
else
return ["0"]
@datramt
datramt / bad-binary.rb
Created April 13, 2019 01:53
generate binary #bad
hi = 8.upto(15).map do |n| n.to_s(2) end
lo = hi.map do |e| e.dup end
lo.map do |o| o[0] = "0" end
lohi = lo + hi
puts lohi
#found a better way to do this
#proud of this silly thing tho, lol
@datramt
datramt / nn_symbol_range.rb
Created April 13, 2019 13:52
snippet for determining ranges with sonic pi note name symbols
# is n within range x..y?
x = :C1
y = :C5
n = :Bb3
puts (x.to_i..y.to_i).cover?(n.to_i)
@datramt
datramt / calculate_BH_FREQ.rb
Created April 13, 2019 14:08
calculate the frequency of the Perseus cluster black hole with [limited] info provided by nasa.gov article
# from music tech class APRIL 11 2019 at Virginia Tech
# https://www.nasa.gov/centers/goddard/universe/black_hole_sound.html
##| formula for midi note 57 octaves below middle C (assuming the starting point is the B-flat below middle C)
bh_midi_note = 60-2-12*57.0
puts bh_midi_note #=> -626.0
##| formula to convert midi to frequency
bh_frequency = 2**((bh_midi_note-69)/12)*440
puts bh_frequency #=> 1.6173304415101714e-15
@datramt
datramt / lilium.rb
Created April 16, 2019 21:38
Elfen Lied Lilium music box realized in sonic pi
notes =(ring 78, 85,
[80, 65], 73, 77, 81, [81, 66], :r, 78, 85,
[80, 65], 73, 77, 81, [83, 66], 81,
[78, 62], 69, 74, 69, 71, 80, 76, 74,
[76, 61], 68, 73, 68, 70, 78, 74, 73,
[74, 59], 76, 78, 71, 60, [80, 63], [81, 66], 83,
[81, 61], 66, 73, 66, [80, 61], :r, 78, 85,
[80, 65], 73, 77, 81, [81, 66], :r, 78, 85,
[80, 65], 73, 77, 81, [83, 66], 81,
[78, 62], 69, 74, 69, 71, 80, 76, 74,
@datramt
datramt / updating_random_seed.rb
Created April 17, 2019 21:48
reliable date-based updating seed for random numbers in sonic pi
#for when you don't want single-seed :P
define :now_time do
t = Time.new
return (t.year.to_s+t.month.to_s+t.day.to_s+t.hour.to_s+t.min.to_s+t.sec.to_s+t.usec.to_s).to_i
end
define :use_updating_random_seed do
use_random_seed now_time
end
@datramt
datramt / Neo-Riemannian_transformations.rb
Created April 20, 2019 21:29
method for indexing an array of chords using neo-riemannian transformations
def nr_t (this_current_chord, this_transform_type)
case this_transform_type
when "t_t" #thru transformation (no transformation occurs)
return this_current_chord
when "p_t" #parallel transformation
return (this_current_chord+12)%24
when "r_t" #relative transformation
return this_current_chord < 12? (this_current_chord = (this_current_chord+3)%12+12)%24 : (((this_current_chord-12)+9)%12)%24
when "l_t" #leading tone transformation
return this_current_chord < 12? (this_current_chord = (this_current_chord+8)%12+12)%24 : (((this_current_chord-12)+4)%12)%24