My first Sonic PI song, well .... tryout after reading the tutorial

Ah yes, I altered it a bit to about something I want:

use_debug false
live_loop :fast, auto_cue: false do
  
  tick_reset
    
  min_r=2.0
  max_r=40.0
  steps=8.0
  counts=(max_r-min_r)/steps
  min_a=0.1
  max_a=1.0
  steps_a=(max_a-min_a)/counts
  dampening_a=5.0
  
  counts.times do
    density (range min_r,max_r,steps).tick do
      sample :drum_snare_hard, amp: (range min_a, max_a, steps_a/dampening_a).look
      sleep 1
    end
  end
  sample :drum_cymbal_open
  sample :guit_em9
  sleep 4
end
1 Like

Hi Nechoj.

Thank you so much for classifying me as ‘non-mathematically-minded’.

In truth, despite being taught quadratic equations in school… I’ve never
actually used one in ‘real life’, in the 63 years I’ve been alive.

Markov chains are not a mystery to me… but my viewpoint is, that
this forum is a gateway for new users to Sonic Pi.

If their first encounter on this forum, is a technical dissertation on Markov,
or a 10 page document on Midi input and output codes, then I can see
them simply walking away from Sonic Pi.

And what a terrible loss that would be.

Regards.

Eli… (the non-mathemathically-minded).

1 Like

Hi again @Nechoj, if nobody has thanked you recently, I just wanted to say that I really appreciate your efforts as a teacher :blush: I think there’s definitely a place for everyone who’s tolerant and open to learning and sharing ideas in this forum. Sonic Pi users are the best! They’re kind and genuinely committed to their craft.

Anyone who takes a cursory glance at the diverse and interesting topics on this forum and loses interest right away… well, they’re always welcome back when they change their mind, because Sonic Pi is going to keep growing.

I think what’s important is that we welcome new arrivals and direct them to the resources appropriate to their knowledge. No one knows everything, and I’m grateful that we all have each other to learn from. Towards this end, I think your contributions are every bit as important and vital to the success of Sonic Pi as cool projects and, OMG, programmed drops! EDM forever :black_heart:

There’ll come a day when this forum will be bustling with too many new ideas for me to scroll through. Creative minds everywhere will be busy melding and evolving together. I’m happy to help the forum grow to that point :’) because I feel welcome here, and I want to pay it forward, all the things I have to be grateful for.

1 Like

Thanks a lot :blush:, very kind of you. I just try to give back a bit of what I have received previously. All I know about SPi I learned from the amazing contributions of you guys. The forum allows newbies to ramp up with warp speed.

1 Like

Hi Eli,
sorry, I didn’t mean to classify you. We are all on a journey and who knows, maybe next year you’ll be using Markov chains? :wink:

I started as a musician and then became a theoretical physicist. This changed my mind (literally) and perception of the world. Whenever I see beautiful things I also see the math in it. When looking at a nice flow a fresh and clean water I wonder how nature manages to solve all these partial differential equations in real-time. And when I came to SPi, this was like waking up an a new planet, unseen before. It’s like when a gardener discovers a previously hidden garden full of flowers, some known, some unknown, all beautiful. I see separate things coming together and joining in a seamless way: random processes, rings of numbers, harmonies and scales, number theory … Suddenly a voice in my head tells me: Apply Roger Penrose’s forbidden symmetries to rhythms!! And the best thing is you can convert it into sound and make it accessible to people without any math background. I can tell my wife: Listen, this is a Markov chain. Isn’t that fascinating?

So the journey goes on …

Interesting! As you are talking about Penrose: lately I was thinking about using Penrose Tilings to create music, take a circular tiling, use polar coordinates and take the distance of the outer points of the shapes from the center (so the radius) and use that as a constant in a formula to determine a frequency of a tone (or the amplitude, whatever you like to try). Then you have a loop of tones as it is a circle obviously. Then you do the same for the points which are close to the center etcetera. As a timing control, you use the angle of the point. This might create some interesting patterns.
So, my belief is this: if something looks beautiful, it can me made to sound beautiful too, you just need to find a correct translation from the vision to audio.
Traversing a mandelbrot like the inside of a Geode, using lerps for sound transitions might also sound awesome!!

I think that dancing on a mandelbrot fractal being made auditive and layering it with a penrose tiling drumloop is quite interesting, but … this probably is already done.

