-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'latest' of https://github.com/dn-m/MusicXML into latest
- Loading branch information
Showing
14 changed files
with
85 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,59 @@ | ||
// | ||
// Score.swift | ||
// MusicXML | ||
// | ||
// Created by James Bean on 12/3/18. | ||
// | ||
// MusicXML score.mod module | ||
// Version 3.1 | ||
// | ||
// Copyright © 2004-2017 the Contributors to the MusicXML | ||
// Specification, published by the W3C Music Notation Community | ||
// Group under the W3C Community Final Specification Agreement | ||
// (FSA): | ||
// | ||
// https://www.w3.org/community/about/agreements/final/ | ||
// | ||
// A human-readable summary is available: | ||
// | ||
// https://www.w3.org/community/about/agreements/fsa-deed/ | ||
// | ||
// > The score is the root element for the DTD. It includes | ||
// > the score-header entity, followed either by a series of | ||
// > parts with measures inside (score-partwise) or a series | ||
// > of measures with parts inside (score-timewise). Having | ||
// > distinct top-level elements for partwise and timewise | ||
// > scores makes it easy to ensure that an XSLT stylesheet | ||
// > does not try to transform a document already in the | ||
// > desired format. The document-attributes entity includes the | ||
// > version attribute and is defined in the common.mod file. | ||
// | ||
// <![ %partwise; [ | ||
// <!ELEMENT score-partwise (%score-header;, part+)> | ||
// <!ATTLIST score-partwise | ||
// %document-attributes; | ||
// > | ||
// TODO: Support Score document-attributes | ||
public struct Score { | ||
public let traversal: Traversal | ||
|
||
public init(traversal: Traversal) { | ||
self.traversal = traversal | ||
} | ||
} | ||
/// | ||
/// Score.swift | ||
/// MusicXML | ||
/// | ||
/// Created by James Bean on 12/3/18. | ||
/// | ||
/// MusicXML score.mod module | ||
/// Version 3.1 | ||
/// | ||
/// Copyright © 2004-2017 the Contributors to the MusicXML | ||
/// Specification, published by the W3C Music Notation Community | ||
/// Group under the W3C Community Final Specification Agreement | ||
/// (FSA): | ||
/// | ||
/// https://www.w3.org/community/about/agreements/final/ | ||
/// | ||
/// A human-readable summary is available: | ||
/// | ||
/// https://www.w3.org/community/about/agreements/fsa-deed/ | ||
/// | ||
|
||
/// Either a `partwise` or `timewise` traversal of a MusicXML score. | ||
public enum Score: Equatable { | ||
|
||
extension Score: Equatable { } | ||
/// The `partwise` traversal of a MusicXML score. | ||
case partwise(Partwise) | ||
|
||
/// The `timewise` traversal of a MusicXML score. | ||
case timewise(Timewise) | ||
} | ||
|
||
extension Score: Codable { | ||
|
||
// MARK: - Codable | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case partwise = "score-partwise" | ||
case timewise = "score-timewise" | ||
} | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.container(keyedBy: CodingKeys.self) | ||
switch self { | ||
case let .partwise(value): | ||
try container.encode(value, forKey: .partwise) | ||
case let .timewise(value): | ||
try container.encode(value, forKey: .timewise) | ||
} | ||
} | ||
|
||
public init(from decoder: Decoder) throws { | ||
let container = try decoder.singleValueContainer() | ||
self.traversal = try container.decode(Traversal.self) | ||
do { | ||
self = .partwise(try container.decode(Partwise.self)) | ||
} catch { | ||
self = .timewise(try container.decode(Timewise.self)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.