Abstract-Metaphysical Composition :The River Flow

# Title: The River Flow
# Artist: Mattia Giovanetti
# Date: 15/06/2019
#
# Sonic Pi v3.1

use_bpm 80

define :a do
  sample :bd_mehackit, rate: [1,-1].choose
  sleep [2,1,0.5].choose
  sample :glitch_perc2, rate: [1,-1].choose
  sleep [4,2,1].choose
end

define :drumloop do
  with_fx :echo, phase: 1, decay: 4, mix: 0.25 do
    sample :drum_bass_hard
    sleep 0.5
    sample :drum_bass_hard
    sleep 0.5
    sample [:drum_cymbal_closed, :drum_cymbal_open].choose, amp: 0.25
    sleep 0.333
    sample [:drum_cymbal_closed, :drum_cymbal_open].choose, amp: 0.25
    sleep 0.333
    sample [:drum_cymbal_closed, :drum_cymbal_open].choose, amp: 0.25
    sleep 0.333
    sample :drum_snare_soft
    sleep 1.0001
    sample :drum_cowbell, amp: [0,0.5,1].choose
    sleep 1
  end
end

define :bassometafisico do
  use_synth :sine
  play 38, release: 0.25
  sleep 0.25
  play 42, release: 0.25
  sleep 0.5
  play 33, release: 0.25
  sleep 1.25
end

define :b do
  with_fx :echo, phase: 0.25, decay: 2.5 do
    12.times do
      use_synth :dull_bell
      rand_skip 10000
      y = [rand_i(1), 0].choose
      play rand_i(24) + 60, amp: (y-0.25).abs, pan: [1,0.75].choose
      rand_skip 10000
      x = rand_i(8)
      sleep x
    end
  end
end

define :c do
  with_fx :echo, phase: 1, decay: 10 do
    12.times do
      use_synth :pretty_bell
      rand_skip 250
      y = rand_i(1)
      play rand_i(24) + 60, pitch: 12, amp: (y-0.25).abs, pan: [-1,-0.5].choose
      rand_skip 250
      x = rand_i(8)
      sleep x
    end
  end
end

define :d do
  use_synth :fm
  play_chord chord(:c4,:augmented), attack: 2, sustain: 5, release: 3
  sleep 12
  play_chord chord(:g4,:dim7), attack: 2, sustain: 5, release: 3
  sleep 12
  play_chord chord(:f4,:sus4), attack: 2, sustain: 5, release: 3
  sleep 12
end

define :da do
  use_synth :dtri
  play_chord chord(:d4,:augmented), attack: 2, sustain: 5, release: 3
  sleep 12
  play_chord chord(:a4,:dim7), attack: 2, sustain: 5, release: 3
  sleep 12
  play_chord chord(:g4,:sus4), attack: 2, sustain: 5, release: 3
  sleep 12
end


define :f do
  with_fx :echo, phase: 8, decay: 12, mix: 0.125 do
    9.times do
      32.times do
        x = rand_i(12) + 72
        use_synth :dtri
        play x, attack: 0, release: 0.0625, amp: [0,0.25,0,0.33,0,0.75].choose
        sleep 0.125
      end
    end
  end
end

define :h do
  use_synth :bnoise
  with_fx :flanger, mix: 0.125 do
    play 60, attack: 2, sustain: 26, release: 2, amp: 0.125
    sleep 30
  end
end



#forma
with_fx :level, amp: 0.125 do
  with_fx :reverb, mix: 0.5, damp: 1, room: 1 do
    with_fx :flanger do
      
      4.times do
        drumloop
      end
      
      define :bloccoA do
        print "BLOCCO A"
        in_thread do
          9.times do
            drumloop
          end
        end
        in_thread do
          f
        end
        in_thread do
          d
        end
        in_thread do
          sleep 24
          a
        end
        in_thread do
          h
        end
      end
      
      define :bloccoB do
        print "BLOCCO B"
        in_thread do
          5.times do
            a
            sleep 12
          end
        end
        in_thread do
          b
        end
        in_thread do
          c
        end
        in_thread do
          da
        end
        in_thread do
          16.times do
            bassometafisico
          end
        end
      end
      
      define :bloccoC do
        print "BLOCCO C"
        in_thread do
          d
        end
        in_thread do
          f
        end
        in_thread do
          h
        end
      end
      
      bloccoA
      sleep 36
      bloccoB
      sleep 36
      bloccoC
      sleep 20
    end
  end
end
2 Likes

Thanks very much, I enjoyed this.

Can I ask what role the rand_skip is doing in your piece? I understand what the rand_skip command does, but would like to know what higher level effect you’re achieving with it.

1 Like

Hi! Thank you for have pay attention to my work.
The role of rand_skip? Maybe was a wrong use of it, because I used it to fix … an error! Then I didn’t think about that, assuming that a previous reasoning was right ie that skip positions in the random serie gives different tunes. I was getting the same tune for different voices, so, in absence of somethink like “seed” as puredata has, I use rand_skip in order to get variety.

I like it. Note you can get a negative amp: option value in line 51. Needs a slight adjustment

    y = [rand_i(1), 0].choose
     play rand_i(24) + 60, amp: y-0.25, pan: [1,0.75].choose
  
2 Likes

Thank you Robin! I will correct it!

Absolute value function is the solution!
here a link: ruby method abs

play rand_i(24) + 60, amp: (y-0.25).abs, pan: [1,0.75].choose

rand_skip looks interesting to me. I quite often use random generation off melodies and patterns. If I like the first half but not the second half, then I could try some rand_skips to get rid of bits I don’t like. Thanks for the info.

1 Like

You’re welcome, however seems that the use of rand_i it’s already fixed over the possibility of generate identical series. I have finish to write out a new piece right now, three voices and each single voice it’s using a different serie, even if the same use of rand_i was write for every voice.