Note patterns using samples

Hi In_Thread’ers!

I created a little function to help me create more readable note patterns using samples. I thought I’d share it incase it helps someone else:

Here is the function:

define :getPitchFromNote do |note, octave, sampleBaseNote, fineTune|
  notePitch = (map a: 0, as: 1, b: 2, c: 3, cs: 4, d: 5, ds: 6, e: 7, f: 8, fs: 9, g: 10, gs: 11)[note]
  samplePitch = (map a: 0, as: 1, b: 2, c: 3, cs: 4, d: 5, ds: 6, e: 7, f: 8, fs: 9, g: 10, gs: 11)[sampleBaseNote]
  
  octaveAdj = -24 if octave == -2
  octaveAdj = -12 if octave == -1
  octaveAdj = 0 if octave == 0
  octaveAdj = 12 if octave == 1
  octaveAdj = 24 if octave == 2
  
  pitch = notePitch - samplePitch + octaveAdj + fineTune
  return pitch
end

And here is some code as an example:

define :getPitchFromNote do |note, octave, sampleBaseNote, fineTune|
  notePitch = (map a: 0, as: 1, b: 2, c: 3, cs: 4, d: 5, ds: 6, e: 7, f: 8, fs: 9, g: 10, gs: 11)[note]
  samplePitch = (map a: 0, as: 1, b: 2, c: 3, cs: 4, d: 5, ds: 6, e: 7, f: 8, fs: 9, g: 10, gs: 11)[sampleBaseNote]
  
  octaveAdj = -24 if octave == -2
  octaveAdj = -12 if octave == -1
  octaveAdj = 0 if octave == 0
  octaveAdj = 12 if octave == 1
  octaveAdj = 24 if octave == 2
  
  pitch = notePitch - samplePitch + octaveAdj + fineTune
  return pitch
end

use_bpm 124

# Using getPitchFromNote so that we can create more readable note patterns using samples
# E.G notes = (ring :a, :a, :a, :a, :r, :r, :b, :b, :r, :c, :d, :e)
# Instead of (ring 0, 0, 0, 0, :r, :r, 1, 1, :r, 2, 4, 5) -- 3 months later, what was this again? ;)

live_loop :bassGroove1 do
  s = :bass_dnb_f
  sampleBaseNote = :f
  octave = 1
  fineTune = 0
  
  sleeps = (ring 0.5, 0.25, 0.75, 0.5, 1, 1)
  notes = (ring :a, :a, :a, :a, :r, :r, :b, :b, :r, :c, :d, :e) 
  
  finish = (line 0.5, 0.8, steps: 6)
  
  tick
  
  with_swing rrand(-0.02, 0.03), phase: 8 do
    with_fx :whammy, grainsize: 1.5 do
      sample s, rpitch: (getPitchFromNote notes.look, octave, sampleBaseNote, fineTune), amp: rrand(0.9, 1), start: 0.2, finish: finish.look if !rest? notes.look
    end
  end
  sleep sleeps.look
end


live_loop :beatGroove1 do
  sleeps = (ring 0.5, 0.5, 0.5, 0.5, 0.5, 0.25, 0.25, 0.25, 0.25, 0.5)
  beats = (ring :bd_fat, :bd_fat, :bd_fat, :bd_fat, :perc_snap, :bd_fat, :perc_snap, :bd_fat, :perc_snap, :bd_fat)
  
  with_swing rrand(-0.03, 0.04), phase: 8 do
    with_fx :distortion, distort: 0.3 do
      sample beats.look, amp: rrand(0.9, 1)
    end
  end
  
  sleep sleeps.tick
end


live_loop :beatGroove2 do
  s = :elec_tick
  sleep 8
  
  64.times do
    with_swing rrand(-0.02, 0.03), phase: 8 do
      sample s, amp: rrand(1.7, 2), start: 0.15 if (spread 2, 9).tick
    end
    
    sleep 0.25
  end
end

Some nice use of whammy there!

Isnt getting pitch from the note easier by reducing the sample key from the played note. You can also use pitch_to_ratio to use the rate directly. I might be tone deaf but this sounds about right:

use_synth :chiplead
notes = [:c,:d,:e,:f,:g,:a,:b,:c5]

s = :bass_dnb_f
notes.each { |n|
  play n, pitch: -24
  sample s, rate: pitch_to_ratio(n-:f)
  sample s, rpitch: n-:f
  sleep 1
}

Thanks Amiika,

This is much simpler - and after listening to your example, I spotted a mistake in the function I posted. I think it is I who is tone deaf! :slight_smile: