Whale-song, anyone?

I was working on a melody for one of my tracks, and got a couple
of parameters messed up… to my suprise.

Needs a bit of cleanup, sure… but still.

Eli…

6 Likes

I dig it! The sound is very atypical of the sonicpi compositions I’ve heard.

Hi Eli,

nice sounds! Are you using the fm-synth?

Martin

This is ace!

Is there any chance you could share the code with us?

My pleasure Sam… I didnt think anyone would want it, so didn’t save it, so here’s as
close as I can remember… also thrown in a ‘Submarine Sonar’ to warn the whales off. :slight_smile:

The key seems to be the note_slide in the synth defaults… I put it to 5.02 instead of 0.25,
by mistake.

Heh… still haven’t figured out that triple-back-tick programming box thing yet.

Eli…

use_bpm 90

live_loop :beat do
  use_sample_defaults amp: 0.7
  cue :kick
  sleep 4
end

comment do
  
  with_fx :echo, phase: 0.375 do
    live_loop :sonar do
      use_synth :sine
      use_synth_defaults note_slide: 5.02, amp: 0.125
      sync :kick
      sync :kick
      notes =  scale( :g5, :minor)
      play notes.tick, release: 6
      sleep 0.25
      31.times do
        control note: notes.choose
        sleep [0.25].choose
        tick
      end
      sleep 2
    end
  end
  
end


with_fx :echo, mix: 0.8, phase: 0.75, decay: 4 do
  live_loop :whales do
    with_fx :flanger, stereo_invert_wave: 1, feedback: 0.5, amp: 0.25 do
        sync :kick
        use_synth :fm
        repeater = [6,7,8,9,12].choose
        use_synth_defaults res: 0.9, attack: 0.25, noise: 2, release: 2 , cutoff: 100, amp: 0.3,
          note_slide: 5.02, sustain: 0.25 * repeater / 1.25, decay: 0.25 * repeater / 1.25, sustain_level: 0.8,
          mod_range: 0.5, mod_phase: 0.125, mod_wave: 2, pulse_width: 0.2
        mynote =  note_range( :g3, :g5, pitches:  scale( :g6, :minor))
        play mynote.tick
        repeater.times do
          control note: mynote.tick + [0, 12].choose
          sleep [0.25, 0.25, 0.5].choose
        end
        sleep 2.5
      end
    end
  end
2 Likes

@Eli - I edited your post directly to add the magic backticks. You should be able to use the edit history to see what I added so you can hopefully do the same in future posts :slight_smile:

1 Like

Excellent! New sounds are always welcome,

Lovely! It’s like having a pod of whales living in my mac :grinning:

1 Like

I had to take it further… not sure people on Soundcloud will understand though… oh well. :slight_smile:

https://soundcloud.com/just-eli-139271289/song-of-the-leviathan

Eli…

1 Like

For it to work I had to assign a variable

p2 = play mynote.tick
repeater.times do
control p2, note: mynote.tick + [0, 12] .choose.

Thanks for sharing the code

Ypur welcome. I love your take on the original, what a head-nodder. :slight_smile:

Code please, and in exchange here’s the code for the the ‘Song of the Leviathan’.

Eli…


#Eli...

use_debug false
use_bpm 120

tracker = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

use_random_seed 66776

sonar_vol = 1
whale_vol = 0.2


round = (ring 50,48,62,48,62)
x=0
distance = 4.0

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


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

drum_vol = (line 0.2, 2, inclusive: true, steps: 5).ramp



define :stop_all do
  tracker[0] = 0
  tracker[1] = 0
  tracker[2] = 0
  tracker[3] = 0
  tracker[4] = 0
  tracker[5] = 0
  tracker[6] = 0
  tracker[7] = 0
  tracker[8] = 0
  tracker[9] = 0
  tracker[10] = 0
  tracker[11] = 0
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 :swirl do
    if tracker[1]>0 then
      with_fx :flanger, stereo_invert_wave: 1, feedback: 0.5, amp: 0.5 do
        sync :beats
        use_synth :mod_beep
        rps = (range 3, 6).choose
        use_synth_defaults res: 0.9, attack: 0.25, noise: 2, release: 2 , cutoff: 100, amp: 0.2,
          note_slide: 0.02, sustain: 0.5 * rps / 1.25, decay: 0.25 * rps / 1.25, sustain_level: 0.8,
          mod_range: 0.5, mod_phase: 0.5, mod_wave: 7, pulse_width: 0.2
        mynote = (note_range, :g2, :g4, pitches: (scale, :g, :minor_pentatonic))
        play mynote.reverse.tick
        rps.times do
          control note: mynote.tick - [0, 12].choose
          sleep [0.25, 0.25, 0.5, 0.5, 0.75].choose
        end
        sleep 2.5
      end
    else
      sleep 0.25
    end
  end
end

with_fx :echo, mix: 0.8, phase: 0.75, decay: 4 do
  live_loop :swirl1 do
    if tracker[2]>0 then
      with_fx :flanger, stereo_invert_wave: 1, feedback: 0.5, amp: 0.5 do
        sync :beats
        use_synth :mod_beep
        rps = (range 6, 9).choose
        use_synth_defaults res: 0.9, attack: 0.25, noise: 2, release: 2 , cutoff: 100, amp: 0.2 ,
          note_slide: 0.02, sustain: 0.25 * rps / 1.25, decay: 0.25 * rps / 1.25, sustain_level: 0.8,
          mod_range: 0.5, mod_phase: 0.125, mod_wave: 2, pulse_width: 0.2
        mynote = (note_range, :g4, :g6, pitches: (scale, :g, :minor_pentatonic))
        play mynote.reverse.tick
        rps.times do
          control note: mynote.tick - [0, 12].choose
          sleep [0.25, 0.25, 0.5, 0.5, 0.75].choose
        end
        sleep 2.5
      end
    else
      sleep 0.25
    end
  end
end

with_fx :echo, mix: 0.8, phase: 0.75, decay: 4 do
  with_fx :flanger, stereo_invert_wave: 1, feedback: 0.5, amp: 0.25 do
    
    live_loop :whales do
      if tracker[3]>0 then
        sync :beats
        use_synth :fm
        if look < 20 then
          whale_vol +=0.4
        end
        if look > 64 then
          whale_vol -=0.2
        end
        if whale_vol < 0.2
          whale_vol = 0.1
        end
        
        puts look
        puts whale_vol
        
        repeater = [6,7,8,9,12].choose
        use_synth_defaults res: 0.9, attack: 0.25, noise: 2, release: 2 , cutoff: 100, amp: 0.3 * whale_vol,
          note_slide: 5.02, sustain: 0.25 * repeater / 1.25, decay: 0.25 * repeater / 1.25, sustain_level: 0.8,
          mod_range: 0.5, mod_phase: 0.125, mod_wave: 2, pulse_width: 0.2
        mynote =  note_range( :g3, :g5, pitches:  scale( :g6, :minor))
        play mynote.tick
        repeater.times do
          control note: mynote.tick + [0, 12].choose
          sleep [0.25, 0.25, 0.5].choose
        end
        sleep 2.5
      else
        sleep 0.1
      end
    end
  end
end

with_fx :echo, phase: 0.375 do
  
  live_loop :sonar do
    if tracker[4]>0 then
      if look == 1 then
        use_bpm 60
        distance = 4.0
      end
      if look == 3 then
        use_bpm 90
        distance = 3.0
      end
      if look ==  5 then
        use_bpm 240
        distance = 2.0
      end
      if look > 7 then
        use_bpm 480
        distance = 1.0
      end
      if look == 64 then
        use_bpm 480
        distance = 1.0
      end
      if look == 80 then
        use_bpm 240
        distance = 2.0
      end
      if look ==  82 then
        use_bpm 120
        distance = 3.0
      end
      if look > 84 && look < 74 then
        use_bpm 90
        distance = 4.0
      end
      if look > 86 then
        use_bpm 60
        distance = 4.0
      end
      puts look
      use_synth :sine
      use_synth_defaults note_slide: 5.02, amp: 0.125
      repeater = rrand_i(1,2)
      repeater.times do
        sync :beats
      end
      notes =  :g5
      play notes, release: 2
      sleep 0.25 * distance
      play notes, release: 2
      tick
    else
      sleep 0.25
    end
  end
end


