Always wondered what this tiny tune actually sounded like

Both our kids grew up with this Sandra Boynton book…

use_synth :piano

play :c4
sleep 1
play :d4
sleep 0.5
play :f4
sleep 0.5

play :f4
play :a4
sleep 1
play :d4
play :f4
sleep 0.75
play :f4
sleep 0.25

play :g4
sleep 1
play :d4
sleep 0.5
play :e4
sleep 0.5

play :c4
play :f4
play :a4
sleep 2
4 Likes

Wondered how I would write this? I found two ways.
1.

live_loop :song do
  use_synth :piano
  tick
  notes = [:c4, :d4, :f4, [:f4,:a4], [:f4,:d4], :f4, :g4, :d4, :e4, [:c4,:f4,:a4] ].look
  play notes
  sl =    [1,   0.5,  0.5, 1,         0.75,     0.25, 1,  0.5,  0.5, 2].look
    sleep sl
end
live_loop :song do
  use_synth :piano
  tick
  notes = [:c4, :d4, :f4, [:f4,:a4], [:f4,:d4], :f4, :g4, :d4, :e4, [:c4,:f4,:a4] ].look
  play notes
    
  w = 1
  h = 0.5
  q = 0.25
  e = 0.125
  sl =    [w,    h,  h,    w,         h+q,       q, w,    h,  h, w+w].look
  sleep sl
end
2 Likes

I like to do it this way:

w = 1
h = 0.5
q = 0.25
e = 0.125
sl =    [w,    h,  h,    w,         h+q,       q, w,    h,  h, w+w]

notes = [:c4, :d4, :f4, [:f4,:a4], [:f4,:d4], :f4, :g4, :d4, :e4, [:c4,:f4,:a4] ]

use_synth :piano

4.times do play_pattern_timed notes, sl end

with implicit tick and look for well structured patterns with notes and pauses.

1 Like

Dude, I forgot about this book. Thank you.

If the synth isn’t piano, play_pattern_timed sounds significantly different because it adds the sustain.
That is also how I would probably do it.