Class: Synthesizer::StepEditor::StGt
- Inherits:
-
Object
- Object
- Synthesizer::StepEditor::StGt
- Defined in:
- lib/synthesizer/step_editor/st_gt.rb
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#ppq ⇒ Object
readonly
Returns the value of attribute ppq.
Instance Method Summary collapse
- #bpm=(bpm) ⇒ Object
- #complete ⇒ Object
-
#initialize(bpm:, ppq: 480, &block) ⇒ StGt
constructor
A new instance of StGt.
- #location(beats: 4) ⇒ Object
- #note(note, st: 0, gt:, vel: 1.0, dev: 0) ⇒ Object
- #pitch_bend(semis, st: 0, dev: 0) ⇒ Object
- #step(st) ⇒ Object
Constructor Details
#initialize(bpm:, ppq: 480, &block) ⇒ StGt
Returns a new instance of StGt.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/synthesizer/step_editor/st_gt.rb', line 8 def initialize(bpm:, ppq: 480, &block) @ppq = ppq @seek = 0.0 @location = 0 @events = [] self.bpm = bpm if block_given? yield self end end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
6 7 8 |
# File 'lib/synthesizer/step_editor/st_gt.rb', line 6 def events @events end |
#ppq ⇒ Object (readonly)
Returns the value of attribute ppq.
5 6 7 |
# File 'lib/synthesizer/step_editor/st_gt.rb', line 5 def ppq @ppq end |
Instance Method Details
#bpm=(bpm) ⇒ Object
20 21 22 |
# File 'lib/synthesizer/step_editor/st_gt.rb', line 20 def bpm=(bpm) @ppq_rate = 60.0 / (@ppq.to_f * bpm) end |
#complete ⇒ Object
50 51 52 |
# File 'lib/synthesizer/step_editor/st_gt.rb', line 50 def complete @events << [@seek, :complete] end |
#location(beats: 4) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/synthesizer/step_editor/st_gt.rb', line 29 def location(beats: 4) tick = @location % @ppq location = (@location - tick) / @ppq beat = location % beats location = location - beat measure = location / beats "#{measure+1}. #{beat+1}. #{tick}" end |
#note(note, st: 0, gt:, vel: 1.0, dev: 0) ⇒ Object
39 40 41 42 43 |
# File 'lib/synthesizer/step_editor/st_gt.rb', line 39 def note(note, st: 0, gt:, vel: 1.0, dev: 0) @events << [@seek + dev * @ppq_rate, :note_on, note, vel] @events << [@seek + (gt + dev) * @ppq_rate, :note_off, note] step(st) end |
#pitch_bend(semis, st: 0, dev: 0) ⇒ Object
45 46 47 48 |
# File 'lib/synthesizer/step_editor/st_gt.rb', line 45 def pitch_bend(semis, st: 0, dev: 0) @events << [@seek + dev * @ppq_rate, :pitch_bend, semis] step(st) end |
#step(st) ⇒ Object
24 25 26 27 |
# File 'lib/synthesizer/step_editor/st_gt.rb', line 24 def step(st) @location += st @seek += st * @ppq_rate end |