NiCMidi 1.1.0
A MIDI library derived from J.D.Koftinoff jdksmidi
|
A MIDITickComponent implementing a metronome. More...
#include <metronome.h>
Public Member Functions | |
Metronome (MIDISequencerGUINotifier *n=0) | |
The constructor. More... | |
virtual | ~Metronome () |
The destructor. The MIDISequencerGUINotifier is not owned by the Metronome. More... | |
virtual void | Reset () |
Stops the metronome and resets it to its default values. More... | |
MIDIClockTime | GetCurrentMIDIClockTime () const |
Returns current MIDIClockTime in MIDI ticks from the start of the metronome. More... | |
float | GetCurrentTimeMs () const |
Returns current time in milliseconds from the start of the metronome. More... | |
unsigned int | GetCurrentMeasure () const |
Returns current measure (1st measure is 0). More... | |
unsigned int | GetCurrentBeat () const |
Returns current beat in the measure (1st beat is 0). More... | |
unsigned int | GetTempoScale () const |
Returns current tempo scale in percentage (100 = no scaling, 200 = twice faster, etc.). More... | |
float | GetTempoWithoutScale () const |
Returns current tempo (BPM) without scaling. More... | |
float | GetTempoWithScale () const |
Returns current tempo (BPM) taking into account scaling (this is the true actual tempo). More... | |
unsigned int | GetOutPort () const |
Returns the number of the MIDI out port assigned to the metronome. More... | |
unsigned int | GetOutChannel () const |
Returns the number of the MIDI channel assigned to the metronome. More... | |
unsigned char | GetMeasNote () const |
Returns the MIDI note number for the measure click. More... | |
unsigned char | GetBeatNote () const |
Returns the MIDI note number for the ordinary beat click. More... | |
unsigned char | GetSubdNote () const |
Returns the MIDI note number for the subdivision click. More... | |
unsigned char | GetSubdType () const |
Returns the subdivision type. It can be 0 (subd clicks disabled), 2, 3, 4, 5, 6. More... | |
unsigned char | GetTimeSigNumerator () const |
Returns the numerator of the current timesig. More... | |
bool | SetTempo (float t) |
Sets the musical tempo. More... | |
bool | SetTempoScale (unsigned int scale) |
Sets the global tempo scale. More... | |
bool | SetOutPort (unsigned int port) |
Sets the MIDI out port for the metronome clicks. More... | |
bool | SetOutChannel (unsigned int chan) |
Sets the MIDI channel for the metronome clicks. More... | |
void | SetMeasNote (unsigned char note) |
Sets the MIDI note number for the measure click (the 1st beat of the measure). More... | |
void | SetBeatNote (unsigned char note) |
Sets the MIDI note number for the ordinary beat click. More... | |
void | SetSubdNote (unsigned char note) |
Sets the MIDI note number for the subdivision click. More... | |
bool | SetSubdType (unsigned char type) |
Sets the subdivision type. More... | |
void | SetTimeSigNumerator (unsigned char n) |
Sets the numerator of the current timesig. More... | |
virtual void | Start () |
Starts the metronome. More... | |
virtual void | Stop () |
Stops the metronome. More... | |
![]() | |
MIDITickComponent (tPriority pr, MIDITick func) | |
The constructor. More... | |
virtual | ~MIDITickComponent () |
The destructor. More... | |
MIDITick * | GetFunc () const |
Returns the address of the StaticTickProc() method, which will be called by the MIDIManager at every clock tick. More... | |
tPriority | GetPriority () const |
Returns the priority. More... | |
tMsecs | GetDevOffset () const |
Returns the user time offset parameter (see SetDevOffset()). More... | |
bool | IsPlaying () const |
Returns true if the callback procedure is active. More... | |
void | SetDevOffset (tMsecs dev_offs) |
Sets an user defined time offset, which will be added to every time calculation. More... | |
Protected Member Functions | |
void | UpdateValues () |
Copies the temp values assigned by the set methods into the effective ones. More... | |
virtual void | TickProc (tMsecs sys_time) |
Implements the pure virtual method inherited from MIDITickComponent (you must not call it directly). More... | |
Static Protected Member Functions | |
static void | StaticTickProc (tMsecs sys_time, void *pt) |
Implements the static method inherited from MIDITickComponent and called at every timer tick. More... | |
![]() | |
static void | StaticTickProc (tMsecs sys_time, void *pt) |
This is the static callback procedure which the MIDIManager will call at every MIDITimer tick. More... | |
Additional Inherited Members | |
![]() | |
const MIDITick * | tick_proc |
The pointer to the static callback (set by the constructor to StaticTickProc()). More... | |
tMsecs | dev_time_offset |
A time offset set by the user and which you can use for your calculations. More... | |
tMsecs | sys_time_offset |
The system time of the last call of Start(). More... | |
std::recursive_mutex | proc_lock |
A mutex you can use for implementing thread safe methods. More... | |
A MIDITickComponent implementing a metronome.
You can select the port, channel and MIDI notes of the metronome clicks; moreover you can have three types of click: the ordinary (beat) click, the measure click (first beat of a measure) and a subdivision click. If you enable measure clicks the metronome can count the measures and the beats of a measure (so you can represent them in a graphical interface). When you change some parameter (tempo, measure, etc./) the metronome is not updated immediately, but only at the subsequent click (see UpdateValues()).
Metronome::Metronome | ( | MIDISequencerGUINotifier * | n = 0 | ) |
The constructor.
It raises an exception if in your system there are no MIDI out ports.
n | a pointer to a MIDISequencerGUINotifier. If you leave 0 the sequencer will not notify the GUI. |
RtMidiError::INVALID_DEVICE | if in the system are not present MIDI out ports. |
|
inlinevirtual |
The destructor. The MIDISequencerGUINotifier is not owned by the Metronome.
|
virtual |
Stops the metronome and resets it to its default values.
Implements MIDITickComponent.
|
inline |
Returns current MIDIClockTime in MIDI ticks from the start of the metronome.
float Metronome::GetCurrentTimeMs | ( | ) | const |
Returns current time in milliseconds from the start of the metronome.
|
inline |
Returns current measure (1st measure is 0).
Measures count is suspended if you disable the measure click (see SetTimeSigNumerator()).
|
inline |
Returns current beat in the measure (1st beat is 0).
|
inline |
Returns current tempo scale in percentage (100 = no scaling, 200 = twice faster, etc.).
|
inline |
Returns current tempo (BPM) without scaling.
|
inline |
Returns current tempo (BPM) taking into account scaling (this is the true actual tempo).
|
inline |
Returns the number of the MIDI out port assigned to the metronome.
|
inline |
Returns the number of the MIDI channel assigned to the metronome.
|
inline |
Returns the MIDI note number for the measure click.
|
inline |
Returns the MIDI note number for the ordinary beat click.
|
inline |
Returns the MIDI note number for the subdivision click.
|
inline |
Returns the subdivision type. It can be 0 (subd clicks disabled), 2, 3, 4, 5, 6.
|
inline |
Returns the numerator of the current timesig.
If it is 0 the measure clicks are disabled, otherwise the 1st click of a measure will sound with different note and volume.
bool Metronome::SetTempo | ( | float | t | ) |
Sets the musical tempo.
You can set it between 1.0 bpm and 300.0 bpm.
bool Metronome::SetTempoScale | ( | unsigned int | scale | ) |
Sets the global tempo scale.
scale | the percentage: 100 = no scaling, 200 = twice faster, 50 = twice slower, etc. |
bool Metronome::SetOutPort | ( | unsigned int | port | ) |
Sets the MIDI out port for the metronome clicks.
port | The out MIDI port id number |
bool Metronome::SetOutChannel | ( | unsigned int | chan | ) |
Sets the MIDI channel for the metronome clicks.
void Metronome::SetMeasNote | ( | unsigned char | note | ) |
Sets the MIDI note number for the measure click (the 1st beat of the measure).
It is only effective if you have already set the timesig numerator (see SetTimesigNumerator()).
void Metronome::SetBeatNote | ( | unsigned char | note | ) |
Sets the MIDI note number for the ordinary beat click.
void Metronome::SetSubdNote | ( | unsigned char | note | ) |
Sets the MIDI note number for the subdivision click.
bool Metronome::SetSubdType | ( | unsigned char | type | ) |
Sets the subdivision type.
It can be 0 (subd clicks disabled), 2, 3, 4, 5, 6.
void Metronome::SetTimeSigNumerator | ( | unsigned char | n | ) |
Sets the numerator of the current timesig.
If it is 0 the measure clicks are disabled, otherwise the 1st click of a measure will sound with different note and volume.
|
virtual |
|
virtual |
|
protected |
Copies the temp values assigned by the set methods into the effective ones.
It is called immediately if the metronome is not running, otherwise at every click, so the metronome parameters are updated in sync.
|
staticprotected |
Implements the static method inherited from MIDITickComponent and called at every timer tick.
It only calls the member TickProc().
|
protectedvirtual |
Implements the pure virtual method inherited from MIDITickComponent (you must not call it directly).
Implements MIDITickComponent.