Sliced up Bach using my answer to Sample slices pattern_timed

This piece is produced using the splaytimed function that I produced in answer to the query sample slices pattern_timed The music is Bach’s Invention no 13 normally played on a harpsichord or piano. Here I use the sample :ambi_glass_rub as a source and play it by using a slice of the sample played with different rpitch settings. I also transposed the left and right hands so that the left hand (bass) plays above the right hand part which is lower in pitch. It give an interesting effect.

You can listen to it here

The code (which is quite log because of the data) is below:

#SlicedBachWithHandsSwapped.rb arrange by Robin Newman, February 2023
#Bach's Invention no 13 played with a single sample but with Left and Right hands of the piano transposed in pitch
#so that the left hand sounds higher than the right. Gives an interesting effect.
#illustrates use of my splaytimed function which acts like play_pattern_timed command only for samples rather than synths
#it also allows manipulation of the sample via slicing and/or use of start and finish parameters.
#an offset parameter allows the transposition of the parts.
use_bpm 100
define :splaytimed do|sn,*args| #this plays patterns of notes with supplied associated durations
  av =args[0] #extract supplied args for pitchlist,durlist and offset
  pl=av[:pitchlist];offset = av[:offset];dur=av[:durlist]
  offset=0 if offset==nil #deal with missing offset
  if pl==nil or dur==nil
    raise "you must supply both pitchlist: and durlist: arguments"
    stop
  end
  #puts "av",av
  #now delete pitchlist and durlist from remaining args
  av.delete(:pitchlist)
  av.delete(:durlist)
  #puts "av stripped",av
  #use a loop to play the sequence of relative pitches and durations
  pl.length.times do
    tick
    #put next rpitch and dur (and offset if there is one)  values into p1,p2
    p1=pl.look+offset;p2=dur.look
    #puts p1,p2
    #now create opts list for calling the sample by merging in rpitch sustain and release values
    opts=( { :rpitch=> p1,:sustain => 0,:release => p2 } ).merge(av)
    #note these values can be overriden in call to splaytimed eg add sustain: 0.1
    #puts opts
    #play thesample
    sample sn,opts if ![:r,:rest,nil].include? pl.look #don't play if a rest
    sleep dur.look #sleep current duration value
  end
end
with_fx :reverb, room: 0.6,mix: 0.7 do
  p1=[:r,:E4,:A4,:C5,:B4,:E4,:B4,:D5,:C5,:E5,:Gs4,:E5,:A4,:E4,:A4,:C5,:B4,:E4,:B4,:D5,:C5,:A4,:r,:r,:E5,:C5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E4,:A4,:C5,:B4,:E4,:B4,:D5,:C5,:A4,:C5,:E5,:D5,:B4,:D5,:F5,:E5,:C5,:E5,:G5,:F5,:E5,:D5,:C5,:B4,:C5,:D5,:E5,:F5,:D5,:Gs5,:D5,:B5,:D5,:C5,:A5,:F5,:D5,:B4,:D5,:Gs4,:B4,:C5,:A4,:E4,:A4,:B4,:Gs4,:A4,:E4,:C4,:E4,:A3]
  d1=[0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.5,0.5,0.5,0.5,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.5,0.5,1.0,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.5,0.5,0.5,0.75,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.5,0.5,0.5,0.75,0.25,0.25,0.25,0.5,0.75,0.25,0.25,0.25,0.5,0.75,0.25,0.25,0.25,0.5,0.5,0.5,0.5,1.0,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.5,0.5,0.5,0.5,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.5,0.5,0.5,0.5,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.5,0.5,0.5,0.5,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.5,0.5,0.5,0.5,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.5,0.75,0.25,0.25,0.25,0.5,0.75,0.25,0.25,0.25,0.5,0.75,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.5,0.5,1.0,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.5,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.5,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.5,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.5,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.5,0.5,0.5,0.5,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.5,0.5,0.5,0.5,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,1.0]
  
  p2=[:A2,:A3,:Gs3,:A3,:E3,:A3,:C4,:B3,:E3,:B3,:D4,:C4,:A3,:Gs3,:E3,:A3,:E3,:A3,:C4,:B3,:E3,:B3,:D4,:C4,:A3,:C4,:A3,:D4,:A3,:F3,:A3,:D3,:F3,:A2,:C3,:B2,:D3,:G3,:B3,:G3,:E3,:G3,:C3,:E3,:G2,:B2,:A2,:C3,:D3,:F3,:B2,:D3,:G2,:B2,:C3,:E3,:A2,:C3,:F2,:D2,:G2,:G3,:F3,:G3,:C3,:G3,:C4,:E4,:D4,:G3,:D4,:F4,:E4,:C4,:B3,:G3,:C4,:G3,:C4,:E4,:D4,:G3,:D4,:F4,:E4,:C4,:r,:r,:G4,:E4,:G4,:C4,:E4,:G3,:B3,:A3,:C4,:E4,:G4,:Fs4,:A4,:D4,:Fs4,:A3,:D4,:Fs3,:A3,:G3,:B3,:D4,:Fs4,:E4,:G4,:C4,:E4,:G3,:C4,:E3,:G3,:Fs3,:A3,:B3,:Ds4,:r,:E4,:C4,:E4,:A3,:C4,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.5,0.5,0.5,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.5,0.5,0.5,0.5,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.5,0.5,0.5,0.5,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.75,0.25,0.25,0.25,0.5,0.5,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.5,0.5,0.5,0.5,0.5,0.5,0.25,0.25,0.25,0.25,0.5,0.5,0.5,0.5,0.5,0.5,0.25,0.25,0.25,0.25,0.5,0.5,0.5,0.5,0.5,0.5,0.25,0.25,0.25,0.25,0.5,0.5,0.5,0.5,0.5,0.5,0.25,0.25,0.25,0.25,0.5,0.5,0.5,0.5,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,2.0]
  in_thread do
    splaytimed :ambi_glass_rub,pitchlist: p1,durlist: d1,offset: -84+5,num_slices: 4,slice: 1,start: 0.2,finish: 0.5,attack: 0.01,release: 0.2,pan: 0.5,amp: 2
  end
  in_thread do
    splaytimed :ambi_glass_rub,pitchlist: p2,durlist: d2,offset: -72+5,num_slices: 4,slice: 1,start: 0.2,finish: 0.5,attack: 0.01,release: 0.2,pan: -0.5,amp: 2
  end
  in_thread do
    splaytimed :ambi_glass_rub,pitchlist: p1,durlist: d1,offset: -96+5,num_slices: 4,slice: 1,start: 0.2,finish: 0.5,attack: 0.01,release: 0.2,pan: 1,amp: 2
  end
  in_thread do
    splaytimed :ambi_glass_rub,pitchlist: p2,durlist: d2,offset: -60+5,num_slices: 4,slice: 1,start: 0.2,finish: 0.5,attack: 0.01,release: 0.2,pan: -1,amp: 2
  end
end
6 Likes