Class: Diamond::SequenceParameters
- Inherits:
-
Object
- Object
- Diamond::SequenceParameters
- Defined in:
- lib/diamond/sequence_parameters.rb
Overview
User-controller parameters that are used to formulate the note event sequence
Instance Attribute Summary collapse
-
#gate ⇒ Object
Returns the value of attribute gate.
-
#interval ⇒ Object
Returns the value of attribute interval.
-
#pattern ⇒ Object
Returns the value of attribute pattern.
-
#pattern_offset ⇒ Object
Returns the value of attribute pattern_offset.
-
#range ⇒ Object
Returns the value of attribute range.
-
#rate ⇒ Object
Returns the value of attribute rate.
-
#resolution ⇒ Object
readonly
Returns the value of attribute resolution.
Instance Method Summary collapse
-
#computed_pattern ⇒ Array<Fixnum>
The computed pattern given the sequence options.
-
#constraints(param) ⇒ Range
Dynamically produce an acceptable range for the given param.
-
#duration ⇒ Numeric
The note duration given the sequence options.
-
#initialize(sequence, resolution, options = {}, &callback) ⇒ SequenceParameters
constructor
A new instance of SequenceParameters.
-
#transpose(num = nil) ⇒ Fixnum?
(also: #transpose=)
Transpose everything by the given number of scale degrees.
Constructor Details
#initialize(sequence, resolution, options = {}, &callback) ⇒ SequenceParameters
Returns a new instance of SequenceParameters.
24 25 26 27 28 29 30 |
# File 'lib/diamond/sequence_parameters.rb', line 24 def initialize(sequence, resolution, = {}, &callback) @transpose = 0 @resolution = resolution @callback = callback () sequence.send(:use_parameters, self) end |
Instance Attribute Details
#gate ⇒ Object
Returns the value of attribute gate.
6 7 8 |
# File 'lib/diamond/sequence_parameters.rb', line 6 def gate @gate end |
#interval ⇒ Object
Returns the value of attribute interval.
6 7 8 |
# File 'lib/diamond/sequence_parameters.rb', line 6 def interval @interval end |
#pattern ⇒ Object
Returns the value of attribute pattern.
6 7 8 |
# File 'lib/diamond/sequence_parameters.rb', line 6 def pattern @pattern end |
#pattern_offset ⇒ Object
Returns the value of attribute pattern_offset.
6 7 8 |
# File 'lib/diamond/sequence_parameters.rb', line 6 def pattern_offset @pattern_offset end |
#range ⇒ Object
Returns the value of attribute range.
6 7 8 |
# File 'lib/diamond/sequence_parameters.rb', line 6 def range @range end |
#rate ⇒ Object
Returns the value of attribute rate.
6 7 8 |
# File 'lib/diamond/sequence_parameters.rb', line 6 def rate @rate end |
#resolution ⇒ Object (readonly)
Returns the value of attribute resolution.
6 7 8 |
# File 'lib/diamond/sequence_parameters.rb', line 6 def resolution @resolution end |
Instance Method Details
#computed_pattern ⇒ Array<Fixnum>
The computed pattern given the sequence options
133 134 135 |
# File 'lib/diamond/sequence_parameters.rb', line 133 def computed_pattern @pattern.compute(@range, @interval) end |
#constraints(param) ⇒ Range
Dynamically produce an acceptable range for the given param
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/diamond/sequence_parameters.rb', line 35 def constraints(param) ranges = { :gate => proc { get_lowest_gate..500 }, :interval => proc { -48..48 }, :pattern_offset => proc { -16..16 }, :range => proc { 0..10 }, :rate => proc { 0..@resolution }, :transpose => proc { -72..72 } } ranges[param].call end |
#duration ⇒ Numeric
The note duration given the sequence options
139 140 141 |
# File 'lib/diamond/sequence_parameters.rb', line 139 def duration @resolution / @rate end |
#transpose(num = nil) ⇒ Fixnum? Also known as: transpose=
Transpose everything by the given number of scale degrees. Can be used as a getter
124 125 126 127 128 |
# File 'lib/diamond/sequence_parameters.rb', line 124 def transpose(num = nil) @transpose = num unless num.nil? mark_changed @transpose end |