A new patch: "Repitches"

Hello there! a new patch just for fun :grinning:…My problem in this patch is to syncronise the different live_loop because they are not of the same length(cf. the samples ), so if you have got an idea, it will be welcome!

##| Repitches

live_loop :ry do
  sample (ring, :bd_zome, :sn_zome).tick
  sleep 1
end

with_fx :reverb, mix: 0.5 do
  live_loop :short do
    use_synth :sc808_maracas
    16.times do
      play 89, amp: 0.1, pan: rrand(-0.9,0.9)
      sleep (ring, 0.125, 0.25, 0.5).choose if spread(3,5)
    end
  end
end

live_loop :guit do
  with_fx :reverb, room: 0.9, mix: 1 do
    4.times do
      with_fx :flanger, phase: 0.7 do
        sample :guit_em9, start: 0.5, finish: 0.75, rate: 0.5, amp: 2, rpitch: 0,  pan: rrand(-0.9,0.9), amp: 4
        sleep sample_duration :guit_em9, start: 0.5, finish: 0.75, rate: 0.5, pan: rrand(-0.9,0.9),amp: 4
      end
    end
    
    
    2.times do
      with_fx :flanger, phase: 0.7 do
        sample :guit_em9, start: 0.5, finish: 0.75, rate: 0.5, amp: 2, rpitch: 7, pan: rrand(-0.9,0.9), amp: 4
        sleep sample_duration :guit_em9, start: 0.5, finish: 0.75, rate: 0.5, rpitch: 7, pan: rrand(-0.9,0.9),amp: 4
      end
    end
    
    2.times  do
      with_fx :flanger, phase: 0.9 do
        sample :guit_em9, start: 0.5, finish: 0.75, rate: 0.5, amp: 2, rpitch: 12 , pan: rrand(-0.9,0.9), amp: 4
        sleep sample_duration :guit_em9, start: 0.5, finish: 0.75, rate: 0.5, rpitch: 12, pan: rrand(-0.9,0.9), amp: 4
      end
    end
    
    
    2.times  do
      with_fx :flanger, phase: 0.9 do
        sample :guit_em9, start: 0.5, finish: 0.75, rate: 0.5, amp: 2, rpitch: 15 , pan: rrand(-0.9,0.9), amp: 4
        sleep sample_duration :guit_em9, start: 0.5, finish: 0.75, rate: 0.5, rpitch: 12, pan: rrand(-0.9,0.9), amp: 4
      end
    end
    
    
  end
end

Take a look at the beat_stretch and pitch_stretch options for the sample function.

1 Like

Thanks David, I didn’t think to it! :+1:

Further to @Davids-Music_Lab comments that is certainly the way to go.
You have problems in that rate; and rpitch: both affect the duration of the sound, and it is a bit tedious to calculate what the end value is, particularly if the original sample does not have a nice round duration value. Also the start: and finish: parameters that you use will ultimately give you 1/4 of the overall duration as 0.5 to 0.75 is a quarter of the whole value.

I would expeiriment with this

bs=16
sample :guit_em9, start: 0.5, finish: 0.75,beat_stretch: bs
puts "actual duration is quarter of bs #{sample_duration :guit_em9, start: 0.5, finish: 0.75,beat_stretch: bs}"

bs is the value of the beat_stretch in beats. Try whole numbers for bs between 4 and 24 to get a range of pitches, the actualduration will be 1/4 of the bs value because of the chosen start and finish values.
However with “nice” numbers it is easier to calculate the duration of the loops.
You can just put the bs value divided by 4 for the sleep eg

bs=12

4.times do
  sample :guit_em9, start: 0.5, finish: 0.75,beat_stretch: bs
  sleep bs/4.0  
end
1 Like

Hello @robin.newman , thanks a lot for this explanation and suggestions to improve it…the proposition of @Davids-Music-Lab is interesting but your corrections bring probably a more complete (and complex!) solution…
so, I am going to rewrite the patch to get a better result! thanks!

Hello @Davids-Music-Lab thanks for your precious help! @robin.newman also proposed a solution based on beat_stretch which is probably more complex but very interesting.