Kofi / Illestpreacha
Code is Poetry & Data is Poetry

Code is Poetry & Data is Poetry

CreativeCodeChallenge: Sonic Pi Recursion

CreativeCodeChallenge: Sonic Pi Recursion

Kofi / Illestpreacha's photo
Kofi / Illestpreacha
·Jul 10, 2022·

4 min read

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

Also being used as the foundational part for theOST Composing Jam #4 as the sounds fits the theme of "Runaway"

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

#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

SendOff 2


#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

3 Min OST for OST Jam

#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

 
Share this