My experiments with Sonic Pi: 2. Are Microwaves Friends?

My first experiment with Sonic Pi was all craft, no art, I’d say. The idea was to create a cover of No Surprises by Radiohead, the aim was to study arrangement, the result was a lullabylike rendition of the Radiohead classic, a successful experiment by my defined criteria. What I wanted to do next, in experiment no. 2, was use Sonic Pi for composition.

The purpose of this experiment

This time, the idea was as much craft as earlier, but a little more art. The idea was to a. see if I could compose an entire track on Sonic Pi, and b. see how easy or difficult such composition was.

The track itself

I set out to compose a minimal house track, Since I wasn’t a huge fan of the preloaded drum samples, I loaded some 808 and 909 drum samples to build the percussive spine of the track. For the bass and melodies, I used the preloaded synths. It was really easy to compose, to be honest, a lot easier than I thought it would be.

Conclusions

The challenge however is that there’s a limited buffer size, so I couldn’t complete the whole track, seeing as my file just ran into a character limit. To extend the track beyond its 2:30 minute run, I’ll have to program the rest of the track on a separate file. Either that, or use live_loops, which appear to be way more economical in terms of characters used. I use functions and not live_loops, because my composition process is not driven by live performance. Compositionally, changing my thinking from what it is now to a performance-based approach will likely make ‘my sound’ evolve in a way that might be interesting.

Next step: continuing work on this track as a series of loops. It’s also, on a side note, how I suspect this thing was intended to be used, hence the focus on ‘live coding’.

The code

Here’s the code I used to make this with the pathnames to my drum samples knocked off.

use_bpm 120

chord_amp = 0.6
pulse_amp = 0.2
pulse_attack = 0
pulse_release = 0.2
hihat_cutoff = 120
closed_hihat_amp = 0.66
open_hihat_amp = 0.33
fade_out = (line 1,0, steps: 2, inclusive: true)
master = (ramp *range(0, 1, 0.01))
kick_cutoffs = range(60, 80, 0.5).mirror

define :intro_bd_thump do
  132.times do
    if (spread 1, 4).tick then
      sample "/~", amp: master.look,
        cutoff: kick_cutoffs.look
    end
    sleep 0.25
  end
end

define :basic_bd_thump do
  8.times do
    sample "/~", cutoff: 60
    sleep 1
  end
end

define :basic_hihat do
  2.times do
    sleep 0.5
    sample "/~", amp: closed_hihat_amp, cutoff: hihat_cutoff
    sleep 0.25
    sample "/~", amp: closed_hihat_amp, cutoff: hihat_cutoff
    sleep 0.75
    sample "/~", amp: closed_hihat_amp, cutoff: hihat_cutoff
    sleep 1
    sample "/~", amp: closed_hihat_amp, cutoff: hihat_cutoff
    sleep 1
    sample "/~", amp: closed_hihat_amp, cutoff: hihat_cutoff
    sleep 0.5
  end
end

define :open_and_shut_hihat do
  2.times do
    sleep 0.5
    sample "/~", amp: open_hihat_amp, cutoff: hihat_cutoff
    sleep 0.25
    sample "/~", amp: closed_hihat_amp, cutoff: hihat_cutoff
    sleep 0.75
    sample "/~", amp: open_hihat_amp, cutoff: hihat_cutoff
    sleep 1
    sample "/~", amp: open_hihat_amp, cutoff: hihat_cutoff
    sleep 1
    sample "/~", amp: open_hihat_amp, cutoff: hihat_cutoff
    sleep 0.5
  end
end

define :basic_snare do
  4.times do
    sleep 1
    sample "/~"
    sleep 1
  end
end

define :full_intro do
  in_thread do
    basic_bd_thump
  end
  basic_snare
end

define :first_beat do
  in_thread do
    basic_bd_thump
  end
  in_thread do
    basic_hihat
  end
  basic_snare
end

