Sha256: e47917dbfa808234ecb9e142b6b911f730a1ea836b08d5f8a11f52a9211dd278
Contents?: true
Size: 801 Bytes
Versions: 5
Compression:
Stored size: 801 Bytes
Contents
module Music module Performance class PortamentoConverter 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 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 end end end
Version data entries
5 entries across 5 versions & 1 rubygems