NiCMidi 1.1.0
A MIDI library derived from J.D.Koftinoff jdksmidi
|
Performs conversions between number of samples, milliseconds and smpte format (hours::minutes::seconds::frames::subframes). More...
#include <smpte.h>
Public Member Functions | |
SMPTE (SMPTE_RATE smpte_rate=SMPTE_RATE_30, SAMPLE_RATE sample_rate=SAMPLE_48000) | |
The constructor sets the smpte rate to SMPTE_30, the sample rate to SAMPLE_48000 and the offset time to 0. More... | |
void | SetSMPTERate (SMPTE_RATE r) |
Sets the smpte rate. See SMPTE_RATE for avalaible smpte rate formats. More... | |
SMPTE_RATE | GetSMPTERate () const |
Returns the smpte rate. See SMPTE_RATE for avalaible smpte rate formats. More... | |
void | SetSampleRate (SAMPLE_RATE r) |
Sets the sample rate. See SAMPLE_RATE for avalaible sample rates formats. More... | |
SAMPLE_RATE | GetSampleRate () const |
Returns the sample rate. See SAMPLE_RATE for avalaible sample rates formats. More... | |
void | SetOffset (unsigned long n) |
Sets an offset to be added to the current time, given the amount of samples. More... | |
void | SetOffset (unsigned char h, unsigned char m, unsigned char s, unsigned char f=0, unsigned char sf=0) |
Sets an offset to be added to the current time, given the smpte time parameters. More... | |
unsigned long | GetOffset () const |
Returns the time offset (in samples). More... | |
unsigned long | GetSampleNumber () |
Performs a smpte-to-samples or milliseconds-to-samples conversion. More... | |
void | SetSampleNumber (unsigned long n) |
Loads the SMPTE with the given amount of samples. More... | |
unsigned long | GetMilliSeconds () |
Performs a smpte-to-millisecond or sample-to-millisecond conversion. More... | |
void | SetMilliSeconds (unsigned long msecs) |
Loads the SMPTE with the given time in milliseconds. More... | |
Conversion to smpte | |
These perform a samples-to-smpte or milliseconds-to-smpte conversion. You must first load the SMPTE with the number of samples (using SetSampleNumber()) or the number of milliseconds (using SetMilliSeconds()) to convert; then you can call these to get the converted smpte values.
| |
unsigned char | GetHours () |
Returns the smpte hours. More... | |
unsigned char | GetMinutes () |
Returns the smpte minutes. More... | |
unsigned char | GetSeconds () |
Returns the smpte seconds. More... | |
unsigned char | GetFrames () |
Returns the smpte frames. More... | |
unsigned char | GetSubFrames () |
Returns the smpte subframes. More... | |
Conversion from smpte | |
Use these to convert from smpte. | |
void | SetTime (unsigned char h, unsigned char m, unsigned char s, unsigned char f=0, unsigned char sf=0) |
Loads the SMPTE with the given time (in smpte format). More... | |
void | SetHours (unsigned char h) |
Loads the SMPTE with the given smpte hours, leaving unchanged other parameters. More... | |
void | SetMinutes (unsigned char m) |
Loads the SMPTE with the given smpte minutes, leaving unchanged other parameters. More... | |
void | SetSeconds (unsigned char s) |
Loads the SMPTE with the given smpte seconds, leaving unchanged other parameters. More... | |
void | SetFrames (unsigned char f) |
Loads the SMPTE with the given smpte frames, leaving unchanged other parameters. More... | |
void | SetSubFrames (unsigned char sf) |
Loads the SMPTE with the given smpte subframes, leaving unchanged other parameters. More... | |
To add, increment and decrement samples | |
These functions add, increment or decrement the current sample number. | |
void | AddSamples (long n) |
Adds n samples. More... | |
void | IncSamples () |
Adds one sample. More... | |
void | DecSamples () |
Subtracts one sample. More... | |
To add, increment and decrement smpte | |
These functions add, increment or decrement smpte time parameters. | |
void | AddHours (signed char h) |
Adds hours to smpte time. More... | |
void | AddMinutes (signed char m) |
Adds minutes to smpte time. More... | |
void | AddSeconds (signed char s) |
Adds seconds to smpte time. More... | |
void | AddFrames (signed char f) |
Adds frames to smpte time. More... | |
void | AddSubFrames (signed char sf) |
Adds subframes to smpte time. More... | |
void | IncHours () |
Adds one hour to smpte time. More... | |
void | IncMinutes () |
Adds one minute to smpte time. More... | |
void | IncSeconds () |
Adds one second to smpte time. More... | |
void | IncFrames () |
Adds one frame to smpte time. More... | |
void | IncSubFrames () |
Adds one subframe to smpte time. More... | |
void | DecHours () |
Subtract one hour from smpte time. More... | |
void | DecMinutes () |
Subtract one minute from smpte time. More... | |
void | DecSeconds () |
Subtract one second from smpte time. More... | |
void | DecFrames () |
Subtract one frame from smpte time. More... | |
void | DecSubFrames () |
Subtract one subframe from smpte time. More... | |
The operators (these compare the current time) | |
| |
bool | operator== (SMPTE &s) |
Equal. More... | |
bool | operator!= (SMPTE &s) |
Not equal. More... | |
bool | operator< (SMPTE &s) |
Lesser. More... | |
bool | operator> (SMPTE &s) |
Greater. More... | |
bool | operator<= (SMPTE &s) |
Lesser or equal. More... | |
bool | operator>= (SMPTE &s) |
Greater or equal. More... | |
Protected Member Functions | |
void | SampleToTime () |
Performs internal samples-to-smpte conversion. More... | |
void | TimeToSample () |
Performs internal smpte-to-samples conversion. More... | |
int | Compare (SMPTE &s) |
Performs internal comparison between sample numbers. More... | |
Performs conversions between number of samples, milliseconds and smpte format (hours::minutes::seconds::frames::subframes).
You can choose between several smpte formats and sample rates (see SMPTE_RATE and SAMPLE_RATE). Moreover you can set an initial time offset to be added to every value passed to the SMPTE.
SMPTE::SMPTE | ( | SMPTE_RATE | smpte_rate = SMPTE_RATE_30 , |
SAMPLE_RATE | sample_rate = SAMPLE_48000 |
||
) |
The constructor sets the smpte rate to SMPTE_30, the sample rate to SAMPLE_48000 and the offset time to 0.
|
inline |
Sets the smpte rate. See SMPTE_RATE for avalaible smpte rate formats.
|
inline |
Returns the smpte rate. See SMPTE_RATE for avalaible smpte rate formats.
|
inline |
Sets the sample rate. See SAMPLE_RATE for avalaible sample rates formats.
|
inline |
Returns the sample rate. See SAMPLE_RATE for avalaible sample rates formats.
|
inline |
Sets an offset to be added to the current time, given the amount of samples.
void SMPTE::SetOffset | ( | unsigned char | h, |
unsigned char | m, | ||
unsigned char | s, | ||
unsigned char | f = 0 , |
||
unsigned char | sf = 0 |
||
) |
Sets an offset to be added to the current time, given the smpte time parameters.
|
inline |
Returns the time offset (in samples).
unsigned long SMPTE::GetSampleNumber | ( | ) |
Performs a smpte-to-samples or milliseconds-to-samples conversion.
You must first load the SMPTE with the smpte values (using SetTime() or SetHours() ...) or the number of milliseconds (using SetMilliSeconds()) to convert; then you can call this to get the converted value.
|
inline |
Loads the SMPTE with the given amount of samples.
You can then call GetHour(), GetMinutes() etc. to perform a samples-to-smpte conversion or GetMilliseconds() to perform a sample-to-milliseconds conversion.
unsigned long SMPTE::GetMilliSeconds | ( | ) |
Performs a smpte-to-millisecond or sample-to-millisecond conversion.
You must first load the SMPTE with the number of samples (using SetSampleNumber()) or with smpte values (using SetTime() or SetHours() ...) to convert; then you can call this to get the converted value.
void SMPTE::SetMilliSeconds | ( | unsigned long | msecs | ) |
Loads the SMPTE with the given time in milliseconds.
You can then call GetSampleNumber() to perform a milliseconds-to-sample conversion or GetHours(), GetMinutes() etc. to perform a milliseconds-to-smpte conversion.
unsigned char SMPTE::GetHours | ( | ) |
Returns the smpte hours.
unsigned char SMPTE::GetMinutes | ( | ) |
Returns the smpte minutes.
unsigned char SMPTE::GetSeconds | ( | ) |
Returns the smpte seconds.
unsigned char SMPTE::GetFrames | ( | ) |
Returns the smpte frames.
unsigned char SMPTE::GetSubFrames | ( | ) |
Returns the smpte subframes.
void SMPTE::SetTime | ( | unsigned char | h, |
unsigned char | m, | ||
unsigned char | s, | ||
unsigned char | f = 0 , |
||
unsigned char | sf = 0 |
||
) |
Loads the SMPTE with the given time (in smpte format).
You can then call GetSampleNumber() to perform a smpte-to-sample conversion or GetMilliSeconds() to perform a smpte-to-milliseconds conversion.
|
inline |
Loads the SMPTE with the given smpte hours, leaving unchanged other parameters.
|
inline |
Loads the SMPTE with the given smpte minutes, leaving unchanged other parameters.
|
inline |
Loads the SMPTE with the given smpte seconds, leaving unchanged other parameters.
|
inline |
Loads the SMPTE with the given smpte frames, leaving unchanged other parameters.
|
inline |
Loads the SMPTE with the given smpte subframes, leaving unchanged other parameters.
void SMPTE::AddSamples | ( | long | n | ) |
Adds n samples.
|
inline |
Adds one sample.
|
inline |
Subtracts one sample.
void SMPTE::AddHours | ( | signed char | h | ) |
Adds hours to smpte time.
void SMPTE::AddMinutes | ( | signed char | m | ) |
Adds minutes to smpte time.
void SMPTE::AddSeconds | ( | signed char | s | ) |
Adds seconds to smpte time.
void SMPTE::AddFrames | ( | signed char | f | ) |
Adds frames to smpte time.
void SMPTE::AddSubFrames | ( | signed char | sf | ) |
Adds subframes to smpte time.
|
inline |
Adds one hour to smpte time.
|
inline |
Adds one minute to smpte time.
|
inline |
Adds one second to smpte time.
|
inline |
Adds one frame to smpte time.
|
inline |
Adds one subframe to smpte time.
|
inline |
Subtract one hour from smpte time.
|
inline |
Subtract one minute from smpte time.
|
inline |
Subtract one second from smpte time.
|
inline |
Subtract one frame from smpte time.
|
inline |
Subtract one subframe from smpte time.
|
inline |
Equal.
|
inline |
Not equal.
|
inline |
Lesser.
|
inline |
Greater.
|
inline |
Lesser or equal.
|
inline |
Greater or equal.
|
protected |
Performs internal samples-to-smpte conversion.
|
protected |
Performs internal smpte-to-samples conversion.
|
protected |
Performs internal comparison between sample numbers.