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

A MIDITickComponent which immediately echoes to an out MIDI port all messages incoming from an in MIDI port. More...

#include <thru.h>

Inheritance diagram for MIDIThru:
MIDITickComponent

Public Member Functions

 MIDIThru ()
 The constructor. More...
 
virtual ~MIDIThru ()
 The destructor. More...
 
virtual void Reset ()
 Resets the class to initial status: More...
 
unsigned int GetInPort () const
 Returns the number of the MIDI in port from which messages are actually being received. More...
 
unsigned int GetOutPort () const
 Returns a pointer to the MIDIOutDriver to whom messages are actually being sent. More...
 
MIDIProcessorGetProcessor ()
 Returns a pointer to the MIDIProcessor attached to the thru (see SetProcessor()). More...
 
const MIDIProcessorGetProcessor () const
 Returns a pointer to the MIDIProcessor attached to the thru (see SetProcessor()). More...
 
int GetInChannel () const
 Returns the thru in channel (see SetInChannel()) More...
 
int GetOutChannel () const
 Returns the thru out channel (see SetOutChannel()) More...
 
virtual bool SetInPort (unsigned int port)
 Selects the hardware in port from which messages will be received. More...
 
virtual bool SetOutPort (unsigned int port)
 Selects the hardware out port to whom messages will be sent. More...
 
virtual void SetProcessor (MIDIProcessor *proc)
 Sets the out processor, which can manipulate messages arrived to the in port before they are sent to the out port (see MIDIProcessor). More...
 
virtual bool SetInChannel (int chan)
 Sets the channel for incoming thru messages. More...
 
virtual bool SetOutChannel (int chan)
 Sets the channel for outgoing thru messages. More...
 
virtual void Start ()
 Starts the MIDI thru. More...
 
virtual void Stop ()
 Stops the MIDI thru. 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...
 

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 from MIDITickComponent and called at every timer tick. 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 immediately echoes to an out MIDI port all messages incoming from an in MIDI port.

You can choose the in and out ports, select an unique channel for receiving and sending messages (or receive and send on any channel) and insert a MIDIProcessor between in and out ports for messages elaboration.

Examples
test_thru.cpp.

Constructor & Destructor Documentation

◆ MIDIThru()

MIDIThru::MIDIThru ( )

The constructor.

It raises an exception if in your system there are no MIDI in or MIDI out ports, otherwise sets them to the OS id 0 ports.

Exceptions
RtMidiError::INVALID_DEVICEif in the system are not present MIDI out or MIDI in ports

◆ ~MIDIThru()

virtual MIDIThru::~MIDIThru ( )
virtual

The destructor.

Member Function Documentation

◆ Reset()

virtual void MIDIThru::Reset ( )
virtual

Resets the class to initial status:

  • In and out ports set to the OS id 0
  • No extra processor (warning: this only sets the processor pointer to 0! The driver doesn't own its processor).
  • Thru input and output channel: all
  • Thru disabled;

Implements MIDITickComponent.

◆ GetInPort()

unsigned int MIDIThru::GetInPort ( ) const
inline

Returns the number of the MIDI in port from which messages are actually being received.

Examples
test_advancedsequencer.cpp, and test_thru.cpp.

◆ GetOutPort()

unsigned int MIDIThru::GetOutPort ( ) const
inline

Returns a pointer to the MIDIOutDriver to whom messages are actually being sent.

Examples
test_advancedsequencer.cpp, and test_thru.cpp.

◆ GetProcessor() [1/2]

MIDIProcessor * MIDIThru::GetProcessor ( )
inline

Returns a pointer to the MIDIProcessor attached to the thru (see SetProcessor()).

◆ GetProcessor() [2/2]

const MIDIProcessor * MIDIThru::GetProcessor ( ) const
inline

Returns a pointer to the MIDIProcessor attached to the thru (see SetProcessor()).

◆ GetInChannel()

int MIDIThru::GetInChannel ( ) const
inline

Returns the thru in channel (see SetInChannel())

Examples
test_thru.cpp.

◆ GetOutChannel()

int MIDIThru::GetOutChannel ( ) const
inline

Returns the thru out channel (see SetOutChannel())

Examples
test_thru.cpp.

◆ SetInPort()

virtual bool MIDIThru::SetInPort ( unsigned int  port)
virtual

Selects the hardware in port from which messages will be received.

This can be done even if thru is already enabled.

Returns
true if port is a valid port number, false otherwise.
Examples
test_thru.cpp.

◆ SetOutPort()

virtual bool MIDIThru::SetOutPort ( unsigned int  port)
virtual

Selects the hardware out port to whom messages will be sent.

This can be done even if thru is already enabled.

Returns
true if port is a valid port number, false otherwise.
Examples
test_thru.cpp.

◆ SetProcessor()

virtual void MIDIThru::SetProcessor ( MIDIProcessor proc)
virtual

Sets the out processor, which can manipulate messages arrived to the in port before they are sent to the out port (see MIDIProcessor).

If you want to eliminate a processor already set, call it with 0 as parameter (this only sets the processor pointer to 0! The class doesn't own its processor).

Examples
test_thru.cpp.

◆ SetInChannel()

virtual bool MIDIThru::SetInChannel ( int  chan)
virtual

Sets the channel for incoming thru messages.

Parameters
chan0 ... 15: the thru will accept only messages with a specific channel; -1: the thru will accept all messages coming from the in port (this is the default). Non channel messages are always received.
Returns
true if chan is a valid channel number, false otherwise.
Examples
test_thru.cpp.

◆ SetOutChannel()

virtual bool MIDIThru::SetOutChannel ( int  chan)
virtual

Sets the channel for outgoing thru messages.

Parameters
chan0 ... 15: the thru will redirect all messages to a specific channel; -1: the thru will leave channel messages unchanged (this is the default).
Returns
true if chan is a valid channel number, false otherwise
Examples
test_thru.cpp.

◆ Start()

virtual void MIDIThru::Start ( )
virtual

Starts the MIDI thru.

Reimplemented from MIDITickComponent.

Examples
test_thru.cpp.

◆ Stop()

virtual void MIDIThru::Stop ( )
virtual

Stops the MIDI thru.

Reimplemented from MIDITickComponent.

Examples
test_thru.cpp.

◆ StaticTickProc()

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

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

It only calls the member TickProc().

◆ TickProc()

virtual void MIDIThru::TickProc ( tMsecs  sys_time)
protectedvirtual

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

Implements MIDITickComponent.


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