Interval

public struct Interval: Hashable, Sendable

The structure for an interval

  • Quality of the interval

    Declaration

    Swift

    public var quality: Quality
  • Degree of the interval

    Declaration

    Swift

    public var degree: Int
  • Semitones interval affect on a pitch

    Declaration

    Swift

    public var semitones: Int
  • P1

    Unison

    Declaration

    Swift

    public static let P1 = Interval(quality: .perfect, degree: 1, semitones: 0)
  • P4

    Perfect fourth

    Declaration

    Swift

    public static let P4 = Interval(quality: .perfect, degree: 4, semitones: 5)
  • P5

    Perfect fifth

    Declaration

    Swift

    public static let P5 = Interval(quality: .perfect, degree: 5, semitones: 7)
  • P8

    Octave

    Declaration

    Swift

    public static let P8 = Interval(quality: .perfect, degree: 8, semitones: 12)
  • P11

    Perfect eleventh

    Declaration

    Swift

    public static let P11 = Interval(quality: .perfect, degree: 11, semitones: 17)
  • P12

    Perfect twelfth

    Declaration

    Swift

    public static let P12 = Interval(quality: .perfect, degree: 12, semitones: 19)
  • P15

    Perfect fifteenth, double octave

    Declaration

    Swift

    public static let P15 = Interval(quality: .perfect, degree: 15, semitones: 24)
  • m2

    Minor second

    Declaration

    Swift

    public static let m2 = Interval(quality: .minor, degree: 2, semitones: 1)
  • m3

    Minor third

    Declaration

    Swift

    public static let m3 = Interval(quality: .minor, degree: 3, semitones: 3)
  • m6

    Minor sixth

    Declaration

    Swift

    public static let m6 = Interval(quality: .minor, degree: 6, semitones: 8)
  • m7

    Minor seventh

    Declaration

    Swift

    public static let m7 = Interval(quality: .minor, degree: 7, semitones: 10)
  • m9

    Minor ninth

    Declaration

    Swift

    public static let m9 = Interval(quality: .minor, degree: 9, semitones: 13)
  • m10

    Minor tenth

    Declaration

    Swift

    public static let m10 = Interval(quality: .minor, degree: 10, semitones: 15)
  • m13

    Minor thirteenth

    Declaration

    Swift

    public static let m13 = Interval(quality: .minor, degree: 13, semitones: 20)
  • m14

    Minor fourteenth

    Declaration

    Swift

    public static let m14 = Interval(quality: .minor, degree: 14, semitones: 22)
  • M2

    Major second

    Declaration

    Swift

    public static let M2 = Interval(quality: .major, degree: 2, semitones: 2)
  • M3

    Major third

    Declaration

    Swift

    public static let M3 = Interval(quality: .major, degree: 3, semitones: 4)
  • M6

    Major sixth

    Declaration

    Swift

    public static let M6 = Interval(quality: .major, degree: 6, semitones: 9)
  • M7

    Major seventh

    Declaration

    Swift

    public static let M7 = Interval(quality: .major, degree: 7, semitones: 11)
  • M9

    Major ninth

    Declaration

    Swift

    public static let M9 = Interval(quality: .major, degree: 9, semitones: 14)
  • M10

    Major tenth

    Declaration

    Swift

    public static let M10 = Interval(quality: .major, degree: 10, semitones: 16)
  • M13

    Major thirteenth

    Declaration

    Swift

    public static let M13 = Interval(quality: .major, degree: 13, semitones: 21)
  • M14

    Major fourteenth

    Declaration

    Swift

    public static let M14 = Interval(quality: .major, degree: 14, semitones: 23)
  • d1

    Diminished first

    Declaration

    Swift

    public static let d1 = Interval(quality: .diminished, degree: 1, semitones: -1)
  • d2

    Diminished second

    Declaration

    Swift

    public static let d2 = Interval(quality: .diminished, degree: 2, semitones: 0)
  • d3

    Diminished third

    Declaration

    Swift

    public static let d3 = Interval(quality: .diminished, degree: 3, semitones: 2)
  • d4

    Diminished fourth

    Declaration

    Swift

    public static let d4 = Interval(quality: .diminished, degree: 4, semitones: 4)
  • d5

    Diminished fifth

    Declaration

    Swift

    public static let d5 = Interval(quality: .diminished, degree: 5, semitones: 6)
  • d6

    Diminished sixth

    Declaration

    Swift

    public static let d6 = Interval(quality: .diminished, degree: 6, semitones: 7)
  • d7

    Diminished seventh

    Declaration

    Swift

    public static let d7 = Interval(quality: .diminished, degree: 7, semitones: 9)
  • d8

    Diminished eighth

    Declaration

    Swift

    public static let d8 = Interval(quality: .diminished, degree: 8, semitones: 11)
  • d9

    Diminished ninth

    Note

    Changed 12 to 13

    Declaration

    Swift

    public static let d9 = Interval(quality: .diminished, degree: 9, semitones: 13)
  • d10

    Diminished tenth

    Declaration

    Swift

    public static let d10 = Interval(quality: .diminished, degree: 10, semitones: 14)
  • d11

    Diminished eleventh

    Declaration

    Swift

    public static let d11 = Interval(quality: .diminished, degree: 11, semitones: 16)
  • d12

    Diminished twelfth

    Declaration

    Swift

    public static let d12 = Interval(quality: .diminished, degree: 12, semitones: 18)
  • d13

    Diminished thirteenth

    Declaration

    Swift

    public static let d13 = Interval(quality: .diminished, degree: 13, semitones: 19)
  • d14

    Diminished fourteenth

    Declaration

    Swift

    public static let d14 = Interval(quality: .diminished, degree: 14, semitones: 21)
  • d15

    Diminished fifteenth

    Declaration

    Swift

    public static let d15 = Interval(quality: .diminished, degree: 15, semitones: 23)
  • A1

    Augmented first

    Declaration

    Swift

    public static let A1 = Interval(quality: .augmented, degree: 1, semitones: 1)
  • A2

    Augmented second

    Declaration

    Swift

    public static let A2 = Interval(quality: .augmented, degree: 2, semitones: 3)
  • A3

    Augmented third

    Declaration

    Swift

    public static let A3 = Interval(quality: .augmented, degree: 3, semitones: 5)
  • A4

    Augmented fourth

    Declaration

    Swift

    public static let A4 = Interval(quality: .augmented, degree: 4, semitones: 6)
  • A5

    Augmented fifth

    Declaration

    Swift

    public static let A5 = Interval(quality: .augmented, degree: 5, semitones: 8)
  • A6

    Augmented sixth

    Declaration

    Swift

    public static let A6 = Interval(quality: .augmented, degree: 6, semitones: 10)
  • A7

    Augmented seventh

    Declaration

    Swift

    public static let A7 = Interval(quality: .augmented, degree: 7, semitones: 12)
  • A8

    Augmented octave

    Declaration

    Swift

    public static let A8 = Interval(quality: .augmented, degree: 8, semitones: 13)
  • A9

    Augmented ninth

    Declaration

    Swift

    public static let A9 = Interval(quality: .augmented, degree: 9, semitones: 15)
  • A10

    Augmented tenth

    Declaration

    Swift

    public static let A10 = Interval(quality: .augmented, degree: 10, semitones: 17)
  • A11

    Augmented eleventh

    Declaration

    Swift

    public static let A11 = Interval(quality: .augmented, degree: 11, semitones: 18)
  • A12

    Augmented twelfth

    Declaration

    Swift

    public static let A12 = Interval(quality: .augmented, degree: 12, semitones: 20)
  • A13

    Augmented thirteenth

    Declaration

    Swift

    public static let A13 = Interval(quality: .augmented, degree: 13, semitones: 22)
  • A14

    Augmented fourteenth

    Declaration

    Swift

    public static let A14 = Interval(quality: .augmented, degree: 14, semitones: 24)
  • A15

    Augmented fifteenth

    Declaration

    Swift

    public static let A15 = Interval(quality: .augmented, degree: 15, semitones: 25)

CustomStringConvertible

  • Returns the notation of the interval.

    Declaration

    Swift

    public var notation: String
  • Returns the name of the interval.

    Declaration

    Swift

    public var description: String
  • The quality of the interval

    See more

    Declaration

    Swift

    enum Quality: Sendable