Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sonic Pi - Soundscape for relaxing
# floating-moment.rb
# ambient soundscape for relaxing and meditation
# Created by Sven Wachsmuth
# https://gist.github.com/sven-wachsmuth/0cc06cc0d698d8932ceb142dcf5231ba
use_bpm 60
laenge_in_takten = 229 # length of the track in beats - 300 means relax 5 minutes :-)
# possible notes out of a sounds-well-scale
notes = (scale :c3, :minor_pentatonic, num_octaves: 3).shuffle
# 12-step-sine-table for panning (0 = middle, 1 = right, -1 = left)
sin_tab = (ring 0, 0.5, 0.86, 1, 0.86, 0.5, 0, -0.5, -0.86, -1, -0.86, -0.5)
pan_pos = 0
in_thread do
with_fx :reverb, room: 0.6 do
tweety = synth :dark_ambience, note: :c3, attack: 8, sustain: (laenge_in_takten-16), release: 8, note_slide: 0.05
# while synth "tweety" is running - change pitch and panning 4 times per second
(laenge_in_takten*4).times do
if one_in(8) # if the dice has an 8
pan_pos = sin_tab.tick # pan gets next value from sin_tab (-1...+1)
end
control tweety, note: notes.choose, pan: pan_pos # always choose random note from "notes"
sleep 0.25
end
end
end
# the beat with little variations
live_loop :dull_beat do
synth :dull_bell, note: :c3, release: 0.2
sleep 0.125
if one_in(6)
synth :dull_bell, note: :g4, release: 0.2
end
sleep 0.375
if one_in(12)
synth :dull_bell, note: :c4, release: 0.2
end
sleep 1.500
tick(:beat_tick, step: 2)
if(look(:beat_tick) > laenge_in_takten)
stop
end
end
# rain noise / waterfall in background
tick_reset(:rain_tick)
live_loop :let_it_rain do
use_synth :noise
tick(:rain_tick)
if(look(:rain_tick) == 0)
puts "ein"
play :c3, attack: 1, sustain: 0, release: 0, amp: 0.04 # fade in
else
if(look(:rain_tick) == laenge_in_takten)
puts "aus"
play :c3, attack: 0, sustain: 0, release: 1, amp: 0.04 # fade out
else
puts "halten"
play :c3, attack: 0, sustain: 1, release: 0, amp: 0.04 # hold same amp
end
end
sleep 1
if(look(:rain_tick) == laenge_in_takten)
stop
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment