Module: Musa::Series::Constructors
- Extended by:
- Constructors
- Included in:
- Musa::Series, Constructors
- Defined in:
- lib/musa-dsl/series/base-series.rb,
lib/musa-dsl/series/proxy-serie.rb,
lib/musa-dsl/series/queue-serie.rb,
lib/musa-dsl/series/timed-serie.rb,
lib/musa-dsl/series/quantizer-serie.rb,
lib/musa-dsl/series/main-serie-constructors.rb
Defined Under Namespace
Classes: FromArray, ProxySerie, QueueSerie, UndefinedSerie
Instance Method Summary collapse
- #A(*series) ⇒ Object
- #AC(*series) ⇒ Object
- #E(*value_args, **key_args, &block) ⇒ Object
- #FIBO ⇒ Object
- #FOR(from: nil, to: nil, step: nil) ⇒ Object
- #H(**series_hash) ⇒ Object
- #HARMO(error: nil, extended: nil) ⇒ Object
- #HC(**series_hash) ⇒ Object
- #MERGE(*series) ⇒ Object
- #NIL ⇒ Object
- #PROXY(serie = nil) ⇒ Object
- #QUANTIZE(time_value_serie, reference: nil, step: nil, value_attribute: nil, stops: nil, predictive: nil, left_open: nil, right_open: nil) ⇒ Object
- #QUEUE(*series) ⇒ Object
- #RND(*_values, values: nil, from: nil, to: nil, step: nil, random: nil) ⇒ Object
- #RND1(*_values, values: nil, from: nil, to: nil, step: nil, random: nil) ⇒ Object
- #S(*values) ⇒ Object
- #SIN(start_value: nil, steps: nil, amplitude: nil, center: nil) ⇒ Object
- #TIMED_UNION(*array_of_timed_series, **hash_of_timed_series) ⇒ Object
- #UNDEFINED ⇒ Object
Instance Method Details
#A(*series) ⇒ Object
32 33 34 |
# File 'lib/musa-dsl/series/main-serie-constructors.rb', line 32 def A(*series) FromArrayOfSeries.new series, false end |
#AC(*series) ⇒ Object
36 37 38 |
# File 'lib/musa-dsl/series/main-serie-constructors.rb', line 36 def AC(*series) FromArrayOfSeries.new series, true end |
#E(*value_args, **key_args, &block) ⇒ Object
40 41 42 |
# File 'lib/musa-dsl/series/main-serie-constructors.rb', line 40 def E(*value_args, **key_args, &block) FromEvalBlockWithParameters.new *value_args, **key_args, &block end |
#FIBO ⇒ Object
99 100 101 |
# File 'lib/musa-dsl/series/main-serie-constructors.rb', line 99 def FIBO() Fibonacci.new end |
#FOR(from: nil, to: nil, step: nil) ⇒ Object
44 45 46 47 48 |
# File 'lib/musa-dsl/series/main-serie-constructors.rb', line 44 def FOR(from: nil, to: nil, step: nil) from ||= 0 step ||= 1 ForLoop.new from, to, step end |
#H(**series_hash) ⇒ Object
24 25 26 |
# File 'lib/musa-dsl/series/main-serie-constructors.rb', line 24 def H(**series_hash) FromHashOfSeries.new series_hash, false end |
#HARMO(error: nil, extended: nil) ⇒ Object
103 104 105 106 107 |
# File 'lib/musa-dsl/series/main-serie-constructors.rb', line 103 def HARMO(error: nil, extended: nil) error ||= 0.5 extended ||= false HarmonicNotes.new error, extended end |
#HC(**series_hash) ⇒ Object
28 29 30 |
# File 'lib/musa-dsl/series/main-serie-constructors.rb', line 28 def HC(**series_hash) FromHashOfSeries.new series_hash, true end |
#MERGE(*series) ⇒ Object
69 70 71 |
# File 'lib/musa-dsl/series/main-serie-constructors.rb', line 69 def MERGE(*series) Sequence.new(series) end |
#NIL ⇒ Object
16 17 18 |
# File 'lib/musa-dsl/series/main-serie-constructors.rb', line 16 def NIL NilSerie.new end |
#PROXY(serie = nil) ⇒ Object
5 6 7 |
# File 'lib/musa-dsl/series/proxy-serie.rb', line 5 def PROXY(serie = nil) ProxySerie.new(serie) end |
#QUANTIZE(time_value_serie, reference: nil, step: nil, value_attribute: nil, stops: nil, predictive: nil, left_open: nil, right_open: nil) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/musa-dsl/series/quantizer-serie.rb', line 28 def QUANTIZE(time_value_serie, reference: nil, step: nil, value_attribute: nil, stops: nil, predictive: nil, left_open: nil, right_open: nil) reference ||= 0r step ||= 1r value_attribute ||= :value stops ||= false predictive ||= false if predictive raise ArgumentError, "Predictive quantization doesn't allow parameters 'left_open' or 'right_open'" if left_open || right_open PredictiveQuantizer.new(reference, step, time_value_serie, value_attribute, stops) else # By default: left closed and right_open # By default 2: # if right_open is true and left_open is nil, left_open will be false # if left_open is true and right_open is nil, right_open will be false right_open = right_open.nil? ? !left_open : right_open left_open = left_open.nil? ? !right_open : left_open RawQuantizer.new(reference, step, time_value_serie, value_attribute, stops, left_open, right_open) end end |
#QUEUE(*series) ⇒ Object
5 6 7 |
# File 'lib/musa-dsl/series/queue-serie.rb', line 5 def QUEUE(*series) QueueSerie.new(series) end |
#RND(*_values, values: nil, from: nil, to: nil, step: nil, random: nil) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/musa-dsl/series/main-serie-constructors.rb', line 50 def RND(*_values, values: nil, from: nil, to: nil, step: nil, random: nil) raise ArgumentError, "Can't use both direct values #{_values} and values named parameter #{values} at the same time." if values && !_values.empty? random = Random.new random if random.is_a?(Integer) random ||= Random.new values ||= _values if !values.empty? && from.nil? && to.nil? && step.nil? RandomValuesFromArray.new values.explode_ranges, random elsif values.empty? && !to.nil? from ||= 0 step ||= 1 RandomNumbersFromRange.new from, to, step, random else raise ArgumentError, 'cannot use values and from:/to:/step: together' end end |
#RND1(*_values, values: nil, from: nil, to: nil, step: nil, random: nil) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/musa-dsl/series/main-serie-constructors.rb', line 73 def RND1(*_values, values: nil, from: nil, to: nil, step: nil, random: nil) raise ArgumentError, "Can't use both direct values #{_values} and values named parameter #{values} at the same time." if values && !_values.empty? random = Random.new random if random.is_a?(Integer) random ||= Random.new values ||= _values if !values.empty? && from.nil? && to.nil? && step.nil? RandomValueFromArray.new values.explode_ranges, random elsif values.empty? && !to.nil? from ||= 0 step ||= 1 RandomNumberFromRange.new from, to, step, random else raise ArgumentError, 'cannot use values and from:/to:/step: parameters together' end end |
#S(*values) ⇒ Object
20 21 22 |
# File 'lib/musa-dsl/series/main-serie-constructors.rb', line 20 def S(*values) FromArray.new values.explode_ranges end |
#SIN(start_value: nil, steps: nil, amplitude: nil, center: nil) ⇒ Object
92 93 94 95 96 97 |
# File 'lib/musa-dsl/series/main-serie-constructors.rb', line 92 def SIN(start_value: nil, steps: nil, amplitude: nil, center: nil) amplitude ||= 1.0 center ||= 0.0 start_value ||= center SinFunction.new start_value, steps, amplitude, center end |
#TIMED_UNION(*array_of_timed_series, **hash_of_timed_series) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/musa-dsl/series/timed-serie.rb', line 7 def TIMED_UNION(*array_of_timed_series, **hash_of_timed_series) raise ArgumentError, 'Can\'t union an array of series with a hash of series' if array_of_timed_series.any? && hash_of_timed_series.any? if array_of_timed_series.any? TimedUnionOfArrayOfTimedSeries.new(array_of_timed_series) elsif hash_of_timed_series.any? TimedUnionOfHashOfTimedSeries.new(hash_of_timed_series) else raise ArgumentError, 'Missing argument series' end end |
#UNDEFINED ⇒ Object
12 13 14 |
# File 'lib/musa-dsl/series/main-serie-constructors.rb', line 12 def UNDEFINED UndefinedSerie.new end |