# Swing Example, put some swing in your rhythms

**URL:** <https://in-thread.sonic-pi.net/t/swing-example-put-some-swing-in-your-rhythms/443>\
**Category:** Creations & Ideas\
**Created:** [November 21, 2017, 12:55pm UTC](https://in-thread.sonic-pi.net/t/swing-example-put-some-swing-in-your-rhythms/443 "2017-11-21T12:55:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bohrbug](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/bohrbug/32/73_2.png) [@Bohrbug](https://in-thread.sonic-pi.net/u/Bohrbug)\
**Post date:** [November 21, 2017, 12:55pm UTC](https://in-thread.sonic-pi.net/t/swing-example-put-some-swing-in-your-rhythms/443/1 "2017-11-21T12:55:45Z")

</div>

If you want to make use of the swing function, you could use this approach as a start,  
I found it works really well with bools :

```ruby
live_loop :swing do
  with_swing 0.08 do
    sample :drum_cymbal_soft if (bools 1, 0, 0, 0, 1, 0, 1, 0).tick
  end
  sleep 0.125
end

```

Now change the swing value to `0.12` and then back again to lets say `0.08` and listen to the change in swing feel.

Or a negative value approach :

```ruby
live_loop :swing do
  with_swing -0.02 do
    sample :drum_cymbal_soft if (bools 1, 0, 0, 0, 1, 0, 0, 1).tick
  end
  sleep 0.125
end

```

Change the value of the swing to `-0.08` and listen to the effect. Then change it back to `-0.06`, etc.

---

<div class="post-metadata">

**Author:** ![ogonemaon](https://avatars.discourse-cdn.com/v4/letter/o/958977/32.png) [@ogonemaon](https://in-thread.sonic-pi.net/u/ogonemaon)\
**Post date:** [November 28, 2017, 6:11pm UTC](https://in-thread.sonic-pi.net/t/swing-example-put-some-swing-in-your-rhythms/443/2 "2017-11-28T18:11:23Z")

</div>

Doesn’t work for me. “with\_swing” is undefined method. Can it be added somehow?

---

<div class="post-metadata">

**Author:** ![Eli](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/eli/32/116_2.png) [@Eli](https://in-thread.sonic-pi.net/u/Eli)\
**Post date:** [November 28, 2017, 8:38pm UTC](https://in-thread.sonic-pi.net/t/swing-example-put-some-swing-in-your-rhythms/443/3 "2017-11-28T20:38:59Z")

</div>

It may be that ‘with\_swing’ is a version 3.0+ command… if you are still using the Windows v 2.11 version  
you may not have access to the command yet… I dont know when 3.0 for Windows is due for release…  
you need to check with Sam.

Eli…

---

<div class="post-metadata">

**Author:** ![samaaron](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/samaaron/32/7_2.png) [@samaaron](https://in-thread.sonic-pi.net/u/samaaron)\
**Post date:** [November 29, 2017, 9:25am UTC](https://in-thread.sonic-pi.net/t/swing-example-put-some-swing-in-your-rhythms/443/4 "2017-11-29T09:25:01Z")

</div>

A beta release of v3 for windows is available to my patreon supporters. Release will be when it’s ready 🙂

> **[Sam Aaron is creating the live coding synth Sonic Pi | Patreon](https://www.patreon.com/samaaron)**
>
> Become a patron of Sam Aaron today:
> Read 70 posts by Sam Aaron and get access to exclusive
> content and experiences on the world’s largest membership
> platform for artists and creators.

---

<div class="post-metadata">

**Author:** ![TonnyStampert](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/tonnystampert/32/269_2.png) [@TonnyStampert](https://in-thread.sonic-pi.net/u/TonnyStampert)\
**Post date:** [January 20, 2018, 12:16pm UTC](https://in-thread.sonic-pi.net/t/swing-example-put-some-swing-in-your-rhythms/443/5 "2018-01-20T12:16:10Z")

</div>

#bohrbugswings

use\_bpm 60

live\_loop :biet do  
sleep 1  
end

a = 0.5

b= 0.01

with\_fx :bitcrusher do

live\_loop :swing1, sync: :biet do  
with\_swing rrand(-0.05,5) do  
sample :drum\_snare\_hard if (bools 1, 0, 0, 0, 0, 0, 0, 1).tick  
end  
sleep a  
end

live\_loop :swing2, sync: :biet do  
with\_swing rrand(-0.04,4) do  
sample :drum\_snare\_soft if (bools 0, 1, 0, 0, 0, 0, 1, 0).tick  
end  
sleep a-b  
end

end

with\_fx :compressor do

live\_loop :swing3, sync: :biet do  
with\_swing rrand(-0.03,3) do  
sample :drum\_splash\_hard if (bools 0, 0, 1, 0, 0, 1, 0, 0).tick  
end  
sleep a-b-b  
end

live\_loop :swing4, sync: :biet do  
with\_swing rrand(-0.02,2) do  
sample :drum\_splash\_soft if (bools 0, 0, 0, 1, 1, 0, 0, 0).tick  
end  
sleep a-b-b-b  
end

end

with\_fx :tremolo do

live\_loop :swing5, sync: :biet do  
with\_swing rrand(-0.01,1) do  
sample :drum\_cymbal\_hard if (bools 1, 0, 0, 1, 0, 0, 0, 1).tick  
end  
sleep a-b-b-b-b  
end

live\_loop :swing6, sync: :biet do  
with\_swing rrand(-0.001,0.1) do  
sample :drum\_cymbal\_soft if (bools 1, 0, 1, 0, 0, 0, 1, 0).tick  
end  
sleep a-b-b-b-b-b  
end

end
