New winter themed rave track

Desktop Raver.
Inspired by raving at your desktop in winter.

# Title: Desktop Raver
# Artist: Binarysweets
# Date: November 2020
# License: cc-by
# Sonic Pi v3.2.2 (Win 10)

# Settings
use_bpm 125
bar_length = 4
use_random_seed 1713.20201118
swing = (ring 0.01, -0.01)
root = "C:/Users/LeeBridge/OneDrive/Sonic Pi/Samples/"

# Scales
scl = scale(:fs2, :minor, num_octaves: 3)

# Functions
define :get_pitch_from_note do |note, sample_base_note, fine_tune|
  return note - sample_base_note + fine_tune
end
define :bar do |length = 8|
  sleep bar_length * length
end

# Loops
define :beats do |length = 8, pattern = 1|
  in_thread do
    s = root + "Urban Technologies/SLOWER BREAKS/UT_060_SLWR BRK_98_D#.wav"
    slices = (ring 0,1,2,3, 2,7,8,9) if pattern == 1
    slices = (ring 0,1,2,3, 2,7,8,9, 0,1,2,3, 10,11,12,13) if pattern == 2
    slices = (ring 0,1,2,2) if pattern == 3 #  (ring 0,1,2,3, 0,9,8,7)
    slices = (ring 0,1,1,1, 0,2,2,2, 0,3,3,3, 0,4,4,4) if pattern == 4
    
    ((bar_length * length) * 4).times do ; tick
      sample s, amp: rrand(0.9, 1.0), slice: slices.look,
        num_slices: 32
      #pan: (ring 0,0,0,0 -1,0,-0.5,0, 0,0,0,0, 1,0,0.5,0).look
      
      sleep 0.25 + swing.look
    end
  end
end
define :beats_2 do |length = 8, pattern = 1|
  in_thread do
    s = root + "Urban Technologies/SLOWER BREAKS/UT_061_SLWR BRK_99_F#.wav"
    slices = (ring  0,1,2,3, 16,17,18,19, 20,21,22,23, 4,5,6,7,
              11,10,9,8, 16,17,18,19, 20,21,22,23, 24,25,26,27) if pattern == 1
    
    slices = (line 0, 31, steps: 32, inclusive: true) if pattern == 2
    
    ((bar_length * length) * 4).times do ; tick
      sample s, amp: rrand(0.4, 0.5), slice: slices.look,
        num_slices: 64, beat_stretch: 21,
        pan: (ring 0,0,0,0 -1,0,-0.5,0, 0,0,0,0, 1,0,0.5,0).look
      
      sleep 0.25 + swing.look
    end
  end
end

define :sq_bass do |length = 8, pattern = 1|
  in_thread do
    notes = (ring scl[0], scl[0], scl[0], scl[1]).repeat(14) +
      (ring scl[5], scl[4], scl[3], scl[2]).repeat(2)
    
    ((bar_length * length) * 4).times do ; tick
      with_synth :square do
        with_octave -1 do
          if pattern == 2
            play notes.look,
              amp: rrand(0.4, 0.5),
              release: (line 0.5, 0.75, steps: 128).look if bools(1,0,0,0, 1,0,0,0, 1,0,0,0, 0,0,0,1).look
          end
          with_synth :sine do
            play notes.look,
              amp: rrand(0.4, 0.5),
              sustain: 1,
              release: 0.25 if bools(1,0,0,0, 1,0,0,0, 1,0,0,0, 0,0,0,1).look
          end
        end
      end
      
      sleep 0.25 + swing.look
    end
  end
end

define :some_chords do |length = 8, pattern = 1|
  in_thread do
    with_fx :hpf, cutoff: 50 do
      ((bar_length * length) / 16).times do ; tick
        with_synth :hollow do
          play chord(scl[0], (ring :minor7, :m9).look), sustain: 15, release: 1, amp: rrand(0.9, 1.1), pan: 0.5
          
          if pattern == 2
            play chord(scl[7], (ring :minor7, :m9).look), sustain: 15, release: 1, amp: rrand(0.9, 1.1), pan: -0.5
          end
        end
        
        sleep 16 + swing.look
      end
    end
  end
