Sonic Pi Monthly Challenge #4

Dear Sonic Pi’ers,

It is time for a new year, and a new challenge – #4.

This months challenge is: Text > binary > music.

Instructions:

  1. Choose a word, name or short phrase of text and convert it into binary code by using this website:
    Text to Binary Converter

  2. Take the converted binary code and use it to create a piece of music or live performance (using rings, bools, arrays, etc). Each loop should use a new word, name, phrase or part of the original converted binary code.
    You may use the built-in synths and samples or use external samples; it’s up to you.
    The length and genre is also up to you.

  3. Post the code and audio links (Youtube/Soundcloud) into this topic.
    Tell us what text you started with for each loop, and a little about your creative process.

The deadline for this challenge is 31st January.

Code and audio links will get added to the challenge repo

Happy coding :computer:

5 Likes

Looking forward to this!

1 Like
# phrase = " 633844564954959411211212"
# returns :
# 00110110 00110011 00110011 00111000
# 00110100 00110100 00110101 00110110
# 00110100 00111001 00110101 00110100
# 00111001 00110101 00111001 00110100
# 00110001 00110001 00110010 00110001
# 00110001 00110010 00110001 00110010

a=["00110110"," 00110011"," 00110011"," 00111000",
   "00110100"," 00110100"," 00110101"," 00110110"]
b=["00110100"," 00111001"," 00110101"," 00110100",
   "00111001"," 00110101"," 00111001"," 00110100"]
c=["00110001"," 00110001"," 00110010"," 00110001",
   "00110001"," 00110010"," 00110001"," 00110010"]

for x in 0..7
  ma=a[x].to_i(2)-48
  mb=b[x].to_i(2)-48
  mc=c[x].to_i(2)-48
  puts ma*mb*mc*11
  play hz_to_midi (ma*mb*mc*11)
  sleep 0.5
end

I like how you did that.

Thank You …
By the seat of my pants …

Here is my Covid-19 themed attempt for this challenge :grinning:
The idea behind the lead is to sound like I’m playing around on a keyboard, not sure it works…

# Sonic Pi Challenge #4 - Text > Binary > Music
# Coded by Binarysweets, Jan 2021
# Sonic Pi v3.2.2 (Win10)

# Settings
use_bpm 150
use_tuning :meantone
use_random_seed 20210107
mode = :augmented
scl = scale(:a1, mode, num_octaves: 4)
swing = (ring 0.05,-0.05)

# Loops
live_loop :metronome do
  sleep 1
end

live_loop :lead, sync: :metronome do ; tick
  # COVID-19
  steps = [0,1,0,0,0,0,1,1, 0,1,0,0,1,1,1,1, 0,1,0,1,0,1,1,0, 0,1,0,0,1,0,0,1,
           0,1,0,0,0,1,0,0, 0,0,1,0,1,1,0,1, 0,0,1,1,0,0,0,1, 0,0,1,1,1,0,0,1].ring.reverse
  notes = [12,15,15,15, 12,15,15,15, 14,15,16,17, 18,19,20,21, 22,23,24,25,
           21,14,14,7, 9,10].ring.mirror
  
  with_fx :echo, mix: 0.1 do
    with_fx :bitcrusher, bits: 8, sample_rate: [10000,1000].choose do
      with_synth :tri do
        play scl[notes.tick(:n)],
          amp: 0.6,
          pan: [0.2,-0.2].choose,
          attack: 0,
          sustain: ((ring 0.125,0.25,0.5).repeat(8)+(ring 2)).tick(:s),
          decay: 0,
          release: 0.125 if steps.look > 0
      end
    end
  end
  
  sleep 0.25 + swing.look
end

live_loop :chords, sync: :metronome do ; tick
  # NHS
  steps = [0,1,0,0,1,1,1,0, 0,1,0,0,1,0,0,0, 0,1,0,1,0,0,1,1].ring.reverse
  notes = (ring 6,8,9).reflect.repeat(2)+(ring 10,10,9)
  
  with_fx :bitcrusher, bits: 8, sample_rate: [10000,1000].choose do
    with_synth :tri do
      play (chord scl[notes.tick(:n)], 'm+5'),
        amp: 0.7,
        pan: -0.2,
        attack: 0,
        sustain: steps.look,
        decay: 0,
        release: 3 if steps.look > 0
    end
  end
  
  sleep 2 + swing.look
end

live_loop :bass, sync: :metronome do ; tick
  # Mask
  steps = [0,1,0,0,1,1,0,1, 0,1,1,0,0,0,0,1,
           0,1,1,1,0,0,1,1, 0,1,1,0,1,0,1,1]
  notes = (ring 1,3,2,4)
  
  with_synth :tri do
    play scl[notes.tick(:n)],
      amp: 0.3,
      attack: 0,
      sustain: 2,
      release: 0 if steps.look > 0
  end
  
  sleep 2 + swing.look
end

live_loop :percussion, sync: :metronome do ; tick
  # Lockdown
  steps = [0,1,0,0,1,1,0,0, 0,1,1,0,1,1,1,1, 0,1,1,0,0,0,1,1, 0,1,1,0,1,0,1,1,
           0,1,1,0,0,1,0,0, 0,1,1,0,1,1,1,1, 0,1,1,1,0,1,1,1, 0,1,1,0,1,1,1,0]
  
  with_fx :hpf, cutoff: (line 90, 80, steps: 64).mirror.look do
    with_fx :ping_pong do
      with_synth :cnoise do
        play :c4,
          amp: 1,
          attack: 0,
          sustain: 0.125,
          decay: 0,
          release: 0 if steps.look > 0
      end
    end
  end
  sleep 0.5 + swing.look
end

live_loop :vaccine, sync: :metronome do ; tick
  stop
  # Vaccine
  steps = [0,1,0,1,0,1,1,0, 0,1,1,0,0,0,0,1, 0,1,1,0,0,0,1,1, 0,1,1,0,0,0,1,1,
           0,1,1,0,1,0,0,1, 0,1,1,0,1,1,1,0, 0,1,1,0,0,1,0,1].ring.reverse
  notes = (ring 12,13,14,15)
  
  with_fx :bitcrusher, bits: 8, sample_rate: (line 500, 100, steps: 128).look do
    with_synth :tri do
      play scl[notes.tick(:n)],
        amp: 0.5,
        pan: (ring -0.5,-0.4,-0.3,-0.2, 0.2,0.3,0.4,0.5).mirror.tick(:p),
        attack: 0,
        sustain: (ring 0.75,0.75,0.75,0.5).tick(:s),
        release: 0.125 if steps.look > 0
    end
  end
  
  sleep 0.25 + swing.look
end

live_loop :beats, sync: :metronome do ; tick
  sample :bd_ada, amp: 1.2
  
  sleep 1 + swing.look
end

Here is my entry for this challenge. I decided not to use the website to generate the bianry string, but to do that within sonic pi itself. It makes it easy to update and try other strings.
I also liked the recent post by @theibbster for a chord progression tool which I developed and used in my code.
EDIT just noticed a couple of glitches in the soundcloud file. I won’t update it, but if you play the SP code it should sound correct.

You can hear the result on soundcloud, with the code link below

2 Likes

Here’s my entry, which is also my first live coding. Still veeery rough around the edges and overly simple…

Code below, I took my cat’s name which is conveniently 8 letters long, turned it into binary, wrote some functions and played them back live…

# Word is Giuliano
# 01000111 01101001 01110101 01101100 01101001 01100001 01101110 01101111

use_bpm 139
use_debug false
#Metronome 16th
in_thread do
  live_loop :metronome do
    cue :tick
    sleep 0.25
  end
end

#Metronome 8th
in_thread do
  live_loop :metronomeSlow do
    cue :tickHalf
    sleep 0.50
  end
end


#Variables

loop1 = [0,1,0,0,0,1,1,1,0,1,1,0,1,0,0,1]
loop2 = [0,1,1,1,0,1,0,1,0,1,1,0,1,1,0,0]
loop3 = [0,1,1,0,1,0,0,1,0,1,1,0,0,0,0,1]
loop4 = [0,1,1,0,1,1,1,0,0,1,1,0,1,1,1,1]

#Kick heavy
define :kick do
  with_fx :distortion do
    sample :bd_mehackit, mix: 0.6, distort: 0.5, amp: 0.7
  end
end

#Kick light
define :kicklight do
  sample :bd_mehackit, amp: 0.3
end


#KickGroove half
define :kicks do |n|
  live_loop :kick do
    16.times do |i|
      sync :tickHalf if n == 1
      sync :tick if n == 2
      stop if n == 0
      kick if loop1[i] == 0
      kicklight if loop1[i]== 1
    end
  end
end


#GlitchSound
define :glitch do
  with_fx :reverb do
    sample :glitch_perc4, amp: 0.7, pan: rrand(-0.25, 0.25), start: rrand(0, 0.5), sustain: rrand(0.1, 0.4), room: 7, rate: [-2, 1, 3].choose
  end
end

#Glitch groove
define :glitches do |n|
  live_loop :chh do
    rrand_i(4, 16).times do |i|
      sync :tick if n == 1
      stop if n == 0
      glitch if loop2 [i] == 1
    end
  end
end


#Bass Sound
define :bass do
  with_fx :bitcrusher do
    sample :bass_hard_c, amp: 0.2, attack: 0.5, release: 0.5
  end
end

#Bass groove
define :bass1 do |n|
  live_loop :bassline1 do
    16.times do |i|
      sync :tick if n == 1
      stop if n == 0
      bass if loop3 [i] == 0 if one_in (2)
    end
  end
end

#Bass SoundShort
define :bassShort do
  sample :bass_hit_c, amp: 1, pitch: +3
end

#Bass groove
define :bass2 do |n|
  live_loop :bassline2 do
    16.times do |i|
      sync :tick if n == 1
      stop if n == 0
      bassShort if loop4 [i] == 1
    end
  end
end

#Lead sound
define :lead do
  with_fx :reverb do
    with_fx :wobble do
      sample :loop_electric, start: rrand(0.1, 0.6), pitch: [1, 3, 5, -3].choose, amp: 1, attack: 0.25, sustain: 0, release: 0.25
    end
  end
end

#Lead synth
define :leads do |n|
  live_loop :lead do
    16.times do |i|
      sync :tick if n ==1
      stop if n ==0
      lead if loop4 [i] == 0
    end
  end
end


#kicks 1== slow; 2== fast; 0== stop
#glitches 0= stop; 1 play
#bass1 0= stop; 1 play
#bass2 0= stop; 1 play
#leads 0= stop; 1 play
#
### set the 0 below to 1 to play that pattern
bass2 0
glitches 0
kicks 0
bass1 0
leads 0
5 Likes

Great for your first attempt :+1:

1 Like

Just two weeks left for this one.
Thank you to those who have submitted already :slight_smile:

Hi, this is nice : ) simple but complex :smiley:

Thanks!
I would like to add a ‘master effect’ next, like a cutoff sweep for a transition, but I still haven’t looked into master effects…

1 Like
# We love Sankt Pauli - we do!
# Sonic Pi Challange Number 4

live_loop :progressionLoop do
  tick(:proTick)
  $a_chord = ring(chord(:D, :maj), chord(:b, :min), chord(:G, :maj), chord(:A, :maj)).tick
  $bar = look(:proTick)
  puts $bar
  sleep 4
end


live_loop :beat_quater do
  tick(:beat_tick)
  #stop
  #we 01110111 01100101
  if $bar >= 4 and $bar <21
    sample :bd_haus if bools(0,1,1,1,0,1,1,1,0,1,1,0,0,1,0,1).reverse.look(:beat_tick)
  end
  #love 01101100 01101111 01110110 01100101
  if $bar >= 4 and $bar <31
    sample :drum_cymbal_closed if bools(0,1,1,0,1,1,0,0,0,1,1,0,1,1,1,1,0,1,1,1,0,1,1,0,0,1,1,0,0,1,0,1).look(:beat_tick)
  end
  if $bar >= 4 and $bar <21
    sample :bd_tek, pan: 0.25 if bools(0,1,0,0,0,0,1,1).reverse.look(:beat_tick)
  end
  #F 01000110 (0,1,0,0,0,1,1,0)
  #C 01000011 (0,1,0,0,0,0,1,1)
  #S 01010011 (0,1,0,1,0,0,1,1)
  #sample :drum_snare_soft if bools(0,1,0,1,0,0,1,1).look(:beat_tick)
  #P 01010000 (0,1,0,1,0,0,1,1)
  sleep 0.25
end

live_loop :beat_full do
  tick(:b_full)
  sample :bd_mehackit if bools(1,1,1,1,1,1,0,1).look(:b_full) if $bar >= 1 and $bar <33
  #Sankt 01010011 01100001 01101110 01101011 01110100
  with_fx :pan, pan: 0.5 do
    with_fx :slicer, phase: 0.75, pulse_width: 0.75 do
      with_fx :bitcrusher, bits: 32, sample_rate: 15000, cutoff: 100 do
        sample :elec_blip, rate: 0.125, amp: 10 if bools(0,1,0,1,0,0,1,1,0,1,1,0,0,0,0,1,0,1,1,0,1,1,1,0,0,1,1,0,1,0,1,1,0,1,1,1,0,1,0,0).look(:b_full) if $bar < 4 or ($bar >= 24 and $bar < 33)
      end
    end
  end
  #F 01000110 (0,1,0,0,0,1,1,0)
  #C 01000011 (0,1,0,0,0,0,1,1)
  #S 01010011 (0,1,0,1,0,0,1,1)
  sample :drum_snare_soft if bools(0,1,0,1,0,0,1,1).rotate(1).look(:b_full) if $bar >= 2 and $bar <33
  #P 01010000 (0,1,0,1,0,0,1,1)
  sleep 0.5
end

live_loop :beat_eights do
  #stop
  #Pauli 01010000 01100001 01110101 01101100 01101001
  if $bar >= 6 and $bar <25
    sample :drum_cymbal_closed if bools(0,1,0,1,0,0,0,0,0,1,1,0,0,0,0,1,0,1,1,1,0,1,0,1,0,1,1,0,1,1,0,0,0,1,1,0,1,0,0,1).tick(:b_eights)
  end
  sleep 0.125
end

live_loop :bass do
  with_random_seed 1910 do
    #we 01110111 01100101
    16.times do
      if bools(0,1,1,1,0,1,1,1,0,1,1,0,0,1,0,1).reverse.rotate(2).tick(:bs_tick)
        with_fx :reverb, room: 0.25, mix: 0.3 do
          synth :fm, note: $a_chord.choose+[-24,-24,-12,-24].choose, release: 0.2, amp: 3 if $bar >= 4 and $bar <25
        end
      end
      sleep 0.125
    end
  end
end

live_loop :melody do
  #stop
  if $bar >= 8 and $bar <21
    with_fx :ixi_techno, cutoff_max: 110, cutoff_min: 90, res: 0.7, phase: 0.75 do
      64.times do
        tick(:mel_tick)
        synth :pluck, release: 0.5, amp: 2, note: $a_chord[0] if bools(0,1,1,1,0,1,1,1,0,1,1,0,0,1,0,1).reverse.look(:mel_tick)
        synth :pluck, release: 0.5, amp: 2, note: $a_chord[1] if bools(0,1,1,0,1,1,0,0,0,1,1,0,1,1,1,1,0,1,1,1,0,1,1,0,0,1,1,0,0,1,0,1).rotate(1).look(:mel_tick)
        synth :pluck, release: 0.5, amp: 2, note: $a_chord[2] if bools(0,1,0,1,0,0,1,1,0,1,1,0,0,0,0,1,0,1,1,0,1,1,1,0,0,1,1,0,1,0,1,1,0,1,1,1,0,1,0,0).look(:mel_tick)
        #synth :pluck, release: 0.5, amp: 2, note: $a_chord[3] if bools(0,1,0,1,0,0,0,0,0,1,1,0,0,0,0,1,0,1,1,1,0,1,0,1,0,1,1,0,1,1,0,0,0,1,1,0,1,0,0,1).look(:mel_tick)
        sleep 0.25
      end
      8.times do
        with_fx :ping_pong, phase: 0.75 do
          synth :pluck, sustain: 1.5, amp: 4, note: $a_chord[0]
          synth :pluck, sustain: 1.5, amp: 4, note: $a_chord[1]
          synth :pluck, sustain: 1.5, amp: 4, note: $a_chord[2]
          synth :pluck, sustain: 1.5, amp: 4, note: $a_chord[3]
          sleep 1
        end
      end
      128.times do
        tick(:mel_tick)
        synth :pluck, release: 0.5, amp: 2, note: $a_chord[0] if bools(0,1,1,1,0,1,1,1,0,1,1,0,0,1,0,1).reverse.look(:mel_tick)
        synth :pluck, release: 0.5, amp: 2, note: $a_chord[1] if bools(0,1,1,0,1,1,0,0,0,1,1,0,1,1,1,1,0,1,1,1,0,1,1,0,0,1,1,0,0,1,0,1).rotate(1).look(:mel_tick)
        synth :pluck, release: 0.5, amp: 2, note: $a_chord[2] if bools(0,1,0,1,0,0,1,1,0,1,1,0,0,0,0,1,0,1,1,0,1,1,1,0,0,1,1,0,1,0,1,1,0,1,1,1,0,1,0,0).look(:mel_tick)
        synth :pluck, release: 0.5, amp: 2, note: $a_chord[3] if bools(0,1,0,1,0,0,0,0,0,1,1,0,0,0,0,1,0,1,1,1,0,1,0,1,0,1,1,0,1,1,0,0,0,1,1,0,1,0,0,1).look(:mel_tick)
        sleep 0.125
      end
      8.times do
        with_fx :ping_pong, phase: 0.75 do
          synth :pluck, sustain: 1.5, amp: 4, note: $a_chord[0]
          synth :pluck, sustain: 1.5, amp: 4, note: $a_chord[1]
          synth :pluck, sustain: 1.5, amp: 4, note: $a_chord[2]
          synth :pluck, sustain: 1.5, amp: 4, note: $a_chord[3]
          sleep 1
        end
      end
    end
  else
    sleep 1
  end
end

Here is my idea.
And I know using global variables is not good, but if I use set and get its not in time. But this is a topic for another post.

1 Like

This is a very nice ‘framework’ for controlling active loops…
I think I’m going to be using it (or similar) in some of my
future twiddlings.

Eli…

1 Like