# MinaCoding2024_FavoriteSong

# GridsToNoise

For the 1st day of **MinaCoding2024 : "Favorite Song"** will be coded in **SonicPi** with the array made in **Python.**

**GridToNoise** remixes a previous ***SonicPi*** coded composition that has been a favorite as of late to code with and sonifies a 16 x 16 array through various ways to produce the sound

## Poetry

```apache
Magic that is within
Others may not see
But for the beholder
it is never hidden
As it is a folder
That holds the gateway to the rhythm
That has its own ocean, its own sea
That may open to its own breeze
The magic that is within
That others may not see
```

## Audio

<iframe width="100%" height="300" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/1834696206&color=%23ff5500&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true&visual=true"></iframe>

[IllestPreacha](https://soundcloud.com/llestreacha) · [GridToNoise](https://soundcloud.com/llestreacha/gridtonoise)

## Code

### SonicPi

```ruby
use_random_seed Time.now.to_i

#array made from a python script

def sonification(shipyard,looping,sampling)
  
  live_loop looping do
    
    #iterating the 2d arrays
    for i in (0...shipyard.size) #overall size of range
      for j in (0...shipyard[i].length) #overall length of the arrays
        
        #these variables will be the main event trigger for each scenario, through different uses
        
        x = shipyard[i][j]
        y = Math.sqrt(shipyard[i][j])
        case x #using case & when as a switch while using
        
        when 1..3
          with_fx :ping_pong, mix: 0.65 do
            with_fx :ixi_techno, mix: 0.75 do
              with_fx [:echo,:whammy].choose, mix: rrand(0.4,0.8) do
                sample [:loop_safari,:tabla_ghe4].choose, amp: 6, rate: x * rrand_i(-2,2) + 0.01, beat_stretch: y
              end
            end
          end
          
        when 4..6
          with_fx [:ping_pong,:vowel].choose, mix: rrand(0.4,0.8) do
            sample [:elec_blip,:elec_blip2,:elec_bong].choose, beat_stretch: y + 1, amp: x - 1, decay: x + 1
          end
          
        when 7..9
          if x % 2 == 0
            use_synth :piano
            n = ring(:b3,:c4,:c5,:d6,:e7,x*9,x*12)
          else
            use_synth [:prophet,:chipbass,:chiplead].choose
            n = ring(:c5,:a4,:b1,x*7)
          end
          
          with_fx :wobble do
            play n.tick, on: spread(x+6,24).look, release: (x/24), pan: -0.5
          end
          
        else
          with_fx [:ping_pong,:flanger,:whammy].choose, amp: 1, mix: rrand(0.4,0.8) do
            sample sampling, attack: x, beat_stretch: (x-3).abs
          end
        end
        
        sleep [0.5,0.75,1,1.5,2].choose #pause in between each spawn, replicating the different thinking processes
      end
    end
  end
  
end


#following a tick format

sonification(shipyard5,:yard5,:ambi_glass_hum)
sonification(shipyard4,:yard4,:ambi_glass_rub)
sonification(shipyard3,:yard3,:ambi_piano)
sonification(shipyard2,:yard2,:ambi_glass_hum)
sonification(shipyard1,:yard1,:ambi_piano)

#following a shuffle format

sonification(shipyard1.shuffle,:yard1mix,:ambi_choir)
sonification(shipyard3.shuffle,:yard3mix,:ambi_lunar_land)
sonification(shipyard5.shuffle,:yard5mix,:ambi_soft_buzz)
```

### Python

```ruby
#originally coded for battleships but transformed into a 16 x 16 array maker

import numpy as np
import seaborn as sns
import matplotlib.pylab as plt

def battle():
    
    boats = [0,1,2,3,4,5,6,7,8,9,10,11]
    prob = [0.025,0.025,0.05,0.05,0.05,0.05,0.1,0.1,0.1,0.1,0.2,0.15]

    #by adding the (10,10) instead of 5, able to make an array with the weighted values
    shipyard2 = np.random.choice(boats, (16,16), p=prob)
    return shipyard2



def plotting(x):
    letters = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P'] #set for the columns
    uniform_data = x
    ax = sns.heatmap(uniform_data, linewidth=0.5,cmap="Reds") #changing it to blue for ocean representation
    ax.set_xticklabels(letters) #setting the ticks of the x axis to letters
    plt.show()
    return x
    
plotting(battle())
```

### Array

```ruby


shipyard1 = [[ 7,  2,  8,  6,  4, 11,  6,  7, 11,  7, 10, 10, 10,  5, 11,  7],
             [ 5,  5, 10,  8,  1,  4, 10, 11, 10, 11,  6, 10, 11, 10,  2,  4],
             [11,  1,  8,  9, 10,  7, 10, 10,  5, 10,  9,  6,  6,  1,  9, 11],
             [10,  8, 10,  6, 11,  1,  5,  9,  6,  1, 10,  4, 10,  7, 10,  7],
             [10,  8, 10, 10,  7,  4,  1,  9, 11,  9, 10,  2,  7, 10,  8,  5],
             [10,  8, 10,  9, 10,  8,  8,  9, 10, 11,  8,  3, 10,  5, 10,  8],
             [ 2,  3,  5, 10,  7,  9, 11,  6,  6,  6,  3, 10,  7,  6, 10,  3],
             [ 9, 11,  9,  9, 10, 11, 11, 10, 11,  7, 10, 10,  7,  6,  8,  6],
             [11,  4,  6,  7, 11, 10,  5,  6,  6, 11,  0,  9,  8, 10, 11,  9],
             [ 4,  7, 11,  6,  7,  9, 11,  9,  1,  9,  8, 11,  3,  9,  6,  8],
             [ 3, 11,  3, 10,  7,  9, 10,  4,  0,  7,  6, 11,  2,  8, 10, 11],
             [ 7,  6, 10,  1, 11,  2,  3, 10,  6,  8,  4, 11,  3,  8,  8,  6],
             [ 4,  2,  1, 11,  1, 11, 11,  8,  6, 10,  8, 10,  1, 10,  4, 10],
             [ 8,  6,  8,  3,  5, 10,  9,  2, 10, 11,  7,  6, 10, 11, 11,  9],
             [ 8,  7, 11, 10,  1, 10,  8, 10,  4,  9, 10,  3,  7, 11,  7,  4],
             [ 8,  8, 10,  5,  9,  0,  2, 10,  9,  5,  0, 10,  6,  0, 10, 11]]

shipyard2 = [[ 8, 10,  7,  6,  4,  7, 10,  1,  5,  8, 10,  9,  6,  9, 10,  5],
             [11,  3,  8, 10,  8, 10,  4,  7, 10,  7, 10,  7, 10, 10, 10, 10],
             [ 7,  5,  7, 10,  7,  7,  8, 10, 10,  3,  6, 10, 11,  6,  6,  9],
             [10, 11,  6, 10,  9, 11, 11,  2,  4,  9,  9,  2,  8,  1, 11,  1],
             [11,  9, 10, 11,  9,  9,  7,  2,  6,  9, 10, 11,  9,  9,  0, 11],
             [ 8,  6,  9,  9, 10,  4,  6, 10,  7,  4,  9, 11,  4,  8,  6,  7],
             [11,  6,  6,  4, 10,  2,  6,  4,  7,  2,  7,  9, 10, 10, 10,  9],
             [ 8,  0, 11,  8,  1, 11,  5,  7, 10,  7,  7,  5, 11,  0, 10,  1],
             [10,  8,  1,  5, 10,  7,  8,  7, 11,  4,  2,  4,  2, 10,  8, 10],
             [ 1, 11,  2,  5,  7, 11, 11,  2,  7,  3,  6, 10,  8,  8, 10,  4],
             [ 6, 10,  6,  6, 10,  2,  9,  5,  8,  6,  8, 10,  1, 11, 10,  6],
             [ 9,  7,  9,  4,  1,  6,  6,  7,  8,  9, 10, 11,  6,  6, 10,  8],
             [ 9,  3, 10,  7,  0, 11, 10,  5, 11, 11,  9,  7,  8, 10, 10,  0],
             [ 2, 11,  6, 10,  9,  7,  1, 10,  7,  0,  0,  9,  7,  8,  3,  8],
             [ 3,  9,  5, 10,  2,  7,  4,  6,  2,  1,  4,  5,  6,  3, 10,  7],
             [ 4, 10,  6,  9,  7, 10,  6,  4, 11,  5,  4,  3,  8, 10,  9,  6]]


shipyard3 = [[10, 11,  6,  7,  8,  6,  6,  4, 10, 11,  2,  2,  2, 10,  6, 10],
             [ 2, 10,  7, 10,  8,  7, 10,  1,  8,  3, 11,  7,  8,  5, 10,  7],
             [ 9, 10,  6,  9,  8,  0,  8, 11,  3,  6,  4, 10,  5, 11,  8,  2],
             [ 7,  7,  3,  6, 11,  6,  3, 10,  7,  7,  8,  7,  6,  8, 11,  3],
             [ 9, 10, 10,  9, 10, 10, 10,  6,  8,  5, 10,  8, 11,  6,  2, 11],
             [10, 10,  2, 10,  7,  5,  5,  6,  7,  9,  5, 10, 11,  7,  9, 10],
             [ 7, 10, 10, 10,  9, 10,  6, 10,  2, 11,  8,  8,  7, 10,  1,  8],
             [11, 10, 11, 10,  8, 10,  8,  9, 10, 10, 10, 10, 10,  2,  0,  3],
             [10, 11,  7,  8, 10, 11,  7,  4, 11,  8,  2,  2, 10,  1,  1,  4],
             [ 5,  6, 11, 10,  2,  1,  6,  5,  7,  2,  8,  8,  8,  6,  5,  4],
             [10,  8,  4,  3, 10,  7, 11,  6,  8,  5,  5,  8,  9,  7,  7, 10],
             [ 7, 11, 11,  2,  9,  3,  9,  8,  9, 11,  7,  6, 11, 11,  4,  2],
             [ 6, 10,  9, 11,  4, 11,  8,  3,  4,  8, 11,  7, 11,  6,  3,  8],
             [ 9,  8,  4,  4, 11,  8,  8, 10, 11,  9,  3, 10, 11, 10,  7,  6],
             [ 4,  5,  9,  4,  1,  7, 10,  5, 10,  6, 11, 11,  0,  0,  8,  7],
             [ 6, 10, 10, 11, 10,  0, 10,  2,  6,  0,  0,  6, 10,  9,  9,  8]]


shipyard4 = [[10, 10,  6,  8,  9,  7,  6,  9, 11,  4,  6,  3,  3,  2,  6, 10],
             [ 1, 11, 11,  9,  5,  6,  8,  1, 10,  7,  3,  3, 10, 11, 10,  5],
             [ 3, 10,  4, 10, 10,  7,  6,  8,  7,  1, 11,  2,  7, 10,  4, 10],
             [ 3, 10,  6,  7,  8,  6,  1,  7,  8,  7,  6,  8,  4,  7,  6, 11],
             [ 9, 10,  9, 11, 10,  8,  7,  4,  5, 11, 11,  3,  9,  7, 10,  7],
             [ 3,  8,  7,  8, 10, 10,  3,  5,  9,  8,  8,  6,  7,  7, 10, 10],
             [ 3,  8,  1,  2,  7,  4,  9,  7,  2, 10,  3,  6,  0,  1, 10,  7],
             [10,  5, 11,  3,  5,  6, 10,  6,  8,  8,  6,  8,  7,  3,  4,  7],
             [ 7,  8,  2,  9,  6, 11,  7,  8,  1,  7, 11, 11, 10,  7, 11, 11],
             [ 5, 11,  0, 11,  6, 10,  5,  9,  9,  6, 10, 10,  8,  1,  9, 11],
             [ 6,  0, 10, 10, 11,  3,  5,  7,  6,  9, 11,  6,  6, 11, 10, 10],
             [ 2,  6, 10,  5, 10,  8,  1,  8, 11,  8,  4,  8, 11,  9, 10, 10],
             [ 6, 11, 11,  6,  7,  8,  2,  8,  8,  6, 10,  8, 10,  7,  2,  3],
             [10,  2, 10,  7,  6,  6, 11, 10,  1,  6, 10, 10, 11,  7, 11, 10],
             [ 8, 11,  9,  8, 10,  9, 10, 10,  3, 11,  5, 11, 10,  7, 11,  3],
             [10,  6, 10,  9, 10,  2,  1,  7,  9,  7,  7,  6,  5,  7,  8, 10]]


shipyard5 = [[11,  7,  6,  9, 10,  2, 10,  5,  8,  3,  6, 10,  6,  0,  9,  3],
             [ 9, 11,  2, 10,  8,  2,  9,  4, 11, 10,  3,  0,  9, 10,  2,  7],
             [10,  6, 11,  6, 11,  9,  0,  7,  9, 11, 11,  5,  7, 11,  8, 11],
             [ 9,  3,  1,  9, 11,  9,  6,  2, 10,  2, 10,  6,  5,  6,  9,  9],
             [10,  5,  6,  3,  9,  5,  5, 11,  6,  3,  6, 10,  3,  4, 10,  3],
             [ 4, 10,  5,  2, 10,  6,  4, 11,  7,  3,  9,  7, 10,  6,  7, 11],
             [11, 10,  9, 10, 10, 11, 10,  0, 11, 11,  7,  9,  2, 11,  6,  8],
             [10, 10,  3,  2, 10,  4,  8,  4, 10,  9,  8,  4,  9,  9,  1,  4],
             [ 7,  7, 11, 11,  4, 11,  6, 10,  6,  9,  9, 11,  6,  0,  4,  7],
             [ 8,  7,  7,  9,  8,  8, 11,  9,  4, 11,  7,  8,  1, 11,  7,  9],
             [10,  4,  2,  4,  6,  6, 11,  7,  5,  6,  7,  7,  6, 11, 10,  7],
             [ 9, 10,  6,  1, 10,  9,  8, 10, 11,  9,  3,  9, 10, 10,  2, 10],
             [ 7, 10,  9, 10,  2, 10,  9, 10,  4, 10, 11,  9, 10, 10,  6,  4],
             [ 6, 10,  3,  7,  2, 10,  6,  9,  6,  9,  8, 10, 11, 11,  9,  3],
             [10,  6, 11, 10,  5,  3, 11,  9,  9,  6,  5,  6,  7,  8,  4,  2],
             [ 1,  2, 10, 10,  4,  9,  4,  1,  9, 10, 11,  8,  4,  9,  7,  2]]
```
