Last active
March 27, 2023 09:57
-
-
Save binarysweets/dcb40a1728d5ed0be132bbf82a61af71 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Title: ? | |
# Artist: ? | |
# Date: ? | |
# License: ? | |
# Sonic Pi v? | |
# Settings | |
use_bpm 100 | |
bar_length = 4 | |
use_random_seed 0 | |
swing = (ring 0.01, -0.01) | |
# Scale | |
mode = :augmented | |
scl = scale(:a1, mode, num_octaves: 4) | |
# Functions | |
define :get_pitch_from_note do |note, sample_base_note, fine_tune| | |
return note - sample_base_note + fine_tune | |
end | |
define :bar do |length = 8| | |
sleep bar_length * length | |
end | |
define :sleep_with_swing do |sleep_duration| | |
sleep sleep_duration + swing.look | |
end | |
# Loops | |
define :lead do |length = 8, pattern = 1| | |
in_thread do | |
notes = (ring 18,17,17,20, 21,18,17,22).mirror | |
idx = get[:lead_counter] | |
with_fx :bitcrusher, bits: 16, mix: 0.5 do |bc| # outside of loop | |
((bar_length * length) * 4).times do ; tick | |
control bc, bits: (line 16, 1, steps: 256)[idx] # control instance here! | |
play scl[notes.tick(:n)], amp: rrand(0.4, 0.5), sustain: 0.2, | |
attack: (line 0.1, 0.5, steps: 128)[idx], | |
release: 0.1 if bools(1,0,0,0, 1,0,0,0, 1,0,0,1, 1,0,0,1).look | |
sleep_with_swing 0.25 | |
idx += 1 | |
end | |
set :lead_counter, idx | |
end | |
end | |
end | |
define :chords do |length = 8, pattern = 1| | |
in_thread do | |
notes = (ring 12,13,12,14) | |
((bar_length * length)).times do ; tick | |
with_synth :hollow do | |
play (chord scl[notes.tick(:n)], 'm+5'), | |
amp: 2.5, | |
pan: 0, | |
attack: 0, | |
sustain: 2, | |
decay: 0.125, | |
release: 4 if bools(1,0,0,0, 0,0,0,1).look | |
end | |
sleep_with_swing 1 | |
end | |
end | |
end | |
define :bass do |length = 8, pattern = 1| | |
in_thread do | |
notes = (ring 0,3,2,4) | |
((bar_length * length)).times do ; tick | |
with_synth :tri do | |
play scl[notes.tick(:n)], | |
amp: 0.3, | |
attack: 0, | |
sustain: 2, | |
release: 0 if bools(1,0,0,0).look | |
end | |
sleep_with_swing 1 | |
end | |
end | |
end | |
define :mids do |length = 8, pattern = 1| | |
in_thread do | |
notes = (ring 12,13,14) if pattern == 1 | |
notes = (ring 8,9,8,11).mirror if pattern == 2 | |
((bar_length * length) * 4).times do ; tick | |
play scl[notes.tick(:n)], amp: rrand(0.5, 0.7), sustain: 0.1, | |
release: (line 0.125, 0.5, steps: 16).look | |
sleep_with_swing 0.25 | |
end | |
end | |
end | |
define :drums do |length = 8, pattern = 1| | |
in_thread do | |
#s = "/path/to/sample.wav" | |
s = :loop_breakbeat | |
slices = (line 0, 15, steps: 16, inclusive: true) | |
with_fx :eq, low_note: 30, low: -0.5, mid_note: 59, mid: -0.8 do | |
((bar_length * length) * 4).times do ; tick | |
sample s, slice: slices.look, beat_stretch: 4, amp: 10 | |
sleep_with_swing 0.25 | |
end | |
end | |
end | |
end | |
# Reset globals | |
set :lead_counter, 0 | |
# Structure | |
chords ; mids(8,1) ; bass ; lead ; bar | |
drums ; chords ; mids(8,1) ; bass ; lead ; bar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment