# WCCC_Blue

# WavyBlues

For this week's Creative Code challenge by @sableRaph:***"Blue”,*** **WavyBlues** is coded in ***LiveCodeLab, Hydra & SonicPi .***

***LiveCodeLab & Hydra*** are used to visualizes various shades of blues while the audio is coded ***SonicPi*** with an aquafication of a color matrix (since aqua is a type of blue and a previous WCCC entry: [https://blog.illestpreacha.com/wcccaqua](https://blog.illestpreacha.com/wcccaqua))

## **Poem**

```ocaml
While taking this ride
While looking onto the sky
As we take this flight to swim
In these waters that are open
Not knowing which direction will be right
Or wrong
Or rather left
Itching to belong
Or be left I should say in these depths
In this portion of the ocean
That this entity belongs
And location is based on a whim
```

## Video

%[https://youtu.be/86WvNkvMH18] 

## Hydra

```javascript
s0.initScreen()

 osc(1,1,1).color(0,0,1).modulateRotate(noise(1,3,1).scrollX([0.5,-0.25,0.1])).brightness(0.5).luma(0.3).modulateScale(src(s0).kaleid(4).repeat(3,3)).out()

speed = 0.5
 
```

```javascript
s0.initScreen()
s1.initScreen()

src(s0).scrollX(0.5,[0.5,-0.3,0.1]).repeat(3,3).modulatePixelate(src(s1).scale(2)).modulateRotate(osc(1,1,1).scale([0.5,1,2].smooth()).blend(src(s1).blend(noise(3,1,1)))).modulateScale(src(s0).kaleid(4),0.75).out()
```

```javascript
s0.initScreen()
s1.initScreen()

src(s0).scrollX(0.5,[0.5,-0.3,0.1]).repeat(3,3).modulate(src(s0).scale(2)).modulateRotate(osc(1,1,1).scale([0.5,1,2].smooth()).blend(src(s1).blend(noise(3,1,1)))).modulateScale(src(s0).kaleid(4),0.75).out()
```

## LiveCodeLab

```javascript
if time % 10  > 7
	simpleGradient teal,blue,aqua
	fill blue
	stroke teal
else if time % 10 < 3
	simpleGradient navy,turquoise,powderblue
	fill teal
	stroke aqua
else
	simpleGradient lightblue,deepskyblue,midnightblue
	fill midnightblue
	stroke lightblue

4 times
box wave(0.003)
move sin(time), cos(time)
```

```javascript
if time % 10  > 7
	simpleGradient teal,blue,aqua
	fill navy
	stroke turquoise
else if time % 10 < 3
	simpleGradient navy,turquoise,powderblue
	fill blue
	stroke aqua
else
	simpleGradient lightblue,deepskyblue,midnightblue
	fill powderblue
	stroke teal

ball sin(time)
```

## SonicPi

```ruby
#In This Remix, I made sure the variables of Aqua was switched in every computation

#Colors pair 1
Aqua = [0,255,255]
Coral = [255,127,80]

#Colors Pair 2
Lavender = [230, 230, 250]
Gold = [255,215,0]

#Colors Pair 3
MidnightBlue = [25,25,112]
DarkOrange = [255,140,0]

#Colors Pair 4
SlateGray = [112, 128, 144]
Crimson = [220,20,60]


def linear_transform(matrixA,vectorA)
  
  #this is the first row of the matrix
  row1 = matrixA[0]
  #this is the second row of the matrix
  row2 = matrixA[1]
  #this is the third row of the matrix
  row3 = matrixA[2]
  
  #this is the first val of the vector
  vec_x = vectorA[0]
  #this is the second val of the vector
  vec_y = vectorA[1]
  #this is the third val of the vector
  vec_z = vectorA[2]
  
  
  #this is the first value of the new vector
  vec_x_formed = [row1[0]*vec_x + row1[1]*vec_y + row1[2]*vec_z]
  #this is the second value of the new vector
  vec_y_formed= [row2[0]*vec_x + row2[1]*vec_y + row2[2]*vec_z]
  #this is the third value of the new vector
  vec_z_formed = [row3[0]*vec_x + row3[1]*vec_y + row3[2]*vec_z]
  
  #new vector
  vec_change = [vec_x_formed[0],vec_y_formed[0],vec_z_formed[0]]
  
  
end

def color_det2(loop,row1,row2,spread1,spread2)
  
  
  #Cramers Rule with Colors
  
  x1a = row1[0]
  x2a = row1[1]
  b_a = row1[2]
  
  x1b = row2[0]
  x2b = row2[1]
  b_b = row2[2]
  
  #determinant of main matrix [x1a,x2a,x1b,x2b]
  det_a = ((x1a * x2b) - (x2a * x1b)).to_f
  
  #determinant of main matrix but first column replace by b_a & b_B
  det_b = (b_a * x2b) - (x2a * b_b)
  
  #determinant of main matrix but second column replace by b_a & b_B
  det_c = (x1a * b_b) - (b_a * x1b)
  
  #the solving of the above equations
  
  det_1 = det_b/det_a
  det_2 = det_c/det_a
  
  puts det_1
  puts det_2
  
  #a ring of halves (120 60 30 15 7.5) then ticks
  #line does the same with steps, using it for the sleep chase
  bpm_chase = (halves 120, 5)
  sleep_chase = (line 0, 4, steps: 4)
  
  live_loop loop do
    use_bpm bpm_chase.choose
    use_random_seed Time.now.to_i
    with_fx :ping_pong, mix: rrand(0.4,0.65) do
      sample [:ambi_choir,:drum_snare_hard,:drum_tom_mid_soft].choose, rate: det_1,beat_stretch: (det_2).abs, pitch: det_1/det_2 if spread(spread1,spread2).tick
      sleep [(det_1+det_2).abs, (spread1/spread2) + sleep_chase.tick].choose
    end
    
    
    with_fx :echo do
      use_synth [:piano,:chiplead,:dull_bell,:piano].choose
      play det_2/det_1
    end
    
  end
end

def color_det(loop,row1,row2)
  
  
  #Cramers Rule with Colors
  
  x1a = row1[0]
  x2a = row1[1]
  b_a = row1[2]
  
  x1b = row2[0]
  x2b = row2[1]
  b_b = row2[2]
  
  #determinant of main matrix [x1a,x2a,x1b,x2b]
  det_a = ((x1a * x2b) - (x2a * x1b)).to_f
  
  #determinant of main matrix but first column replace by b_a & b_B
  det_b = (b_a * x2b) - (x2a * b_b)
  
  #determinant of main matrix but second column replace by b_a & b_B
  det_c = (x1a * b_b) - (b_a * x1b)
  
  #the solving of the above equations
  
  det_1 = det_b/det_a
  det_2 = det_c/det_a
  
  puts det_1
  puts det_2
  
  sample
  
  live_loop loop do
    use_random_seed Time.now.to_i
    with_fx :ping_pong, mix: rrand(0.4,0.65) do
      
      sample [:ambi_choir,:glitch_perc3,:bass_woodsy_c].choose, rate: [det_1,det_2].choose,beat_stretch: [(det_2).abs,(det_1).abs].tick, pitch: [det_1/det_2,det_2/det_1].choose
      sleep (det_1+det_2).abs
      
      use_synth :piano
      play (det_1/det_2).abs
      
      with_fx :krush do
        use_synth :prophet
        play (det_2/det_1).abs
      end
    end
  end
end


#this mathematical sections turns the combo of Aqua, Lavender, Gold into Cyber Neon Green
#R,G,B(0,250,40)

color_matrix1 = [Aqua, Lavender, Gold]
first_vector = [1,-1,1]

CyberNeonGreen = linear_transform(color_matrix1,first_vector) #not cybergreen no more due to aqua inclusion

#this mathematical sections turns the combo of Aqua, DarkOrange, MidnightBLue into
color_matrix2 = [Aqua, DarkOrange, MidnightBlue]
second_vector = [1,-1,1.75]

SoftPink = linear_transform(color_matrix2,second_vector) #not softpink due to the aqua inclusion

color_matrix3 = [Crimson, Aqua, Coral]
third_vector = [0.5,1,2]

CucumberIce  = linear_transform(color_matrix3,third_vector)
#getting the traces
color_mx1_trace = color_matrix1[0][0] + color_matrix1[1][1] + color_matrix2[2][2]
color_mx2_trace = color_matrix2[0][0] + color_matrix2[1][1] + color_matrix2[2][2]
color_mx3_trace = color_matrix3[0][0] + color_matrix3[1][1] + color_matrix3[2][2]


live_loop :ColorBending do
  use_random_seed Time.now.to_i / 2
  
  with_fx :whammy, mix: 0.25 do
    color_det(:aquaVcoral,Aqua,Coral)
    sleep [0.5,1,4].choose
    color_det(:LavenderVgold, Lavender, Gold)
    sleep [0.5,1,2].choose
    color_det(:MidnightvsOrange,MidnightBlue, DarkOrange)
    sleep 2
    color_det(:GrayvCrimson,SlateGray, Crimson)
    sleep [1,2].choose
  end
  
  with_fx :hpf do
    with_fx [:wobble,:ping_pong].choose, mix: rrand(0.2,0.6) do
      with_fx [:ping_pong,:vowel].choose,  mix: rrand(0.25,0.75) do
        color_det(:aquaVGold,Aqua,Gold)
        sleep [2,4,8].choose
        color_det(:CrimsonVAqua,Crimson,Aqua)
        sleep [2,4,8].choose
        color_det(:AquaVOrange,DarkOrange,Aqua)
        color_det(:GrayvAqua,SlateGray, Aqua)
      end
    end
  end
  
  
  sleep [0.5,1,2,4].choose
end

live_loop :colortwisting do
  with_fx :echo, mix: 0.65 do
    with_fx :ping_pong do
      color_det2(:CybervsSoft,CyberNeonGreen,SoftPink,color_mx1_trace,color_mx2_trace)
      sleep [2,4,8].choose
      color_det2(:IcevsWarmth,SoftPink,CucumberIce,color_mx2_trace,color_mx3_trace)
      sleep [2,4,8].choose
      color_det2(:IcevsCyber,CucumberIce,CyberNeonGreen,color_mx3_trace,color_mx1_trace)
      sleep [3,6,9].choose
    end
  end
  sleep [0.5,1,2].choose
end


#//3 x 3 matrix sound by random numbers between 0  & 30
live_loop :choirflow do
  use_random_seed Time.now.to_i
  
  #using the halves with a random integer
  bpm_chase = (halves 120, rrand_i(4,9))
  use_bpm bpm_chase.reverse.tick
  
  y = rrand(0,30)
  puts y
  
  pos = [y*2,y-21,y,y+3,(y-7).abs,y+5,y/4, y/5+2, y-14]
  
  a = pos[0]
  b = pos[1]
  c = pos[2]
  d = pos[3]
  e = pos[4]
  f = pos[5]
  g = pos[6]
  h = pos[7]
  i = pos[8]
  
  #//recoding into Matrix Coordinates
  
  A11 = a
  A12 = b
  A13 = c
  A21 = d
  A22 = e
  A23 = f
  A31 = g
  A32 = h
  A33 = i
  
  
  #//determinant formula
  det_a = a*(e*i - f*h) - b*(d*i - f*g) + c*(d*h - e*g)
  trace = a + e +  i
  normal = Math.sqrt(a*a + b*b + c*c + d*d + e*e + f*f + g*g + h*h +  i*i)
  
  #//Adjoint Formula
  
  Adj_a = (A22*A33 - A23*A32)
  Adj_b = -1 * (A12 * A33 - A13 * A32)
  Adj_c = A12 * A23 - A13 * A22
  Adj_d = -1 * (A21 * A33 - A23 * A31)
  Adj_e = (A11 * A33 - A13 * A31)
  Adj_f = -1 * (A11 * A23 - A13 * A21)
  Adj_g = (A21 * A32 - A22 * A31)
  Adj_h = -1 *(A11 * A32 - A12 * A31)
  Adj_i = (A11 * A22 - A12 * A21)
  
  #inverse formula
  #*A-1 = (adj A)/(det A)*/
  
  inv_a = Adj_a/det_a
  inv_b = Adj_b/det_a
  inv_c = Adj_c/det_a
  inv_d = Adj_d/det_a
  inv_e = Adj_e/det_a
  inv_f = Adj_f/det_a
  inv_g = Adj_g/det_a
  inv_h = Adj_h/det_a
  inv_i = Adj_i/det_a
  
  
  counter_tick = (line 0, 14, steps: 7)
  
  
  sample :ambi_choir, decay: Adj_a.abs, rate: inv_a if spread(5,12).tick
  sample [:ambi_choir,:loop_breakbeat].choose , decay: Adj_b.abs, rate: inv_b
  sample :ambi_choir , decay: Adj_c.abs, rate: inv_c if spread(19,39).tick
  sleep [1,2,4,8].choose
  sample [:ambi_choir,:tabla_ghe3].tick , decay: Adj_d.abs, rate: inv_d
  sample :ambi_choir , decay: Adj_e.abs, rate: inv_e
  sample [:ambi_choir,:loop_weirdo].choose , decay: Adj_f.abs, rate: inv_f if spread(27 - counter_tick.tick,195).tick
  sleep [4,8,16].choose
  puts inv_i
  
  sleep [0.5,1,2,4].choose
  
end


```
