Blue Monday full intro version

Hi. I’m new to Sonic Pi - which I love so far - and thought a good way to ease into it might be to try to complete the intro to Blue Monday that Dr Sam provides in the “Examples” section of Help. I feel sure it uses twice as many lines as necessary and is probably arse about face in all kinds of ways, but it does work I think! So I thought I’d post in the hope that one or more Sonic Pi wizards might fancy improving and refactoring . . . things I tried to do but couldn’t quite manage were: a) using lists or rings where there were irregularities of note or rhythm, b) using a conditional to stop the main bass drum beat from paying through the snare break (ie “if snare break = true, don’t play the main beat” or somesuch), c) in the original there’s a low string melody that comes in at the end between the choir and “ethereal strings”, whose timing I never managed to get right (so left out in the end) and d) there is a natural end to this section in New Order’s original, but I spent so long trying to figure the missing “low strings” that I ran out of steam! Yak Shaving I think it’s called? Anyway, here’s the code - I’ll also try to putt it up on Github - thanks in advance for your thoughts:

=begin
a version of the second part of the extended intro to New Order’s “Blue Monday”. First each of the five
parts is defined as a function, with a short song assembly at the end. The parts are: the two sections
of the main bass drum beat (given as “slow drums” and “fast drums”; the main bass sequencer, based on
Sam Aaron’s formulation; Peter Hook’s lead bass line (given as “Hooky Bass 1”), for which I’ve used a
piano sample; the snare drum break, given as “intro drum break 1”; the choir at tthe end and “etheral
strings” at the climax.
=end

load_samples [:drum_heavy_kick, :drum_snare_soft, :bass_thick_c, :bass_voxy_hit_c, :piano, :drum_snare_soft]

use_bpm 120

define :slow_drums do #first part of the main drum beat
puts “slow drums”
6.times do
sample :drum_heavy_kick, rate: 0.8
sleep 1
end
end

define :fast_drums do #second part of the main beat
puts “fast drums”
8.times do
sample :drum_heavy_kick, rate: 0.8
sleep 0.25
end
end

define :bass_seq do #the main bass sequencer
puts “bass sequencer”
use_synth :mod_saw
use_synth_defaults amp: 0.1, attack: 0.1, sustain: 0.9, release: 0.7, mod_range: 12,
mod_phase: 0.5, mod_invert_wave: 1
notes = (ring :F, :C, :D, :D, :G, :C, :D, :D)
notes.each do |n|
tick
with_fx :flanger, pre_mix: 0.7, mix: 0.1, phase: 6 do
with_fx :echo, attack: 0.7, pre_mix: 1, mix: 0.9, phase: 1, decay: 1.5 do
with_fx :reverb, pre_mix: 0.8, mix: 0.7, room: 0.6 do
play note(n, octave: 1), cutoff: (line 90, 130, steps: 16).look
play note(n, octave: 2), cutoff: (line 90, 130, steps: 32).look
sleep 2
end
end
end
end
end

hooky_bass = :piano # Peter Hook’s lead bassline, on piano
use_synth_defaults amp: 0.3, attack: 0, decay: 1, sustain: 0.5, release: 0.5

define :lead_bass1 do
puts “hooky bass 1”
use_synth hooky_bass
with_fx :reverb, pre_mix: 0.8, mix: 0.6, room: 1 do
8.times do
play 38
sleep 0.5
end
play 38
sleep 1
play 36
sleep 1
play 38
sleep 2
8.times do
play 41
sleep 0.5
end
play 41
sleep 1
play 43
sleep 1
play 38
sleep 2
8.times do
play 38
sleep 0.5
end
play 38
sleep 1
play 36
sleep 1
play 38
sleep 2
8.times do
play 41
sleep 0.5
end
play 41
sleep 0.5
play 43
sleep 1.5
play 38
sleep 2
end
end

define :break1_snare do #the snare break that follows Hook’s lead bass line
puts “intro drum break 1”
21.times do
sample :drum_snare_soft
sleep (ring 0.25, 0.25, 0.25, 0.25, 0.5, 0.5, 0.25, 0.25, 0.5, 0.25,
0.25, 0.25, 0.25, 0.5, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 1).tick
end
with_fx :lpf, cutoff: 95 do
sample :drum_splash_hard
end
end

define :choir do #the choir that builds to the end
puts “choir”
use_synth :hollow
play chord(:d, :minor7), amp: 0.6, attack: 0, decay: 1, sustain: 12, release: 1
(octs :d, 3)
sleep 1
end

define :high_strings do # ethereal string melody at the climax
puts “ethereal strings”
loop do
with_fx :reverb, room: 0.7 do
with_fx :distortion, amp: 0.2, distort: 0.8 do
use_synth :supersaw
use_synth_defaults amp: 0.1, attack: 0.1, decay: 0.2, sustain: 1, release: 1
2.times do
play :c5
sleep 1
play :b4
sleep 1
play :a4
sleep 1
play :f4, sustain: 4.5
sleep 4.5
play :a
sleep 0.5
play :c5
sleep 1
play :b4
sleep 1
play :a4
sleep 1
play :e5, sustain: 5
sleep 5
end
end
end
end
end

#the song assembly!

in_thread do # drums
loop do
slow_drums
fast_drums
end
end

in_thread do # bass sequencer
live_loop :bass, delay: 32 do
bass_seq
end
end

in_thread delay: 64 do # Hooky’s lead bass
lead_bass1
end

in_thread delay: 96 do # the snare break
break1_snare
end

in_thread delay: 104 do # the choir
48.times do
choir
end
end

in_thread delay: 112 do # climactic string melody
high_strings
end

3 Likes

Hi OvaNova and welcome to using Sonic Pi.
Your piece sound nice. One point, when posting code try putting it inside three back quotes `
before and after the code. That way the code will be nicely presented, and easily copiable.
I’ve taken the liberty of doing this below so you can see the effect.

load_samples [:drum_heavy_kick, :drum_snare_soft, :bass_thick_c, :bass_voxy_hit_c, :piano, :drum_snare_soft]

use_bpm 120

define :slow_drums do #first part of the main drum beat
  puts "slow drums"
  6.times do
    sample :drum_heavy_kick, rate: 0.8
    sleep 1
  end
end

define :fast_drums do #second part of the main beat
  puts "fast drums"
  8.times do
    sample :drum_heavy_kick, rate: 0.8
    sleep 0.25
  end
end

define :bass_seq do #the main bass sequencer
  puts "bass sequencer"
  use_synth :mod_saw
  use_synth_defaults amp: 0.1, attack: 0.1, sustain: 0.9, release: 0.7, mod_range: 12,
    mod_phase: 0.5, mod_invert_wave: 1
  notes = (ring :F, :C, :D, :D, :G, :C, :D, :D)
  notes.each do |n|
    tick
    with_fx :flanger, pre_mix: 0.7, mix: 0.1, phase: 6 do
      with_fx :echo, attack: 0.7, pre_mix: 1, mix: 0.9, phase: 1, decay: 1.5 do
        with_fx :reverb, pre_mix: 0.8, mix: 0.7, room: 0.6 do
          play note(n, octave: 1), cutoff: (line 90, 130, steps: 16).look
          play note(n, octave: 2), cutoff: (line 90, 130, steps: 32).look
          sleep 2
        end
      end
    end
  end
end

hooky_bass = :piano # Peter Hook’s lead bassline, on piano
use_synth_defaults amp: 0.3, attack: 0, decay: 1, sustain: 0.5, release: 0.5

define :lead_bass1 do
  puts "hooky bass 1"
  use_synth hooky_bass
  with_fx :reverb, pre_mix: 0.8, mix: 0.6, room: 1 do
    8.times do
      play 38
      sleep 0.5
    end
    play 38
    sleep 1
    play 36
    sleep 1
    play 38
    sleep 2
    8.times do
      play 41
      sleep 0.5
    end
    play 41
    sleep 1
    play 43
    sleep 1
    play 38
    sleep 2
    8.times do
      play 38
      sleep 0.5
    end
    play 38
    sleep 1
    play 36
    sleep 1
    play 38
    sleep 2
    8.times do
      play 41
      sleep 0.5
    end
    play 41
    sleep 0.5
    play 43
    sleep 1.5
    play 38
    sleep 2
  end
end

define :break1_snare do #the snare break that follows Hook’s lead bass line
  puts "intro drum break 1"
  21.times do
    sample :drum_snare_soft
    sleep (ring 0.25, 0.25, 0.25, 0.25, 0.5, 0.5, 0.25, 0.25, 0.5, 0.25,
           0.25, 0.25, 0.25, 0.5, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 1).tick
  end
  with_fx :lpf, cutoff: 95 do
    sample :drum_splash_hard
  end
end

define :choir do #the choir that builds to the end
  puts "choir"
  use_synth :hollow
  play chord(:d, :minor7), amp: 0.6, attack: 0, decay: 1, sustain: 12, release: 1
  (octs :d, 3)
  sleep 1
end

define :high_strings do # ethereal string melody at the climax
  puts "ethereal strings"
  loop do
    with_fx :reverb, room: 0.7 do
      with_fx :distortion, amp: 0.2, distort: 0.8 do
        use_synth :supersaw
        use_synth_defaults amp: 0.1, attack: 0.1, decay: 0.2, sustain: 1, release: 1
        2.times do
          play :c5
          sleep 1
          play :b4
          sleep 1
          play :a4
          sleep 1
          play :f4, sustain: 4.5
          sleep 4.5
          play :a
          sleep 0.5
          play :c5
          sleep 1
          play :b4
          sleep 1
          play :a4
          sleep 1
          play :e5, sustain: 5
          sleep 5
        end
      end
    end
  end
end

#the song assembly!

in_thread do # drums
  loop do
    slow_drums
    fast_drums
  end
end

in_thread do # bass sequencer
  live_loop :bass, delay: 32 do
    bass_seq
  end
end

in_thread delay: 64 do # Hooky’s lead bass
  lead_bass1
end

in_thread delay: 96 do # the snare break
  break1_snare
end

in_thread delay: 104 do # the choir
  48.times do
    choir
  end
end

in_thread delay: 112 do # climactic string melody
  high_strings
end

As you say, you have a lot of lines here, but your code is well laid out and easy to follow. There are various techniques which can be used to reduce it a bit.
One I like to use is to put notes into a list, with a corresponding list of their durations. as I produce a lot of linear classical music arranged for Sonic Pi, this helps to reduce the file size a bit.
Here is one recent piece I did using this technique. However there is no right or wrong way to produce code for Sonic Pi. The important thing is to enjoy it and have fun!

4 Likes

Nice one!!

Much better than my very small intro XD

1 Like

Robin - thank you so much for this. I’ll be sure to use the three backquotes next time (I wondered whether there was a way to present it more naturally) and will go to your piece right now, which will be a pleasure in itself and also a great opportunity to familiarise myself with the technique you describe (again, had imagined there must be a way of doing this, but couldn’t work out how! Excited :slight_smile:

Actually I like yours, it has a nice bleepy old school vibe to it!

Wow, just listened to the Paretorius…amazing Robin.

Robin — one of the joys for me on here is discovering new music. I didn’t know Michael Praetorius but love what I’m hearing. What works do recommend starting on? I’m a big fan of Gesualdo, who clearly overlapped with Praetorius . . .

Glad you enjoyed the Praetorius. I enjoy setting any music of that era for Sonic Pi. I have also converted pieces by Gabrieli, Byrd, Morley, Diegop Ortiz, Pachabal, Purcell, Albinoni and Taeggio just to list some, together with a lot of JS Bach.

I hadn’t done any Gesualdo before so I thought I’d try one of his madrigals this afternoon.
The resultant code is posted below. Use run_file "path/to/gesualdo1-RF.rb" to execute it as it is a bit long for the buffer.
Enjoy!

#gesualdo1-RF.rb
#Book iv Madrigal 1 by Carlo Gesualdo
rm=0.2 #release multiplier

define :playnotes do |notes,durs,pan=0|
  in_thread do
    notes.zip(durs).each do |n,d|
      play n,sustain: 0.9*d,release: rm*d,pan: pan
      sleep d
    end
  end
end

use_bpm 120
with_fx :reverb,room: 0.8,mix: 0.7 do

use_synth :tri

a1=[:C5,:C5,:C5,:C5,:D5,:F5,:D5,:r,:r,:C5,:Bf4,:A4,:D5,:Bf4,:D5,:A4,:D5,:C5,:D5,:G4,:r,:r,:D5,:Bf4,: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0,1.5,0.5,1.0,2.0,2.0,2.0,2.0,1.0,0.5,0.5,0.5,0.5,1.0,2.0,4.0,1.0,1.0,0.5,0.5,0.5,0.5,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,4.0,4.0,4.0,4.0,2.0,4.0,1.0,1.0,4.0,2.0,4.0,1.0,1.0,8.0,12.0]
playnotes(a5,b5,0.8)
end #reverb
1 Like

Hi Robin. Not wanting to overload you, but I assume ‘.zip’ is a method that ties two arrays together? (can’t find any documentation on it! :slight_smile:

Yes using the .zip method you can stick the arrays together and then iterate over common elements together. If you google Ruby zip iterate you should get something like
https://stackoverflow.com/questions/4816959/best-way-to-iterate-over-multiple-arrays.
or
https://stackoverflow.com/questions/3580049/whats-the-ruby-way-to-iterate-over-two-arrays-at-once

It is NOT part of Sonic Pi’s language, but a general Ruby language construct, so maybe in the future something might break it from working, but it is very useful when you have a series of lists like note_pitches, durations and maybe amplitudes, enabling you to extract the corresponding values easily.
I use it quite a lot.

Ah! So that’s why I couldn’t find anything in the documentation to tell me how to do this. Thanks again, that’s incredibly useful. Has anyone suggested incorporating .zip more formally into sonic Pi, I wonder?

Hello and thank you for ‘Luci serene e chiare’.

An astonishing piece of music.

A question by a young Sonic Pi 8th grade pupil in
my little SPI newcomers computer science class:
How long did it take you to produce it?

A question on my side:
With what material did you produce your SPI version? Just a score-sheet in one of your classic music sheet books or based on a midi file? Or something else?

Best regards.

BTW here comes a ‘classic’ recently implemented from a public midi-file used
to generate a score-sheet in Musecore and the Notenames with the Plug-in there.

To train myself in notes reading and spi implementation.

# french traditional https://de.wikipedia.org/wiki/Alouette_(Volkslied)
# based on https://www.8notes.com/school/midi/piano/alouette.mid

use_bpm 100
use_synth :pluck
use_synth_defaults release: 2

# Notenlaengen / Zeiten
g=4      # ganze Note
h=2      # halbe Note
vh=3/2.0 # gepunktete Viertel-Note
v=1      # Viertel-Note
a=1/2.0  # Achtel-Note

#           1. Takt               2. Takt               3. Takt          4. Takt                5. Takt          6. Takt
# hohe Noten (rechte Hand)
notenRH= [:F,:G,:A,:A]  + [:G,:F,:G,:A,:F,:C3]   +  [:F,:G,:A,:A]  + [:G,:F,:G,:A,:F]     +  [:F,:G,:A,:A]+   [:G,:F,:G,:A,:F,:C]
zeitenRH=[vh, a, v, v]  + [ a, a, a, a, v, v ]   +  [vh, a, v, v]  + [ a, a, a, a, h]     +  [vh, a, v, v]+   [ a, a, a, a, v, v]
# Bassschluessel -> tiefere Noten (linke Hand)
notenLH= [:F3,:C,:F3,:C]+ [:Bf3,:C,[:A3,:F3],:r] +  [:F3,:C,:F3,:C]+ [:Bf3,:C,[:A3,:F3],:r]+ [:F3,:C,:F3,:C]+ [:Bf3,:C,[:A3,:F3],:r]
zeitenLH=[ v,  v, v,  v]+ [ v,  v,    v,     v]  +  [ v,  v, v,  v]+ [ v,  v,    v,     v]+  [ v , v , v ,v]+ [ v , v ,   v    , v]

#            7. Takt               8. Takt                9. Takt                      10. Takt                  11. Takt
# hohe Noten
notenRH+= [:F,:G,:A,:A]  + [:G,:F,:G,:A,:F]    +         [:r]      +             [:C5,:Bf,:A,:G,:F,:F,:F]+  [:C5,:C5,:C5,:r]
zeitenRH+=[vh, a, v, v]  + [ a, a, a, a, h]    +         [g]       +             [ a, a, a, a, a, a, v]  +  [ a, a, v, h]
# Bassschluessel -> tiefere Noten
notenLH+= [:F3,:C,:F3,:C]+ [:Bf3,:C,[:A3,:F3],:r] + [:F3,:G3,:A3,:Bf3,:C,:C,:C]+       [:r]     +           [:r,:C,:C,:C]
zeitenLH+=[ v,  v,  v, v]+ [ v,  v,    v,     v]  + [ a,  a,  a,  a,  a,  a, v] +      [g]      +           [ h, a, a, v]

#            12. Takt                 13. Takt            14. Takt             15. Takt         16. Takt
# hohe Noten
notenRH+= [:C5,:C5,:C5,:C,:C,:C]+ [:F,:G,:A,:A]+   [:G,:F,:G,:A,:F,:C]+    [:F,:G,:A,:A] + [:G,:F,:G,:A,:F]
zeitenRH+=[ a,  a,  v,  a, a, v]+ [vh, a, v, v]+   [ a, a, a, a, v, v]+    [vh, a, v, v] + [ a, a, a, a, h]
# Bassschluessel -> tiefere Noten
notenLH+=        [:r]    +        [:F3,:C,:F3,:C]+ [:Bf3,:C,[:A3,:F3],:r]+ [:F3,:C,:F3,:C]+[:Bf3,:C,[:A3,:F3],:r]
zeitenLH+=        [g]    +        [ v,  v, v,  v]+ [ v,  v,    v,     v] + [ v,  v, v,  v]+[ v,  v,    v,     v]

in_thread do
  play_pattern_timed notenLH, zeitenLH
end

play_pattern_timed notenRH, zeitenRH

JFI

1 Like

Hi Bruce. It probably took around an hour and a half to produce the piece. I start with a midi file and load it into MuseScore 3. There I produce separate parts and ensure that the parts adhere to some constraints. In particular if a part contains two or more voices these have to be separated to separate parts, and there are also contraints with tied chords. Recent changes in muse score mean that rest pars have to be replaced with a rest equivalent to the bar duration eg a 4beat great rather than a bar rest symbol. Multiple bar rests have to be expanded and replaced for example using five individual bar rests rather than representing it with a bar rest marked 5. Once this is done save the MuseScore file thenI export the parts as uncompressed musical files. The reason for saving before export is that there is currently a bug in MuseScore which causes the program to crash during the first export. You restart and restore the file then on the second and subsequent exports it works!
The exported files are then fed into a script by Hiroshi TACHIBANA written in Processing which I discuss in two articles which produces Sonic Pi language code. The scripts can cope with tempo changes provided that they occur in every part at the same time. Each part is processed separately by the script and the rustling text is copied and pasted into an editor (I use Visual Studio Code editor on my Mac) where it is tidied up. For example at that stage I write the play notes function and just paste in the notes and duration lists for each part to assemble the final program, adding pan info reverb synth choices etc.

The process sounds fairly horrendous and involved, but if you use it frequently it becomes quite slick and quick. I have produced many many pieces using this technique.

As an aside, I wrote the Gesualdo piece over three years ago. Two changes I would incorporate now for the latest Sonic Pi versions. First I would limit the amplitude of each part following changes in the audio processing and add use_synth_defaults amp: 0.5 for this piece. Secondly rather than using the zip function I use code more in keeping with Sonic Pi using tick and look

This gives the new complete code for the piece shown below. As before run it using
run_file "path-to-file/Luci_Serena-Gesualdo-RF.rb"

#Luci_Serena-Gesualdo-RF.rb
#coded for Sonic Pi by Robin Newman. This version December 2022
use_synth :tri
use_synth_defaults amp: 0.5
rm =0.2
use_bpm 120
define :playnotes do |notes,durations,pan=0|
    notes.length.times do
        play notes.tick, sustain: (durations.look)*0.9,release: (durations.look)*rm,pan: pan
        sleep durations.look
    end
end
with_fx :reverb,room: 0.8,mix: 0.7 do 

    a1=[:C5,:C5,:C5,:C5,:D5,:F5,:D5,:r,:r,:C5,:Bf4,:A4,:D5,:Bf4,:D5,:A4,:D5,:C5,:D5,:G4,:r,:r,:D5,:Bf4,:Ef5,:Ef5,:D5,:F5,:F5,:r,:C5,:Bf4,:A4,:A4,:r,:r,:G5,:r,:C5,:D5,:Cs5,:D5,:r,:C5,:C5,:C5,:C5,:D5,:F5,:D5,:D5,:C5,:Bf4,:Ef5,:D5,:F5,:r,:G4,:F4,:E4,:A4,:F4,:F5,:D5,:G5,:E5,:F5,:E5,:r,:F4,:C5,:Bf4,:D5,:A4,:r,:r,:C5,:F5,:D5,:D5,:G5,:F5,:E5,:r,:C5,:r,:A4,:Bf4,:A4,:Bf4,:F5,:D5,:C5,:C5,:r,:F5,:Fs5,:G5,:G5,:D5,:Ef5,:D5,:r,:r,:r,:r,:A4,:G4,:A4,:Bf4,:C5,:D5,:C5,:F5,:E5,:r,:C5,:E5,:E5,:F5,:E5,:C5,:E5,:Fs5,:G5,:G5,:r,:G5,:C5,:C5,:D5,:Cs5,:D5,:E5,:E5,:D5,:F5,:E5,:F5,:E5,:E5,:E5,:C5,:A4,:r,:F5,:Fs5,:G5,:G5,:D5,:Ef5,:D5,:r,:r,:r,:r,:A4,:G4,:A4,:Bf4,:C5,:D5,:C5,:F5,:E5,:r,:C5,:E5,:E5,:F5,:E5,:C5,:E5,:Fs5,:G5,:G5,:r,:G5,:C5,:C5,:D5,:Cs5,:D5,:E5,:E5,:D5,:F5,:E5,:F5,:r,:r,:r,:D5,:C5,:C5,:C5,:A4,:r,:G5,:Ef5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2.0,2.0,1.0,0.5,0.5,1.0,0.5,0.5,2.0,2.0,4.0,4.0,4.0,1.0,2.0,1.0,2.0,2.0,4.0,4.0,1.0,1.0,4.0,2.0,4.0,4.0,4.0,2.0,1.0,1.0,1.0,2.0,1.0,1.0,0.5,0.5,1.0,1.0,2.0,1.0,1.0,1.0,1.0,2.0,2.0,2.0,1.0,0.5,0.5,1.0,0.5,0.5,2.0,2.0,3.0,1.0,2.0,2.0,2.0,1.5,0.5,4.0,2.0,2.0,2.0,1.0,1.5,0.5,1.0,2.0,2.0,1.0,1.0,1.0,1.0,1.0,0.5,0.5,0.5,0.5,1.0,2.0,1.0,3.0,1.0,1.0,0.5,0.5,0.5,0.5,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,4.0,2.0,4.0,1.0,1.0,4.0,8.0,2.0,2.0,1.0,1.5,0.5,1.0,2.0,2.0,1.0,1.0,1.0,1.0,1.0,0.5,0.5,0.5,0.5,1.0,2.0,1.0,3.0,1.0,1.0,0.5,0.5,0.5,0.5,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,4.0,2.0,4.0,4.0,4.0,4.0,1.0,1.0,4.0,2.0,4.0,1.0,1.0,10.0,12.0]
    in_thread do
      playnotes a5,b5,0.8
    end
end#reverb

Thank you very much for the details.
It sounds really like a process …
but it is good to hear that you prefer
already available digital note sequences
and do not write them down all from sheets.

You are very aware of it but you could
gain routhly 25% of buffer size reduction
and a little bit of readability
if you would also use here your on many
other pieces shown practice of duration
letter naming like:

#Note times
wt = 12
wd = 8
dw = 6
w = 4
dh = 3
h = 2
dq = 1.5
q = 1
de = 0.75
e = 0.5
s = 0.25