Functions | Variables

/Users/garethloy/Musimathics/Musimat1.2/MusimatLib/Rhythm.cpp File Reference

#include "Musimat.h"

Go to the source code of this file.

Functions

Void SetTempoScale (Real ts)
 Set the tempo used by all instances of Rhythm.
Real metronome (Rhythm B, Real T)
 Calculate the tempo coefficient corresponding to some rhythmic duration B at some tempo T.
Real Duration (Real x)
 Calculate the actual duration of a Real with the implicit tempo scale applied, as a fraction of a whole note.
Real Duration (Integer n, Integer d)
Real AbsDuration (Real x)
 Calculate the absolute duration of a Real without the implicit tempo scale applied, as a fraction of a whole note.
Real Duration (Rhythm y)
 Calculate the actual duration of a Rhythm with the implicit tempo scale applied, as a fraction of a whole note.
Real AbsDuration (Rhythm y)
 Calculate the absolute duration of a Rhythm without the implicit tempo scale applied, as a fraction of a whole note.
ostream & operator<< (ostream &os, Rhythm &r)
istream & operator>> (istream &is, Rhythm &p)

Variables

Rhythm Whole = Duration( 1 )
 Duration of a whole note.
Rhythm Half = Duration( 1, 2 )
 Duration of a half note.
Rhythm Quarter = Duration( 1, 4 )
 Duration of a quarter note.
Rhythm Eighth = Duration( 1, 8 )
 Duration of a eighth note.
Rhythm Sixteenth = Duration( 1, 16 )
 Duration of a sixteenth note.

Function Documentation

Real AbsDuration ( Real  x )

Calculate the absolute duration of a Real without the implicit tempo scale applied, as a fraction of a whole note.

Definition at line 49 of file Rhythm.cpp.

References Return.

{
        Rhythm(y);
        Return y.absDuration();
}
Real AbsDuration ( Rhythm  x )

Calculate the absolute duration of a Rhythm without the implicit tempo scale applied, as a fraction of a whole note.

Definition at line 60 of file Rhythm.cpp.

References Rhythm::absDuration(), and Return.

Real Duration ( Real  x )

Calculate the actual duration of a Real with the implicit tempo scale applied, as a fraction of a whole note.

For example, SetTempoScale( 0.5 ); Print( Duration( 1.0/4.0 ) ); prints 0.125.

Definition at line 37 of file Rhythm.cpp.

References Return.

{
        Rhythm(y);
        Return y.duration();
}
Real Duration ( Integer  n,
Integer  d 
)

Definition at line 43 of file Rhythm.cpp.

References Rhythm::duration(), and Return.

{
        Rhythm y = Rhythm(n, d);
        Return y.duration();
}
Real Duration ( Rhythm  x )

Calculate the actual duration of a Rhythm with the implicit tempo scale applied, as a fraction of a whole note.

Definition at line 55 of file Rhythm.cpp.

References Rhythm::absDuration(), and Return.

Real metronome ( Rhythm  B,
Real  T 
)

Calculate the tempo coefficient corresponding to some rhythmic duration B at some tempo T.

B can be expressed as a ratio of reals, e.g., 1.0/4.0 for a quarternote. The expression metronome( 1.0/4.0, 60.0 ) returns the tempo coefficient for "quarter note gets the beat and there are sixty beats per minute". Hence, it returns 1.0.

Definition at line 32 of file Rhythm.cpp.

References Rhythm::absDuration(), and Return.

{
        Return( 1.0 / (4.0 * B.absDuration()) * 60.0 / T );
}
ostream& operator<< ( ostream &  os,
Rhythm r 
)

Definition at line 65 of file Rhythm.cpp.

References Rhythm::print(), and Return.

{
        os << r.print();
        Return os;
}
istream& operator>> ( istream &  is,
Rhythm p 
)

Definition at line 71 of file Rhythm.cpp.

References Return.

{
        char ch;
        is >> ch && (ch == '{' || ch == '(')
                && is >> p.m_num >> ch && ch == ','
                && is >> p.m_den >> ch && (ch == '}' || ch == '(');
        Return is;
}
Void SetTempoScale ( Real  ts )

Set the tempo used by all instances of Rhythm.

Definition at line 27 of file Rhythm.cpp.

References Rhythm::tempo().

{
        Rhythm::tempo(ts);
}