@Eli: I can completely relate to you and I agree with you too, that such conversations might scare people away. Often those conversations also scare me away, because it makes me depressed to read about complex theories which I don’t understand at all, even though basically, the topic being explained is not difficult at all, it is just explained difficult. Making mathematics fun is also something Sam has managed to do with Sonic PI I believe.
I suck at math, simply because I don’t have the correct education, so all the basics are not known to me. But, I am a human and I also can perceive the beauty of mathematics, all around us in nature to see and all around us in music to hear. I don’t understand the formulas involved, but I see and feel the beauty and for me personally that is all that counts.

2 Likes

Exactly. And math has got hidden beauty and I am trying to help people to see it. Making it sound is one way of doing it. Others tried to visualize it (M.C. Escher…).

My first idea to approach the Penrose sound was to choose an arbitrary straight line and use the intersections with the pattern. Another line - another rhythm. But circles for notes is a good approach as well.

1 Like

I am now busy doing this now, with the help of Fusion 360, will show the results, if something interesting comes out:

2 Likes

So, here is a sample, just walking the outside points as you can see in the picture. It sounds pretty interesting after fooling around with some constants:

#Penrose Tilings test 1 - Aurolis
#Playing the outer points of a circular penrose tiling, using
#polar coordinates => length=frequency, angle = rest
base_note=:C3.to_i

#Or uglify, it's in the ear of the beholder =)
beautify=1.0


bpms=70.0
use_bpm bpms
angie_factor=(bpms/60.0) * 30.0

outer_rad=(ring 68, 78, 65, 72, 72, 76, 73, 72, 66, 79, 68, 79, 66, 72,
           73, 76, 73, 73, 66, 79, 69, 79, 67, 73, 74, 77,
           74, 73, 67, 80, 69, 79, 67, 73, 73, 76,73,72,
           66,79,68, 79, 66, 72, 73, 76, 73, 72, 65, 78)

outer_ang=(ring 5.5, 1.1, 9.5, 10.3, 9.8, 9.7, 10.3, 1.1, 5.6, 5.4,1.2,
           9.2,10.2,9.6,9.8, 10.1,9.2,1.1,5.6,5.4,1.2,9.2,10.1,9.7,
           9.7,9.9,9.2,1.2,5.4,5.5,1.1,9.1,10.4,9.5,9.6,10.2,
           9.3,1.3,5.3,5.7,0.99,9.4,10.2,9.8,9.6,10.3,9.5,1.1,5.5)

define :to_note do |n1,n2|
  return (([n2,n1].max - [n2,n1].min) * beautify) + base_note
end

n1=outer_rad.tick
n2=outer_rad.tick


with_fx :reverb, room: 1 do
  with_fx :lpf do |fx1|
    loop do
      s=synth :chipbass, note: to_note(n1,n2), release: 0.2
      control fx1, cutoff: (range 90,110,rrand(1,10)).mirror.tick(:fxt)
      sleep [0.1,outer_ang.tick(:angie)/angie_factor].max
      n2=outer_rad.look
      n1=outer_rad.tick
    end
  end
end
2 Likes

Interesting! This is the sound I kind of expected. Almost regular and symmetric, but not really.
A quick search yields some Penrose pattern generator algorithms. Maybe those can be transferred in a simple way to provide a rhythm or melody generator for SPi. If you label your music ‘Movements on Penrose tiles’ the marketing piece is already done :wink:

Small comment on posts: If you put your code inside 3 backticks it will be nicely formatted with colors.
```

code

```

Play it first, then analyse it. :slight_smile:

Eli…

# Drop Anchor!
#Eli...


use_bpm 110
tracker = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
n = (ring :r, :r, :d2, :d3, :f3, :r, :d1, :f2)
vol=2

kick=0
hats=1
rim=2
background=3
windup=4
rewind=5


define :start_loop do |i|
  tracker[i] = 1
end

define :once_only do |i|
  tracker[i] = 1
end

define :stop_loop do |i|
  tracker[i] = 0
end

define :stop_all do
  (0..12).each do |i|
    tracker[i] = 0
  end
end

live_loop :bar do
  sleep 1
end

live_loop :beats do
  sync :bar
  sleep 4
end

