Sonic Pi Pizza Ad


‘’’
############ pizza song ##############
mn=[];for jn in 1…1024
mn[jn] = hz_to_midi((5.5)*jn)
end; mn[0]=:r; use_bpm 110

c=[8,6,9,6, 6,6,9,6, 8,6,9,9, 6,6,8,6,
8,6,9,6]; m=[2,4,3,4]; o=[1,2,2]
z=[2,0,1,1,4,0,1,1]
d=[0,0,0,0,8,0,0,0]
s=[ :fm, :pluck, :pretty_bell]
e=[ 0.5, 1.0, 0.1 ]
v=[ 0.5, 0.5, 0.3 ]

for i in 0…3; play 77, release: 0.01, amp: 0.5
sleep 1; end

live_loop :percussion do
for x in 0…7
synth :noise, release: 0.1, amp: z[x]/8.0
synth :beep, note: mn[16*d[x]], release: 0.01,
amp: 0.5
sleep 0.25; end; end

use_bpm 55
live_loop :synth do
for x in 0…19
synth :dsaw, note: mn[4*c[x]], detune: 7,
sustain: 1.0, release: 0, amp: 0.06
for y in 0…3; r=rand_i(3)
synth s[r], note: mn[c[x]*m[y]*o[r]],
release: e[r], amp: v[r]
sleep 0.25; end; end; end
‘’’

1 Like

It crashed on my machine. I think you want
two dots not three in the for loops. Also use back ticks not straight appostrophies to get the nice layout.
Here is my corrected version which works for me.
Nice piece. Well done!

mn=[];for jn in 1..1024
  mn[jn] = hz_to_midi((5.5)*jn)
end; mn[0]=:r; use_bpm 110
c=[8,6,9,6, 6,6,9,6, 8,6,9,9, 6,6,8,6,
   8,6,9,6]; m=[2,4,3,4]; o=[1,2,2]
z=[2,0,1,1,4,0,1,1]
d=[0,0,0,0,8,0,0,0]
s=[ :fm, :pluck, :pretty_bell]
e=[ 0.5, 1.0, 0.1 ]
v=[ 0.5, 0.5, 0.3 ]

for i in 0..3; play 77, release: 0.01, amp: 0.5
sleep 1; end

live_loop :percussion do
  for x in 0..7
    synth :noise, release: 0.1, amp: z[x]/8.0
synth :beep, note: mn[16*d[x]], release: 0.01,
amp: 0.5
sleep 0.25; end; end

use_bpm 55
live_loop :synth do
for x in 0..19
synth :dsaw, note: mn[4*c[x]], detune: 7,
sustain: 1.0, release: 0, amp: 0.06
for y in 0..3; r=rand_i(3)
synth s[r], note: mn[c[x]*m[y]*o[r]],
release: e[r], amp: v[r]
sleep 0.25; end; end; end
mn=[];for jn in 1…1024
mn[jn] = hz_to_midi((5.5)*jn)
end; mn[0]=:r; use_bpm 110

Thank You ! Never used the ‘backticks’ before : )
If by ’ dots ’ you mean the indentation , my RPi seems
to handle a lot of that on its own ( sometimes frustratingly so )
Runs on my machine though ???

By the 3 dots he means:

If you look at his code, he only uses 2 dots, on
his computer, and Operating System, 3 dots
produces an error message.

This may be a problem with the editor used here to make posts,
as it seems to be showing 3 dots for Robins quote, but only 2 dots
in his previous post where the code was in an edit-box… ?

for jn in 1..1024

Eli…

for i in 0..3
  puts i
end
puts "demo dots difference"
for i in 0...3
  puts i
end

Yes it may just the editor here because of not using back ticks in the initial post. Anyway with teo dots it works and sounds nice.

Anyways … If the 3 dots crashed your system ,
( as opposed to 2 ) , it must have ran it beyond some
memory bound ?

I think the problem is that outside of the code block, the 3 dots got converted into a single unicode ellipsis character (…) as opposed to 3 actual dots (...). Ruby (and therefore Sonic Pi, at least for now) should accept 3 dots for half-open ranges (see here).