Mystic::Interval
Represents an interval
To create an Interval:
# Ascending Major 3rd
Interval.new("M3")
# Descending intervals have a negative value
# Descending Perfect 5th
Interval.new("P-5")
Available qualities are: M (major), m (minor), P (perfect), d (diminished), A (augmented). Going further is also possible, for example dd (doubly diminished) and AAA (triply augmented)
Constants
BASE_SEMITONES = [0, 2, 3, 5, 7, 8, 10]
INTERVAL_COORDS = {
"1": Coords.new(0, 0),
"2": Coords.new(3, -5),
"3": Coords.new(2, -3),
"4": Coords.new(1, -1),
"5": Coords.new(0, 1),
"6": Coords.new(3, -4),
"7": Coords.new(2, -2),
"8": Coords.new(1, 0),
}
QUALITY_SEMITONE_OFFSETS = {
P: 0,
m: 0,
M: 1,
A: 1,
d: -1,
}
SHARP_COORDS = Coords.new(-4, 7)
Constructors
from_coords(coords : Coords) : Interval
SourceInstance methods
+(other : self) : Interval
Source-(other : self) : Interval
Source<=>(other : self) : Int32
Note: this compares intervals as ordered on a staff rather than by pitch. For example, an A2 < d3 even though an A2 spans more semitones Also note: this compares magnitude only, so direction is not taken into account
octaves
Returns number of octaves above the simple interval Note: an octave is considered a simple interval
quality
Sourceto_s(io : IO)
Appends a short String representation of this object which includes its class name and its object address.
class Person
def initialize(@name : String, @age : Int32)
end
end
Person.new("John", 32).to_s # => #<Person:0x10a199f20>
value
Source