musicxml/elements/
swing.rs

1use super::{First, Second, Straight, SwingStyle, SwingType};
2use alloc::{string::String, vec::Vec};
3use musicxml_internal::*;
4use musicxml_macros::*;
5
6/// Contents of the [Swing] element.
7#[derive(Debug, Default, PartialEq, Eq, ContentDeserialize, ContentSerialize)]
8pub struct SwingContents {
9  /// The [Straight] element specifies whether or not to use straight playback.
10  pub straight: Option<Straight>,
11  /// The [First] and [Second] elements specify the ratio between durations of consecutive notes.
12  pub first: Option<First>,
13  /// The [First] and [Second] elements specify the ratio between durations of consecutive notes.
14  pub second: Option<Second>,
15  /// The [SwingType] element specifies the type of swing to use.
16  pub swing_type: Option<SwingType>,
17  /// The [SwingStyle] element specifies the style of swing to use.
18  pub swing_style: Option<SwingStyle>,
19}
20
21/// The [Swing] element specifies whether or not to use swing playback, where consecutive on-beat / off-beat eighth or 16th notes are played with unequal nominal durations.
22///
23/// The [First] and [Second] elements are positive integers that specify the ratio between durations of consecutive notes. For example, a [First] element
24/// with a value of 2 and a [Second] element with a value of 1 applied to eighth notes specifies a quarter note / eighth note tuplet playback,
25/// where the first note is twice as long as the second note. Ratios should be specified with the smallest integers possible. For example, a ratio
26/// of 6 to 4 should be specified as 3 to 2 instead.
27///
28/// The [Swing] element has no effect for playback of grace notes, notes where a [Type][super::Type] element is not present, and notes where the
29/// specified [Duration][super::Duration] is different than the nominal value associated with the specified [Type][super::Type]. If a swung note has
30/// `attack` and `release` attributes, those values modify the swung playback.
31#[derive(Debug, PartialEq, Eq, ElementDeserialize, ElementSerialize)]
32pub struct Swing {
33  /// Element-specific attributes
34  pub attributes: (),
35  #[flatten]
36  /// Element-specific content
37  pub content: SwingContents,
38}