NiCMidi 1.1.0
A MIDI library derived from J.D.Koftinoff jdksmidi
|
A MIDITickComponent which can record MIDI messages incoming from a MIDI in port, putting them into an internal MIDIMultiTrack. More...
#include <recorder.h>
Public Types | |
enum | { REC_MERGE , REC_OVER } |
Recording mode: You can choose to merge the new with the old track content, or to overwrite it. More... | |
Public Member Functions | |
MIDIRecorder (MIDISequencer *const s) | |
The constructor. It binds the recorder to the given MIDISequencer. More... | |
virtual | ~MIDIRecorder () |
The destructor. More... | |
virtual void | Reset () |
It sets all tracks to recording disabled, empties the internal multitrack and sets the start and end recording times to 0 ... TIME_INFINITE. More... | |
MIDIMultiTrack * | GetMultiTrack () const |
Returns a pointer to the internal MIDIMultiTrack. More... | |
int | GetRecMode () const |
Returns the recording mode. More... | |
MIDIClockTime | GetStartRecTime () const |
Returns the recording start time in MIDI ticks. More... | |
MIDIClockTime | GetEndRecTime () const |
Returns the recording end time in MIDI ticks. More... | |
MIDITrack * | GetTrack (unsigned int trk_num) |
Returns the pointer to a track of the internal multitrack. More... | |
const MIDITrack * | GetTrack (unsigned int trk_num) const |
Returns the pointer to a track of the internal multitrack. More... | |
unsigned int | GetTrackInPort (unsigned int trk_num) const |
Returns the number of the MIDI in port assigned to the given track. More... | |
int | GetTrackRecChannel (unsigned int trk_num) |
Returns the recording channel for the given track, or -1 for any channel. More... | |
bool | SetTrackInPort (unsigned int trk_num, unsigned int port) |
Sets the MIDI in port for a track. More... | |
bool | SetTrackRecChannel (unsigned int trk_num, int chan) |
Sets the recording channel for the given track. More... | |
bool | SetRecMode (int mode) |
Sets the recording mode. More... | |
bool | SetStartRecTime (MIDIClockTime t) |
Sets the recording start time. More... | |
bool | SetStartRecTime (unsigned int meas, unsigned int beat=0) |
Sets the recording start time, giving the measure and beat. See SetStartRecTime(MIDIClockTime). More... | |
bool | SetEndRecTime (MIDIClockTime t) |
Sets the recording end time. More... | |
bool | SetEndRecTime (unsigned int meas, unsigned int beat=0) |
Sets the recording end time, giving the measure and beat. See SetEndRecTime(MIDIClockTime). More... | |
bool | InsertTrack (int trk_num=-1) |
Inserts into the internal MIDIMultiTrack a new track. More... | |
bool | DeleteTrack (int trk_num=-1) |
Deletes a track and all its events from the internal MIDIMultiTrack. More... | |
bool | MoveTrack (int from, int to) |
Moves a track from one position to another in the internal MIDIMultiTrack. More... | |
bool | EnableTrack (unsigned int trk_num) |
Enables a sequencer track for recording. More... | |
bool | DisableTrack (unsigned int trk_num) |
Disables a sequencer track for recording. More... | |
bool | UndoRec () |
Deletes the changes made in the last recording. More... | |
virtual void | Start () |
Starts the recording from the enabled ports and channels. More... | |
virtual void | Stop () |
Stops the recording from the enabled ports and channels. 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 | ResizeTracks (unsigned int max_num) |
Internal function. More... | |
void | SetSeqNotifier () |
Internal function. More... | |
void | ResetSeqNotifier () |
Internal function. It is used in Stop() to reset the hook in the sequencer notifier. More... | |
void | PrepareTrack (unsigned int trk_num) |
Internal function. 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 by 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 which can record MIDI messages incoming from a MIDI in port, putting them into an internal MIDIMultiTrack.
These are its main features:
The recorder is bounded to a MIDISequencer component (given in the constructor) which plays the tracks content while recording and sets the current time. Recorder and sequencer manage separate MIDIMultiTrack components: when the recording stops the recorder copies the new content into the sequencer MIDIMultiTrack, keeping them synchronized.
anonymous enum |
MIDIRecorder::MIDIRecorder | ( | MIDISequencer *const | s | ) |
The constructor. It binds the recorder to the given MIDISequencer.
|
virtual |
The destructor.
|
virtual |
It sets all tracks to recording disabled, empties the internal multitrack and sets the start and end recording times to 0 ... TIME_INFINITE.
Implements MIDITickComponent.
|
inline |
Returns a pointer to the internal MIDIMultiTrack.
|
inline |
|
inline |
Returns the recording start time in MIDI ticks.
|
inline |
Returns the recording end time in MIDI ticks.
|
inline |
Returns the pointer to a track of the internal multitrack.
trk_num | The track number |
|
inline |
Returns the pointer to a track of the internal multitrack.
trk_num | The track number |
|
inline |
Returns the number of the MIDI in port assigned to the given track.
trk_num | the track number |
|
inline |
Returns the recording channel for the given track, or -1 for any channel.
You can force a track to receive only a given channel with SetTrackRecChannel(). See Numbering conventions
bool MIDIRecorder::SetTrackInPort | ( | unsigned int | trk_num, |
unsigned int | port | ||
) |
Sets the MIDI in port for a track.
This cannot be called during recording.
trk_num | the track number |
port | the id number of the port (see MIDIManager::GetOutPorts()) |
bool MIDIRecorder::SetTrackRecChannel | ( | unsigned int | trk_num, |
int | chan | ||
) |
Sets the recording channel for the given track.
This cannot be called during recording.
trk_num | the track number |
chan | the channel: you can specify a number between 0 ... 15 or -1 for any channel. |
bool MIDIRecorder::SetRecMode | ( | int | mode | ) |
bool MIDIRecorder::SetStartRecTime | ( | MIDIClockTime | t | ) |
Sets the recording start time.
If the recording end time is less than t it sets it to t. You cannot change the time while recording.
t | the MIDI clock time to assign |
|
inline |
Sets the recording start time, giving the measure and beat. See SetStartRecTime(MIDIClockTime).
bool MIDIRecorder::SetEndRecTime | ( | MIDIClockTime | t | ) |
Sets the recording end time.
If the recording start time is greater than t it sets it to t. You cannot change the time while recording.
t | the MIDI clock time to assign |
|
inline |
Sets the recording end time, giving the measure and beat. See SetEndRecTime(MIDIClockTime).
bool MIDIRecorder::InsertTrack | ( | int | trk_num = -1 | ) |
Inserts into the internal MIDIMultiTrack a new track.
This method is thread-safe and can be called during sequencer playback, but not during recording.
trk_num | the track number. If you leave the default value the track will be appended as last. |
bool MIDIRecorder::DeleteTrack | ( | int | trk_num = -1 | ) |
Deletes a track and all its events from the internal MIDIMultiTrack.
This method is thread-safe and can be called during sequencer playback, but not while recording.
trk_num | the track number (must be in the range 0 ... GetNumTracks() - 1). If you leave he default value the last track wil be deleted. |
bool MIDIRecorder::MoveTrack | ( | int | from, |
int | to | ||
) |
Moves a track from one position to another in the internal MIDIMultiTrack.
This method is thread-safe and can be called during playback.
from,to | the start and destination track numbers (both must be in the range 0 ... GetNumTracks() - 1). |
bool MIDIRecorder::EnableTrack | ( | unsigned int | trk_num | ) |
Enables a sequencer track for recording.
If the track was already enabled it does nothing.
trk_num | the track number |
bool MIDIRecorder::DisableTrack | ( | unsigned int | trk_num | ) |
Disables a sequencer track for recording.
If the track was not enabled it does nothing.
trk_num | the track number |
bool MIDIRecorder::UndoRec | ( | ) |
Deletes the changes made in the last recording.
You have multiple levels of undo.
|
virtual |
Starts the recording from the enabled ports and channels.
It starts the attached MIDISequencer from its current position, after a lead in measure.
Reimplemented from MIDITickComponent.
|
virtual |
Stops the recording from the enabled ports and channels.
Reimplemented from MIDITickComponent.
|
protected |
Internal function.
It is used to resize the internal multitrack according to the number of enabled tracks.
|
protected |
Internal function.
It is used in Start() to put an hook to the metronome in the sequencer notifier.
|
protected |
Internal function. It is used in Stop() to reset the hook in the sequencer notifier.
|
protected |
Internal function.
It copies an enabled sequencer track in the recorder multitrack, deleting the channel events.
|
staticprotected |
Implements the static method inherited by 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.