NiCMidi 1.1.0
A MIDI library derived from J.D.Koftinoff jdksmidi
MIDISequencer Class Reference

A MIDITickComponent which implements a basic sequencer, able to play the MIDI events contained in a MIDIMultiTrack. More...

#include <sequencer.h>

Inheritance diagram for MIDISequencer:
MIDITickComponent AdvancedSequencer

Public Types

enum  { FOLLOW_MIDI_TIMESIG_MESSAGE , FOLLOW_TIMESIG_DENOMINATOR , FOLLOW_THEORETIC_VALUE }
 Values for the SetMetronomeMode() method. More...
 
enum  { PLAY_BOUNDED , PLAY_UNBOUNDED }
 Values for the play mode. More...
 
enum  { COUNT_IN_ENABLED = 1 , COUNT_IN_PENDING = 2 , AUTO_STOP_PENDING = 4 }
 Values for count_in_status. More...
 

Public Member Functions

 MIDISequencer (MIDIMultiTrack *m, MIDISequencerGUINotifier *n=0)
 The constructor. More...
 
virtual ~MIDISequencer ()
 The destructor. More...
 
virtual void Reset ()
 Resets the MIDISequencer to its initial state. More...
 
MIDIClockTime GetCurrentMIDIClockTime () const
 Returns current MIDIClockTime in MIDI ticks; it is effective even during playback. More...
 
float GetCurrentTimeMs () const
 Returns current time in milliseconds; it is effective even during playback. 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...
 
MIDIClockTime GetCurrentBeatOffset () const
 Returns the current MIDI time offset respect to current beat. More...
 
unsigned int GetClksPerBeat () const
 Returns the base MIDI ticks per beat ratio of the internal MIDIMultiTrack. More...
 
MIDIMultiTrackGetMultiTrack ()
 Returns a pointer to the internal MIDIMultiTrack. More...
 
const MIDIMultiTrackGetMultiTrack () const
 Returns a pointer to the internal MIDIMultiTrack. More...
 
MIDITrackGetTrack (unsigned int trk_num)
 Returns a pointer to the given track, or 0 if _num_trk is not a valid number. More...
 
unsigned int GetNumTracks () const
 Returns the number of tracks of the multitrack. 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...
 
bool GetRepeatPlay () const
 Returns the repeat play (loop) status on/off. More...
 
unsigned int GetRepeatPlayStart () const
 Returns the repeat play (loop) start measure. More...
 
unsigned int GetRepeatPlayEnd () const
 Returns the repeat play (loop) end measure. More...
 
bool GetCountInEnable () const
 Returns true if the count in is enabled. More...
 
bool GetCountInPending () const
 Returns true if the count in is pending (the sequencer is counting in). More...
 
bool GetTimeShiftMode () const
 Returns the time shift mode (on or off). More...
 