end

define :sub_bass do |length = 8|
  in_thread do
    notes = [scl[4], scl[4], scl[3], scl[1]].ring
    
    ((bar_length * length) / 8).times do ; tick
      if bools(1,0,1,1).look
        play notes.look-12, sustain: (ring 15,7,7,7).look, amp: rrand(0.2, 0.3), pan: 0.5
        play notes.look-12, sustain: (ring 15,7,7,7).look, amp: rrand(0.2, 0.3), pan: -0.8
      end
      
      sleep 8
    end
  end
end

define :rave_riff do |length = 8, pattern = 1|
  in_thread do
    if pattern == 1
      s = root + "Breakbusters/synth loops/synth loops 140bpm/breaks_synthloop_140_cheesytrafic_F#.wav"
      base_note = 54
      _s = 0.156
      _f = 0.169
      notes = [scl[7], scl[7], scl[7], scl[7],
               scl[7], scl[7], scl[7], scl[7],
               scl[7], scl[7], scl[7], scl[7],
               scl[7], scl[7], scl[7], scl[7],
               scl[7], scl[7], scl[7], scl[7],
               scl[7], scl[7], scl[7], scl[7],
               scl[7], scl[7], scl[7], scl[7],
               scl[0], scl[1], scl[2], scl[3]].ring
    end
    
    if pattern == 2
      s = root + "Breakbusters/synth loops/synth loops 140bpm/breaks_synthloop_140_chiizomeeta_E.wav"
      base_note = 52
      _s = 0
      _f = 0.025
      notes = [scl[7], scl[7], scl[7], scl[6],
               scl[7], scl[7], scl[7], scl[5],
               scl[7], scl[7], scl[7], scl[4],
               scl[7], scl[7], scl[7], scl[3],
               scl[7], scl[7], scl[7], scl[2],
               scl[7], scl[7], scl[7], scl[1],
               scl[7], scl[7], scl[7], scl[7],
               scl[0], scl[1], scl[2], scl[3]].ring
    end
    
    with_fx :ping_pong, feedback: 0.7 do
      ((bar_length * length) * 4).times do ; tick
        if bools(1,0,0,1, 1,0,0,0, 1,1,1,1, 1,0,1,0).look
          sample s, amp: rrand(0.5, 0.6), start: _s, finish: _f,
            num_slices: 32, rate: [1,-1].choose,
            rpitch: get_pitch_from_note(notes.look, base_note, 0)
        end
        
        sleep 0.25 + swing.look
      end
    end
  end
end

define :atmos do |length = 8, pattern = 1|
  in_thread do
    s = root + "Urban Technologies/SOUND LOOPS/AMBIENT ONE SHOT/UT_036_AMB SND_154_F.wav"
    
    ((bar_length * length) / 4).times do ; tick
      sample s, amp: rrand(0.8, 0.9),
        rpitch: get_pitch_from_note(scl[7], 53, 0),
        pan: -0.8 if bools(1,0,0,0, 0,0,0,0).look
      
      sleep 4 + swing.look
    end
  end
end

define :atmos_2 do |length = 8, pattern = 1|
  in_thread do
    s = root + "Urban Technologies/SOUND LOOPS/AMBIENT ONE SHOT/UT_030_AMB SND_141_F#.wav"
    notes = (ring scl[7], scl[7], scl[5], scl[6], scl[4])
    note_index = 0
    
    ((bar_length * length) / 2).times do ; tick
      if bools(0,1,0,1, 0,0,0,0, 0,1,0,1, 0,1,0,0).look
        sample s, amp: rrand(0.5, 0.6),
          rpitch: get_pitch_from_note(notes[note_index], 55, 0),
          pan: 0.7,
          attack: 0.25
        note_index += 1
      end
      
      sleep 2 + swing.look
    end
  end
