Haunting Sines Interplay

Played around with some sine waves this afternoon and came up with this

#haunting sines interplay by Robin Newman July 2023
#you can adjust the notes by changing the random see. Initially set to 0.
#you can choose any number, or Time.new.to_i
#to set a new seed on every run.
#the current seed is pritned each run and can be retriveved
#using puts get(:rn) after the run finishes if you hit on a nice one.
use_synth :sine
rn = 0 #   Time.now.to_i  #use alternative to change every time
puts "current random seed is #{rn}"
set :rn,rn #stores current seed if you want to look it up get(:rn)
use_random_seed rn
fadeAt = 236 #adjust the run time as desired
set :kill,false #used to kill the live loopsd at the end

define :liss do |p,t,b| # sets up two beating sime waves
  n=play p,release: t,amp: 0,pan: -1
  n2=play p+b,release: t,amp: 0,pan: 1
  control n,amp: 1,amp_slide: t/2.0 #fade in (release fades out again)
  control n2,amp: 1,amp_slide: t/2.0 #fade in (release fades out again)
end

with_fx :gverb, room: 20,mix: 0.7 do
  with_fx :panslicer, phase: 2,wave: 3 do |s| #pan slice at changing rates
    set :s,s #save pointer to panslicer
    with_fx :level,amp: 0 do |v| #envelope to fade in at start out at end
      at [0,fadeAt],[1,0] do |a|
        control v,amp: a,amp_slide: 4
        if a==0
          sleep 4
          puts "last random seed was #{get(:rn)}" #print seed for last run
          set :kill,true #flag to stop live loops
        end
      end
      
      live_loop :haunt do
        stop if get(:kill)
        p=rrand_i(72,84)
        t=rrand(4,12)
        b=rrand(0.1,0.4)
        liss p,t,b
        sleep t
        control get(:s), phase: rrand(0.20,1) #change pansliceer rate
      end
      
      live_loop :haunt2,delay: 0.2 do #2nd pair of sines delayed start
        stop if get(:kill)
        p=rrand_i(72,84)
        t=rrand(4,12)
        b=rrand(0.1,0.4)
        liss p,t,b
        sleep t
      end
      
      live_loop :haunt3,delay: 0.4 do #3rd pair of sines delayed and octave lower
        stop if get(:kill)
        p=rrand_i(60,72)
        t=rrand(4,12)
        b=rrand(0.1,0.4)
        liss p,t,b
        sleep t
      end
    end
  end
end
6 Likes

Ooh, that’s very beautiful. Especially considering it’s three random notes—a testament to your sound design!

The set :kill technique looks really useful too. I’ll have to start doing that in my own projects. Thanks for sharing this.

2 Likes