Class: Stretto::Voice
Overview
Represent a channel or track, according to the MIDI specification. Each voice has an individual key signature, instrument, and for some values, different controller variables
The MIDI specification allows a pattern to have up to 16 channels, being the channel 9 the percussion 1.
Constant Summary
- DEFAULT_LAYER_INDEX =
0
Instance Attribute Summary (collapse)
-
- (Object) index
readonly
Returns the value of attribute index.
-
- (Object) layers
readonly
Returns the value of attribute layers.
Instance Method Summary (collapse)
-
- (Object) <<(element)
Appends an element to the voice, creating an additional layer if necessary.
-
- (Array(MusicElement)) elements
Method intended to keep consistency between array-like structures.
-
- (Voice) initialize(index, *args)
constructor
A new instance of Voice.
-
- (Object) layer(index)
Accesor for the layer in the specified index.
Methods inherited from Array
Constructor Details
- (Voice) initialize(index, *args)
A new instance of Voice
18 19 20 21 22 |
# File 'lib/stretto/music_elements/voice.rb', line 18 def initialize(index, *args) @layers = {} @index = index super(*args) end |
Instance Attribute Details
- (Object) index (readonly)
Returns the value of attribute index
16 17 18 |
# File 'lib/stretto/music_elements/voice.rb', line 16 def index @index end |
- (Object) layers (readonly)
Returns the value of attribute layers
15 16 17 |
# File 'lib/stretto/music_elements/voice.rb', line 15 def layers @layers end |
Instance Method Details
- (Object) <<(element)
Appends an element to the voice, creating an additional layer if necessary.
32 33 34 35 36 37 38 39 40 |
# File 'lib/stretto/music_elements/voice.rb', line 32 def <<(element) if element.kind_of?(Stretto::MusicElements::LayerChange) @current_layer = (@layers[element.index] ||= Layer.new) else @layers[DEFAULT_LAYER_INDEX] = @current_layer = Layer.new unless @current_layer @current_layer << element end super(element) end |
- (Array(MusicElement)) elements
Method intended to keep consistency between array-like structures
26 27 28 |
# File 'lib/stretto/music_elements/voice.rb', line 26 def elements to_a end |