     
     static var imperfectMembers: [IntervalQuality.EnumKind] {
         return [major, minor, diminished, augmented]
+    }
+    
+    static func adjustDifference(difference: Float,
+        forLowerPitchSpelling pitchSpelling: PitchSpelling
+    ) -> Float
+    {
+        return [.b, .e].contains(pitchSpelling.letterName) ? difference - 1 : difference
     }
     
     static func intervalQuality(fromDirectionDifference difference: Float)

        }
    }
    
    /// Fourth interval family.
    public class Fourth: EnumFamily, PerfectIntervalQuatlityType {
        
        /// diminished Fourth interval.
        public static let diminished: EnumKind = .diminishedFourth
        
        /// perfect Fourth interval.
        public static let perfect: EnumKind = .perfectFourth
        
        /// augmented Fouth interval.
        public static let augmented: EnumKind = .augmentedFourth
        
        public override class var members: [EnumKind] { return perfectMembers }
        
        // DEFAULT Perfect implementation
        public override class func kind(
            forPitchSpellingDyad pitchSpellingDyad: PitchSpellingDyad
        ) -> EnumKind
        {
            // exception if lower is F
            let lowerDirection = pitchSpellingDyad.lower.coarse.direction.rawValue
            let higherDirection = pitchSpellingDyad.higher.coarse.direction.rawValue
            var difference: Float {
                var result = (higherDirection - lowerDirection)
                if pitchSpellingDyad.lower.letterName == .f { result += 1 }
                return result
            }

            switch difference {
            case -1, -2: return diminished
            case -0: return perfect
            case +1, +2: return augmented
            default: fatalError("Such an interval couldn't possibly exist")
            }
        }
    }
    
    /// Fifth interval family.
    public class Fifth: EnumFamily, PerfectIntervalQuatlityType {
        
        /// diminished Fifth interval.
        public static let diminished: EnumKind = .diminishedFifth
        
        /// perfect Fifth interval.
        public static let perfect: EnumKind = .perfectFifth
        
        /// augmented Fifth interval.
        public static let augmented: EnumKind = .augmentedFifth
        
        public override class var members: [EnumKind] { return perfectMembers }
    
        // DEFAULT Perfect implementation
        public override class func kind(
            forPitchSpellingDyad pitchSpellingDyad: PitchSpellingDyad
            ) -> EnumKind
        {
            // exception if lower is B
            let lowerDirection = pitchSpellingDyad.lower.coarse.direction.rawValue
            let higherDirection = pitchSpellingDyad.higher.coarse.direction.rawValue
            var difference: Float {
                var result = (higherDirection - lowerDirection)
                if pitchSpellingDyad.lower.letterName == .b { result -= 1 }
                return result
            }
            
            switch difference {
            case -1, -2: return diminished
            case -0: return perfect
            case +1, +2: return augmented
            default: fatalError("Such an interval couldn't possibly exist")
            }
        }
    }
    
    /// Sixth interval family.
    public class Sixth: EnumFamily, ImperfectIntervalQualityType {
        
        /// diminished Sixth interval.
        public static let diminished: EnumKind = .diminishedSixth
        
        /// minor Sixth interval.
        public static let minor: EnumKind = .minorSixth
        
        /// major Sixth interval.
        public static let major: EnumKind = .majorSixth
        
        /// augmented Sixth interval.
        public static let augmented: EnumKind = .augmentedSixth
        
        public override class var members: [EnumKind] { return imperfectMembers }
        
        // DEFAULT Impefect implementation
        public override class func kind(forPitchSpellingDyad pitchSpellingDyad: PitchSpellingDyad)
            -> EnumKind
        {
            // exception if lower is B or E
            let lowerDirection = pitchSpellingDyad.lower.coarse.direction.rawValue
            let higherDirection = pitchSpellingDyad.higher.coarse.direction.rawValue
            var difference: Float {
                var result = (higherDirection - lowerDirection)
                if [.b, .e].contains(pitchSpellingDyad.lower.letterName) { result -= 1 }
                return result
            }
            switch difference {
            case -2: return diminished
            case -1: return minor
            case +0: return major
            case +1: return augmented
            default: fatalError("Such an interval couldn't possibly exist")
            }
        }
    }
    
    /// Seventh interval family.
    public class Seventh: EnumFamily, ImperfectIntervalQualityType {
        
        /// diminished Seventh interval.
        public static let diminished: EnumKind = .diminishedSeventh
        
        /// minor Seventh interval.
        public static let minor: EnumKind = .minorSeventh
        
        /// major Seventh interval.
        public static let major: EnumKind = .majorSeventh
        
        /// augmented Seventh interal.
        public static let augmented: EnumKind = .augmentedSeventh
        
        public override class var members: [EnumKind] { return imperfectMembers }
        
        // DEFAULT Impefect implementation
        public override class func kind(forPitchSpellingDyad pitchSpellingDyad: PitchSpellingDyad)
            -> EnumKind
        {
            // exception if lower is B or E
            let lowerDirection = pitchSpellingDyad.lower.coarse.direction.rawValue
            let higherDirection = pitchSpellingDyad.higher.coarse.direction.rawValue
            var difference: Float {
                var result = (higherDirection - lowerDirection)
                if [.b, .e].contains(pitchSpellingDyad.lower.letterName) { result -= 1 }
                return result
            }
            switch difference {
            case -2: return diminished
            case -1: return minor
            case +0: return major
            case +1: return augmented
            default: fatalError("Such an interval couldn't possibly exist")
            }
        }
    }
    
    public class var members: [EnumKind] { return [] }
    
    public class var subFamilies: [EnumFamily.Type] {

            forLowerPitchSpelling pitchSpelling: PitchSpelling
        ) -> Float
        {
            return pitchSpelling.letterName == .f ? difference + 1 : difference
        }
    }
    
    /// Fifth interval family.
    public class Fifth: EnumFamily, PerfectIntervalQuatlityType {
        
        /// diminished Fifth interval.
        public static let diminished: EnumKind = .diminishedFifth
        
        /// perfect Fifth interval.
        public static let perfect: EnumKind = .perfectFifth
        
        /// augmented Fifth interval.
        public static let augmented: EnumKind = .augmentedFifth
        
        public override class var members: [EnumKind] { return perfectMembers }
    
        public override class func kind(
            forPitchSpellingDyad pitchSpellingDyad: PitchSpellingDyad
        ) -> EnumKind
        {
            let difference = directionDifference(fromPitchSpellingDyad: pitchSpellingDyad)
            return intervalQuality(fromDirectionDifference: difference)
        }
        
        static func adjustDifference(difference: Float,
            forLowerPitchSpelling pitchSpelling: PitchSpelling
        ) -> Float
        {
            return pitchSpelling.letterName == .b ? difference - 1 : difference
        }
    }
    
    /// Sixth interval family.
    public class Sixth: EnumFamily, ImperfectIntervalQualityType {
        
        /// diminished Sixth interval.
        public static let diminished: EnumKind = .diminishedSixth
        
        /// minor Sixth interval.
        public static let minor: EnumKind = .minorSixth
        
        /// major Sixth interval.
        public static let major: EnumKind = .majorSixth
        
        /// augmented Sixth interval.
        public static let augmented: EnumKind = .augmentedSixth
        
        public override class var members: [EnumKind] { return imperfectMembers }
        
        public override class func kind(
            forPitchSpellingDyad pitchSpellingDyad: PitchSpellingDyad
            ) -> EnumKind
        {
            let difference = directionDifference(fromPitchSpellingDyad: pitchSpellingDyad)
            return intervalQuality(fromDirectionDifference: difference)
        }
    }
    
    /// Seventh interval family.
    public class Seventh: EnumFamily, ImperfectIntervalQualityType {
        
        /// diminished Seventh interval.
        public static let diminished: EnumKind = .diminishedSeventh
        
        /// minor Seventh interval.
        public static let minor: EnumKind = .minorSeventh
        
        /// major Seventh interval.
        public static let major: EnumKind = .majorSeventh
        
        /// augmented Seventh interal.
        public static let augmented: EnumKind = .augmentedSeventh
        
        public override class var members: [EnumKind] { return imperfectMembers }
        
