# Meandering chord progressions and melody through Sonic Pi scales

**URL:** <https://in-thread.sonic-pi.net/t/meandering-chord-progressions-and-melody-through-sonic-pi-scales/7888>\
**Category:** Creations & Ideas\
**Created:** [June 17, 2023, 6:29pm UTC](https://in-thread.sonic-pi.net/t/meandering-chord-progressions-and-melody-through-sonic-pi-scales/7888 "2023-06-17T18:29:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![robin.newman](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@robin.newman](https://in-thread.sonic-pi.net/u/robin.newman)\
**Post date:** [June 17, 2023, 6:29pm UTC](https://in-thread.sonic-pi.net/t/meandering-chord-progressions-and-melody-through-sonic-pi-scales/7888/1 "2023-06-17T18:29:08Z")

</div>

I was looking at some of @mrbombmusic tutorials on youtube which are a good start to start playing with ideas, and developed [one of them](https://www.youtube.com/watch?v=QeDm_8r1-bQ) to produce the piece below. It can easily be altered or developed further.

```ruby
#chord progressions and melody meandering through Sonic Pi's scales
#code by Robin Newman, inspired by a tutorial by Mr Bomb
#https://www.youtube.com/watch?v=QeDm_8r1-bQ

use_debug false
use_bpm 110

sn= scale_names #internally defined scale names in Sonic Pi

define :dub do |n| #n is a list of notes
  #list n is duplicated an octave above and below the original
  #a rest (nil) is added to the list
  op=[nil] #output list initiated to a rest (nil) to add some rhythmic change to what is played
  n.each do |nv|
    op += [nv] #original
    op += [nv - 12] #down an octave
    op += [nv + 12] #up an octave
  end
  return op #expanded list is returned
end

with_fx :reverb, room: 0.6,mix: 0.7 do
  live_loop :prog do
    use_synth :pluck #for melody notes
    #choose one of the two progressions. Could add others
    progression = [(ring, :i,:vi,:ii,:v),(ring, :i, :v,:vi,:iv)].choose
    puts progression
    s=scale_names.choose #.tick can be used instead to sequence through them all
    puts s
    tick_reset :prog #reset tick counter :prog
    progression.length.times do #iterate through the progression
      #take three note chord for each degree
      cn=chord_degree(progression.tick(:prog),:c4,s,3)
      in_thread do #individual note thread played at same time as chord
        cx=dub(cn) #produced extended list using dub
        puts cx
        16.times do #play 16 notes/rests from the list
          play cx.choose,pan: rrand_i(-1,1) #distribute note to pan -1,0 or 1
          sleep 0.25
        end
      end
      with_synth :tb303 do
        #play the next chord in the progression
        play cn,release: 4,cutoff: 90,amp: 0.5,pan: rrand_i(-1,1)
      end
      sleep 4
    end
  end
end#reverb

```

---

<div class="post-metadata">

**Author:** ![hitsware](https://avatars.discourse-cdn.com/v4/letter/h/a9adbd/32.png) [@hitsware](https://in-thread.sonic-pi.net/u/hitsware)\
**Post date:** [June 18, 2023, 6:10pm UTC](https://in-thread.sonic-pi.net/t/meandering-chord-progressions-and-melody-through-sonic-pi-scales/7888/2 "2023-06-18T18:10:30Z")

</div>

Thank You …  
Good YouTubes … AND  
Your piece is delightful …  
" Artificial Musical Intelligence "  
is a great possibility with scripted  
audio . The most interesting facet  
( to me ) being the interaction of  
mind ( perception ) with the  
performance . One man ’ s  
( or moment ’ s ) music is  
the next man ’ s ( or moment ’ s )  
noise …

---

<div class="post-metadata">

**Author:** ![brendanmac](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/brendanmac/32/2809_2.png) [@brendanmac](https://in-thread.sonic-pi.net/u/brendanmac)\
**Post date:** [May 18, 2024, 10:59am UTC](https://in-thread.sonic-pi.net/t/meandering-chord-progressions-and-melody-through-sonic-pi-scales/7888/3 "2024-05-18T10:59:01Z")

</div>

@robin.newman Some of my recent posts reveal that this is a favourite topic of mine - constrained randomisation for harmony and melody, and improvising with code. I plan to dissect, adapt and understand this excellent example of yours. One day, I too will know Kung Fu.

PD-Pi
