WCCC_Lines

LinesUponLines

For this week's Creative Code challenge by @sableRaph: “Only Lines ”, LinesUponLines uses Line Based equations/functions in SonicPi & LiveCodelab

The Point to Plane and Line to Plane equations in the SonicPi code were previously used in Genuary 2024, where these linear algebra components were used to create the sound.

While the LiveCodeLab sketch contains various collages of the same piece of code.

Poetry

Lines Upon Lines
Lines Across
Lines Underneath
Lines Wanting to speak
Lines itching to creep
Lines willing to weep
Lines embracing a leak
Lines feeling a loss
Just Lines Upon Lines

Video

Code

LiveCodeLab

if time % 30 > 20
    animationStyle motionBlur
    simpleGradient color(154 + time % 30 * 2,155 - sin(time)* 50,tan(time)/sin(time) - 0.2),color((time % 30)*7 + 24,abs(sin(time) * 244),(cos(time) * cos(time)) * 255), color(255 - (time % 45 * 5),200/time % 12 + 1,155)

if time % 30 < 10
    animationStyle paintOver
    simpleGradient color((time % 30)*7 + 24,abs(sin(time) * 244),(cos(time) * cos(time)) * 255), color(255 - (time % 45 * 5),200/time % 12 + 1,155),color(154 + time % 30 * 2,155 - sin(time)* 50,tan(time)/sin(time) - 0.2)

if time % 30 > 10 && time % 30 < 20
    simpleGradient color((time % 30)*7 + 24,abs(sin(time) * 244),(cos(time) * cos(time)) * 255),color(154 + time % 30 * 2,155 - sin(time)* 50,tan(time)/sin(time) - 0.2), color(255 - (time % 45 * 5),200/time % 12 + 1,155)

scale time % 12  / 2 + 1
rotate time, time / 2, time / 3

90 + (time % 15)*10  times

    pushMatrix
    rotate time % 6, time % 17, time % 32
    line
    rotate sin(time)
    move 0.5, 0, Math.hypot(wave(0.003),time % 6) * 4
    line
    popMatrix

    pushMatrix
    move -0.5, 0, 0
    line
    move 0.5,-0.5,0
        orange
    line time % 6
    popMatrix

SonicPi

#linear algebra - point to a plane forumla

# distance between point and
# plane is: d = |Axo + Byo + Czo + D |/√(A**2 + B**2 + C**2)

#pt_$ = variable for points
#pl_$ = variable for plane



def pointToPlane (pt_a,pt_b,pt_c, pl_a,pl_b,pl_c,pl_d)

  use_random_seed (Time.now.to_i)/5

  point_a = [pt_a,pt_b,pt_c]
  plane_a = [pl_a,pl_b,pl_c,pl_d]

  #dot product of the point and planes
  dot = point_a[0]*plane_a[0] + point_a[1] * plane_a[1] + point_a[2] * plane_a[2] + plane_a[3]

  #the distance of the point to plane
  return plane_D = dot / Math.sqrt(plane_a[0] ** 2 + plane_a[1] ** 2 + plane_a[2] ** 2)

  #puts plane_D
end

def lineToPlane(xt,yt,zt, pl_a,pl_b,pl_c,pl_d)

  use_random_seed (Time.now.to_i)/4

  t = 0

  # line to point
  point_a = [xt + t,yt * t + yt,zt * 2]

  plane_a = [pl_a,pl_b,pl_c,pl_d]

  #dot product of the point and planes
  dot = point_a[0]*plane_a[0] + point_a[1] * plane_a[1] + point_a[2] * plane_a[2] + plane_a[3]

  #the distance of the point to plane
  return plane_D = dot / Math.sqrt(plane_a[0] ** 2 + plane_a[1] ** 2 + plane_a[2] ** 2)

  #puts plane_D
end

#the rate of the loops are determined by the distance to the plane
#as well as the sustain length


live_loop :lineToPlaneDistance do
  use_random_seed (Time.now.to_i)/2
  speed = lineToPlane(dice(5),dice(9),rrand_i(1,12),dice(10),8,rrand_i(-4,4),[0,1,2,3,4].choose)
  sample [:loop_perc1,:ambi_dark_woosh].choose, rate: speed + 0.1, sustain: speed, amp: dice(5)
  sleep [0.5,1,1.5,2,4].choose
end


live_loop :pointToPlaneDistance do
  use_random_seed (Time.now.to_i)
  speed = pointToPlane(dice(3),dice(4),rrand_i(0,3),dice(10),8,rrand_i(-4,4),[0,1,2,3,4].choose)
  speed2 = pointToPlane(rrand_i(0,3),5,dice(4),dice(10),rrand_i(-4,4),9,[0,1,2,3,4].tick)
  sample [:loop_electric,:elec_chime].choose, rate: speed, sustain: speed2, amp: dice(5)
  sleep [0.5,1,1.5,2].choose
end


live_loop :DistanceToDistance do
  use_random_seed (Time.now.to_i)/3

  speed = pointToPlane(dice(3),dice(4),rrand_i(0,3),dice(10),8,rrand_i(-4,4),[0,1,2,3,4].choose)
  speed2 = lineToPlane(rrand_i(0,3),5,dice(4),dice(10),rrand_i(-4,4),9,[0,1,2,3,4].tick)

  #undecided geometry
  distToDist = speed + speed2
  distXdist = speed * speed2
  dist_dist = speed / speed2

  #points into circle
  circumference = (2 * Math::PI * ([distToDist,distXdist,dist_dist].choose)).abs
  area = Math::PI * (distToDist ** 2)

  play [circumference,circumference/2], decay: rrand(1,4)
  sample [:ambi_drone,:elec_beep,:drum_splash_hard,:guit_em9].choose, beat_stretch: area / 80

  sleep [0.5,1,1.5,2,4].choose
end



live_loop :pointing do

  #random seeding based on time
  use_random_seed (Time.now.to_i) /2

  #pointX = the x value of the points
  pointX = [dice(8)+3,dice(9)-5]

  #pointY = the y value of the points
  pointY = [rrand_i(-5,10),rrand_i(-10,20)]

  #making the point to line using distance formula
  Line_Distance = Math.sqrt((pointX[1] - pointX[0])**2 + (pointY[1] - pointY[0])**2)

  #playing the sounds, the notes and pitch are based on the line made
  with_fx :ping_pong do
    use_synth [:piano,:prophet].choose
    play Line_Distance, pitch: Line_Distance, rate: Line_Distance/2, amp: 7
  end


  sleep [0.25,0.5,0.75,1,1.5,2].choose
end
0
Subscribe to my newsletter

Read articles from Kofi / Illestpreacha directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Kofi / Illestpreacha
Kofi / Illestpreacha