class Musicality::PortamentoConverter
Public Class Methods
portamento_elements(start_pitch, target_pitch, cents_per_step, duration, attack)
click to toggle source
# File lib/musicality/performance/conversion/portamento_converter.rb, line 15 def self.portamento_elements(start_pitch, target_pitch, cents_per_step, duration, attack) pitches = portamento_pitches(start_pitch, target_pitch, cents_per_step) subdur = Rational(duration, pitches.size) first = true pitches.map do |pitch| el = NoteSequence::Element.new(subdur, pitch, first ? attack : Attack::NONE) first = false el end end
portamento_pitches(start_pitch, target_pitch, cents_per_step)
click to toggle source
# File lib/musicality/performance/conversion/portamento_converter.rb, line 4 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| Pitch.new(cent: cent) end end