Class: Synthesizer::NotePerform
- Inherits:
-
Object
- Object
- Synthesizer::NotePerform
- Defined in:
- lib/synthesizer/note_perform.rb
Instance Attribute Summary collapse
-
#note ⇒ Object
readonly
Returns the value of attribute note.
-
#synth ⇒ Object
readonly
Returns the value of attribute synth.
-
#velocity ⇒ Object
readonly
Returns the value of attribute velocity.
Instance Method Summary collapse
-
#initialize(synth, note, velocity) ⇒ NotePerform
constructor
A new instance of NotePerform.
- #next ⇒ Object
- #note_off! ⇒ Object
- #note_on? ⇒ Boolean
- #released? ⇒ Boolean
Constructor Details
#initialize(synth, note, velocity) ⇒ NotePerform
Returns a new instance of NotePerform.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/synthesizer/note_perform.rb', line 8 def initialize(synth, note, velocity) @synth = synth @note = note @velocity = velocity @processors = synth.oscillators.map {|osc| synth.processor.generator(osc, self) } @note_on = true @released = false end |
Instance Attribute Details
#note ⇒ Object (readonly)
Returns the value of attribute note.
5 6 7 |
# File 'lib/synthesizer/note_perform.rb', line 5 def note @note end |
#synth ⇒ Object (readonly)
Returns the value of attribute synth.
4 5 6 |
# File 'lib/synthesizer/note_perform.rb', line 4 def synth @synth end |
#velocity ⇒ Object (readonly)
Returns the value of attribute velocity.
6 7 8 |
# File 'lib/synthesizer/note_perform.rb', line 6 def velocity @velocity end |
Instance Method Details
#next ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/synthesizer/note_perform.rb', line 21 def next begin @processors.map(&:[]).inject(:+) rescue StopIteration => e @released = true nil end end |
#note_off! ⇒ Object
34 35 36 |
# File 'lib/synthesizer/note_perform.rb', line 34 def note_off! @note_on = false end |
#note_on? ⇒ Boolean
30 31 32 |
# File 'lib/synthesizer/note_perform.rb', line 30 def note_on? @note_on end |
#released? ⇒ Boolean
38 39 40 |
# File 'lib/synthesizer/note_perform.rb', line 38 def released? @released end |