Journal

Sonic Pi Tips

Cet article n’existe qu’en anglais.

Short Sonic Pi snippets: debug info, euclidean beats, rings and tick, real time, every synth, conditional drum kits.

Part of the Sonic Pi notebook, 2016–2018.

# debug info

puts status

## euclidian beat ##

puts (spread 3, 8)

## bar graph ##

spark (range 1, 25)

# x occurence of each element of the array

(stretch [1,2], 3)

# keeps the same tick on different rings

live_loop :foo do
tick
use_synth :blade
play (scale :e3, :minor_pentatonic).look
sleep 0.75
use_synth :prophet
play (ring :e1, :e2, :e3).look, release: 0.25
sleep 0.25
end

# use realtime .. time instead of bpm based

use_bpm 120
play 50
sleep 1
play 62
sleep rt(1)
play 72

# read all the synths with defaults settings

live_loop :testing do
stop
synth [:beep, :blade, :bnoise, :chipbass, :chiplead, :chipnoise, :dark_ambience ].tick
sleep 1
end
live_loop :testing2 do
stop
synth [:dpulse, :dsaw, :dtri, :dull_bell, :fm, :gnoise ].tick
sleep 1
end
live_loop :testing3 do
stop
synth [:growl, :hollow, :hoover, :mod_beep, :mod_dsaw, :mod_fm ].tick
sleep 1
end
live_loop :testing4 do
stop
synth [:mod_saw, :mod_sine, :mod_tri, :noise, :piano, :pluck ].tick
sleep 1
end
live_loop :testing5 do
stop
synth [:pnoise, :pretty_bell, :prophet, :pulse, :saw, :sine ].tick
sleep 1
end
live_loop :testing6 do
synth [:square, :subpulse, :supersaw, :tb303, :tri, :zawa ].tick
sleep 1
end

Simple drumkit based on conditional with tick (might not be the best way to do this …)

live_loop :guitar_pluck do | index_i |
# tick_reset
puts tick=>0
notes = [:g4, :gs4]
s = synth :pluck, release: [0.1, 0.5].choose, amp: [0.2, 0.3].choose
control s ,note: (chord notes.choose, :madd9).tick
sleep 0.25
# drumkit based on conditonnals with tick
if tick % 4 == 0
sample :bd_tek, amp: 0.5
end
if tick % 8 == 0
sample :drum_cymbal_open, amp: 0.1
end
if tick % 3 == 0
sample :drum_snare_soft, amp: 0.5
end
end

incremental value, dnb

live_loop :foo, init: jean=1 do |jean|
puts jean
sample :ambi_drone, beat_stretch: jean
if jean % 16 == [11, 1] or jean % 16 == 1 then
sample :bd_tek
end
if jean % 16 == 5 or jean % 16 == 13 then
sample :sn_dub
end
sleep 0.125
jean += 1
end

Originally published on svdk.fr in 2017.

Esc