define :second_beat do
  in_thread do
    basic_bd_thump
  end
  in_thread do
    open_and_shut_hihat
  end
  basic_snare
end

define :basic_melody_line do
  use_synth :fm
  play :c3
  sleep 0.25
  play :ds3
  sleep 0.5
  play :c3
  sleep 0.75
  play :as3
  sleep 1
  play :as3
  sleep 0.5
  play :gs3
  sleep 0.5
  play :g3
  sleep 4.5
end

define :minimised_melody_line do
  use_synth :fm
  play :c3
  sleep 8
end
define :simple_melody_line do
  use_synth :fm
    play :c3, release: 12, amp: 0.75
    sleep 4
    play :ds3, release: 12, amp: 0.75
    sleep 4
    play :f3, release: 12, amp: 0.75
    sleep 8
end
define :basic_melo_intro do
  in_thread do
    full_intro
  end
  basic_melody_line
end

define :ibiza_verse_1 do
  use_synth :beep
  play chord(:c4, :minor), sustain: 1, amp: chord_amp
  sleep 0.75
  play chord(:c4, :minor), sustain: 1, amp: chord_amp
  sleep 0.75
  play chord(:c4, :minor), sustain: 1, amp: chord_amp
  sleep 1
  play chord(:as4, :major), sustain: 1, amp: chord_amp
  sleep 0.75
  play chord(:as4, :major), sustain: 1, amp: chord_amp
  sleep 0.75
  play chord(:g4, :minor), sustain: 1, amp: chord_amp
  sleep 0.75
  play chord(:g4, :minor), sustain: 1, amp: chord_amp
  sleep 0.75
  play chord(:g4, :minor), sustain: 1, amp: chord_amp
  sleep 1
  play chord(:f4, :major), sustain: 1, amp: chord_amp
  sleep 0.75
  play chord(:f4, :major), sustain: 1, amp: chord_amp
  sleep 0.75
end

define :ibiza_verse_1_part_2 do
  use_synth :beep
  play chord(:c4, :minor), sustain: 1, amp: chord_amp
  sleep 0.75
  play chord(:c4, :minor), sustain: 1, amp: chord_amp
  sleep 0.75
  play chord(:c4, :minor), sustain: 1, amp: chord_amp
  sleep 1
  play chord(:as4, :major), sustain: 1, amp: chord_amp
  sleep 0.75
  play chord(:as4, :major), sustain: 1, amp: chord_amp
  sleep 0.75
  play chord(:g4, :minor), sustain: 1, amp: chord_amp
  sleep 0.75
  play chord(:g4, :minor), sustain: 1, amp: chord_amp
  sleep 0.75
  play chord(:g4, :minor), sustain: 1, amp: chord_amp
  sleep 1
  play chord(:g4, :minor), sustain: 1, amp: chord_amp
  sleep 0.75
  play chord(:g4, :minor), sustain: 1, amp: chord_amp
  sleep 0.75
end

define :hihatless_ibiza_verse do
  in_thread do
    ibiza_verse_1
  end
  in_thread do
    full_intro
  end
  basic_melody_line
end

define :drumless_ibiza_verse do
  in_thread do
    ibiza_verse_1
  end
  basic_melody_line
end

define :first_hihat_ibiza_verse do
  in_thread do
    ibiza_verse_1
  end
  in_thread do
    first_beat
  end
  minimised_melody_line
end

define :pulse do
  use_synth :dpulse
  128. times do
    play :c4, attack: pulse_attack, release: pulse_release, cutoff: 85, amp: pulse_amp
    sleep 0.25
  end
end

define :shaker do
  16.times do
    with_fx :slicer, mix: 1, phase: 0.25, pulse_width: rrand(0.1,0.2) do
      with_fx :hpf, cutoff: 130 do
        with_synth :noise do
          play :c1, decay: 1
        end
      end
    end
    sleep 1
  end
end

