# MinaCoding2023_Human_HeartTraits

# **JuneHeartTraits**

The Second of the Seven Sketches for the **MinaCoding** Prompt of **Humans is JuneHeartTraits**

**JuneHeartTraits** uses ***SonicPi*** code to sonify the speculative nature of what traits a digi-physical human heart may sound like in this realm that is being built.

As explained in [https://blog.illestpreacha.com/decibelschallengepersonaldata](https://blog.illestpreacha.com/decibelschallengepersonaldata):

> I wanted the sounds to represent the various stages a heart goes through in a workout. This explains some of the chaotic tension/feelings that can be heard in this track

## JuneHeartTraits

<iframe width="100%" height="300" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/1545949303&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) · [MInaCoding Humans: JuneHeartTraits](https://soundcloud.com/llestreacha/minacoding-humans-junehearttraits)

## Poem

```ocaml
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
```

## **Previous SonicPi Audio**

<iframe width="100%" height="300" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/1467050401&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) · [Decibels 2023 March Challenge ; Personal Data : Heart Edition](https://soundcloud.com/llestreacha/decibels-2023-march-challenge-personal-data-heart-edition)

## **SonicPi Code**

```ruby
require 'csv'
#Compared to the original, there are more math functions added to this
#and more samples

#naming the Dataset DipInCode and going to read the file
Heart = CSV.parse(File.read("E:/Creatuve Code Challenges/Sonification Challenges/March 2023/HeartRatePrep.csv"), headers: true)



i = 0


live_loop :HeartZone do
  
  #using this equation to add more variance to the sounds
  use_bpm Math.hypot(Heart[i]['HR_MIN'].to_f,Heart[i]['HR_MAX'].to_f)
  
  #these effects are going to be affected by the zones, since they are between 0 and 1, which is the range for the mix function
  with_fx :echo, mix: Heart[i]['Other Zones'].to_f  do
    with_fx :ixi_techno, mix: Heart[i]['Zone3'].to_f do
      with_fx :krush, mix: Heart[i]['Zone2+3'].to_f do
        
        #a trio of synths to add more musicality/variance to the listening experience
        use_synth [:organ_tonewheel,:mod_sine,:mod_sine,:piano,:beep].choose
        
        #Corresponds to the note being played
        play Heart[i]['HR_MIN'].to_f, decay: Math.hypot(Math.sin(Heart[i]['Other Zones'].to_f * 5),Math.sin(Heart[i]['Other Zones'].to_f)), amp: dice(12)
        
        #We can even pass a list of times which it will treat as a circle of times:
        play_pattern_timed chord(Heart[i]['HR_MIN'].to_f, :m13), [Heart[i]['Zone2+3'].to_f, Heart[i]['Other Zones'].to_f ,Heart[i]['HR_MAX'].to_f/ Heart[i]['HR_MIN'].to_f]
      end
    end
  end
  
  i += 1 #counter
  
  if i == Heart.length #make the loop nonstop
    i = 0
  end
  
  #spacing
  sleep Math.sin(Heart[i]['HR_MAX'].to_f/ Heart[i]['HR_MIN'].to_f)
end


live_loop :HeartBeat do
  
  use_bpm 45
  
  #same as the previous loop, with the difference being a random choosing of 3 effects instead of 3 synths in this portion
  with_fx :ping_pong do
    with_fx :flanger, depth: Heart[i]['Other Zones'].to_f  do
      with_fx :echo,  mix: Heart[i]['Zone2+3'].to_f do
        with_fx [:ping_pong,:vowel,:whammy].choose, mix: Heart[i]['Other Zones'].to_f do
          sample [:ambi_piano,:elec_bong],beat_stretch: Heart[i]['Zone2'].to_f ,pitch: Math.cbrt(Heart[i]['CaloLoad'].to_f) * 3
          sample :perc_impact1,beat_stretch: Math.hypot(Heart[i]['Other Zones'].to_f,Heart[i]['CaloLoad'].to_f), decay: Heart[i]['CaloLoad'].to_f
        end
      end
    end
  end
  
  
  i += 1
  
  if i == Heart.length #make the loop nonstop
    i = 0
  end
  
  sleep Heart[i]['HR_MAX'].to_f/ Heart[i]['HR_MIN'].to_f
end

live_loop :HeartBeat2 do
  
  #same as the previous loop, with the difference being a random choosing of 3 effects instead of 3 synths in this portion
  #added more samples
  with_fx :ping_pong do
    with_fx :flanger, depth: Heart[i]['Other Zones'].to_f  do
      with_fx :echo,  mix: Heart[i]['Zone2+3'].to_f do
        with_fx [:ping_pong,:vowel,:whammy].choose, mix: Heart[i]['Other Zones'].to_f do
          sample [:ambi_piano,:elec_bong].tick,beat_stretch: Heart[i]['Zone2'].to_f ,pitch: Math.cbrt(Heart[i]['CaloLoad'].to_f) * 3
          sample [:elec_beep,:perc_snap].choose, beat_stretch: Math.hypot(Heart[i]['Other Zones'].to_f,Heart[i]['CaloLoad'].to_f), decay: Heart[i]['CaloLoad'].to_f
        end
      end
    end
  end
  
  
  i += 1
  
  if i == Heart.length #make the loop nonstop
    i = 0
  end
  
  sleep Heart[i]['HR_MIN'].to_f/Heart[i]['HR_MAX'].to_f
end

```
