Rhythm class implements standard methods and data structures to manipulate musical rhythm arithmetically. More...
#include <Rhythm.h>
Public Member Functions | |
| Rhythm () | |
| Default constructor. | |
| Rhythm (Integer i) | |
| Default constructor. | |
| Rhythm (Real x) | |
| Construct rhythm given a fractional rhythmic value. | |
| Rhythm (Integer num, Integer den) | |
| Construct rhythm given a rational fraction rhythmic value. | |
| Rhythm (Real x, Integer &num, Integer &den) | |
| Construct rhythm given a Real fractional rhythmic value, determine its rational approximation, assign numerator and denominator to reference arguments. | |
| Rhythm (Rhythm x, Integer &num, Integer &den) | |
| Construct rhythm given a Rhythm, determine its rational approximation, assign numerator and denominator to reference arguments. | |
| Bool | operator== (Const Rhythm &x) Const |
| Rhythm equality operator. | |
| Bool | operator!= (Const Rhythm &x) Const |
| Rhythm inequality operator. | |
| Bool | operator>= (Const Rhythm &x) Const |
| Rhythm >= operator. | |
| Bool | operator> (Const Rhythm &x) Const |
| Rhythm > operator. | |
| Bool | operator< (Const Rhythm &x) Const |
| Rhythm < operator. | |
| Bool | operator<= (Const Rhythm &x) Const |
| Rhythm <= operator. | |
| Rhythm & | operator+= (Const Real x) |
| Rhythm plus-equals operator. | |
| Rhythm & | operator+= (Rhythm x) |
| Rhythm plus-equals operator. | |
| Rhythm & | operator-= (Const Real x) |
| Rhythm minus-equals operator. | |
| Rhythm & | operator-= (Rhythm x) |
| Rhythm minus-equals operator. | |
| Rhythm & | operator*= (Const Real x) |
| Rhythm times-equals operator. | |
| Rhythm & | operator*= (Rhythm x) |
| Rhythm times-equals operator. | |
| Rhythm & | operator/= (Const Real x) |
| Rhythm divide-equals operator. | |
| Rhythm & | operator/= (Rhythm x) |
| Rhythm divide-equals operator. | |
| Rhythm | operator+ (Rhythm &x) |
| Rhythm addition operator. | |
| Rhythm | operator- (Rhythm &x) |
| Rhythm subtraction operator. | |
| Rhythm | operator* (Rhythm &x) |
| Rhythm times operator. | |
| Rhythm | operator/ (Rhythm &x) |
| Rhythm divide operator. | |
| Rhythm | operator+ (Const Real x) |
| Rhythm add to Real operator. | |
| Rhythm | operator- (Const Real x) |
| Rhythm subtract from Real operator. | |
| Rhythm | operator* (Const Real x) |
| Rhythm multiply by Real operator. | |
| Rhythm | operator/ (Const Real x) |
| Rhythm divide by Real operator. | |
| String | print (String s=0) Const |
| Print Rhythm prefixed by String. | |
| Static Real | tempo (Void) |
| Return the tempo used by all Rhythm instances to determine tempo. | |
| Static Real | tempo (Real t) |
| Set the tempo used by all Rhythm instances to determine tempo. | |
| Real | mm (Rhythm beats, Real perMinute) Const |
| Return the duration of a Rhythm given a Real beats per minute. | |
| Real | duration () |
| Return the duration of this Rhythm at the prevailing tempo. | |
| Real | absDuration () Const |
| Return the absolute duration of this Rhythm. | |
Friends | |
| ostream & | operator<< (ostream &, Rhythm &) |
| istream & | operator>> (istream &is, Rhythm &p) |
| Bool | operator== (Integer &i, Rhythm &p) |
| Bool | operator== (Rhythm &p, Integer &i) |
| Bool | operator!= (Integer &i, Rhythm &p) |
| Bool | operator!= (Rhythm &p, Integer &i) |
| Bool | operator>= (Rhythm &p, Integer &r) |
| Bool | operator>= (Integer &i, Rhythm &p) |
| Bool | operator> (Rhythm &p, Integer &i) |
| Bool | operator> (Integer &i, Rhythm &p) |
| Bool | operator<= (Rhythm &p, Integer &i) |
| Bool | operator<= (Integer &i, Rhythm &p) |
| Bool | operator== (Real &r, Rhythm &p) |
| Bool | operator== (Rhythm &p, Real &r) |
| Bool | operator!= (Real &r, Rhythm &p) |
| Bool | operator!= (Rhythm &p, Real &r) |
| Bool | operator>= (Rhythm &p, Real &r) |
| Bool | operator>= (Real &r, Rhythm &p) |
| Bool | operator> (Rhythm &p, Real &r) |
| Bool | operator> (Real &r, Rhythm &p) |
| Bool | operator<= (Rhythm &p, Real &r) |
| Bool | operator<= (Real &r, Rhythm &p) |
Rhythm class implements standard methods and data structures to manipulate musical rhythm arithmetically.
Definition at line 29 of file Rhythm.h.
| Rhythm::Rhythm | ( | ) | [inline] |
Default constructor.
Definition at line 60 of file Rhythm.h.
Referenced by operator*(), operator+(), operator+=(), operator-(), and operator/().
: m_num(0), m_den(0) { }
| Rhythm::Rhythm | ( | Integer | i ) | [inline] |
| Rhythm::Rhythm | ( | Real | x ) | [inline] |
Construct rhythm given a fractional rhythmic value.
| x | Rhythmic fraction expressed as a Real |
Definition at line 67 of file Rhythm.h.
References RealToRational().
: m_num(0), m_den(0) { RealToRational( x, m_num, m_den ); }
Construct rhythm given a Real fractional rhythmic value, determine its rational approximation, assign numerator and denominator to reference arguments.
| x | Real fractional reference rhythmic value |
| num | Reference Integer numerator of derived rational fraction approximation |
| den | Reference Integer denominator of derived rational fraction approximation |
Definition at line 81 of file Rhythm.h.
References RealToRational().
: m_num(0), m_den(0) {
RealToRational( x, num, den );
m_num = num;
m_den = den;
}
Construct rhythm given a Rhythm, determine its rational approximation, assign numerator and denominator to reference arguments.
| x | Rhythmic value |
| num | Reference Integer numerator of derived rational fraction approximation |
| den | Reference Integer denominator of derived rational fraction approximation |
Definition at line 91 of file Rhythm.h.
References RealToRational().
: m_num(0), m_den(0) {
RealToRational( x.quotient(), num, den );
m_num = num;
m_den = den;
}
| Real Rhythm::absDuration | ( | ) | [inline] |
Return the absolute duration of this Rhythm.
Definition at line 252 of file Rhythm.h.
References Return.
Referenced by AbsDuration(), Duration(), and metronome().
| Real Rhythm::duration | ( | ) | [inline] |
Return the duration of a Rhythm given a Real beats per minute.
| beats | Rhythm indicating a duration to measure in time |
| perMinute | Real value indicating how many beats occupy a minute |
Definition at line 242 of file Rhythm.h.
References Return.
{
Return( 1.0 / (4.0 * beats.quotient()) * 60.0 / perMinute );
}
Print Rhythm prefixed by String.
| s | Prefix string |
Definition at line 209 of file Rhythm.h.
Referenced by operator<<().
{
If (s)
cout << s;
#ifdef _MSC_VER
// Disable Microsoft Visual Studio warning about sprintf()
// until is universal agreement about how to handle its insecurities
#pragma warning(push)
#pragma warning(disable: 4996)
sprintf(s_buf, "{%d,%d}", m_num, m_den);
#pragma warning(pop)
#else
sprintf(s_buf, "{%d,%d}", m_num, m_den);
#endif
Return s_buf;
}
| Static Real Rhythm::tempo | ( | Void | ) | [inline] |
| ostream& operator<< | ( | ostream & | os, |
| Rhythm & | r | ||
| ) | [friend] |
Definition at line 65 of file Rhythm.cpp.
| istream& operator>> | ( | istream & | is, |
| Rhythm & | p | ||
| ) | [friend] |
Definition at line 71 of file Rhythm.cpp.
{
char ch;
is >> ch && (ch == '{' || ch == '(')
&& is >> p.m_num >> ch && ch == ','
&& is >> p.m_den >> ch && (ch == '}' || ch == '(');
Return is;
}
1.7.2