# Generative ambient kalimba based

**URL:** <https://in-thread.sonic-pi.net/t/generative-ambient-kalimba-based/8995>\
**Category:** Creations & Ideas\
**Created:** [June 30, 2024, 9:31pm UTC](https://in-thread.sonic-pi.net/t/generative-ambient-kalimba-based/8995 "2024-06-30T21:31:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Le\_Peuneuj](https://avatars.discourse-cdn.com/v4/letter/l/5f9b8f/32.png) [@Le\_Peuneuj](https://in-thread.sonic-pi.net/u/Le_Peuneuj)\
**Post date:** [June 30, 2024, 9:31pm UTC](https://in-thread.sonic-pi.net/t/generative-ambient-kalimba-based/8995/1 "2024-06-30T21:31:23Z")

</div>

Here is a simple piece I made, cause I love generative music and for the first time, I did it /o/

```ruby

a = 0.1 #amplitude globale
b = -0.3156 #ça c'est pour accorder en 432 hertz
c = 22.5 #metronome
highnotes = [:b5-b, :d6-b, :e6-b, :fs5-b]
melodicnotes = [:g4-b, :a4-b, :b4-b, :d5-b, :e5-b, :fs5-b, :g5-b, :a5-b]
chordnotes = [:g3-b, :b3-b, :d4-b, :e4-b]

use_bpm c

use_random_seed 30289

with_fx :lpf do
  live_loop :ambient1 do
    sample "/home/[My name]/Music/Samples/campfire.mp3", amp: 0.5
    sleep 40
  end
  live_loop :ambient2 do
    sample :ambi_choir, rate: 0.10, amp: 0.05
    sleep 1
  end
end

with_fx :gverb, damp: 0.5, release: 16, spread: 1, mix: 0.1 do
  with_fx :compressor do
    with_fx :echo, decay: 32, phase: 0.8, max_phase: 64, mix: 0.3 do
      with_fx :flanger, depth: 10, wave: 4, feedback: 0.3, delay: 2 do
        
        live_loop :kalihigh do
          use_synth :kalimba
          use_synth_defaults clickiness: 0.5, amp: a*3
          play choose(highnotes), pan: [-1, -0.85, 0.85, 1].choose
          sleep [0.125, 0.25, 0.5, 1, 2, 7, 8, 9].choose
        end
        
        live_loop :kalimelodic do
          use_synth :kalimba
          use_synth_defaults clickiness: 0.5, amp: a*2
          play choose(melodicnotes), pan: [-1, -0.75, 0.75, 1].choose
          sleep [0.125, 0.25, 0.5, 1, 2, 3, 4].choose
        end
        
        live_loop :kalichord do
          use_synth :kalimba
          use_synth_defaults clickiness: 0.5, amp: a
          play choose(chordnotes)
          sleep [1, 1.5, 2, 2.5, 4, 4.5, 6].choose
        end
        
        live_loop :kalibass do
          use_synth :kalimba
          use_synth_defaults clickiness: 0.5, amp: a*2
          play [:e2, :g2, :b2, :d3].choose
          sleep [3.5, 4, 4.5, 5, 5.5, 6].choose
        end
      end
    end
  end
end

```

Hope you’ll like it :3

---

<div class="post-metadata">

**Author:** ![Relaxnow](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/relaxnow/32/2172_2.png) [@Relaxnow](https://in-thread.sonic-pi.net/u/Relaxnow)\
**Post date:** [June 30, 2024, 9:38pm UTC](https://in-thread.sonic-pi.net/t/generative-ambient-kalimba-based/8995/2 "2024-06-30T21:38:16Z")

</div>

Very beautiful. Thank you for sharing

---

<div class="post-metadata">

**Author:** ![HarryLeBlanc](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/harryleblanc/32/2813_2.png) [@HarryLeBlanc](https://in-thread.sonic-pi.net/u/HarryLeBlanc)\
**Post date:** [July 1, 2024, 11:43pm UTC](https://in-thread.sonic-pi.net/t/generative-ambient-kalimba-based/8995/3 "2024-07-01T23:43:50Z")

</div>

I love it. So hypnotic and slow.  
I like the trick of shifting everything from 440 to 432.  
You can do math on every item in a buffer like so:

```ruby
b = -0.3156
highnotes = [:b5, :d6, :e6, Fs5].collect {|n| n - b}

```

Runs the block of code in curly braces against each item. This is a trivial example, but it’s a powerful tool.  
Cheers,  
H

---

<div class="post-metadata">

**Author:** ![H\_Tachibana](https://avatars.discourse-cdn.com/v4/letter/h/e68b1a/32.png) [@H\_Tachibana](https://in-thread.sonic-pi.net/u/H_Tachibana)\
**Post date:** [July 6, 2024, 3:26pm UTC](https://in-thread.sonic-pi.net/t/generative-ambient-kalimba-based/8995/4 "2024-07-06T15:26:33Z")

</div>

What does campfire.mp3 sound like?

To tune from A=440Hz to 432Hz,  
set\_cent\_tuning! ( hz\_to\_midi(432) - note(:A4))\*100

---

<div class="post-metadata">

**Author:** ![Le\_Peuneuj](https://avatars.discourse-cdn.com/v4/letter/l/5f9b8f/32.png) [@Le\_Peuneuj](https://in-thread.sonic-pi.net/u/Le_Peuneuj)\
**Post date:** [July 7, 2024, 5:07pm UTC](https://in-thread.sonic-pi.net/t/generative-ambient-kalimba-based/8995/5 "2024-07-07T17:07:04Z")

</div>

Thanks for the tips ^^ Can you give me more info of how your code works please ?

> **[campfire.mp3](https://drive.google.com/file/d/1Xm-O3RaAzjR6l28ab6PfdzZ2j55s5QTn/view?usp=drive_link)**
>
> Google Drive file.

Here is a link for the campfire !

---

<div class="post-metadata">

**Author:** ![H\_Tachibana](https://avatars.discourse-cdn.com/v4/letter/h/e68b1a/32.png) [@H\_Tachibana](https://in-thread.sonic-pi.net/u/H_Tachibana)\
**Post date:** [July 8, 2024, 4:59am UTC](https://in-thread.sonic-pi.net/t/generative-ambient-kalimba-based/8995/6 "2024-07-08T04:59:12Z")

</div>

Better feeling.

Please try,

```ruby
set_cent_tuning! 0
play 60,sustain:10
set_cent_tuning! ( hz_to_midi(441) - note(:A4))*100
play 60,sustain:10

```

A sound roar occurs once per second.

---

<div class="post-metadata">

**Author:** ![H\_Tachibana](https://avatars.discourse-cdn.com/v4/letter/h/e68b1a/32.png) [@H\_Tachibana](https://in-thread.sonic-pi.net/u/H_Tachibana)\
**Post date:** [July 8, 2024, 5:51am UTC](https://in-thread.sonic-pi.net/t/generative-ambient-kalimba-based/8995/7 "2024-07-08T05:51:51Z")

</div>

Sorry. The number of roars depends on the frequency.  
In the case of A4, it is one roar per second.  
For C4 the roar is a little slower.

```ruby
hz_to_midi(440) - note(:A4) = 0

```

---

<div class="post-metadata">

**Author:** ![Le\_Peuneuj](https://avatars.discourse-cdn.com/v4/letter/l/5f9b8f/32.png) [@Le\_Peuneuj](https://in-thread.sonic-pi.net/u/Le_Peuneuj)\
**Post date:** [August 13, 2024, 3:13am UTC](https://in-thread.sonic-pi.net/t/generative-ambient-kalimba-based/8995/8 "2024-08-13T03:13:35Z")

</div>

I just saw your answer, I’ll try and give feedback ❤
