Sonic Pi Scripts

Jumping-off points for Sonic Pi!

Volume Control on a Live DnB Jam
Volume Control on a Live DnB Jam

Volume Control on a Live DnB Jam

By setting some global values for volume controls you can run a set of live loops and easily alter the mix.

What it sounds like:

Code:

# Settings
use_bpm 168
use_random_seed 1001


# Functions
# Get the correct pitch for a sample note.
define :get_pitch_from_note do |note, sample_root_note|
  return note - sample_root_note
end


# Mix
# Setting the values here which will apply them to the sounds in each live loop.
# Change them while running...
set :choir_mash_vol, 0.5
set :bass1_vol, 0.5
set :beat1_vol, 6.5
set :beat2_vol, 1.5



# Loops
live_loop :choir_mash do
  notes = (ring :A3, :Cs4, :E4, :Ab4,  :F3, :A3, :C4, :E4)
  amp = get[:choir_mash_vol]

  sample :ambi_choir,
    rpitch: get_pitch_from_note(notes.tick, :a3),
    amp: amp,
    start: 0.2,
    finish: 0.5

  sleep 0.5
end

with_fx :eq, low_note: 60, low: -0.5 do
  live_loop :beat1 do
    main_slices = (ring 4,3,2,3, 3,8,2,3, 4,3,10,3, 3,4,2,4)
    end_slices = (line 0, 15, steps: 16, inclusive: true).shuffle
    amp = get[:beat1_vol]

    48.times do
      sample :loop_compus,
        amp: rrand(amp, amp + 0.5),
        slice: main_slices.tick,
        beat_stretch: 16

      sample :loop_perc2,
        amp: (amp / 8),
        slice: look

      sample :loop_perc1,
        amp: (amp / 8),
        slice: look,
        pan: [-0.2, 0, 0.2].choose

      sleep 0.5
    end

    16.times do
      sample :loop_compus,
        amp: rrand(amp, amp + 0.5),
        slice: end_slices.tick,
        beat_stretch: 16

      sample :loop_perc2,
        amp: (amp / 8),
        slice: look

      sample :loop_perc1,
        amp: (amp / 8),
        slice: look,
        pan: [-0.2, 0, 0.2].choose

      sleep 0.5
    end
  end
end

with_fx :eq, low_note: 60, low: -0.5 do
  live_loop :beat2 do
    sleep 64
    fixed_slices = (ring 4,3,2,3, 3,8,2,3, 4,3,10,3, 3,4,2,4)
    amp = get[:beat2_vol]

    128.times do
      sample :loop_amen,
        amp: rrand(amp, amp + 0.2),
        slice: fixed_slices.tick,
        beat_stretch: 6,
        pan: 0.2

      sleep 0.25
    end
  end
end

with_fx :wobble, phase: 0.25, wave: 1, smooth: 1 do
  live_loop :bass1 do; tick
    notes = (ring :A1,:B1,:F1,:G1, :A1,:B1,:F1,:G1, :A1,:B1,:F1,:G1, :A2,:B2,:F2,:G2)
    amp = get[:bass1_vol]

    with_synth :tri do
      play notes.look,
        sustain: 4,
        release: 0.5,
        amp: amp
    end

    sleep 4
  end
end

Music Platforms:

Leave a Reply

Your email address will not be published. Required fields are marked *