59 lines
1.9 KiB
Swift
59 lines
1.9 KiB
Swift
// FermataShape.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
/// The shape of a fermata symbol, corresponding to MusicXML 4.0 fermata shape values.
|
|
///
|
|
/// Use as the associated value of ``NotationMark/fermata(_:)``.
|
|
///
|
|
/// Common shorthands:
|
|
/// - "Long fermata" = `.square`
|
|
/// - "Very long / longa fermata" = `.doubleSquare`
|
|
///
|
|
/// > Note: ``NotationMark`` is emit-only — ``Score/fromMusicXML(data:)`` does not
|
|
/// > parse fermata shapes back into `NotationMark` values.
|
|
public enum FermataShape: Hashable, Sendable {
|
|
|
|
/// Standard curved fermata (the most common kind). MusicXML `<fermata/>`.
|
|
case normal
|
|
|
|
/// Pointed / angled fermata. MusicXML body text: `angled`.
|
|
case angled
|
|
|
|
/// Square fermata — the conventional "long fermata". MusicXML body text: `square`.
|
|
case square
|
|
|
|
/// Double angled fermata. MusicXML body text: `double-angled`.
|
|
case doubleAngled
|
|
|
|
/// Double square fermata — the conventional "very long / longa fermata".
|
|
/// MusicXML body text: `double-square`.
|
|
case doubleSquare
|
|
|
|
/// Double dot fermata. MusicXML body text: `double-dot`.
|
|
case doubleDot
|
|
|
|
/// Half-curve fermata. MusicXML body text: `half-curve`.
|
|
case halfCurve
|
|
|
|
/// Curlew fermata. MusicXML body text: `curlew`.
|
|
case curlew
|
|
|
|
/// The MusicXML body text for shapes other than `.normal`.
|
|
/// Returns `nil` for `.normal` (which emits as self-closing `<fermata/>`).
|
|
var musicXMLBodyText: String? {
|
|
switch self {
|
|
case .normal: return nil
|
|
case .angled: return "angled"
|
|
case .square: return "square"
|
|
case .doubleAngled: return "double-angled"
|
|
case .doubleSquare: return "double-square"
|
|
case .doubleDot: return "double-dot"
|
|
case .halfCurve: return "half-curve"
|
|
case .curlew: return "curlew"
|
|
}
|
|
}
|
|
}
|