Skip to content

Commit

Permalink
swift 2 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bg-stripe committed Sep 19, 2015
1 parent e581271 commit 8414631
Show file tree
Hide file tree
Showing 37 changed files with 188 additions and 208 deletions.
2 changes: 1 addition & 1 deletion Documentation/FrameworkOverview.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ print(ch) // [A4, C♯5, E5, G♯5]
* `Chord.name` can be used to derive a chord name from a pitch set

```swift
let pitchSet : PitchSet = [Chroma.B*0, Chroma.Cs*2, Chroma.F*3, Chroma.G*4]
let pitchSet: PitchSet = [Chroma.B*0, Chroma.Cs*2, Chroma.F*3, Chroma.G*4]
print(Chord.name(pitchSet)!) // G7♭5/B
let descriptor = Chord.descriptor(pitchSet)
print(descriptor!) // root: G, quality: dominant seventh flat five, bass: B
Expand Down
12 changes: 11 additions & 1 deletion MusicKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,8 @@
96F299191A5663E500D7B006 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0610;
LastSwiftUpdateCheck = 0710;
LastUpgradeCheck = 0700;
ORGANIZATIONNAME = benzguo;
TargetAttributes = {
9691BB231A57C75500421B56 = {
Expand Down Expand Up @@ -700,6 +701,7 @@
INFOPLIST_FILE = MusicKitTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "benzguo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
};
Expand All @@ -715,6 +717,7 @@
INFOPLIST_FILE = MusicKitTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "benzguo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
Expand All @@ -737,6 +740,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "benzguo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = MusicKit;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
Expand All @@ -757,6 +761,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "benzguo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = MusicKit;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -786,6 +791,7 @@
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
Expand Down Expand Up @@ -860,6 +866,7 @@
INFOPLIST_FILE = MusicKit/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "benzguo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = MusicKit;
SKIP_INSTALL = YES;
SWIFT_OBJC_BRIDGING_HEADER = "";
Expand All @@ -880,6 +887,7 @@
INFOPLIST_FILE = MusicKit/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "benzguo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = MusicKit;
SKIP_INSTALL = YES;
SWIFT_OBJC_BRIDGING_HEADER = "";
Expand All @@ -900,6 +908,7 @@
);
INFOPLIST_FILE = MusicKitTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "benzguo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
Expand All @@ -914,6 +923,7 @@
);
INFOPLIST_FILE = MusicKitTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "benzguo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
Expand Down
13 changes: 8 additions & 5 deletions MusicKit.xcodeproj/xcshareddata/xcschemes/MusicKit_OSX.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0610"
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -37,10 +37,10 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -62,15 +62,18 @@
ReferencedContainer = "container:MusicKit.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
Expand All @@ -85,10 +88,10 @@
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
Expand Down
13 changes: 8 additions & 5 deletions MusicKit.xcodeproj/xcshareddata/xcschemes/MusicKit_iOS.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0610"
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -37,10 +37,10 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -62,15 +62,18 @@
ReferencedContainer = "container:MusicKit.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
Expand All @@ -85,10 +88,10 @@
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
Expand Down
4 changes: 2 additions & 2 deletions MusicKit/Accidental.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Foundation

public enum Accidental : Float, Printable {
public enum Accidental: Float, CustomStringConvertible {
case DoubleFlat = -2
case Flat = -1
case Natural = 0
Expand All @@ -18,7 +18,7 @@ public enum Accidental : Float, Printable {
}
}

public var description : String {
public var description: String {
switch self {
case .DoubleFlat:
return "𝄫"
Expand Down
10 changes: 5 additions & 5 deletions MusicKit/ChordDescriptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

import Foundation

public struct ChordDescriptor : Printable {
public struct ChordDescriptor: CustomStringConvertible {
/// The root of the chord.
public let root : Chroma
public let root: Chroma

/// The quality of the chord.
public let quality : ChordQuality
public let quality: ChordQuality

/// The lowest note of the chord.
public let bass : Chroma
public let bass: Chroma

public init(root: Chroma, quality: ChordQuality, bass: Chroma) {
self.root = root
self.quality = quality
self.bass = bass
}

public var description : String {
public var description: String {
return "root: \(root), quality: \(quality), bass: \(bass)"
}
}
4 changes: 2 additions & 2 deletions MusicKit/ChordExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import Foundation

public enum ChordExtension : UInt, Printable {
public enum ChordExtension: UInt, CustomStringConvertible {
case FlatNine = 13
case Nine = 14
case Eleven = 17
case SharpEleven = 18
case FlatThirteen = 20
case Thirteen = 21

public var description : String {
public var description: String {
switch self {
case FlatNine: return "9"
case Nine: return "♭9"
Expand Down
4 changes: 2 additions & 2 deletions MusicKit/ChordExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import Foundation
extension Chord {
/// Creates a new `Harmonizer` using the (1-indexed) indices of the given harmonizer
public static func create(harmonizer: Harmonizer, indices: [UInt]) -> Harmonizer {
if indices.count < 2 || contains(indices, 0) {
if indices.count < 2 || indices.contains(0) {
return Harmony.IdentityHarmonizer
}

// sort and convert to zero-indexed indices
let sortedIndices = sorted(indices.map { $0 - 1 })
let sortedIndices = (indices.map { $0 - 1 }).sort()
let maxIndex = Int(sortedIndices.last!)
var scalePitches = harmonizer(Chroma.C*0)

Expand Down
4 changes: 2 additions & 2 deletions MusicKit/ChordName.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ extension Chord {
let fullOpt = _descriptor(pitchSet, qualities: fullQs)
// unaltered, no-slash, root position -> return
if let full = fullOpt {
if contains(fullUnalteredQs, full.quality) &&
if fullUnalteredQs.contains(full.quality) &&
full.bass == full.root {
return full
}
}
// try to simplify chord by slashing
let noBassOpt = _descriptor(bassRemoved, qualities: slashQs)
var slashNoBassOpt : ChordDescriptor? = nil
var slashNoBassOpt: ChordDescriptor? = nil
if let noBass = noBassOpt {
slashNoBassOpt = bassChromaOpt.map {
ChordDescriptor(root: noBass.root, quality: noBass.quality, bass: $0)
Expand Down
2 changes: 1 addition & 1 deletion MusicKit/ChordQualities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ ChordQuality.MajorSeventhFlatNineSharpElevenFlatThirteen,
ChordQuality.MinorMajorSeventhFlatNineSharpElevenFlatThirteen,
ChordQuality.MinorSeventhFlatNineSharpElevenFlatThirteen,
]
public var name : String {
public var name: String {
switch self {
case PowerChord: return "PowerChord"
case Major: return "Major"
Expand Down
6 changes: 3 additions & 3 deletions MusicKit/ChordQuality.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Foundation

public enum ChordQuality : String {
public enum ChordQuality: String {
//: Dyads
case PowerChord = "5"
//> Triads
Expand Down Expand Up @@ -368,8 +368,8 @@ public enum ChordQuality : String {
}
}

extension ChordQuality : Printable {
public var description : String {
extension ChordQuality: CustomStringConvertible {
public var description: String {
return rawValue
}
}
10 changes: 5 additions & 5 deletions MusicKit/Chroma.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Foundation
typealias ChromaNameTuple = (LetterName, Accidental)

/// Pitch quality; also known as pitch class.
public enum Chroma : UInt {
public enum Chroma: UInt {
/// C
case C = 0
/// C Sharp
Expand All @@ -31,7 +31,7 @@ public enum Chroma : UInt {
/// B
case B = 11

var names : [ChromaNameTuple] {
var names: [ChromaNameTuple] {
switch self.rawValue {
case 0:
return [(.C, .Natural), (.B, .Sharp), (.D, .DoubleFlat)]
Expand Down Expand Up @@ -71,9 +71,9 @@ public enum Chroma : UInt {
}

// MARK: Printable
extension Chroma : Printable {
public var description : String {
let nameTupleOpt : ChromaNameTuple? = self.names.first
extension Chroma: CustomStringConvertible {
public var description: String {
let nameTupleOpt: ChromaNameTuple? = self.names.first
if let (letterName, accidental) = nameTupleOpt {
return "\(letterName.description)\(accidental.description(true))"
}
Expand Down
2 changes: 1 addition & 1 deletion MusicKit/Harmony.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Foundation

public struct Harmony {
/// The identity Harmonizer function
public static let IdentityHarmonizer : Harmonizer = { pitch in
public static let IdentityHarmonizer: Harmonizer = { pitch in
return PitchSet(pitches: pitch)
}

Expand Down
2 changes: 1 addition & 1 deletion MusicKit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>benzguo.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
6 changes: 3 additions & 3 deletions MusicKit/IntervalQuality.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Foundation

public enum IntervalQuality : UInt, Printable {
public enum IntervalQuality: UInt, CustomStringConvertible {
case Unison = 0
case MinorSecond = 1
case MajorSecond = 2
Expand All @@ -28,7 +28,7 @@ public enum IntervalQuality : UInt, Printable {
case MinorFourteenth = 22
case MajorFourteenth = 23

public var description : String {
public var description: String {
switch self {
case Unison: return "unison"
case MinorSecond: return "minor second"
Expand Down Expand Up @@ -57,7 +57,7 @@ public enum IntervalQuality : UInt, Printable {
}
}

public var shortName : String {
public var shortName: String {
switch self {
case Unison: return "P1"
case MinorSecond: return "m2"
Expand Down
Loading

0 comments on commit 8414631

Please sign in to comment.