MIDISequencerStateGetState ()
 Returns a pointer to the current MIDISequencerState (i.e. More...
 
const MIDISequencerStateGetState () const
 Returns a pointer to the current MIDISequencerState (i.e. More...
 
bool GetPlayMode ()
 Returns the play mode state (see SetPlayMode()). More...
 
MIDISequencerTrackStateGetTrackState (unsigned int trk_num)
 Returns a pointer to the MIDISequencerTrackState for a track. More...
 
const MIDISequencerTrackStateGetTrackState (unsigned int trk_num) const
 Returns a pointer to the MIDISequencerTrackState for a track. More...
 
unsigned int GetTrackOutPort (unsigned int trk_num) const
 Returns the number of the out port assigned to a track. More...
 
MIDIProcessorGetTrackProcessor (unsigned int trk_num)
 Returns a pointer to the MIDISequencerTrackProcessor for a track. More...
 
const MIDIProcessorGetTrackProcessor (unsigned int trk_num) const
 Returns a pointer to the MIDISequencerTrackProcessor for a track. More...
 
int GetTrackTimeShift (unsigned int trk_num) const
 Returns the time offset (in MIDI ticks) assigned to a track. More...
 
virtual bool SetRepeatPlay (int on_off, int start_meas=-1, int end_meas=-1)
 Sets the repeat play (loop) parameters: you can set the repeat play status on/off, the start and the end measure. More...
 
virtual void SetCountIn (bool on_off)
 Sets the count in enable or disable. More...
 
virtual bool SetTempoScale (unsigned int scale)
 Sets the global tempo scale. More...
 
virtual void SetTimeShiftMode (bool f)
 Sets the time shifting of events on and off. More...
 
virtual void SetState (MIDISequencerState *s)
 Copies a given MIDISequencerState into the internal sequencer state. More...
 
virtual void SetPlayMode (int mode)
 Sets the play mode. More...
 
virtual bool SetTrackOutPort (unsigned int trk_num, unsigned int port)
 Sets the MIDI out port for a track. More...
 
virtual bool SetTrackProcessor (unsigned int trk_num, MIDIProcessor *p)
 Sets a MIDIProcessor for the given track. More...
 
virtual bool SetTrackTimeShift (unsigned int trk_num, int offset)
 Sets the time shift offset (in MIDI ticks) for a track. More...
 
virtual bool InsertTrack (int trk_num=-1)
 Inserts into the internal MIDIMultiTrack a new empty track with default track parameters (transpose, time offset, etc.). More...
 
virtual bool DeleteTrack (int trk_num=-1)
 Deletes a track and all its events from the internal MIDIMultiTrack. More...
 
virtual bool MoveTrack (int from, int to)
 Moves a track from one position to another in the internal MIDIMultiTrack. More...
 
virtual void GoToZero ()
 Sets the current time to the beginning of the song, updating the internal status. More...
 
virtual bool GoToTime (MIDIClockTime time_clk)
 Sets the current time to a given the MIDI time, updating the internal status. More...
 
virtual bool GoToTimeMs (float time_ms)
 Same as GoToTime(), but the time is given in milliseconds. More...
 
virtual bool GoToMeasure (unsigned int measure, unsigned int beat=0)
 Sets the current time to the given measure and beat, updating the internal status. More...
 
virtual bool GetNextEvent (int *trk_num, MIDITimedMessage *msg)
 Gets the next event (respect current position). More...
 
virtual bool GetNextEventTime (MIDIClockTime *time_clk)
 Gets the time of the next event (it can be different from current time if at current time there are not events). More...
 
virtual bool GetNextEventTimeMs (float *time_ms)
 Same of GetNextEventTime(), but time is returned in milliseconds from the beginning. More...
 
float MIDItoMs (MIDIClockTime time_clk)
 Converts a time from MIDI ticks into milliseconds, taking into account all tempo changes from the beginning of the song to the given time. More...
 
MIDIClockTime MeasToMIDI (unsigned int meas, unsigned int beat=0, unsigned int offset=0)
 TODO. More...
 
virtual void UpdateStatus ()
 This is equivalent of GoToTime(state.cur_clock) and should be used to update the sequencer state after an edit in the multitrack (adding, deleting or editing events, for changes in the track structure see InsertTrack(), DeleteTrack() and MoveTrack()). More...
 
virtual void Start ()
 Starts the sequencer playing from the current time. More...
 
virtual void Stop ()
 Stops the sequencer playing. More...
 
virtual void Play ()
 This is an alias of Start(). More...
 
- Public Member Functions inherited from MIDITickComponent
 MIDITickComponent (tPriority pr, MIDITick func)
 The constructor. More...
 
virtual ~MIDITickComponent ()
 The destructor. More...
 
MIDITickGetFunc () 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...
 

Static Public Member Functions

static void SetMetronomeMode (int mode)
 Selects the way the sequencer calculates metronome beat. More...
 

Protected Member Functions

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 StaticStopProc (MIDISequencer *p)
 Internal use for auto stop. More...
 
- Static Protected Member Functions inherited from MIDITickComponent
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

- Protected Attributes inherited from MIDITickComponent
const MIDITicktick_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...
 

Detailed Description

A MIDITickComponent which implements a basic sequencer, able to play the MIDI events contained in a MIDIMultiTrack.

It embeds:

You can call Start() (aliased by Play()) and Stop() to start and stop a separate thread which takes care of playing. All methods are thread safe and can be called during playback. Moreover the class allows the user to:

  • assign a separate MIDI out port for each track
  • assign a separate time shift amount (positive or negative) in MIDI ticks for every track
  • set a separate MIDIProcessor for each track
  • stretch the global tempo by a percentage (lesser or greater than 100)
  • set a repeat play loop between two measures
Note
This class is especially suitable for subclassing but has limited playing capacity (for example, if you jump from a time to another it updates the track parameters but doesn't send the appropriate MIDI messages to the drivers, so playing could be inconsistent with showed parameters). The AdvancedSequencer class is an enhanced sequencer with more features and more easy use.
Examples
test_sequencer.cpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Values for the SetMetronomeMode() method.

Enumerator
FOLLOW_MIDI_TIMESIG_MESSAGE 

follow the value stored in the last seen MIDI TimeSig message

FOLLOW_TIMESIG_DENOMINATOR 

follow the denominator of the time signature

FOLLOW_THEORETIC_VALUE 

follow the music theory value

◆ anonymous enum

anonymous enum

Values for the play mode.

Enumerator
PLAY_BOUNDED 

See SetPlayMode()

PLAY_UNBOUNDED 

See SetPlayMode()

◆ anonymous enum

anonymous enum

Values for count_in_status.

Enumerator
COUNT_IN_ENABLED 

0 if no count in before starting, 1 if yes

COUNT_IN_PENDING 

0 if count in is done, 2 if it is pending

AUTO_STOP_PENDING 

0 if no autostop, 4 if yes

Constructor & Destructor Documentation

◆ MIDISequencer()

MIDISequencer::MIDISequencer ( MIDIMultiTrack m,
MIDISequencerGUINotifier n = 0 
)

The constructor.

It raises an exception if in your system there are no MIDI out ports.

Parameters
ma pointer to a MIDIMultiTrack that will hold MIDI messages
na pointer to a MIDISequencerGUINotifier. If you leave 0 the sequencer will not notify the GUI.
Exceptions
RtMidiError::INVALID_DEVICEif in the system are not present MIDI out ports

◆ ~MIDISequencer()

virtual MIDISequencer::~MIDISequencer ( )
virtual

The destructor.

The MIDIMultiTrack and the MIDISequencerGUINotifier are not owned by the MIDISequencer; the MIDIProcessor objects, instead, (if you have set them with SetProcessor()) are deleted.

Member Function Documentation

◆ Reset()

virtual void MIDISequencer::Reset ( )
virtual

Resets the MIDISequencer to its initial state.

Moves the time to 0 updating the state (see MIDISequencerState::Reset()), deletes all the track processors (if you have set them with SetProcessor()), sets all the tracks to MIDI out 0 and no time offset, sets tempo scale to 100.

Note
This doesn't affect the multitrack content. If you want to empty it call GetMultiTrack()->Clear() before this (so the sequencer state is correctly updated). You should call this when the multitrack contents are changed (adding or deleting tracks) to reinitialize the MIDISequencer according to the new contents.

Implements MIDITickComponent.

Reimplemented in AdvancedSequencer.

◆ GetCurrentMIDIClockTime()

MIDIClockTime MIDISequencer::GetCurrentMIDIClockTime ( ) const

Returns current MIDIClockTime in MIDI ticks; it is effective even during playback.

◆ GetCurrentTimeMs()

float MIDISequencer::GetCurrentTimeMs ( ) const

Returns current time in milliseconds; it is effective even during playback.

Examples
test_win32_player.cpp.

◆ GetCurrentMeasure()

unsigned int MIDISequencer::GetCurrentMeasure ( ) const
inline

Returns current measure (1st measure is 0).

◆ GetCurrentBeat()

unsigned int MIDISequencer::GetCurrentBeat ( ) const
inline

Returns current beat in the measure (1st beat is 0).

◆ GetCurrentBeatOffset()

MIDIClockTime MIDISequencer::GetCurrentBeatOffset ( ) const
inline

Returns the current MIDI time offset respect to current beat.

◆ GetClksPerBeat()

unsigned int MIDISequencer::GetClksPerBeat ( ) const
inline

Returns the base MIDI ticks per beat ratio of the internal MIDIMultiTrack.

Default value is 120 clocks per quarter beat. However, loading a MIDIFile into the MIDIMultiTrack can change this according to the file clock.

◆ GetMultiTrack() [1/2]

MIDIMultiTrack * MIDISequencer::GetMultiTrack ( )
inline

◆ GetMultiTrack() [2/2]

const MIDIMultiTrack * MIDISequencer::GetMultiTrack ( ) const
inline

Returns a pointer to the internal MIDIMultiTrack.

◆ GetTrack()

MIDITrack * MIDISequencer::GetTrack ( unsigned int  trk_num)
inline

Returns a pointer to the given track, or 0 if _num_trk is not a valid number.

Examples
test_advancedsequencer.cpp.

◆ GetNumTracks()

unsigned int MIDISequencer::GetNumTracks ( ) const
inline

Returns the number of tracks of the multitrack.

Examples
test_win32_player.cpp.

◆ GetTempoScale()

unsigned int MIDISequencer::GetTempoScale ( ) const
inline

Returns current tempo scale in percentage (100 = no scaling, 200 = twice faster, etc.).

◆ GetTempoWithoutScale()

float MIDISequencer::GetTempoWithoutScale ( ) const
inline

Returns current tempo (BPM) without scaling.

Examples
test_win32_player.cpp.

◆ GetTempoWithScale()

float MIDISequencer::GetTempoWithScale ( ) const
inline

Returns current tempo (BPM) taking into account scaling (this is the true actual tempo).

Examples
test_advancedsequencer.cpp.

◆ GetRepeatPlay()

bool MIDISequencer::GetRepeatPlay ( ) const
inline

Returns the repeat play (loop) status on/off.

◆ GetRepeatPlayStart()

unsigned int MIDISequencer::GetRepeatPlayStart ( ) const
inline

Returns the repeat play (loop) start measure.

◆ GetRepeatPlayEnd()

unsigned int MIDISequencer::GetRepeatPlayEnd ( ) const
inline

Returns the repeat play (loop) end measure.

◆ GetCountInEnable()

bool MIDISequencer::GetCountInEnable ( ) const
inline

Returns true if the count in is enabled.

◆ GetCountInPending()

bool MIDISequencer::GetCountInPending ( ) const
inline

Returns true if the count in is pending (the sequencer is counting in).

◆ GetTimeShiftMode()

bool MIDISequencer::GetTimeShiftMode ( ) const
inline

Returns the time shift mode (on or off).

This is the value of the internal parameter, not the actual mode (during the playback the Start() method always sets it to on, while at the end the Stop() method resets it to this value).

◆ GetState() [1/2]

MIDISequencerState * MIDISequencer::GetState ( )
inline

Returns a pointer to the current MIDISequencerState (i.e.

the global sequencer state at current time). You can easily jump from a time to another saving and retrieving sequencer states.

Examples
test_win32_player.cpp.

◆ GetState() [2/2]

const MIDISequencerState * MIDISequencer::GetState ( ) const
inline

Returns a pointer to the current MIDISequencerState (i.e.

the global sequencer state at current time). You can easily jump from a time to another saving and retrieving sequencer states.

◆ GetPlayMode()

bool MIDISequencer::GetPlayMode ( )
inline

Returns the play mode state (see SetPlayMode()).

◆ GetTrackState() [1/2]

MIDISequencerTrackState * MIDISequencer::GetTrackState ( unsigned int  trk_num)
inline

Returns a pointer to the MIDISequencerTrackState for a track.

Parameters
trk_numthe track number

◆ GetTrackState() [2/2]

const MIDISequencerTrackState * MIDISequencer::GetTrackState ( unsigned int  trk_num) const
inline

Returns a pointer to the MIDISequencerTrackState for a track.

Parameters
trk_numthe track number

◆ GetTrackOutPort()

unsigned int MIDISequencer::GetTrackOutPort ( unsigned int  trk_num) const
inline

Returns the number of the out port assigned to a track.

Parameters
trk_numthe track number

◆ GetTrackProcessor() [1/2]

MIDIProcessor * MIDISequencer::GetTrackProcessor ( unsigned int  trk_num)
inline

Returns a pointer to the MIDISequencerTrackProcessor for a track.

Parameters
trk_numthe track number
Returns
the processor pointer (if you have already set it with the SetProcessor() method), otherwise 0

◆ GetTrackProcessor() [2/2]

const MIDIProcessor * MIDISequencer::GetTrackProcessor ( unsigned int  trk_num) const
inline

Returns a pointer to the MIDISequencerTrackProcessor for a track.

Parameters
trk_numthe track number
Returns
the processor pointer (if you have already set it with the SetProcessor() method), otherwise 0

◆ GetTrackTimeShift()

int MIDISequencer::GetTrackTimeShift ( unsigned int  trk_num) const
inline

Returns the time offset (in MIDI ticks) assigned to a track.

See also
SetTimeOffset(), SetTimeOffsetMode().
Parameters
trk_numthe track number

◆ SetRepeatPlay()

virtual bool MIDISequencer::SetRepeatPlay ( int  on_off,
int  start_meas = -1,
int  end_meas = -1 
)
virtual

Sets the repeat play (loop) parameters: you can set the repeat play status on/off, the start and the end measure.

When the repeat play mode is on, the sequencer will start playing from its current position if it is before the end measure, or from the start measure otherwise. When it reaches the end of the loop it jumps to the start.

Parameters
on_offcan be 0 (repeat play off), 1 (repeat play on) or -1 (leave the state unchanged). The latter can be useful if you only want to change the start or stop measure
start_meas,end_measyou can set the start and end measures (remember that measure numbers start with 0). If you set an end measure lesser or equal to the start the loop is automatically disabled. If you leave the default values the measures are left unchanged (useful if you only want to turn on or off the loop).
Returns
true if parameters are valid (and the mode has been changed), false otherwise (the mode has been set to false).
Examples
test_advancedsequencer.cpp.

◆ SetCountIn()

virtual void MIDISequencer::SetCountIn ( bool  on_off)
virtual

Sets the count in enable or disable.

◆ SetTempoScale()

virtual bool MIDISequencer::SetTempoScale ( unsigned int  scale)
virtual

Sets the global tempo scale.

Parameters
scalethe percentage: 100 = no scaling, 200 = twice faster, 50 = twice slower, etc.
Returns
true if scale is a valid number, false otherwise (actually only if it is 0).
Examples
test_advancedsequencer.cpp.

◆ SetTimeShiftMode()

virtual void MIDISequencer::SetTimeShiftMode ( bool  f)
virtual

Sets the time shifting of events on and off.

If you are editing the multitrack events you probably want to see the original (not shifted) MIDI time of events, while during playback you want them shifted. So you can turn time shifting on and off (and all the time related methods of the sequencer will return the shifted or the original time of events). The Start() method sets time shifting on, while the Stop() resets it to your choice, so usually you can leave time shifting off.

◆ SetState()

virtual void MIDISequencer::SetState ( MIDISequencerState s)
virtual

Copies a given MIDISequencerState into the internal sequencer state.

This method is thread-safe and can be called during playback. Notifies the GUI a GROUP_ALL event to signify a full GUI reset.

Parameters
sa pointer to the new state.
Note
You can save and restore the sequencer states for quickly jumping from a time to another; however you should avoid to save a state, edit the multitrack events and then restore the old state, because you can get inconsistent state parameters.

◆ SetPlayMode()

virtual void MIDISequencer::SetPlayMode ( int  mode)
virtual

Sets the play mode.

Parameters
modean enum value with the following meaning:
  • PLAY_BOUNDED: The sequencer auto stops after the last event. You cannot set the 'now' time after it
  • PLAY_UNBOUNDED: The sequencer doesn't stops after last event, but continues playing sending only beat markers events.
Note
The play mode affects the behavior of the methods GetNextEvent(), GetNextEventTime(), GetNextEventTimeMs(), GoToTime(), GoToTimeMs(), GoToMeasure().

◆ SetTrackOutPort()

virtual bool MIDISequencer::SetTrackOutPort ( unsigned int  trk_num,
unsigned int  port 
)
virtual

Sets the MIDI out port for a track.

This method is thread-safe and can be called during playback (in this case the sequencer will send a MIDI AllNotesOff message to the old port).

Parameters
trk_numthe track number
portthe id number of the port (see MIDIManager::GetOutPorts())
Returns
true if parameters are valid (and the port has been changed), false otherwise.
Examples
test_advancedsequencer.cpp.

◆ SetTrackProcessor()

virtual bool MIDISequencer::SetTrackProcessor ( unsigned int  trk_num,
MIDIProcessor p 
)
virtual

Sets a MIDIProcessor for the given track.

This can't be done while the sequencer is playing so it stops it.

Parameters
trk_numthe track number
pa pointer to a MIDIProcessor; calling this with p = 0 sets the track to no processor
Note
the Reset() method deletes all processors set by this method.
Returns
true if trk_num is valid (and the processor has been changed), false otherwise.

◆ SetTrackTimeShift()

virtual bool MIDISequencer::SetTrackTimeShift ( unsigned int  trk_num,
int  offset 
)
virtual

Sets the time shift offset (in MIDI ticks) for a track.

The offset can be positive or negative; events shifted include all channel messages and sysex messages (others remain at their time). If you select a negative offset, be sure not to have shifted events at lesser time than the offset (they won't be shifted). This method is thread-safe and can be called during playback.

See also
SetTimeOffsetMode().
Parameters
trk_numthe track number
offsetthe offset in MIDI ticks
Returns
true if trk_num is valid (and the offset has been changed), false otherwise.
Examples
test_advancedsequencer.cpp.

◆ InsertTrack()

virtual bool MIDISequencer::InsertTrack ( int  trk_num = -1)
virtual

Inserts into the internal MIDIMultiTrack a new empty track with default track parameters (transpose, time offset, etc.).

This method is thread-safe and can be called during playback. Notifies the GUI a GROUP_ALL event to signify a full GUI reset.

Parameters
trk_numthe track number (it must be in the range 0 ... GetNumTracks() - 1). If you leave the default value the track will be appended as last.
Returns
true if the track was effectively inserted
Note
You should not use the corresponding method of MIDIMultiTrack class, as it does not sync the iterator and the sequencer internal arrays. If you change the number of tracks directly in the multitrack (for example when loading a MIDI file) you must then call MIDISequencer::Reset() for updating the sequencer parameters, but this will reset all track parameters to the default.
Warning
if the sequencer is connected to a MIDIRecorder see MIDIRecorder::InsertTrack().

◆ DeleteTrack()

virtual bool MIDISequencer::DeleteTrack ( int  trk_num = -1)
virtual

Deletes a track and all its events from the internal MIDIMultiTrack.

This method is thread-safe and can be called during playback (in this case the sequencer will send a MIDI AllNotesOff message to the old track port). Notifies the GUI a GROUP_ALL event to signify a full GUI reset.

Parameters
trk_numthe track number (must be in the range 0 ... GetNumTracks() - 1). If you leave he default value the last track wil be deleted.
Returns
true if the track was effectively deleted
See also
note to InsertTrack()
Warning
if the sequencer is connected to a MIDIRecorder see MIDIRecorder::DeleteTrack().

◆ MoveTrack()

virtual bool MIDISequencer::MoveTrack ( int  from,
int  to 
)
virtual

Moves a track from one position to another in the internal MIDIMultiTrack.

This method is thread-safe and can be called during playback (in this case the sequencer will send a MIDI AllNotesOff message to the involved ports). Notifies the GUI a GROUP_ALL event to signify a full GUI reset.

Parameters
from,tothe start and destination track numbers (both must be in the range 0 ... GetNumTracks() - 1).
Returns
true if the track was effectively moved
See also
note to InsertTrack()
Warning
if the sequencer is connected to a MIDIRecorder see MIDIRecorder::MoveTrack().

◆ GoToZero()

virtual void MIDISequencer::GoToZero ( )
virtual

Sets the current time to the beginning of the song, updating the internal status.

This method is thread-safe and can be called during playback. Notifies the GUI a GROUP_ALL event to signify a full GUI reset.

Reimplemented in AdvancedSequencer.

◆ GoToTime()

virtual bool MIDISequencer::GoToTime ( MIDIClockTime  time_clk)
virtual

Sets the current time to a given the MIDI time, updating the internal status.

This method is thread-safe and can be called during playback. Notifies the GUI a GROUP_ALL event to signify a full GUI reset

Parameters
time_clkthe new time in MIDI ticks
Returns
true if the new time is effectively reached, false otherwise (time_clk is after the end of the song and the play mode is set to PLAY_BOUNDED: in this case the sequencer is leaved in its original state)

Reimplemented in AdvancedSequencer.

◆ GoToTimeMs()

virtual bool MIDISequencer::GoToTimeMs ( float  time_ms)
virtual

Same as GoToTime(), but the time is given in milliseconds.

Returns
see GoToTime()

Reimplemented in AdvancedSequencer.

◆ GoToMeasure()

virtual bool MIDISequencer::GoToMeasure ( unsigned int  measure,
unsigned int  beat = 0 
)
virtual

Sets the current time to the given measure and beat, updating the internal status.

This method is thread-safe and can be called during playback. Notifies the GUI a GROUP_ALL event to signify a GUI reset. See Numbering conventions.

Returns
see GoToTime()

◆ GetNextEvent()

virtual bool MIDISequencer::GetNextEvent ( int *  trk_num,
MIDITimedMessage msg 
)
virtual

Gets the next event (respect current position).

This queries the state for the next event in the multitrack, then processes it with the corresponding track processor (if you have set it with SetProcessor)) and updates the state. Moreover it notifies the GUI with appropriate messages. If there are no events before the next metronome click you will get a Beat Marker internal event.

Parameters
[out]trk_numwill return the track number of the next event
[out]msgwill return the MIDI event
Returns
true if there is effectively a next event (we are not at the end of the song or the play mode is set to PLAY_UNBOUNDED) , false otherwise (in this case *trk_num and *msg are undefined and the sequencer is leaved in its original state).
Note
if we set the play mode to PLAY_UNBOUNDED and go beyond the end of song this will return the next beat event (on track 0).

◆ GetNextEventTime()

virtual bool MIDISequencer::GetNextEventTime ( MIDIClockTime time_clk)
virtual

Gets the time of the next event (it can be different from current time if at current time there are not events).

Parameters
[out]time_clkwill return the requested time in MIDI ticks from the beginning
Returns
true if there is effectively a next event (we are not at the end of the song or the play mode is set to PLAY_UNBOUNDED) , false otherwise (in this case *time_clk is undefined).
Note
if we set the play mode to PLAY_UNBOUNDED and go beyond the end of song this will return the time of the next beat.

◆ GetNextEventTimeMs()

virtual bool MIDISequencer::GetNextEventTimeMs ( float *  time_ms)
virtual

Same of GetNextEventTime(), but time is returned in milliseconds from the beginning.

◆ MIDItoMs()

float MIDISequencer::MIDItoMs ( MIDIClockTime  time_clk)

Converts a time from MIDI ticks into milliseconds, taking into account all tempo changes from the beginning of the song to the given time.

Parameters
time_clkthe time to convert

◆ MeasToMIDI()

MIDIClockTime MIDISequencer::MeasToMIDI ( unsigned int  meas,
unsigned int  beat = 0,
unsigned int  offset = 0 
)

TODO.

◆ UpdateStatus()

virtual void MIDISequencer::UpdateStatus ( )
inlinevirtual

This is equivalent of GoToTime(state.cur_clock) and should be used to update the sequencer state after an edit in the multitrack (adding, deleting or editing events, for changes in the track structure see InsertTrack(), DeleteTrack() and MoveTrack()).

If you have edited the multitrack, call this before moving time, getting events or playing.

Reimplemented in AdvancedSequencer.

◆ Start()

virtual void MIDISequencer::Start ( )
virtual

Starts the sequencer playing from the current time.

Reimplemented from MIDITickComponent.

Reimplemented in AdvancedSequencer.

◆ Stop()

virtual void MIDISequencer::Stop ( )
virtual

Stops the sequencer playing.

Reimplemented from MIDITickComponent.

Reimplemented in AdvancedSequencer.

◆ Play()

virtual void MIDISequencer::Play ( )
inlinevirtual

◆ SetMetronomeMode()

static void MIDISequencer::SetMetronomeMode ( int  mode)
inlinestatic

Selects the way the sequencer calculates metronome beat.

You have three choices:

  • FOLLOW_MIDI_TIMESIG_MESSAGE the sequencer uses as metronome beat the value stored in the last seen MIDI TimeSig message
  • FOLLOW_TIMESIG_DENOMINATOR the sequencer uses as metronome beat the denominator of the time signature (so 4/4 => quarter note, 6/8 -> eighth note etc.)
  • FOLLOW_THEORETICAL_VALUE the sequencer uses as metronome beat the music theory value, taking into account simple and composite time signatures (so 4/4 => quarter note, 6/8 => dotted quarter note, etc.)

Don't use this while the sequencer is playing.

◆ StaticTickProc()

static void MIDISequencer::StaticTickProc ( tMsecs  sys_time,
void *  pt 
)
staticprotected

Implements the static method inherited by MIDITickComponent and called at every timer tick.

It only calls the member TickProc().

◆ TickProc()

virtual void MIDISequencer::TickProc ( tMsecs  sys_time)
protectedvirtual

Implements the pure virtual method inherited from MIDITickComponent (you must not call it directly).

Implements MIDITickComponent.

◆ StaticStopProc()

static void MIDISequencer::StaticStopProc ( MIDISequencer p)
inlinestaticprotected

Internal use for auto stop.


The documentation for this class was generated from the following file: