Kofi / Illestpreacha
Code is Poetry & Data is Poetry

Follow

Code is Poetry & Data is Poetry

Follow
Genuary2023_Textile

Genuary2023_Textile

Textile Drying: Night & Day

Kofi / Illestpreacha's photo
Kofi / Illestpreacha
·Jan 24, 2023·

4 min read

Table of contents

  • The prompt for Genuary 2023 Day 24 is
  • Textile

The prompt for Genuary 2023 Day 24 is

Textile

  • Using the Livecoding Environment BarbaraDesign to make the textile and overlay it with Hydra Code

    • For this prompt, decided to have a night & day version
  • Sound is coded in SonicPi, where the code is doing a real-time comparison of the difference between two files

    • One is based on words associated with the day and the other is associated with the night

    • While the SonicPi code is running, poems are being written in both docs, which modifies the sounds being heard

      • There will be an overlay of sounds for the audio portion: One for the real-time execution and the other is the same audio but in reverse

      • Audio is slowed down by 25% for the day version and 33% for the night version

      • The poem can be seen within the SonicPi code

Barbara Design Code

triangle rand-c color 180 rotate 8 10 translate
50 triangle red color 90 rotate 35 11 size
all repeat
50 triangle blue color 50 50 translate 40 10 size
50 triangle purple color 90 rotate 50 0 translate 35 50 scale
all repeat
rect rand-c color 70 35 rotate 14 7 translate
rect rand-c gradient 70 35 rotate 14 7 translate
triangle rand-c color 180 rotate 25 0 translate
triangle rand-c color 25 0 translate
triangle rand-c color 180 rotate 0 25 translate
rect rand-c color 97 19 rotate 43 6 translate 23 11 size
triangle rand-c color 0 25 rotate 5 15 translate
circle rand-c color 97 19 rotate 43 6 translate 17 5 size
triangle rand-c color 5 30 translate
duplicate 25 25 translate rand-c color
duplicate 180 rotate rand-c color
all repeat

HydraCode

  • NIght
//making 3 instances of the same screen

s0.initScreen()
s1.initScreen()
s2.initScreen()

src(s0).repeat(()=> (time % 25 + 1)/5).blend(src(s1).scale(2)).diff(o1).modulateScale(o2).out(o0)

src(s1).pixelate(10000,1000).out(o2)

src(s2).scale(0.33).scroll(()=> Math.sin(time % 25)/10).out(o1)
  • Day
//making 3 instances of the same screen share
s0.initScreen()
s1.initScreen()
s2.initScreen()

src(s0).repeat(()=> (time % 25 + 1)/5).blend(src(s1).scale(2)).layer(o1).modulateScale(o2).out(o0)

src(s1).pixelate(10000,1000).out(o2)

src(s2).scale(0.33).scroll(()=> Math.sin(time % 25)/10).out(o1)

SonicPi Code

=begin

---Text Being Compared

--Day
The sky is ready to be bright
Not by the moon but by the sun
The sun is willing to provide some heat
As this is complete
Between the Sun and the moon
For they both share a room
That we call the sky
As they both shine
The sun engulfs the skyline
With it hues

--Night
The night is calling
The words are stalling
The moon is bright
Which makes the stars in delight
As they shine
As they go along with their time
For the darkness of the sky
Is what makes them arise
Oh well, this is the case
When the darkness emulates the space


=end



require 'uri'
require 'open-uri'

class LiveWriting
  def initialize(url)
    @url = url
  end

  #lines breakdown
  def lines
    uri = @url
    uri = URI.parse(url)

    puts uri

    #gsub replaces a substring, in this case the left over "r"
    poetry1 = uri.read.gsub("\r","") #reads the file

    poemLines = poetry1.split("\n") #split into lines, not words
  end

  #words breakdown
  def words
    uri = @url
    uri = URI.parse(url)

    puts uri

    #gsub replaces a substring, in this case the left over "r"
    poetry1 = uri.read.gsub("\r","") #reads the file

    poemWords = poetry1.split(" ") #split into words
  end

  #character breakdown
  def char
    uri = @url
    uri = URI.parse(url)

    puts uri

    #gsub replaces a substring, in this case the left over "r"
    poetry1 = uri.read.gsub("\r","") #reads the file

    poemChars = poetry1.split("") #split into words
  end
end

#hamming distance but going to add 1 in this test run since these are identical
def hamming_distance(str1, str2)
  distance = 0
  str1.each_char.with_index do |char, i|
    distance += 1 if char != str2[i]
  end
  distance + 10
end

#checking to see which one of the four possibilites the char can be in
def charRange(char1,char2)
  if char1.between?('a', 'm') and char2.between?('a','m')
    sample :drum_bass_hard, sustain: 4
  elsif char1.between?('a', 'm') and char2.between?('m','z')
    sample :elec_blip, decay: 6
  elsif char1.between?('m', 'z') and char2.between?('a','m')
    sample :tabla_ghe1, attack: 5
  elsif char1.between?('m','z') and char2.between?('m','z')
    sample :perc_snap, sustain: dice(7)
  else
    sample :ambi_piano
  end
end

piece = LiveWriting.new("https://docs.google.com/document/d/1acj3B_WLJLuJxtxaclYPDlwnND8I8G3SPel0WJeFipM/export?format=txt")
piece2 = LiveWriting.new("https://docs.google.com/document/d/1oPW5hr1fg7O3EjWnv3C-JzZjJTBxRlNhQbH1zz1MXII/export?format=txt")

#puts piece.lines
#puts piece2.lines
#puts piece.words
#puts piece2.words
#puts piece.char
#puts piece2.char

i = 0
live_loop :wordCheck do  #while loop

  shuffle1 = piece.words.shuffle()
  shuffle2 = piece2.words.shuffle()

  #hamming distance
  use_synth :piano

  puts shuffle1[i]
  puts shuffle2[i]

  play hamming_distance(shuffle1[i],shuffle2[i])
  #distancing = hamming_distance(shuffle1[i],shuffle2[i])

  i += 1 #increment

  if i >= piece.words.length - 1 #make the loop nonstop of the whole array
    i = 0
  end

  sleep [4,8].choose

end

j = 0
live_loop :lineCheck do  #while loop

  shuffle1 = piece.lines.shuffle()
  shuffle2 = piece2.lines.shuffle()

  #hamming distance
  use_synth :piano
  puts shuffle1[j]
  puts shuffle2[j]

  distancing = hamming_distance(shuffle1[j],shuffle2[j])

  play distancing, sustain: (distancing - shuffle2[j].length).abs * 2


  j += 1 #increment

  if j >= piece.lines.length - 1 #make the loop nonstop of the whole array
    j = 0
  end

  sleep [3,4,5,6].choose

end

k = 0
live_loop :charCheck do  #while loop

  shuffle1 = piece.char.shuffle()
  shuffle2 = piece2.char.shuffle()


  puts shuffle1[k]
  puts shuffle2[k]

  charRange(shuffle1[k],shuffle2[k])

  k += 1 #increment

  if k >= piece.char.length - 1 #make the loop nonstop of the whole array
    k = 0
  end

  sleep [3,5,7,9].choose

end
 
Share this