Skip to content

Commit

Permalink
Make ScaleType CustomStringConvertible
Browse files Browse the repository at this point in the history
  • Loading branch information
cemolcay committed Feb 13, 2019
1 parent fc44ffe commit 8a2ee25
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
8 changes: 7 additions & 1 deletion Source/ChordProgression.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@
import Foundation

/// A struct for storing custom progressions.
public struct CustomChordProgression: Codable {
public struct CustomChordProgression: Codable, CustomStringConvertible {
/// Name of the progression.
public var name: String
/// Chord progression with `ChordProgresion.custom` type.
public var progression: ChordProgression

// MARK: CustomStringConvertible

public var description: String {
return name
}
}

/// A node of chord progression in intervals.
Expand Down
2 changes: 1 addition & 1 deletion Source/Scale.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Foundation
// MARK: - ScaleType

/// Represents scale by the intervals between note sequences.
public struct ScaleType: Equatable {
public struct ScaleType: Equatable, CustomStringConvertible {
/// Major scale.
public static let major = ScaleType(intervals: ScaleType.ionian.intervals, description: "Major")
/// Minor scale.
Expand Down
9 changes: 7 additions & 2 deletions Source/Tempo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
import Foundation

/// Defines the tempo of the music with beats per second and time signature.
public struct Tempo: Codable {
public struct Tempo: Codable, CustomStringConvertible {
/// Time signature of music.
public var timeSignature: TimeSignature

/// Beats per minutes.
public var bpm: Double

Expand Down Expand Up @@ -49,4 +48,10 @@ public struct Tempo: Codable {
public func hertz(of noteValue: NoteValue) -> Double {
return 1 / duration(of: noteValue)
}

// MARK: CustomStringConvertible

public var description: String {
return "\(bpm)"
}
}
9 changes: 7 additions & 2 deletions Source/TimeSignature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
import Foundation

/// Defines how many beats in a measure with which note value.
public struct TimeSignature: Codable {
public struct TimeSignature: Codable, CustomStringConvertible {
/// Beats per measure.
public var beats: Int

/// Note value per beat.
public var noteValue: NoteValueType

Expand All @@ -41,4 +40,10 @@ public struct TimeSignature: Codable {
self.beats = beats
self.noteValue = noteValue
}

// MARK: CustomStringConvertible

public var description: String {
return "\(beats)/\(Int(noteValue.rawValue))"
}
}

0 comments on commit 8a2ee25

Please sign in to comment.