# Improvising in live code, with syncopation

**URL:** <https://in-thread.sonic-pi.net/t/improvising-in-live-code-with-syncopation/8585>\
**Category:** Support, Help & Resources\
**Created:** [January 30, 2024, 10:29pm UTC](https://in-thread.sonic-pi.net/t/improvising-in-live-code-with-syncopation/8585 "2024-01-30T22:29:12Z")\
**Posts on this page:** 5\
**Page:** 1

<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:** [January 30, 2024, 10:29pm UTC](https://in-thread.sonic-pi.net/t/improvising-in-live-code-with-syncopation/8585/1 "2024-01-30T22:29:13Z")

</div>

I find it hard to jam/sketch/improv in Sonic Pi, purely because I’m not a live coding expert. To help me on my way, there MUST be a quicker way to realise the following (unoriginal) riff that came to me:

use\_bpm 100

live\_loop :crotchet do  
sample :perc\_snap  
sleep 1  
end

# blues scale [60, 60, 51, 52, 53, 54, 55]

live\_loop :blueRiff do  
use\_synth\_defaults release: 0.5  
play 60  
sleep 0.5  
play 60  
sleep 1  
play 51  
sleep 1  
play 52  
sleep 1  
play 53  
sleep 1  
play 54  
sleep 0.5  
play 55  
sleep 1  
end

---

<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:** [January 30, 2024, 11:14pm UTC](https://in-thread.sonic-pi.net/t/improvising-in-live-code-with-syncopation/8585/2 "2024-01-30T23:14:16Z")

</div>

You could create the riff using a ring, and associated note timeings using another ring  
In the sample below I’ve done this. Also added some variety you can try out  
use differnt synths . ;fm is good. Try others.Add density function to get more interesting snap rhythm. Change the dice(20 to dice(1) to play orginal  
add changes in pan setting (comment out end of line if yoiu want to swithchit out)  
add optional use\_transpose (try -12,0 or 12)

```ruby
use_bpm 100

live_loop :crotchet do
  density dice(2) do
    sample :perc_snap#,pan: (-1)**dice(2)
    sleep 1
  end
end

blues_scale = (ring 60, 60, 51, 52, 53, 54, 55)
durs=(ring 0.5,1,1,1,1,0.5,1)

live_loop :blueRiff do
  use_synth :fm
  use_transpose 0 #try -12 or 12
  use_synth_defaults release: 0.5,amp: 4
  play blues_scale.tick #tick advances to next note each pass of the loop
  sleep durs.look #look gives same as tick value without advancing it
end

```

---

<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:** [January 31, 2024, 7:35am UTC](https://in-thread.sonic-pi.net/t/improvising-in-live-code-with-syncopation/8585/3 "2024-01-31T07:35:31Z")

</div>

ring! Of course, much more elegant and flexible, many thanks

---

<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:** [January 31, 2024, 3:20pm UTC](https://in-thread.sonic-pi.net/t/improvising-in-live-code-with-syncopation/8585/4 "2024-01-31T15:20:07Z")

</div>

Having waaay too much fun with .shuffle, .mirror etc on those rings 😃

---

<div class="post-metadata">

**Author:** ![rebelcello](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/rebelcello/32/2602_2.png) [@rebelcello](https://in-thread.sonic-pi.net/u/rebelcello)\
**Post date:** [February 1, 2024, 10:30pm UTC](https://in-thread.sonic-pi.net/t/improvising-in-live-code-with-syncopation/8585/5 "2024-02-01T22:30:41Z")

</div>

this is seriously groovy!
