Class: Banjo::Note
- Inherits:
-
Object
- Object
- Banjo::Note
- Defined in:
- lib/banjo/note.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
Returns the value of attribute channel.
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#note ⇒ Object
Returns the value of attribute note.
-
#velocity ⇒ Object
Returns the value of attribute velocity.
Instance Method Summary collapse
- #at(tick) ⇒ Object
- #every(period, offset = 0) ⇒ Object
- #for(duration) ⇒ Object
-
#initialize(channel, note) ⇒ Note
constructor
A new instance of Note.
- #play ⇒ Object
- #with_velocity(velocity) ⇒ Object
Constructor Details
#initialize(channel, note) ⇒ Note
Returns a new instance of Note.
5 6 7 8 9 10 |
# File 'lib/banjo/note.rb', line 5 def initialize(channel, note) self.channel = channel self.note = note self.velocity = 100 self.duration = 0.5 end |
Instance Attribute Details
#channel ⇒ Object
Returns the value of attribute channel.
3 4 5 |
# File 'lib/banjo/note.rb', line 3 def channel @channel end |
#duration ⇒ Object
Returns the value of attribute duration.
3 4 5 |
# File 'lib/banjo/note.rb', line 3 def duration @duration end |
#note ⇒ Object
Returns the value of attribute note.
3 4 5 |
# File 'lib/banjo/note.rb', line 3 def note @note end |
#velocity ⇒ Object
Returns the value of attribute velocity.
3 4 5 |
# File 'lib/banjo/note.rb', line 3 def velocity @velocity end |
Instance Method Details
#at(tick) ⇒ Object
12 13 14 |
# File 'lib/banjo/note.rb', line 12 def at(tick) play if Banjo.tick == tick end |
#every(period, offset = 0) ⇒ Object
16 17 18 |
# File 'lib/banjo/note.rb', line 16 def every(period, offset = 0) play if ((Banjo.tick + offset) % period == 0) end |
#for(duration) ⇒ Object
25 26 27 28 |
# File 'lib/banjo/note.rb', line 25 def for(duration) self.duration = duration self end |
#play ⇒ Object
30 31 32 |
# File 'lib/banjo/note.rb', line 30 def play channel.play_note!(note, velocity, duration) end |
#with_velocity(velocity) ⇒ Object
20 21 22 23 |
# File 'lib/banjo/note.rb', line 20 def with_velocity(velocity) self.velocity = velocity self end |