Class: Music::Performance::PortamentoConverter
- Inherits:
-
Object
- Object
- Music::Performance::PortamentoConverter
- Defined in:
- lib/music-performance/conversion/portamento_converter.rb
Class Method Summary collapse
- .portamento_elements(start_pitch, target_pitch, cents_per_step, duration, accented) ⇒ Object
- .portamento_pitches(start_pitch, target_pitch, cents_per_step) ⇒ Object
Class Method Details
.portamento_elements(start_pitch, target_pitch, cents_per_step, duration, accented) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/music-performance/conversion/portamento_converter.rb', line 16 def self.portamento_elements(start_pitch, target_pitch, cents_per_step, duration, accented) pitches = portamento_pitches(start_pitch, target_pitch, cents_per_step) subdur = Rational(duration, pitches.size) pitches.map do |pitch| SlurredElement.new(subdur, pitch, accented) end end |
.portamento_pitches(start_pitch, target_pitch, cents_per_step) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/music-performance/conversion/portamento_converter.rb', line 5 def self.portamento_pitches(start_pitch, target_pitch, cents_per_step) start, finish = start_pitch.total_cents, target_pitch.total_cents step_size = finish >= start ? cents_per_step : -cents_per_step nsteps = ((finish - 1 - start) / step_size.to_f).ceil cents = Array.new(nsteps+1){|i| start + i * step_size } cents.map do |cent| Music::Transcription::Pitch.new(cent: cent) end end |