FoscRhythm

Returns a FoscRhythm.


Description

Rhythm


Attributes Summary

Instance Properties

duration
durations
improperParentage
offsets
parentageRatios A sequence describing the relative durations of the nodes in a node’s improper parentage.
prolation Prolation of rhythm tree node.
prolations Prolations of rhythm tree node.
properParentage
startOffset The starting offset of a node in a rhythm-tree relative to the root.
stopOffset The stopping offset of a node in a rhythm-tree relative to the root.

Instance Methods: Special Methods

doesNotUnderstand Delegate to FoscRhythmMixin.
value

Instance Methods: Special Methods

==
!=
illustrate Illustrates FoscRhythm.
inspect
show


Usage

  1. Example

    a = FoscRhythm(1/4, #[-2, 2]);
    a.value.items.collect { |each| each.format }[0];
    \scaleDurations #'(1 . 1) {
        r8
        c'8
    }
  2. Example

    a = FoscRhythm(1/4, #[-2, 3]);
    a.value.items.collect { |each| each.format }[0];
    \times 4/5 {
        r8
        c'8.
    }
    a.show;

  3. Can be nested.

    a = FoscRhythm(3/16, [1, -2, FoscRhythm(2, #[1, 2, 4])]);
    a.show;

  4. Ircam-style rhythm-tree syntax.

    a = FoscRhythm(1/4, #[1, -2, [2, [1, 2, 4]]]);
    a.show;

  5. DEPRECATED

    Floats are interpreted as ties.

    a = FoscRhythm(3/16, [1, 2, [2, [2.0, -3]]]);
    a.show;
    ERROR: FoscRhythm::new: bad value: 2.0.


Instance Properties


duration

  1. Example

    a = FoscRhythm([3, 4], [1, 2, 2, 1, 1]);
    a.duration.cs;
    FoscDuration(3, 4)
  2. Example

    b = FoscRhythm(4, [-3, 2]);
    a = FoscRhythm([3, 4], [1, 2, b]);
    a.duration.cs;
    b.duration.cs;
    FoscDuration(3, 7)


durations

  1. Example

    a = FoscRhythm(4/4, #[-3, 2, 2]);
    a.durations;
    [ FoscDuration(3, 7), FoscDuration(2, 7), FoscDuration(2, 7) ]
  2. Example

    a = FoscRhythm(1/4, #[1, 2, [2, [2, -3]]]);
    a.durations;
    [ FoscDuration(1, 20), FoscDuration(1, 10), FoscDuration(1, 25), FoscDuration(3, 50) ]


improperParentage

  1. Example

    b = FoscRhythm(4, [-3, 2]);
    a = FoscRhythm([3, 4], [1, 2, b]);
    a.improperParentage;
    b.improperParentage;
    b.items.last.improperParentage;
    [ FoscRhythmLeaf.new, FoscRhythm.new, FoscRhythm.new ]


offsets

  1. Example

    a = FoscRhythm(4/4, #[-3, 2, 2]);
    a.offsets;
    [ FoscOffset(0, 1), FoscOffset(3, 7), FoscOffset(5, 7), FoscOffset(1, 1) ]
  2. Example

    a = FoscRhythm(1/4, #[1, 2, [2, [2, -3]]]);
    a.offsets
    [ FoscOffset(0, 1), FoscOffset(1, 20), FoscOffset(3, 20), FoscOffset(19, 100), FoscOffset(1, 4) ]


parentageRatios

A sequence describing the relative durations of the nodes in a node’s improper parentage.

The first item in the sequence is the preprolatedDuration of the root node, and subsequent items are pairs of the preprolated duration of the next node in the parentage and the total preprolated_duration of that node and its siblings.

Returns array.


prolation

Prolation of rhythm tree node.

Returns multiplier.

  1. Example

    b = FoscRhythm(4, #[-3, 2]);
    a = FoscRhythm(3/4, [1, 2, b]);
    a.prolation.cs;
    FoscMultiplier(1, 1)
    b.prolation.cs;
    FoscMultiplier(3, 28)


prolations

Prolations of rhythm tree node.

Returns array.

  1. Example

    b = FoscRhythm(4, #[-3, 2]);
    a = FoscRhythm(3/4, [1, 2, b]);
    a.prolations;
    [ FoscMultiplier(1, 1) ]
    b.prolations;
    [ FoscMultiplier(1, 1), FoscMultiplier(3, 28) ]


properParentage

  1. Example

    b = FoscRhythm(4, #[-3, 2]);
    a = FoscRhythm(3/4, [1, 2, b]);
    a.properParentage;
    [  ]
    b.properParentage;
    [ FoscRhythm.new ]


startOffset

The starting offset of a node in a rhythm-tree relative to the root.

Returns a FoscOffset.

  1. Example

    a = FoscRhythm(1, #[1, [1, [1, 1]], [1, [1, 1]]]);
    b = [];
    a.do { |node| b = b.add("".padLeft(node.depth, "\t") ++ node.startOffset.cs) };
    b.join("\n");
    FoscOffset(0, 1)
        FoscOffset(0, 1)
        FoscOffset(1, 3)
            FoscOffset(1, 3)
            FoscOffset(1, 2)
        FoscOffset(2, 3)
            FoscOffset(2, 3)
            FoscOffset(5, 6)


stopOffset

The stopping offset of a node in a rhythm-tree relative to the root.

Returns a FoscOffset.

  1. Example

    a = FoscRhythm(1, #[1, [1, [1, 1]], [1, [1, 1]]]);
    b = [];
    a.do { |node| b = b.add("".padLeft(node.depth, "\t") ++ node.stopOffset.cs) };
    b.join("\n");
    FoscOffset(1, 1)
        FoscOffset(1, 3)
        FoscOffset(2, 3)
            FoscOffset(1, 2)
            FoscOffset(2, 3)
        FoscOffset(1, 1)
            FoscOffset(5, 6)
            FoscOffset(1, 1)


Instance Methods: Special Methods


doesNotUnderstand

Delegate to FoscRhythmMixin.


value


Instance Methods: Special Methods


==

  1. Example

    a = FoscRhythm(FoscDuration(2, 4), [-2, 5]);
    b = FoscRhythm(FoscDuration(2, 4), [-2, 5]);
    c = FoscRhythm(FoscDuration(2, 4), [2, 5]);
    a == b;     // true
    true
    a == c;     // false
    false


!=

  1. Example

    a = FoscRhythm(FoscDuration(2, 4), [-2, 5]);
    b = FoscRhythm(FoscDuration(2, 4), [-2, 5]);
    c = FoscRhythm(FoscDuration(2, 4), [2, 5]);
    a != b;     // false
    false
    a != c;     // true
    true


illustrate

Illustrates FoscRhythm.

Returns LilyPond file.


inspect

  1. Example

    a = FoscRhythm(2/4, #[-2, [2, [-2, 3]], 3]);
    a.inspect;
    1/2
      2
      2
        2
        3
      3


show

  1. Example

    a = FoscRhythm(3/8, #[-2, 2, 3]);
    a.show;

  2. Example

    a = FoscRhythm(3/16, [1, -2, FoscRhythm(2, #[1, 2, 4])]);
    a.show;