# CreativeCodeChallenge: Sonic Pi Recursion

For this challenge, decided to recursion in an Audio sense.

Also being used as the foundational part for the[OST Composing Jam #4](https://itch.io/jam/ost-composing-jam-4) as the sounds fits the theme of "Runaway"

```ocaml
The name Sendoff was to represent a game where  the protagonist is running away but tells people that they were sent off. Problem with this tale is the entities that made them runaway are still chasing them.

Lurking in the shadows
no matter the path that you chose
don't know where you belong
but the entitles hunting don't care about right or wrong
Funny thing is, you have not seen what is chasing
and that is what makes the heart keep pacing
the body feel it has to still be escaping
What is it that you have taken
for these beings to be lurking in the shadows
```

Below you will find the code and the Audio created from those code pieces

**SendOff 1**

```ruby
#Recursion Challenge
#Aided with https://www.tutorialspoint.com/how-does-recursion-work-in-ruby-programming


live_loop :addition do
  
  
  # recursion call 
  def Addition(arr)
    return 1 if arr.length == 0
    arr[0] + Addition(arr[1..-1]) 
  end
  
  #variables that will be used in the Method Call below
  #Dice is a randomizer that functions as a dice roll
  a = dice(6)
  b = dice(6)
  c = dice(6)
  d = 2
  e = 3
  
  #Calling the Method to aid with sound design
  smacks = Addition([a,b,c,d,e])
  notes = Addition([a,b,d])
  
  #sound elements
  
  with_fx :flanger do
    with_fx :echo do
      use_synth [:pretty_bell, :kalimba, :prophet].choose
      play notes * 4, attack: dice(6)
    end
  end
  
  with_fx :vowel do
    sample :drum_bass_hard, decay: smacks / 12 if spread(smacks/4, smacks/3).look
  end
  
  #print out numbers
  puts Addition([a,b,c,d,e])
  puts notes
  
  sleep [0.25,0.5,1,2].choose
end
```

<iframe width="100%" height="300" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/1302744385&color=%23ff5500&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true&visual=true"></iframe>

[IllestPreacha](https://soundcloud.com/llestreacha) · [2022 - 07 - 10 Recursion SendOff](https://soundcloud.com/llestreacha/2022-07-10-recursion-sendoff)

**SendOff 2**

```ruby

#Recursion Challenge
#Aided with https://www.tutorialspoint.com/how-does-recursion-work-in-ruby-programming


live_loop :addition do
  
  
  # recursion call being the function calling a new sub string
  def Addition(arr)
    return 1 if arr.length == 0
    arr[0] + Addition(arr[1..-1])
  end
  
  #variables that will be used in the Method Call below
  #Dice is a randomizer that functions as a dice roll
  a = dice(6)
  b = dice(6)
  c = dice(6)
  d = 2
  e = 3
  
  #Calling the Method to aid with sound design
  smacks = Addition([a,b,c,d,e])
  notes = Addition([a,b,d])
  
  #sound elements
  if notes % 2 == 0
    
    with_fx :flanger, mix: rrand(0.3,0.5) do
      with_fx :echo do
        use_synth [:pretty_bell, :kalimba, :prophet].choose
        play notes * 4, attack: dice(6)
      end
    end
  else
    
    with_fx :whammy, mix: rrand(0.2,0.6) do
      with_fx :gverb do
        use_synth [:pretty_bell, :kalimba, :prophet].choose
        play notes * 4, attack: dice(6)
      end
    end
  end
  
  if smacks > 10
    
    if notes > 8
      
      with_fx :vowel ,voice: dice(4) do
        sample :drum_bass_hard, decay: smacks / 12 if spread(smacks/4, smacks/3).look
      end
      
    else
      with_fx :ixi_techno, mix: 0.75 do
        sample :drum_bass_soft, decay: smacks / 12 if spread(smacks/4, smacks/3).look
      end
    end
    
  else
    
    if notes > 8
      
      with_fx :vowel do
        sample :tabla_ghe1, decay: smacks / 12 if spread(smacks/4, smacks/3).look
      end
      
    else
      with_fx :ixi_techno, mix: 0.75 do
        sample :tabla_ghe3, decay: smacks / 12 if spread(smacks/4, smacks/3).look
      end
    end
    
  end
  
  
  #print out numbers
  puts Addition([a,b,c,d,e])
  puts notes
  
  sleep [0.25,0.5,1,2].choose
end
```

<iframe width="100%" height="300" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/1302774577&color=%23ff5500&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true&visual=true"></iframe>

[IllestPreacha](https://soundcloud.com/llestreacha) · [2022 - 07 - 10 Recursion SendOff 2](https://soundcloud.com/llestreacha/2022-07-10-recursion-sendoff-2)

**3 Min OST for OST Jam**

```ruby
#Recursion Challenge
#Aided with https://www.tutorialspoint.com/how-does-recursion-work-in-ruby-programming
# 3 Minute Version for the OST Soundtrack


live_loop :addition do
  
  
  # recursion call being the function calling a new sub string
  def Addition(arr)
    return 1 if arr.length == 0
    arr[0] + Addition(arr[1..-1])
  end
  
  #variables that will be used in the Method Call below
  #Dice is a randomizer that functions as a dice roll
  a = dice(8)
  b = dice(8)
  c = dice(8)
  d = 2
  e = 3
  
  #Calling the Method to aid with sound design
  smacks = Addition([a,b,c,d,e])
  notes = Addition([a,b,d])
  
  #sound elements
  if notes % 2 == 0
    
    with_fx :flanger, mix: rrand(0.3,0.5) do
      with_fx :echo do
        use_synth [:pretty_bell, :kalimba, :prophet].choose
        play notes * 4, attack: dice(6), decay: dice(2)
      end
    end
  else
    
    with_fx :whammy, mix: rrand(0.2,0.6) do
      with_fx :gverb do
        use_synth [:pretty_bell, :kalimba, :prophet].choose
        play notes * 4, attack: dice(6), sustain: dice(3)
      end
    end
  end
  
  if smacks > 10
    
    if notes > 8
      
      with_fx :vowel ,voice: dice(4), mix: rrand(0.3,0.8) do
        sample :drum_bass_hard, decay: smacks / 12 if spread(smacks/4, smacks/3).look
      end
      
    else
      with_fx :ixi_techno, mix: rrand(0.25,0.75) do
        sample :drum_bass_soft, decay: smacks / 12 if spread(smacks/4, smacks/3).look
      end
    end
    
  else
    
    if notes > 8
      
      with_fx :whammy, amp: dice(3) do
        sample :tabla_ghe1, decay: smacks / 12 if spread(smacks/4, smacks/3).look
      end
      
    else
      with_fx :ixi_techno, mix: 0.75 do
        sample :tabla_ghe3, decay: smacks / 12 if spread(smacks/4, smacks/3).look
      end
    end
    
  end
  
  
  #print out numbers
  puts Addition([a,b,c,d,e])
  puts notes
  
  sleep [0.25,0.5,1,2,4].choose
end
```

<iframe width="100%" height="300" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/1302788644&color=%23ff5500&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true&visual=true"></iframe>

[IllestPreacha](https://soundcloud.com/llestreacha) · [Send Off - 4 Minute Version - OST Composing Jam #4](https://soundcloud.com/llestreacha/send-off-4-minute-version-ost-composing-jam-4)
