From 0b9a1f7eed2dc9e7743ffc2305524620f8c970f2 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 15 Nov 2018 12:02:58 -0500 Subject: [PATCH 1/4] Remove Pitch.h --- Sources/Pitch/Pitch.h | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 Sources/Pitch/Pitch.h diff --git a/Sources/Pitch/Pitch.h b/Sources/Pitch/Pitch.h deleted file mode 100644 index 47ede67..0000000 --- a/Sources/Pitch/Pitch.h +++ /dev/null @@ -1,7 +0,0 @@ -// -// Pitch.h -// Pitch -// -// Created by James Bean on 3/12/16. -// Copyright © 2016 James Bean. All rights reserved. -// From 252fd7081955e7dd45c5b64120944f52d1eab5c9 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 15 Nov 2018 12:08:58 -0500 Subject: [PATCH 2/4] Add Pitch.init(_: Pitch.Class) --- Sources/Pitch/Pitch.swift | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Sources/Pitch/Pitch.swift b/Sources/Pitch/Pitch.swift index bcfd0af..3dbfcef 100644 --- a/Sources/Pitch/Pitch.swift +++ b/Sources/Pitch/Pitch.swift @@ -37,7 +37,17 @@ public struct Pitch: NoteNumberRepresentable { extension Pitch { - // MARK: Computed Properties + // MARK: - Initializers + + /// Creates a `Pitch` with the given `Pitch.Class`. + public init(_ pitchClass: Pitch.Class) { + self.init(pitchClass.value) + } +} + +extension Pitch { + + // MARK: - Computed Properties /// - Returns: The `mod 12` representation of this `Pitch`. public var `class`: Pitch.Class { From 975459c33db596ac7c1fbbe01a30077a07adff5b Mon Sep 17 00:00:00 2001 From: James Date: Thu, 15 Nov 2018 12:15:29 -0500 Subject: [PATCH 3/4] Add Pitch and Pitch.Class conformances to CustomStringConvertible --- Sources/Pitch/NoteNumber.swift | 10 ++++++++++ Sources/Pitch/Pitch.Class.swift | 10 ++++++++++ Sources/Pitch/Pitch.swift | 10 ++++++++++ 3 files changed, 30 insertions(+) diff --git a/Sources/Pitch/NoteNumber.swift b/Sources/Pitch/NoteNumber.swift index ea5f3fc..254454a 100644 --- a/Sources/Pitch/NoteNumber.swift +++ b/Sources/Pitch/NoteNumber.swift @@ -63,3 +63,13 @@ extension NoteNumber { extension NoteNumber: Equatable { } extension NoteNumber: Hashable { } + +extension NoteNumber: CustomStringConvertible { + + // MARK: - CustomStringConvertible + + /// Printable description of `NoteNumber`. + public var description: String { + return value.description + } +} diff --git a/Sources/Pitch/Pitch.Class.swift b/Sources/Pitch/Pitch.Class.swift index 331bf60..7ffdc19 100644 --- a/Sources/Pitch/Pitch.Class.swift +++ b/Sources/Pitch/Pitch.Class.swift @@ -51,6 +51,16 @@ extension Pitch { extension Pitch.Class: Equatable { } extension Pitch.Class: Hashable { } +extension Pitch.Class: CustomStringConvertible { + + // MARK: - CustomStringConvertible + + /// Printable description of `Pitch.Class`. + public var description: String { + return value.description + } +} + extension Pitch.Class { // MARK: - Nested Types diff --git a/Sources/Pitch/Pitch.swift b/Sources/Pitch/Pitch.swift index 3dbfcef..8ee0df7 100644 --- a/Sources/Pitch/Pitch.swift +++ b/Sources/Pitch/Pitch.swift @@ -79,3 +79,13 @@ extension Pitch: Additive { return 0 } } + +extension Pitch: CustomStringConvertible { + + // MARK: - CustomStringConvertible + + /// Printable description of `Pitch`. + public var description: String { + return value.description + } +} From f0b7f3b863b0e927cb4165c994256e84bad7fec8 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 15 Nov 2018 12:16:09 -0500 Subject: [PATCH 4/4] Streamline Pitch.Class.inversion implementation --- Sources/Pitch/Pitch.Class.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Pitch/Pitch.Class.swift b/Sources/Pitch/Pitch.Class.swift index 7ffdc19..d6cf8a9 100644 --- a/Sources/Pitch/Pitch.Class.swift +++ b/Sources/Pitch/Pitch.Class.swift @@ -29,7 +29,7 @@ extension Pitch { /// let light = dark.inversion // => 8 /// public var inversion: Pitch.Class { - return Pitch.Class(NoteNumber(12) - value) + return Pitch.Class(12 - value) } /// Value of `Pitch.Class`.