Simple semitone array for the rate opt

Hi
My student and I are exploring samples and re-pitching via rate:, so here is a simple sketch that fills an array with increments of the 12th root of 2, then applies those values to a sample’s playback rate - this is prolly already in the tutorial somewhere :wink:

a = []
12.times do
  y = tick #counter from 0 to 11
  x = 2**(y/12.0) #12th root of 2 = ~1.0594
  a.push(x) #fill array with semitone increments, starting at 1.0
end
puts a
sleep 1

12.times do
  sample :bass_thick_c, onset: 0, sustain: 0.4, rate: a.tick
  sleep 0.5
end

PD-Pi

1 Like

. . . and from there, you can choose different diatonic patterns - yes, you can do this with the scale function, but I like to teach students how to ‘roll your own’ first.

a = []
13.times do
  y = tick #counter from 0 to 12
  x = 2**(y/12.0) 
  a.push(x) 
end
puts a
sleep 1
tick_reset

8.times do
  maj = [0,2,4,5,7,9,11,12].tick
  sample :bass_thick_c, onset: 0, sustain: 0.4, rate: a[maj]
  sleep 0.5
end

PD-Pi

1 Like

Interesting. It’s an easy way to get just intonation, too. Could stick it in an array.