Module: SampleGenerator

Defined in:
lib/sample_generator.rb

Instance Method Summary collapse

Instance Method Details

#make_parabolic_samples(count) ⇒ Object

Make a set of samples conforming to a parabola. This method would be used in place of loading the WAV file.



13
14
15
16
17
18
19
20
# File 'lib/sample_generator.rb', line 13

def make_parabolic_samples(count)
  f = ->(x) { -4*x**2 + 4*x }
  count.times.map {|index|
    index.to_f / (count-1)
  }.map(&f).map {|sample|
    sample*2-1
  }
end

#make_random_samples(count) ⇒ Object

Make a set of random samples. Useful for generating a cyclic noise wavetable. This method would be used in place of loading the WAV file.



5
6
7
8
9
# File 'lib/sample_generator.rb', line 5

def make_random_samples(count)
  count.times.map {
    rand*2-1
  }
end