define :bassline do
  use_synth :fm
  play :c3
  sleep 1.75
  play :c3
  sleep 0.5
  play :ds3
  sleep 0.25
  play :c3
  sleep 0.5
  play :c3
  sleep 0.5
  play :c4
  sleep 0.5
end

define :wah do
  with_fx :ixi_techno, phase: 0.25, res: 0.1, amp: 0.6, mix: 0.8 do
    use_synth :fm
    play chord(:c4, :minor), release: 12
    sleep 4
    play chord(:ds4, :major), release: 12
    sleep 4
    play chord(:f4, :minor), release: 12
    sleep 4
    play chord(:cs4, :major), release: 12
    sleep 4
  end
end

define :first_pulse_hihat_ibiza_verse do
  in_thread do
    4.times do
      ibiza_verse_1
    end
  end
  in_thread do
    4.times do
      first_beat
    end
  end
  in_thread do
    pulse
  end
  2.times do
    3.times do
      bassline
    end
    sleep 4
  end
end

define :first_pulse_hihat_shaker_ibiza_verse do
  in_thread do
    2.times do
      shaker
    end
  end
  in_thread do
    4.times do
      ibiza_verse_1_part_2
    end
  end
  in_thread do
    4.times do
      first_beat
    end
  end
  in_thread do
    pulse
  end
  2.times do
    3.times do
      bassline
    end
    sleep 4
  end
end

define :first_pulse_open_and_shut_hihat_shaker_ibiza_verse do
  in_thread do
    2.times do
      shaker
    end
  end
  in_thread do
    4.times do
      ibiza_verse_1_part_2
    end
  end
  in_thread do
    4.times do
      second_beat
    end
  end
  in_thread do
    pulse
  end
  2.times do
    3.times do
      bassline
    end
    sleep 4
  end
end

define :first_pulse_open_and_shut_hihat_shaker_wah_ibiza_verse do
  in_thread do
    2.times do
      shaker
    end
  end
  in_thread do
    4.times do
      with_fx :level, amp: fade_out.tick do
        ibiza_verse_1_part_2
      end
    end
  end
  in_thread do
    4.times do
      second_beat
    end
  end
  in_thread do
    pulse
  end
  in_thread do
    2.times do
      wah
    end
  end
    2.times do
      simple_melody_line
  end
end

define :first_pulse_open_and_shut_hihat_shaker_wah_verse do
  in_thread do
    2.times do
      shaker
    end
  end
  in_thread do
    4.times do
      second_beat
    end
  end
  in_thread do
    pulse
  end
  in_thread do
    2.times do
      wah
    end
  end
    2.times do
      simple_melody_line
  end
end

define :first_pulse_shaker_wah_verse do
  in_thread do
    2.times do
      shaker
    end
  end
  in_thread do
    4.times do
      full_intro
    end
  end
  in_thread do
    pulse
  end
  in_thread do
    2.times do
      wah
    end
  end
    2.times do
      simple_melody_line
  end
end

define :bd_snare_wah_verse do
  in_thread do
    4.times do
      full_intro
    end
  end
  2.times do
    wah
  end
end

#-------track arrangement----------
with_fx :reverb do
  intro_bd_thump
  3.times do
    hihatless_ibiza_verse
  end
  drumless_ibiza_verse
  3.times do
    first_hihat_ibiza_verse
  end
  drumless_ibiza_verse
  first_pulse_hihat_shaker_ibiza_verse
  first_pulse_open_and_shut_hihat_shaker_ibiza_verse
  first_pulse_open_and_shut_hihat_shaker_wah_ibiza_verse
  first_pulse_open_and_shut_hihat_shaker_wah_verse
  first_pulse_shaker_wah_verse
  wah
  wah
end
Previous
Previous

The Boat, based on The Boat, written by Nam Le, adapted by Matt Huynh

Next
Next

My experiments with Sonic Pi: 1. No Surprises.