end

# Structure
with_fx :compressor, threshold: 0.3 do
  atmos ; atmos_2 ; bar
  atmos ; atmos_2 ; bar(7) ; beats(1,1) ; bar(1)
  atmos ; atmos_2 ; beats(8,1) ; bar
  atmos ; atmos_2 ; beats(7,2) ; bar(7) ; beats_2(1,1) ; bar(1)
  atmos ; beats(7,2) ; rave_riff(8,1) ; bar(7) ; beats_2(1,1) ; bar(1)
  beats(7,2) ; sq_bass ; rave_riff(8,1) ; beats_2 ; bar
  beats(8,3) ; sq_bass ; rave_riff(8,1) ; beats_2 ; bar
  beats(8,3) ; sq_bass(8,2) ; rave_riff(8,2) ; beats_2 ; bar(7) ; beats(1,4) ; bar(1)
  beats(7,2) ; sq_bass(8,2) ; rave_riff(8,2) ; beats_2 ; bar
  beats(8,3) ; sq_bass(8,2) ; rave_riff(8,2) ; bar(7) ; beats(1,4) ; bar(1)
  beats(8,2) ; sq_bass(8,2) ; beats_2 ; bar
  beats(7,2) ; sq_bass(8,2) ; beats_2 ; bar # ?
  some_chords ; bar
  sub_bass ; some_chords; bar
  sub_bass ; beats(8,1) ; some_chords(8,2) ; bar
  sub_bass ; beats(7,1) ; some_chords(8,2) ; beats_2(8,2) ; bar
  sub_bass ; beats(8,2) ; some_chords(8,2) ; rave_riff(8,1) ; beats_2(8,2) ; bar
  sub_bass ; beats(7,3) ; some_chords(8,2) ; rave_riff(8,1) ; beats_2 ; bar
  beats(8,3) ; sq_bass(8,2) ; rave_riff(8,2) ; beats_2 ; bar(7) ; beats(1,4) ; bar(1)
  beats(7,3) ; sq_bass(8,2) ; rave_riff(8,2) ; beats_2 ; bar
  sq_bass(8,2) ; rave_riff(8,2) ; bar(7) ; beats(1,4) ; bar(1)
end
4 Likes

That’s fantastic. The code is very dense and will take some unpicking! Rather beautiful though - are you a C programmer?? :smile: As a newcomer to Ruby I didn’t actually know you could have multiple statements on a line d’Oh that’s going to be handy.

Great sonic result. Definitely raving at the desk here on a dank grey day

.net c# mostly. I found ruby/sonic pi syntax fairly easy to learn, but it took me a couple of years to get results out of it that I’m happy with :slight_smile:

2 Likes

I see, anyway nice layout. I was from C originally, the culture was to cram as much functionality into each line as possible. Something of an art form. These days, people give things meaningful names - how gauche :smiley:

I love your tracks on Bandcamp. The 3R album came up first - it says they are remixes, could you say a bit about these? Did you use SPi for these, really great soundscapes.

Many thanks :+1:

They were made in Sonic Pi - Basically, I attempted to replicate the original tracks in my own way using the samples that the authors sent me.
The soundscape one is actually the simplest one and is mainly repeating delay/filter effects with some weird drum samples.
The code is on github if you want to have a look - https://gist.github.com/binarysweets

Thank you, fascinating. I do like the way you structure the song - both the code and the result. In the code you can really see how it’s evolving, if I’ve read it right.

I’ve been concentrating on structures for live coding mostly, which is ok. But the control structures for a self-playing track have been a bit if-then-else-casey if you know what I mean.

Nice artwork too, do you do that?

1 Like

Yeah, for the artwork I normally hit https://pixabay.com and then use GIMP to edit and add effects etc.

1 Like