Sha256: 6ce0e171cb0725ee5c5fa7f36b8ab51a4b3e463d0cdf778ad55cd87dffc2a2db

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

module Music
module Transcription

# Connect one note pitch to the target pitch of the next note, via slur, legato, etc.
#
# @!attribute [rw] target_pitch
#   @return [Pitch] The pitch of the note which is being connected to.
#
class Link
  def clone
    Marshal.load(Marshal.dump(self))
  end

  class Tie < Link
    def initialize; end
    
    def ==(other)
      self.class == other.class
    end
    
    def transpose! diff
      # do nothing, of course
    end
    
    def to_s; "="; end
  end
  
  class TargetedLink < Link
    attr_accessor :target_pitch, :link_char
    
    def initialize target_pitch, link_char
      @target_pitch = target_pitch
      @link_char = link_char
    end
    
    def ==(other)
      self.class == other.class && @target_pitch == other.target_pitch
    end
    
    def transpose! diff
      @target_pitch += diff
    end
    
    def to_s
      @link_char + @target_pitch.to_s
    end
  end
  
  class Glissando < TargetedLink
    def initialize(target_pitch); super(target_pitch,"~"); end
  end
  
  class Portamento < TargetedLink
    def initialize(target_pitch); super(target_pitch,"/"); end
  end
  
  class Slur < TargetedLink
    def initialize(target_pitch); super(target_pitch,"="); end
  end
  
  class Legato < TargetedLink
    def initialize(target_pitch); super(target_pitch,"-"); end
  end
end

end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
music-transcription-0.14.0 lib/music-transcription/model/link.rb
music-transcription-0.13.0 lib/music-transcription/model/link.rb