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
.
# File lib/alda-rb/event.rb, line 503 def initialize num @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 518 def +@ @up_or_down += 1 self end
-octave → octave
click to toggle source
Octave down. See +@
.
# File lib/alda-rb/event.rb, line 529 def -@ @up_or_down -= 1 self end
to_alda_code()
click to toggle source
# File lib/alda-rb/event.rb, line 534 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