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

A static class that manages computer hardware resources (in and out MIDI ports) and timing. More...

#include <manager.h>

Public Member Functions

 MIDIManager ()=delete
 The constructor is deleted. More...
 

Static Public Member Functions

static void Reset ()
 Stops the timer if it is running, resets all the MIDI in and out ports and flushes the MIDITickComponent queue. More...
 
static unsigned int GetNumMIDIIns ()
 Returns the number of MIDI in ports in the system. More...
 
static const std::string & GetMIDIInName (unsigned int n)
 Returns the system name of the given MIDI in port. More...
 
static MIDIInDriverGetInDriver (unsigned int n)
 Returns a pointer to the MIDIInDriver with given port id. More...
 
static bool IsValidInPortNumber (unsigned int n)
 Returns true if n is a valid MIDI in port number. More...
 
static unsigned int GetNumMIDIOuts ()
 Returns the number of MIDI out ports in the system. More...
 
static const std::string & GetMIDIOutName (unsigned int n)
 Returns the system name of the given MIDI out port. More...
 
static MIDIOutDriverGetOutDriver (unsigned int n)
 Returns a pointer to the MIDIOutDriver with given port id. More...
 
static bool IsValidOutPortNumber (unsigned int n)
 Returns true if n is a valid MIDI out port number. More...
 
static MIDISequencerGetSequencer ()
 Returns the pointer to the (unique) MIDITickComponent in the queue with tPriority PR_SEQ (0 if not found). More...
 
static void OpenInPorts ()
 Opens all the system MIDI In ports. More...
 
static void CloseInPorts ()
 Closes all the system MIDI In ports. More...
 
static void OpenOutPorts ()
 Opens all the system MIDI Out ports. More...
 
static void CloseOutPorts ()
 Closes all the system MIDI Out ports. More...
 
static void AllNotesOff ()
 Sends a MIDI AllNotesOff message to all open out ports. More...
 
static void AddMIDITick (MIDITickComponent *tick)
 Inserts a MIDITickComponent object into the queue. More...
 
static bool RemoveMIDITick (MIDITickComponent *tick)
 Removes the given MIDITickComponent pointer from the queue. More...
 

Static Protected Member Functions

static void TickProc (tMsecs sys_time_, void *p)
 This is the main callback, called at every tick of the MIDITimer. More...
 
static void Init ()
 This is the initialization function, called the first time a class method is accessed. More...
 

Detailed Description

A static class that manages computer hardware resources (in and out MIDI ports) and timing.

It controls the MIDITimer object and embeds a MIDIInDriver or MIDIOutDriver for every hardware port; moreover it manages a queue of MIDITickComponent (objects with a callback procedure to be called at regular pace). When the timer is started the MIDIManager begins to call its main tick procedure at every timer tick; this in turn calls the callback procedure of all the MIDITickComponent objects in the queue; typically one of the MIDITickComponent is a sequencer, which can in this way pick the MIDI messages stored in its internal MIDIMultiTrack object and send them to the out ports. You can add and remove other MIDITickComponent objects with the AddMIDITick() and RemoveMIDITick() methods (for example you could add a MIDIThru or a MIDIRecorder).

Constructor & Destructor Documentation

◆ MIDIManager()

MIDIManager::MIDIManager ( )
delete

The constructor is deleted.

Member Function Documentation

◆ Reset()

static void MIDIManager::Reset ( )
static

Stops the timer if it is running, resets all the MIDI in and out ports and flushes the MIDITickComponent queue.

◆ GetNumMIDIIns()

static unsigned int MIDIManager::GetNumMIDIIns ( )
static

Returns the number of MIDI in ports in the system.

Examples
test_advancedsequencer.cpp, test_metronome.cpp, test_midiports.cpp, test_recorder.cpp, test_sequencer.cpp, and test_thru.cpp.

◆ GetMIDIInName()

static const std::string & MIDIManager::GetMIDIInName ( unsigned int  n)
static

Returns the system name of the given MIDI in port.

Examples
test_advancedsequencer.cpp, test_metronome.cpp, test_midiports.cpp, test_recorder.cpp, test_sequencer.cpp, and test_thru.cpp.

