Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Pitch / Pitch.Class APIs #116

Merged
merged 4 commits into from
Nov 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Sources/Pitch/NoteNumber.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
12 changes: 11 additions & 1 deletion Sources/Pitch/Pitch.Class.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -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
Expand Down
7 changes: 0 additions & 7 deletions Sources/Pitch/Pitch.h

This file was deleted.

22 changes: 21 additions & 1 deletion Sources/Pitch/Pitch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -69,3 +79,13 @@ extension Pitch: Additive {
return 0
}
}

extension Pitch: CustomStringConvertible {

// MARK: - CustomStringConvertible

/// Printable description of `Pitch`.
public var description: String {
return value.description
}
}