CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/data/post/sonic_pi_example.rb
Views: 11766
1
use_bpm 130
2
use_synth_defaults sustain: 0
3
4
live_loop :drums do
5
sample :drum_heavy_kick, amp: 2
6
sleep 1
7
sample :drum_snare_hard
8
sleep 1
9
end
10
11
live_loop :hi_hat do
12
sample :drum_cymbal_closed, amp: 0.5
13
sleep 0.5
14
end
15
16
live_loop :bass do
17
use_synth :pluck
18
19
notes = %i[
20
Eb3 Eb3 Eb3
21
B2 B2 B2
22
Fs2 Fs2 Fs2
23
As2 As2 As2 As2
24
]
25
26
beats = %w[
27
2.0 1.0 1.0
28
2.0 1.0 1.0
29
2.0 1.0 1.0
30
1.5 1.0 0.5 1.0
31
].map(&:to_f)
32
33
with_fx :reverb do
34
play_pattern_timed notes, beats
35
end
36
end
37
38
live_loop :lead do
39
use_synth :piano
40
41
notes = %i[
42
As4 As4 As4 As4 Gs4 As4 As4
43
As4 As4 As4 Gs4 As4 As4
44
Db5 As4 Gs4 Fs4
45
Eb4 Eb4 F4 Fs4 Eb4
46
]
47
48
beats = %w[
49
2.00 0.50 0.25 0.25 0.25 0.75 2.00
50
0.50 0.25 0.25 0.25 0.75 1.50
51
1.00 1.00 1.00 1.00
52
0.50 0.50 0.50 0.50 0.50
53
].map(&:to_f)
54
55
with_fx :reverb do
56
play_pattern_timed notes, beats
57
end
58
end
59
60