lib/xi/pattern/generators.rb in xi-lang-0.1.5 vs lib/xi/pattern/generators.rb in xi-lang-0.1.6

- old
+ new

@@ -63,11 +63,11 @@ # @param list [#each] list of values # @param repeats [Fixnum, Symbol] number or inf (default: 1) # @return [Pattern] # def rand(list, repeats=1) - Pattern.new(size: repeats) do |y| + Pattern.new(list, size: repeats) do |y| ls = list.to_a loop_n(repeats) { y << ls.sample } end end @@ -85,11 +85,11 @@ # @param list [#each] list of values # @param repeats [Fixnum, Symbol] number or inf (default: 1) # @return [Pattern] # def xrand(list, repeats=1) - Pattern.new(size: repeats) do |y| + Pattern.new(list, size: repeats) do |y| ls = list.to_a xs = nil loop_n(repeats) do |i| xs = ls.shuffle if i % ls.size == 0 y << xs[i % ls.size] @@ -111,11 +111,11 @@ # @param list [#each] list of values # @param repeats [Fixnum, Symbol] number or inf (default: 1) # @return [Pattern] # def shuf(list, repeats=1) - Pattern.new(size: list.size * repeats) do |y| + Pattern.new(list, size: list.size * repeats) do |y| xs = list.to_a.shuffle loop_n(repeats) do |i| xs.each { |x| y << x } end end @@ -127,11 +127,11 @@ # Values range from -1 to 1 # # @see #sin1 for the same function but constrained on 0 to 1 values # # @example - # P.sin(8).map { |i| i.round(2) } + # peek P.sin(8).map { |i| i.round(2) } # #=> [0.0, 0.71, 1.0, 0.71, 0.0, -0.71, -1.0, -0.71] # # @example +quant+ determines the size, +delta+ the total duration # P.sin(8).size #=> 8 # P.sin(22).duration #=> (1/1) @@ -155,10 +155,10 @@ # Values range from 0 to 1 # # @see #sin # # @example - # P.sin1(8).map { |i| i.round(2) } + # peek P.sin1(8).map { |i| i.round(2) } # #=> [0.5, 0.85, 1.0, 0.85, 0.5, 0.15, 0.0, 0.15] # # @param quant [Fixnum] # @param delta [Fixnum] (default: 1) # @return [Pattern]