Returns a FoscDuration.
A musical duration.
| durationsToNonreducedFractions | Changes durations to nonreduced fractions sharing least common denominator. |
| fromLilypondDurationString | |
| isToken |
| dotCount | Gets dot count. |
| equalOrGreaterAssignable | Gets assignable duration equal to or just greater than this duration. |
| equalOrGreaterPowerOfTwo | Gets duration equal or just greater power of two. |
| equalOrLesserAssignable | Gets assignable duration equal or just less than this duration. |
| equalOrLesserPowerOfTwo | Gets duration equal to or just less than power of two. |
| flagCount | Gets flag count. Flag count defined equal to number of flags required to notate duration. |
| hasPowerOfTwoDenominator | Is true when duration is an integer power of two. Otherwise false. |
| impliedProlation | Gets implied prolation. |
| isAssignable | Is true when duration is assignable. Otherwise false. |
| lilypondDurationString | Gets LilyPond duration string. Raises assignability error when duration is not assignable. |
| str | (inherited in abjad) |
| pair | Gets numerator and denominator. |
| prolationString | Gets prolation string. |
| reciprocal | Gets reciprocal. |
| abs | Gets absolute value of duration. |
| asCompileString | |
| + | Adds duration to expr. |
| asFloat | |
| / | Divides duration by expr. |
| divmod | Equals the pair (duration // args, duration % args). |
| == | Is true when duration equals arg. Otherwise false. |
| format | Formats duration. |
| >= | Is true when duration is greater than or equal to arg. Otherwise false. |
| > | Is true when duration is greater than arg. Otherwise false. |
| <= | Is true when duration is less than or equal to arg. Otherwise false. |
| < | Is true when duration is less than arg. Otherwise false. |
| mod | Modulus operator applied to duration. |
| * | Duration multiplied by expr. |
| != | Is true when duration does not equal arg. Otherwise false. |
| neg | Negates duration. |
| ** | Raises duration to expr power. |
| reduce | |
| - | Subtracts expr from duration. |
| truediv | Documentation required. |
| toClockString | |
| toScoreMarkup | |
| withDenominator | Changes duration to nonreduced fraction with denominator. |
FoscDuration
FoscDuration(1, 4).str;1/4
FoscDuration(0.25).str;1/4
FoscDuration(pi).str;355/113
FoscDuration(inf).str;inf
FoscDuration(4, 4).str;1/1
FoscDuration(3, 8).str;3/8
FoscDuration(7, 16).str;7/16
FoscDuration(17, 16).str; // not assignable error17/16Changes durations to nonreduced fractions sharing least common denominator.
Example
d = [FoscDuration(2, 4), 3, [5, 16]];
f = FoscDuration.durationsToNonreducedFractions(d);
f.collect { |each| each.str }.postln;[ "8/16", "48/16", "5/16" ]Gets dot count.
Dot count defined equal to number of dots required to notate duration.
Raises assignability error when duration is not assignable.
Returns positive integer.
Example
o = [];
(1..16).do { |num|
d = FoscDuration(num, 16);
if (d.isAssignable) { o = o.add("%\t%".format(d.str, d.dotCount)) };
};
o.join("\n");1/16 0
1/8 0
3/16 1
1/4 0
3/8 1
7/16 2
1/2 0
3/4 1
7/8 2
15/16 3
1/1 0Gets assignable duration equal to or just greater than this duration.
Returns new duration.
Example
o = [];
(1..16).do { |num|
d = FoscDuration(num, 16);
o = o.add("%\t%".format(d.str, d.equalOrGreaterAssignable.str));
};
o.join("\n");1/16 1/16
1/8 1/8
3/16 3/16
1/4 1/4
5/16 3/8
3/8 3/8
7/16 7/16
1/2 1/2
9/16 3/4
5/8 3/4
11/16 3/4
3/4 3/4
13/16 7/8
7/8 7/8
15/16 15/16
1/1 1/1Gets duration equal or just greater power of two.
Returns new duration.
Example
o = [];
(1..16).do { |num|
d = FoscDuration(num, 16);
o = o.add("%\t%".format(d.str, d.equalOrGreaterPowerOfTwo.str));
};
o.join("\n");1/16 1/16
1/8 1/8
3/16 1/4
1/4 1/4
5/16 1/2
3/8 1/2
7/16 1/2
1/2 1/2
9/16 1/1
5/8 1/1
11/16 1/1
3/4 1/1
13/16 1/1
7/8 1/1
15/16 1/1
1/1 1/1Gets assignable duration equal or just less than this duration.
Returns new duration.
Example
o = [];
(1..16).do { |num|
d = FoscDuration(num, 16);
o = o.add("%\t%".format(d.str, d.equalOrLesserAssignable.str));
};
o.join("\n");1/16 1/16
1/8 1/8
3/16 3/16
1/4 1/4
5/16 1/4
3/8 3/8
7/16 7/16
1/2 1/2
9/16 1/2
5/8 1/2
11/16 1/2
3/4 3/4
13/16 3/4
7/8 7/8
15/16 15/16
1/1 1/1Gets duration equal to or just less than power of two.
Returns new duration.
Example
o = [];
(1..16).do { |num|
d = FoscDuration(num, 16);
o = o.add("%\t%".format(d.str, d.equalOrLesserPowerOfTwo.str));
};
o.join("\n");1/16 1/16
1/8 1/8
3/16 1/8
1/4 1/4
5/16 1/4
3/8 1/4
7/16 1/4
1/2 1/2
9/16 1/2
5/8 1/2
11/16 1/2
3/4 1/2
13/16 1/2
7/8 1/2
15/16 1/2
1/1 1/1Gets flag count. Flag count defined equal to number of flags required to notate duration.
Returns nonnegative integer.
Example
o = [];
(1..16).do { |num|
d = FoscDuration(num, 64);
o = o.add("%\t%".format(d.str, d.flagCount));
};
o.join("\n");1/64 4
1/32 3
3/64 3
1/16 2
5/64 2
3/32 2
7/64 2
1/8 1
9/64 1
5/32 1
11/64 1
3/16 1
13/64 1
7/32 1
15/64 1
1/4 0Is true when duration is an integer power of two. Otherwise false.
Example
FoscDuration(1, 4).hasPowerOfTwoDenominator.postln;true
FoscDuration(1, 7).hasPowerOfTwoDenominator.postln;falseGets implied prolation.
Returns multipler.
Example
o = [];
(1..16).do { |num|
d = FoscDuration(1, num);
o = o.add("%\t%".format(d.str, d.impliedProlation.str));
};
o.join("\n");1/1 1/1
1/2 1/1
1/3 2/3
1/4 1/1
1/5 4/5
1/6 2/3
1/7 4/7
1/8 1/1
1/9 8/9
1/10 4/5
1/11 8/11
1/12 2/3
1/13 8/13
1/14 4/7
1/15 8/15
1/16 1/1Is true when duration is assignable. Otherwise false.
Returns true or false.
Example
o = [];
(1..16).do { |num|
d = FoscDuration(num, 8);
o = o.add("%\t%".format(d.str, d.isAssignable));
};
o.join("\n");1/8 true
1/4 true
3/8 true
1/2 true
5/8 false
3/4 true
7/8 true
1/1 true
9/8 false
5/4 false
11/8 false
3/2 true
13/8 false
7/4 true
15/8 true
2/1 trueGets LilyPond duration string. Raises assignability error when duration is not assignable.
Returns string.
Example
FoscDuration(3, 16).lilypondDurationString.postln;8.
FoscDuration(5, 16).lilypondDurationString; // assignability error ERROR: FoscDuration:lilypondDurationString: duration 5/16 is not assignable.(inherited in abjad)
Example
FoscDuration(1, 4).str;1/4
FoscDuration(inf).str;infGets numerator and denominator.
Returns integer pair.
Example
FoscDuration(3, 16).str;3/16Gets prolation string.
Returns string.
Example
o = [];
(1..16).do { |num|
d = FoscDuration(1, num);
o = o.add("%\t%".format(d.str, d.prolationString));
};
o.join("\n");1/1 1:1
1/2 2:1
1/3 3:1
1/4 4:1
1/5 5:1
1/6 6:1
1/7 7:1
1/8 8:1
1/9 9:1
1/10 10:1
1/11 11:1
1/12 12:1
1/13 13:1
1/14 14:1
1/15 15:1
1/16 16:1Gets reciprocal.
Returns new duration.
code:: FoscDuration(1, 2).reciprocal.str;
• reciprocal
Gets reciprocal.
Returns new duration.
FoscDuration(1, 2).reciprocal.str;2/1Gets absolute value of duration.
Returns nonnegative duration.
Example
a = FoscDuration(-1, 4);
b = a.abs;
b.str;1/4Example
a = FoscDuration(1, 4);
a.asCompileString.postln;FoscDuration(1, 4)Adds duration to expr.
Returns duration.
Returns duration when expr is a duration.
a = FoscDuration(1, 2);
b = FoscDuration(3, 2);
c = (a + b);
c.str;2/1Returns nonreduced fraction when expr is a nonreduced fraction.
a = FoscDuration(1, 2);
b = FoscNonreducedFraction(3, 2);
c = (a + b);
c.str;4/2Example
FoscDuration(3, 2).asFloat.postln;1.5Divides duration by expr.
Returns multiplier.
Returns multiplier when expr is a duration.
a = FoscDuration(2, 4);
b = FoscDuration(2, 1);
c = (a / b);
c.str;1/4Returns nonreduced fraction when expr is a nonreduced fraction.
a = FoscDuration(2, 4);
b = FoscNonreducedFraction(2, 1);
c = (a / b);
c.str;1/4Equals the pair (duration // args, duration % args).
Returns pair.
Example
a = FoscDuration(7, 4);
b = a.divmod(FoscDuration(4, 4));
b.collect { |each| each.str };[ "1/1", "3/4" ]Is true when duration equals arg. Otherwise false.
Returns true or false.
Example
(FoscDuration(4, 4) == FoscDuration(4, 4)).postln;true
(FoscDuration(4, 4) == FoscDuration(2, 4)).postln;false
(FoscDuration(4, 4) == FoscDuration(2, 2)).postln;trueFormats duration.
Set format_specification to ’’ or storage. Interprets ’’ equal to storage.
Returns string.
Example
FoscDuration(1, 4).format;1/4Is true when duration is greater than or equal to arg. Otherwise false.
Returns true or false.
Example
(FoscDuration(4, 4) >= FoscDuration(4, 4)).postln;true
(FoscDuration(4, 4) >= FoscDuration(2, 4)).postln;true
(FoscDuration(4, 4) >= FoscDuration(2, 2)).postln;trueIs true when duration is greater than arg. Otherwise false.
Returns true or false.
Example
(FoscDuration(4, 4) > FoscDuration(4, 4)).postln;false
(FoscDuration(4, 4) > FoscDuration(2, 4)).postln;true
(FoscDuration(4, 4) > FoscDuration(2, 2)).postln;falseIs true when duration is less than or equal to arg. Otherwise false.
Returns true or false.
Example
(FoscDuration(4, 4) <= FoscDuration(4, 4)).postln;true
(FoscDuration(4, 4) <= FoscDuration(2, 4)).postln;false
(FoscDuration(4, 4) <= FoscDuration(2, 2)).postln;trueIs true when duration is less than arg. Otherwise false.
Returns true or false.
Example
(FoscDuration(4, 4) < FoscDuration(4, 4)).postln;false
(FoscDuration(4, 4) < FoscDuration(2, 4)).postln;false
(FoscDuration(4, 4) < FoscDuration(2, 2)).postln;falseModulus operator applied to duration.
Returns duration.
Example
a = FoscDuration(4, 4);
b = FoscDuration(2, 4);
c = (a % b);
c.str;0/1
d = (b % a);
d.str;1/2Duration multiplied by expr.
Returns duration.
Returns duration when expr is a duration.
a = FoscDuration(1, 2);
b = FoscDuration(3, 2);
c = (a * b);
c.str;3/4Returns nonreduced fraction when expr is a nonreduced fraction.
a = FoscDuration(1, 2);
b = FoscNonreducedFraction(3, 6);
c = (a * b);
c.str;3/12Is true when duration does not equal arg. Otherwise false.
Returns true or false.
Example
(FoscDuration(4, 4) != FoscDuration(4, 4)).postln;false
(FoscDuration(4, 4) != FoscDuration(2, 4)).postln;true
(FoscDuration(4, 4) != FoscDuration(2, 2)).postln;falseNegates duration.
Returns new duration.
Example
a = FoscDuration(1, 4);
b = a.neg;
b.str;-1/4Raises duration to expr power.
Returns new duration.
Example
a = FoscDuration(4, 2) ** 2;
a.str;4/1Subtracts expr from duration.
Returns new duration.
Returns duration when expr is a duration.
a = FoscDuration(3, 2);
b = FoscDuration(1, 2);
c = (a - b);
c.str;1/1Returns nonreduced fraction when expr is a nonreduced fraction.
a = FoscDuration(3, 2);
b = FoscNonreducedFraction(1, 2);
c = (a - b);
c.str;2/2Documentation required.
Changes duration to nonreduced fraction with denominator.
Returns new duration.
Example
a = FoscDuration(1, 4);
[4, 8, 16, 32].collect { |each| a.withDenominator(each).str }.postln;[ "1/4", "2/8", "4/16", "8/32" ]