class Alda::Octave
An octave event. An Alda::EventContainer containing an Alda::Octave can be derived using event list sugar. See Alda::EventList#method_missing.
o! means octave up, and o? means octave down. You can also use +@ and -@ to denote octave up and down.
Attributes
num[RW]
up_or_down[RW]
Positive for up, negative for down, and 0 as default.
Alda::Score.new do p((++++o).event.up_or_down) # => 4 end
Public Class Methods
new(num) → Alda::Octave
click to toggle source
Creates an Alda::Octave.
Calls superclass method
# File lib/alda-rb/event.rb, line 672 def initialize num super() @num = num.to_s @up_or_down = 0 end
Public Instance Methods
+octave → octave
click to toggle source
Octave up.
Alda::Score.new { piano_; c; +o; c }.play # (plays C4, then C5)
See -@.
# File lib/alda-rb/event.rb, line 688 def +@ @up_or_down += 1 self end
-octave → octave
click to toggle source
Octave down. See +@.
# File lib/alda-rb/event.rb, line 699 def -@ @up_or_down -= 1 self end
octave == other → true or false
click to toggle source
Overrides Alda::Event#==. Returns true if other is an Alda::Octave and has the same num and up_or_down as octave (using ==).
Calls superclass method
Alda::Event#==
# File lib/alda-rb/event.rb, line 727 def == other super || other.is_a?(Alda::Octave) && @num == other.num && @up_or_down == other.up_or_down end
to_alda_code() → String
click to toggle source
Overrides Alda::Event#to_alda_code.
# File lib/alda-rb/event.rb, line 709 def to_alda_code case @up_or_down <=> 0 when 0 ?o + @num when 1 ?> * @up_or_down when -1 ?< * -@up_or_down end end