class Alda::Part
A part event. An Alda::EventContainer
containing an Alda::Part
can be derived using event list sugar. See Alda::EventList#method_missing
.
A part can have nickname.
Alda::Score.new do piano_ 'player1' c4 d e e e1 piano_ 'player2' e4 d g g g1 end
You can use Alda::EventContainer#/ to have a set of instruments.
Alda::Score.new do violin_/viola_ c2 d4 e2_4 end
A set of instruments can also have nickname. You can also access an instruments from a set. See method_missing
.
Alda::Score.new do violin_/viola_/cello_('strings') g1_1_1 strings_.cello_ c1_1_1 end
Attributes
arg[RW]
The nickname of the part. nil
if none.
names[RW]
The names of the part. To be joined with /
as delimiter.
Public Class Methods
new(names, arg=nil) → Alda::Part
click to toggle source
Creates an Alda::Part
.
# File lib/alda-rb/event.rb, line 633 def initialize names, arg = nil @names = names.map { |name| name.to_s.tr ?_, ?- } @arg = arg end
Public Instance Methods
(component)_() → Alda::EventContainer or Alda::Part
click to toggle source
Enables dot accessor.
Alda::Score.new do violin_/viola_/cello_('strings'); g1_1_1 strings_.cello_; -o; c1_1_1 end.play
Calls superclass method
# File lib/alda-rb/event.rb, line 654 def method_missing name, *args str = name.to_s return super unless str[-1] == ?_ str[-1] = '' @names.last.concat ?., str if args.size == 1 unless @container @container = Alda::EventContainer.new nil, @parent @parent.events.delete self @parent.push @container end @container.event = Alda::Sequence.join self, args.first.tap(&:detach_from_parent) @container else @container || self end end
to_alda_code()
click to toggle source
# File lib/alda-rb/event.rb, line 638 def to_alda_code result = @names.join ?/ result.concat " \"#{@arg}\"" if @arg result.concat ?: end