with_fx :echo, mix: 0.8, phase: 0.75, decay: 4 do
  live_loop :kick do
    if tracker[0] == 1 then
      sync :beats
      sample :bd_ada,amp: vol / 2.0
      sleep 1
      sample :bd_ada,amp: vol / 3.0
      sample :sn_dolf, sustain: 0, release: 0.08, hpf: 80,amp: vol / 2.0
      sleep 1
      sample :bd_ada,amp: vol / 2.0
      sleep 1
      sample :bd_ada,amp: vol / 2.0
      sample :sn_dolf, sustain: 0, release: 0.08, hpf: 80,amp: vol / 2.0
      sleep 1
    else
      sleep 1
    end
  end
end

with_fx :rhpf, res: 0.85, cutoff: 118, amp: 0.7 do
  live_loop :hats do
    if tracker[1] == 1 then
      sync :bar
      use_synth_defaults sustain_level: 0.5
      synth :dsaw, sustain: 0, release: 0.09, freq_band: 15,amp: vol / 0.5
      sleep 1
    else
      sleep 1
    end
  end
  
  with_fx :distortion do
    live_loop :rim do
      if tracker[2] == 1 then
        sleep 0.5
        use_sample_defaults amp: 0.2
        sample :elec_blip, sustain: 0.006, cutoff:110, rate: 0.8,amp: vol
        sleep 0.25
        sample :elec_blip, sustain: 0.005, cutoff:110, rate: 0.8,amp: vol if one_in(5)
        sleep 0.25
      else
        sleep 1
      end
    end
  end
end

with_fx :flanger, stereo_invert_wave: 1, feedback: 0.625, amp: 0.3 do
  with_fx :echo, mix: 0.8, phase: 0.75, decay: 4 do
    live_loop :background do
      if tracker[3] == 1 then
        use_synth :fm
        mynote = (note_range, :g2, :g4, pitches: (scale, :g6, :minor_pentatonic))
        play mynote.choose,amp: vol / 8.0
        sleep 0.25
      else
        sleep 1
      end
    end
  end
end


with_fx :level,amp: 0 do |v|
  live_loop :windup do
    if tracker[4] == 1 then
      control v,amp: 2
      dense = [1,1,2,4].ring.tick
      with_fx :echo, mix: 0.8, phase: 0.75, decay: 4 do
        density dense do
          sample :bd_ada,amp: vol / 2.0
          sleep 1
          sample :bd_ada,amp: vol / 3.0
          sample :sn_dolf, sustain: 0, release: 0.08, hpf: 80,amp: vol / 2.0
          sleep 1
          sample :bd_ada,amp: vol / 2.0
          sleep 1
          sample :bd_ada,amp: vol / 2.0
          sample :sn_dolf, sustain: 0, release: 0.08, hpf: 80,amp: vol / 2.0
          sleep 1
        end
      end
    else
      control v,amp: 0
      sleep 1
    end
  end
end

with_fx :flanger, stereo_invert_wave: 1, feedback: 0.625, amp: 0.3 do
  with_fx :echo, mix: 0.8, phase: 0.75, decay: 4 do
    live_loop :rewind do
      if tracker[5] == 1 then
        sample :vinyl_rewind,amp: vol
        tracker[5] = 0
        sleep 0.25
      else
        sleep 1
      end
    end
  end
end



start_loop kick
start_loop hats
start_loop rim
start_loop background
sleep 16
stop_all
sleep 2
puts 'NOW'
start_loop windup
sleep 16
stop_loop windup
sleep 2
start_loop rewind
sleep 8
start_loop kick
start_loop hats
start_loop rim
start_loop background
3 Likes

Very nice!! :sparkling_heart: :sparkling_heart: :pray:
I love that easy off-beat feeling produced by the low guitar imitated by the :fm synth in the background loop.
Well balanced sounds and effects covering the whole space in time and frequency.
Great!

Summary of analysis: a lot of ideas using a lot of math (rings, fractions, waves, …) nicely integrated :wink:

EDIT: When having a second look at the notes I found this:

(note_range, :g2, :g4, pitches: (scale, :g6, :minor_pentatonic))

produces the same notes as

(scale, :g2, :minor_pentatonic, num_octaves: 2)

This is because note_range produces a chromatic scale (=all notes) which then are filtered by the pitches argument to only contain those from the minor_pentatonic scale. So, producing them directly using scale gives the same result.

Maybe it’s useful to know.