◆ GetInDriver()

static MIDIInDriver * MIDIManager::GetInDriver ( unsigned int  n)
static

Returns a pointer to the MIDIInDriver with given port id.

Examples
test_advancedsequencer.cpp.

◆ IsValidInPortNumber()

static bool MIDIManager::IsValidInPortNumber ( unsigned int  n)
static

Returns true if n is a valid MIDI in port number.

If you call this with 0 as argument and it returns false no MIDI in port is present in the system.

◆ GetNumMIDIOuts()

static unsigned int MIDIManager::GetNumMIDIOuts ( )
static

Returns the number of MIDI out ports in the system.

Examples
test_advancedsequencer.cpp, test_metronome.cpp, test_midiports.cpp, test_recorder.cpp, test_sequencer.cpp, and test_thru.cpp.

◆ GetMIDIOutName()

static const std::string & MIDIManager::GetMIDIOutName ( unsigned int  n)
static

Returns the system name of the given MIDI out port.

Examples
test_advancedsequencer.cpp, test_metronome.cpp, test_midiports.cpp, test_recorder.cpp, test_sequencer.cpp, and test_thru.cpp.

◆ GetOutDriver()

static MIDIOutDriver * MIDIManager::GetOutDriver ( unsigned int  n)
static

Returns a pointer to the MIDIOutDriver with given port id.

Examples
test_advancedsequencer.cpp, test_component.cpp, and test_thru.cpp.

◆ IsValidOutPortNumber()

static bool MIDIManager::IsValidOutPortNumber ( unsigned int  n)
static

Returns true if n is a valid MIDI out port number.

If you call this with 0 as argument and it returns false no MIDI out port is present in the system.

◆ GetSequencer()

static MIDISequencer * MIDIManager::GetSequencer ( )
static

Returns the pointer to the (unique) MIDITickComponent in the queue with tPriority PR_SEQ (0 if not found).

◆ OpenInPorts()

static void MIDIManager::OpenInPorts ( )
static

Opens all the system MIDI In ports.

It calls the MIDIInDriver::OpenPort() method for every port.

◆ CloseInPorts()

static void MIDIManager::CloseInPorts ( )
static

Closes all the system MIDI In ports.

It calls the MIDIInDriver::ClosePort() method for every port.

◆ OpenOutPorts()

static void MIDIManager::OpenOutPorts ( )
static

Opens all the system MIDI Out ports.

It calls the MIDIOutDriver::OpenPort() method for every port.

◆ CloseOutPorts()

static void MIDIManager::CloseOutPorts ( )
static

Closes all the system MIDI Out ports.

It calls the MIDIOutDriver::OpenPort() method for every port.

◆ AllNotesOff()

static void MIDIManager::AllNotesOff ( )
static

Sends a MIDI AllNotesOff message to all open out ports.

◆ AddMIDITick()

static void MIDIManager::AddMIDITick ( MIDITickComponent tick)
static

Inserts a MIDITickComponent object into the queue.

The objects are queued according to their tPriority parameter; you can add only one of them with PR_SEQ priority (i.e. a sequencer). Advanced classes (as AdvancedSequencer) auto add themselves to the manager queue when they are created, so they are ready to play. For other MIDITickComponent derived classes you must do this by this method if you want their callback become effective.

◆ RemoveMIDITick()

static bool MIDIManager::RemoveMIDITick ( MIDITickComponent tick)
static

Removes the given MIDITickComponent pointer from the queue.

It does nothing if the pointer is not in the queue. The destructor of a MIDITickComponent call this before destroying the object, preventing the manager from using an invalid pointer, so usually you don't need to call this.

◆ TickProc()

static void MIDIManager::TickProc ( tMsecs  sys_time_,
void *  p 
)
staticprotected

This is the main callback, called at every tick of the MIDITimer.

It calls in turn the StaticTickProc() method of every queued MIDITickComponent object with running status. The user must not call it directly.

◆ Init()

static void MIDIManager::Init ( )
staticprotected

This is the initialization function, called the first time a class method is accessed.

It creates


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