with_fx :reverb, mix: 0.5 do
  use_bpm 30
  live_loop :oceans do
    if tracker[0]>0 then
      s = synth [:bnoise, :cnoise, :gnoise].choose, amp: rrand(0.175, 0.2), attack: rrand(0, 4),
        sustain: rrand(0, 2), release: rrand(1, 3),
        cutoff_slide: rrand(0, 5), cutoff: rrand(60, 100), pan: rrand(-1, 1), pan_slide: rrand(1, 5),
        amp: rrand(0.05, 0.1)
      control s, pan: rrand(-1, 1), cutoff: rrand(60, 70)
      sleep rrand(2, 4)
    else
      sleep 0.1
    end
  end
end

oceans=0
swirl=1
swirl1=2
whales=3
sonar=4


3.times do
  start_loop swirl
  start_loop swirl1
  sleep 4
  stop_loop swirl
  stop_loop swirl1
end
start_loop oceans
sleep 8
start_loop sonar
sleep 12
start_loop whales
sleep 40
stop_loop whales
sleep 4
stop_loop sonar
sleep 8
stop_loop oceans
1 Like

Samples of freesound

https://drive.google.com/drive/folders/1aAd9h-F6zSf5GEtxMn42UPsHqgIUIQ7V?usp=sharing

muestra1 = '/home/raul/Sonic Pi/Samples/whales sonic pi/' # change your directory of samples

live_loop :muestras do
  sample muestra1, 2 # ocean
  sample muestra1, 0 # bass
  sample muestra1, 1 # drum
  sample muestra1, 8 # 3,5,7,8 pads,vox..etc
  sleep sample_duration muestra1,1
end

use_bpm 90
live_loop :beat do
  use_sample_defaults amp: 0.7
  cue :kick
  sleep 4
end

with_fx :echo, phase: 0.375 do
  sync :muestras
  live_loop :sonar do
    use_synth :sine
    use_synth_defaults note_slide: 5.02, amp: 0.125
    sync :kick
    sync :kick
    notes =  scale( :g5, :minor)
    p1=play notes.tick, release: 6
    sleep 0.25
    31.times do
      control p1, note: notes.choose
      sleep [0.25].choose
      tick
    end
    sleep 2
  end
end

with_fx :echo, mix: 0.8, phase: 0.75, decay: 4 do
  live_loop :whales do
    sync :muestras
    with_fx :flanger, stereo_invert_wave: 1, feedback: 0.5, amp: 0.25 do
      sync :kick
      use_synth :fm
      repeater = [6,7,8,9,12].choose
      use_synth_defaults res: 0.9, attack: 0.25, noise: 2, release: 2 , cutoff: 100, amp: 0.3,
        note_slide: 5.02, sustain: 0.25 * repeater / 1.25, decay: 0.25 * repeater / 1.25, sustain_level: 0.8,
        mod_range: 0.5, mod_phase: 0.125, mod_wave: 2, pulse_width: 0.2
      mynote =  note_range( :g3, :g5, pitches:  scale( :g6, :minor))
      p2 = play mynote.tick
      repeater.times do
        control p2 ,note: mynote.tick + [0, 12].choose
        sleep [0.25, 0.25, 0.5].choose
      end
      sleep 2.5
    end
  end
end
2 Likes

This has been a great thread with some great code!

Truly.

And despite some initial reservations on using Rauls samples,
I remembered beat_stretch and rate, which makes them quite
versatile, so I’ve learnt even more. :slight_smile:

Eli…


live_loop :muestras do
  
  speed = [60,90,120].choose
  
  if speed == 120 then
    r = 0.25
  else
    r = 0.5
  end

  use_bpm speed

  puts speed
  puts r
  
  sample muestra1,2, beat_stretch: 4, rate: r # drum
  sample muestra1, 0, beat_stretch: 4, rate: r # bass
  sample muestra1, 1, beat_stretch: 4, rate: r  # drum
  sample muestra1, 8, beat_stretch: 4, rate: r  # 3,5,7,8 pads,vox…etc
  sleep sample_duration muestra1,2, beat_stretch: 4, rate: r
end
1 Like

Great working, Eli :rofl:

Okay, time to call this a finished piece and move on to new experiences…

Enjoy,

Eli…

1 Like

This has been fun :). Thank you for sharing. I can use this as is to pacify my classroom :slight_smile: . Seriously though, great coding and wav files. Thanks again. Much to learn from you and Eli.

Fascinating conceptually especially how you put the code together to achieve your symphony of whales. Beautiful. Thank you.

Very cool and intriguing. I love the whole whale song approach. It’s a haunting yet soothing vibe.