Hello all - major code and music lover just discovering this

Hello!

I came across a video of a developer conference talk called “The Art of Code” - https://www.youtube.com/watch?v=6avJHaC3C2U

Part of the talk referenced Sonic Pi and it made me consider that there are probably a lot of folks out there that have been using this to do random music generators which I’ve always played around with the notion in my head, but here is this tool now to actually start messing around with it. Cool! I’m looking forward to reading through the forum to see anyone doing this – already saw a few posts that got my attention. Awesome.

I downloaded a few days ago, and made a thing in three hours that I think is cool. Wanna try it? I loop through each of the synths really quickly - I can’t have been the first to try that. But then I randomized the chord, added a bass root note, a random highlight note from the chord and then some additional percussive sounds. I put a thing in there that speeds it up slowly at the start and fades in the synth chords. It’s neat when it comes up to top volume. The compressor starts kicking in hard.

Anyway, can’t wait to try more!!


# Loop through synths

# Cool seeds
# 7
# 100
# 50
# 600
# 37347
# 902
# 3001
# 3002

use_random_seed 3002     #### CHANGE ME!

# starting BPM
use_bpm 100     #### CHANGE ME!

# Set initial octave, root note and chord type
rootoctave = choose([32,48])
root = rrand_i(1,12) + rootoctave
chordtype = chord_names[rrand_i(0,58)]

# This is the primary loop
live_loop :main do
  
  # Compress this whole thing
  with_fx :compressor, pre_amp: 1, amp: 5, clamp_time: 0.1, relax_time: 0.2, threshold: 0.015 do
    
    # Tick and switch synths - increments tick (which is accessed later by 'look' but does not increment)
    use_synth synth_names[tick]
    
    # Max volume of the chord
    maxchordamp = 0.18        #### CHANGE ME!
    
    # Speed Up
    maxbpm = 200     #### CHANGE ME!
    if (current_bpm < maxbpm)
      if (factor?(look, 2))
        use_bpm current_bpm + 1
      end
    end
    
    # Fade in
    curramp = 0
    fadelen = 300     #### CHANGE ME!
    if (look < fadelen)
      if (look == 0)
        curramp = 0
      else
        curramp = curramp + ((maxchordamp / fadelen) * look)
      end
      if (curramp > maxchordamp)
        curramp = maxchordamp
      end
    else
      curramp = maxchordamp
    end
    
    # Kick & Change Chord
    if (factor?(look,8))
      sample :bd_ada, amp: curramp + 3
      
      # Random Chord Change
      # Did this here to always make sure it happens with kick
      if (look == 0)
        # pick a root and chord type at the beginning
        root = rrand_i(1,12) + rootoctave
        chordtype = chord_names[rrand_i(0,58)]
        
      elsif (factor?(look, choose([64, 128, 256])))
        # pick one every 64, 128 or 256 iterations
        root = rrand_i(1,12) + rootoctave
        chordtype = chord_names[rrand_i(0,58)]
        
      end
      
    elsif (factor?(look, 4))
      # Snare - only when NOT a kick drum
      sample :glitch_perc1, amp: curramp + rrand(0.01, 0.2)
    end
    
    # set the chord
    playchord = chord(root, chordtype)
    
    # play each chord note panned out
    play playchord[0], amp: curramp, pan: 0
    play playchord[1], amp: curramp, pan: -0.3
    play playchord[2], amp: curramp, pan: 0.3
    play playchord[3], amp: curramp, pan: -0.6
    play playchord[4], amp: curramp, pan: 0.6
    play playchord[5], amp: curramp, pan: -1
    play playchord[6], amp: curramp, pan: 1
    
    # Accent note - play it a bit louder and higher up
    accentamp = 0
    if (look < fadelen)
      accentamp = curramp
    else
      accentamp = curramp + 0.15
    end
    
    play playchord[rrand_i(0,5)] + 24, amp: accentamp, pan: rrand(-1,1)
    
    # Bass note
    use_synth :sine
    play playchord[0] - 12, amp: accentamp + 0.8, pan: 0
    
    
    # Hats
    if (factor?(look,2))
      if (!one_in(8))
        sample :glitch_perc5, amp: curramp, pan: rrand(-1,1)
      else
        if (one_in(2))
          sample :elec_filt_snare, amp: curramp
        else
          sample :glitch_perc4, amp: curramp + 0.05
        end
      end
    end
    
    # Toms
    if (factor?(look+3,8))
      sample :drum_tom_hi_soft, amp: curramp + 0.75, pan: -0.8
    end
    if (factor?(look+2,8))
      sample :drum_tom_mid_soft, amp: curramp + 0.85, pan: 0
    end
    if (factor?(look+1,8))
      sample :drum_tom_lo_soft, amp: curramp + 0.75, pan: 0.8
    end
    
    
  end
  
  sleep 0.3
end

3 Likes