Code-style consistency improvement:
Apply clang-format-all.sh using the _clang-format file through all the cpp/.h files. make sure not to apply it to certain serialization structures, since some parser expects the * as part of the name, instead of type. This commit contains no other changes aside from adding and applying clang-format-all.sh
This commit is contained in:
@@ -20,7 +20,8 @@ class RtError : public std::exception
|
||||
{
|
||||
public:
|
||||
//! Defined RtError types.
|
||||
enum Type {
|
||||
enum Type
|
||||
{
|
||||
WARNING, /*!< A non-critical error. */
|
||||
DEBUG_WARNING, /*!< A non-critical error which might be useful for debugging. */
|
||||
UNSPECIFIED, /*!< The default, unspecified error type. */
|
||||
@@ -41,7 +42,8 @@ public:
|
||||
virtual ~RtError(void) throw() {}
|
||||
|
||||
//! Prints thrown error message to stderr.
|
||||
virtual void printMessage(void) const throw() { std::cerr << '\n' << message_ << "\n\n"; }
|
||||
virtual void printMessage(void) const throw() { std::cerr << '\n'
|
||||
<< message_ << "\n\n"; }
|
||||
|
||||
//! Returns the thrown error message type.
|
||||
virtual const Type& getType(void) const throw() { return type_; }
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -51,49 +51,48 @@
|
||||
|
||||
class RtMidi
|
||||
{
|
||||
public:
|
||||
public:
|
||||
//! MIDI API specifier arguments.
|
||||
enum Api
|
||||
{
|
||||
UNSPECIFIED, /*!< Search for a working compiled API. */
|
||||
MACOSX_CORE, /*!< Macintosh OS-X Core Midi API. */
|
||||
LINUX_ALSA, /*!< The Advanced Linux Sound Architecture API. */
|
||||
UNIX_JACK, /*!< The Jack Low-Latency MIDI Server API. */
|
||||
WINDOWS_MM, /*!< The Microsoft Multimedia MIDI API. */
|
||||
WINDOWS_KS, /*!< The Microsoft Kernel Streaming MIDI API. */
|
||||
RTMIDI_DUMMY /*!< A compilable but non-functional API. */
|
||||
};
|
||||
|
||||
//! MIDI API specifier arguments.
|
||||
enum Api {
|
||||
UNSPECIFIED, /*!< Search for a working compiled API. */
|
||||
MACOSX_CORE, /*!< Macintosh OS-X Core Midi API. */
|
||||
LINUX_ALSA, /*!< The Advanced Linux Sound Architecture API. */
|
||||
UNIX_JACK, /*!< The Jack Low-Latency MIDI Server API. */
|
||||
WINDOWS_MM, /*!< The Microsoft Multimedia MIDI API. */
|
||||
WINDOWS_KS, /*!< The Microsoft Kernel Streaming MIDI API. */
|
||||
RTMIDI_DUMMY /*!< A compilable but non-functional API. */
|
||||
};
|
||||
|
||||
//! A static function to determine the available compiled MIDI APIs.
|
||||
/*!
|
||||
//! A static function to determine the available compiled MIDI APIs.
|
||||
/*!
|
||||
The values returned in the std::vector can be compared against
|
||||
the enumerated list values. Note that there can be more than one
|
||||
API compiled for certain operating systems.
|
||||
*/
|
||||
static void getCompiledApi( std::vector<RtMidi::Api> &apis );
|
||||
static void getCompiledApi(std::vector<RtMidi::Api> &apis);
|
||||
|
||||
//! Pure virtual openPort() function.
|
||||
virtual void openPort( unsigned int portNumber = 0, const std::string portName = std::string( "RtMidi" ) ) = 0;
|
||||
//! Pure virtual openPort() function.
|
||||
virtual void openPort(unsigned int portNumber = 0, const std::string portName = std::string("RtMidi")) = 0;
|
||||
|
||||
//! Pure virtual openVirtualPort() function.
|
||||
virtual void openVirtualPort( const std::string portName = std::string( "RtMidi" ) ) = 0;
|
||||
//! Pure virtual openVirtualPort() function.
|
||||
virtual void openVirtualPort(const std::string portName = std::string("RtMidi")) = 0;
|
||||
|
||||
//! Pure virtual getPortCount() function.
|
||||
virtual unsigned int getPortCount() = 0;
|
||||
//! Pure virtual getPortCount() function.
|
||||
virtual unsigned int getPortCount() = 0;
|
||||
|
||||
//! Pure virtual getPortName() function.
|
||||
virtual std::string getPortName( unsigned int portNumber = 0 ) = 0;
|
||||
//! Pure virtual getPortName() function.
|
||||
virtual std::string getPortName(unsigned int portNumber = 0) = 0;
|
||||
|
||||
//! Pure virtual closePort() function.
|
||||
virtual void closePort( void ) = 0;
|
||||
//! Pure virtual closePort() function.
|
||||
virtual void closePort(void) = 0;
|
||||
|
||||
//! A basic error reporting function for RtMidi classes.
|
||||
static void error( RtError::Type type, std::string errorString );
|
||||
//! A basic error reporting function for RtMidi classes.
|
||||
static void error(RtError::Type type, std::string errorString);
|
||||
|
||||
protected:
|
||||
|
||||
RtMidi() {};
|
||||
virtual ~RtMidi() {};
|
||||
protected:
|
||||
RtMidi(){};
|
||||
virtual ~RtMidi(){};
|
||||
};
|
||||
|
||||
/**********************************************************************/
|
||||
@@ -133,13 +132,12 @@ class MidiOutApi;
|
||||
|
||||
class RtMidiIn : public RtMidi
|
||||
{
|
||||
public:
|
||||
public:
|
||||
//! User callback function type definition.
|
||||
typedef void (*RtMidiCallback)(double timeStamp, std::vector<unsigned char> *message, void *userData);
|
||||
|
||||
//! User callback function type definition.
|
||||
typedef void (*RtMidiCallback)( double timeStamp, std::vector<unsigned char> *message, void *userData);
|
||||
|
||||
//! Default constructor that allows an optional api, client name and queue size.
|
||||
/*!
|
||||
//! Default constructor that allows an optional api, client name and queue size.
|
||||
/*!
|
||||
An assert will be fired if a MIDI system initialization
|
||||
error occurs. The queue size defines the maximum number of
|
||||
messages that can be held in the MIDI queue (when not using a
|
||||
@@ -150,84 +148,83 @@ class RtMidiIn : public RtMidi
|
||||
compiled, the default order of use is JACK, ALSA (Linux) and CORE,
|
||||
Jack (OS-X).
|
||||
*/
|
||||
RtMidiIn( RtMidi::Api api=UNSPECIFIED,
|
||||
const std::string clientName = std::string( "RtMidi Input Client"),
|
||||
unsigned int queueSizeLimit = 100 );
|
||||
RtMidiIn(RtMidi::Api api = UNSPECIFIED,
|
||||
const std::string clientName = std::string("RtMidi Input Client"),
|
||||
unsigned int queueSizeLimit = 100);
|
||||
|
||||
//! If a MIDI connection is still open, it will be closed by the destructor.
|
||||
~RtMidiIn ( void );
|
||||
//! If a MIDI connection is still open, it will be closed by the destructor.
|
||||
~RtMidiIn(void);
|
||||
|
||||
//! Returns the MIDI API specifier for the current instance of RtMidiIn.
|
||||
RtMidi::Api getCurrentApi( void );
|
||||
//! Returns the MIDI API specifier for the current instance of RtMidiIn.
|
||||
RtMidi::Api getCurrentApi(void);
|
||||
|
||||
//! Open a MIDI input connection.
|
||||
/*!
|
||||
//! Open a MIDI input connection.
|
||||
/*!
|
||||
An optional port number greater than 0 can be specified.
|
||||
Otherwise, the default or first port found is opened.
|
||||
*/
|
||||
void openPort( unsigned int portNumber = 0, const std::string portName = std::string( "RtMidi Input" ) );
|
||||
void openPort(unsigned int portNumber = 0, const std::string portName = std::string("RtMidi Input"));
|
||||
|
||||
//! Create a virtual input port, with optional name, to allow software connections (OS X and ALSA only).
|
||||
/*!
|
||||
//! Create a virtual input port, with optional name, to allow software connections (OS X and ALSA only).
|
||||
/*!
|
||||
This function creates a virtual MIDI input port to which other
|
||||
software applications can connect. This type of functionality
|
||||
is currently only supported by the Macintosh OS-X and Linux ALSA
|
||||
APIs (the function does nothing for the other APIs).
|
||||
*/
|
||||
void openVirtualPort( const std::string portName = std::string( "RtMidi Input" ) );
|
||||
void openVirtualPort(const std::string portName = std::string("RtMidi Input"));
|
||||
|
||||
//! Set a callback function to be invoked for incoming MIDI messages.
|
||||
/*!
|
||||
//! Set a callback function to be invoked for incoming MIDI messages.
|
||||
/*!
|
||||
The callback function will be called whenever an incoming MIDI
|
||||
message is received. While not absolutely necessary, it is best
|
||||
to set the callback function before opening a MIDI port to avoid
|
||||
leaving some messages in the queue.
|
||||
*/
|
||||
void setCallback( RtMidiCallback callback, void *userData = 0 );
|
||||
void setCallback(RtMidiCallback callback, void *userData = 0);
|
||||
|
||||
//! Cancel use of the current callback function (if one exists).
|
||||
/*!
|
||||
//! Cancel use of the current callback function (if one exists).
|
||||
/*!
|
||||
Subsequent incoming MIDI messages will be written to the queue
|
||||
and can be retrieved with the \e getMessage function.
|
||||
*/
|
||||
void cancelCallback();
|
||||
void cancelCallback();
|
||||
|
||||
//! Close an open MIDI connection (if one exists).
|
||||
void closePort( void );
|
||||
//! Close an open MIDI connection (if one exists).
|
||||
void closePort(void);
|
||||
|
||||
//! Return the number of available MIDI input ports.
|
||||
unsigned int getPortCount();
|
||||
//! Return the number of available MIDI input ports.
|
||||
unsigned int getPortCount();
|
||||
|
||||
//! Return a string identifier for the specified MIDI input port number.
|
||||
/*!
|
||||
//! Return a string identifier for the specified MIDI input port number.
|
||||
/*!
|
||||
An empty string is returned if an invalid port specifier is provided.
|
||||
*/
|
||||
std::string getPortName( unsigned int portNumber = 0 );
|
||||
std::string getPortName(unsigned int portNumber = 0);
|
||||
|
||||
//! Specify whether certain MIDI message types should be queued or ignored during input.
|
||||
/*!
|
||||
//! Specify whether certain MIDI message types should be queued or ignored during input.
|
||||
/*!
|
||||
o By default, MIDI timing and active sensing messages are ignored
|
||||
during message input because of their relative high data rates.
|
||||
MIDI sysex messages are ignored by default as well. Variable
|
||||
values of "true" imply that the respective message type will be
|
||||
ignored.
|
||||
*/
|
||||
void ignoreTypes( bool midiSysex = true, bool midiTime = true, bool midiSense = true );
|
||||
void ignoreTypes(bool midiSysex = true, bool midiTime = true, bool midiSense = true);
|
||||
|
||||
//! Fill the user-provided vector with the data bytes for the next available MIDI message in the input queue and return the event delta-time in seconds.
|
||||
/*!
|
||||
//! Fill the user-provided vector with the data bytes for the next available MIDI message in the input queue and return the event delta-time in seconds.
|
||||
/*!
|
||||
This function returns immediately whether a new message is
|
||||
available or not. A valid message is indicated by a non-zero
|
||||
vector size. An assert is fired if an error occurs during
|
||||
message retrieval or an input connection was not previously
|
||||
established.
|
||||
*/
|
||||
double getMessage( std::vector<unsigned char> *message );
|
||||
|
||||
protected:
|
||||
void openMidiApi( RtMidi::Api api, const std::string clientName, unsigned int queueSizeLimit );
|
||||
MidiInApi *rtapi_;
|
||||
double getMessage(std::vector<unsigned char> *message);
|
||||
|
||||
protected:
|
||||
void openMidiApi(RtMidi::Api api, const std::string clientName, unsigned int queueSizeLimit);
|
||||
MidiInApi *rtapi_;
|
||||
};
|
||||
|
||||
/**********************************************************************/
|
||||
@@ -248,39 +245,38 @@ class RtMidiIn : public RtMidi
|
||||
|
||||
class RtMidiOut : public RtMidi
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor that allows an optional client name.
|
||||
/*!
|
||||
public:
|
||||
//! Default constructor that allows an optional client name.
|
||||
/*!
|
||||
An exception will be thrown if a MIDI system initialization error occurs.
|
||||
|
||||
If no API argument is specified and multiple API support has been
|
||||
compiled, the default order of use is JACK, ALSA (Linux) and CORE,
|
||||
Jack (OS-X).
|
||||
*/
|
||||
RtMidiOut( RtMidi::Api api=UNSPECIFIED,
|
||||
const std::string clientName = std::string( "RtMidi Output Client") );
|
||||
RtMidiOut(RtMidi::Api api = UNSPECIFIED,
|
||||
const std::string clientName = std::string("RtMidi Output Client"));
|
||||
|
||||
//! The destructor closes any open MIDI connections.
|
||||
~RtMidiOut( void );
|
||||
//! The destructor closes any open MIDI connections.
|
||||
~RtMidiOut(void);
|
||||
|
||||
//! Returns the MIDI API specifier for the current instance of RtMidiOut.
|
||||
RtMidi::Api getCurrentApi( void );
|
||||
//! Returns the MIDI API specifier for the current instance of RtMidiOut.
|
||||
RtMidi::Api getCurrentApi(void);
|
||||
|
||||
//! Open a MIDI output connection.
|
||||
/*!
|
||||
//! Open a MIDI output connection.
|
||||
/*!
|
||||
An optional port number greater than 0 can be specified.
|
||||
Otherwise, the default or first port found is opened. An
|
||||
exception is thrown if an error occurs while attempting to make
|
||||
the port connection.
|
||||
*/
|
||||
void openPort( unsigned int portNumber = 0, const std::string portName = std::string( "RtMidi Output" ) );
|
||||
void openPort(unsigned int portNumber = 0, const std::string portName = std::string("RtMidi Output"));
|
||||
|
||||
//! Close an open MIDI connection (if one exists).
|
||||
void closePort( void );
|
||||
//! Close an open MIDI connection (if one exists).
|
||||
void closePort(void);
|
||||
|
||||
//! Create a virtual output port, with optional name, to allow software connections (OS X and ALSA only).
|
||||
/*!
|
||||
//! Create a virtual output port, with optional name, to allow software connections (OS X and ALSA only).
|
||||
/*!
|
||||
This function creates a virtual MIDI output port to which other
|
||||
software applications can connect. This type of functionality
|
||||
is currently only supported by the Macintosh OS-X and Linux ALSA
|
||||
@@ -288,30 +284,29 @@ class RtMidiOut : public RtMidi
|
||||
exception is thrown if an error occurs while attempting to create
|
||||
the virtual port.
|
||||
*/
|
||||
void openVirtualPort( const std::string portName = std::string( "RtMidi Output" ) );
|
||||
void openVirtualPort(const std::string portName = std::string("RtMidi Output"));
|
||||
|
||||
//! Return the number of available MIDI output ports.
|
||||
unsigned int getPortCount( void );
|
||||
//! Return the number of available MIDI output ports.
|
||||
unsigned int getPortCount(void);
|
||||
|
||||
//! Return a string identifier for the specified MIDI port type and number.
|
||||
/*!
|
||||
//! Return a string identifier for the specified MIDI port type and number.
|
||||
/*!
|
||||
An empty string is returned if an invalid port specifier is provided.
|
||||
*/
|
||||
std::string getPortName( unsigned int portNumber = 0 );
|
||||
std::string getPortName(unsigned int portNumber = 0);
|
||||
|
||||
//! Immediately send a single message out an open MIDI output port.
|
||||
/*!
|
||||
//! Immediately send a single message out an open MIDI output port.
|
||||
/*!
|
||||
An exception is thrown if an error occurs during output or an
|
||||
output connection was not previously established.
|
||||
*/
|
||||
void sendMessage( std::vector<unsigned char> *message );
|
||||
void sendMessage(std::vector<unsigned char> *message);
|
||||
|
||||
protected:
|
||||
void openMidiApi( RtMidi::Api api, const std::string clientName );
|
||||
MidiOutApi *rtapi_;
|
||||
protected:
|
||||
void openMidiApi(RtMidi::Api api, const std::string clientName);
|
||||
MidiOutApi *rtapi_;
|
||||
};
|
||||
|
||||
|
||||
// **************************************************************** //
|
||||
//
|
||||
// MidiInApi / MidiOutApi class declarations.
|
||||
@@ -327,94 +322,93 @@ class RtMidiOut : public RtMidi
|
||||
|
||||
class MidiInApi
|
||||
{
|
||||
public:
|
||||
public:
|
||||
MidiInApi(unsigned int queueSizeLimit);
|
||||
virtual ~MidiInApi(void);
|
||||
virtual RtMidi::Api getCurrentApi(void) = 0;
|
||||
virtual void openPort(unsigned int portNumber, const std::string portName) = 0;
|
||||
virtual void openVirtualPort(const std::string portName) = 0;
|
||||
virtual void closePort(void) = 0;
|
||||
void setCallback(RtMidiIn::RtMidiCallback callback, void *userData);
|
||||
void cancelCallback(void);
|
||||
virtual unsigned int getPortCount(void) = 0;
|
||||
virtual std::string getPortName(unsigned int portNumber) = 0;
|
||||
virtual void ignoreTypes(bool midiSysex, bool midiTime, bool midiSense);
|
||||
double getMessage(std::vector<unsigned char> *message);
|
||||
|
||||
MidiInApi( unsigned int queueSizeLimit );
|
||||
virtual ~MidiInApi( void );
|
||||
virtual RtMidi::Api getCurrentApi( void ) = 0;
|
||||
virtual void openPort( unsigned int portNumber, const std::string portName ) = 0;
|
||||
virtual void openVirtualPort( const std::string portName ) = 0;
|
||||
virtual void closePort( void ) = 0;
|
||||
void setCallback( RtMidiIn::RtMidiCallback callback, void *userData );
|
||||
void cancelCallback( void );
|
||||
virtual unsigned int getPortCount( void ) = 0;
|
||||
virtual std::string getPortName( unsigned int portNumber ) = 0;
|
||||
virtual void ignoreTypes( bool midiSysex, bool midiTime, bool midiSense );
|
||||
double getMessage( std::vector<unsigned char> *message );
|
||||
// A MIDI structure used internally by the class to store incoming
|
||||
// messages. Each message represents one and only one MIDI message.
|
||||
struct MidiMessage
|
||||
{
|
||||
std::vector<unsigned char> bytes;
|
||||
double timeStamp;
|
||||
|
||||
// A MIDI structure used internally by the class to store incoming
|
||||
// messages. Each message represents one and only one MIDI message.
|
||||
struct MidiMessage {
|
||||
std::vector<unsigned char> bytes;
|
||||
double timeStamp;
|
||||
// Default constructor.
|
||||
MidiMessage()
|
||||
: bytes(0), timeStamp(0.0) {}
|
||||
};
|
||||
|
||||
// Default constructor.
|
||||
MidiMessage()
|
||||
:bytes(0), timeStamp(0.0) {}
|
||||
};
|
||||
struct MidiQueue
|
||||
{
|
||||
unsigned int front;
|
||||
unsigned int back;
|
||||
unsigned int size;
|
||||
unsigned int ringSize;
|
||||
MidiMessage *ring;
|
||||
|
||||
struct MidiQueue {
|
||||
unsigned int front;
|
||||
unsigned int back;
|
||||
unsigned int size;
|
||||
unsigned int ringSize;
|
||||
MidiMessage *ring;
|
||||
// Default constructor.
|
||||
MidiQueue()
|
||||
: front(0), back(0), size(0), ringSize(0) {}
|
||||
};
|
||||
|
||||
// Default constructor.
|
||||
MidiQueue()
|
||||
:front(0), back(0), size(0), ringSize(0) {}
|
||||
};
|
||||
// The RtMidiInData structure is used to pass private class data to
|
||||
// the MIDI input handling function or thread.
|
||||
struct RtMidiInData
|
||||
{
|
||||
MidiQueue queue;
|
||||
MidiMessage message;
|
||||
unsigned char ignoreFlags;
|
||||
bool doInput;
|
||||
bool firstMessage;
|
||||
void *apiData;
|
||||
bool usingCallback;
|
||||
void *userCallback;
|
||||
void *userData;
|
||||
bool continueSysex;
|
||||
|
||||
// The RtMidiInData structure is used to pass private class data to
|
||||
// the MIDI input handling function or thread.
|
||||
struct RtMidiInData {
|
||||
MidiQueue queue;
|
||||
MidiMessage message;
|
||||
unsigned char ignoreFlags;
|
||||
bool doInput;
|
||||
bool firstMessage;
|
||||
void *apiData;
|
||||
bool usingCallback;
|
||||
void *userCallback;
|
||||
void *userData;
|
||||
bool continueSysex;
|
||||
// Default constructor.
|
||||
RtMidiInData()
|
||||
: ignoreFlags(7), doInput(false), firstMessage(true), apiData(0), usingCallback(false), userCallback(0), userData(0), continueSysex(false) {}
|
||||
};
|
||||
|
||||
// Default constructor.
|
||||
RtMidiInData()
|
||||
: ignoreFlags(7), doInput(false), firstMessage(true),
|
||||
apiData(0), usingCallback(false), userCallback(0), userData(0),
|
||||
continueSysex(false) {}
|
||||
};
|
||||
protected:
|
||||
virtual void initialize(const std::string &clientName) = 0;
|
||||
RtMidiInData inputData_;
|
||||
|
||||
protected:
|
||||
virtual void initialize( const std::string& clientName ) = 0;
|
||||
RtMidiInData inputData_;
|
||||
|
||||
void *apiData_;
|
||||
bool connected_;
|
||||
std::string errorString_;
|
||||
void *apiData_;
|
||||
bool connected_;
|
||||
std::string errorString_;
|
||||
};
|
||||
|
||||
class MidiOutApi
|
||||
{
|
||||
public:
|
||||
public:
|
||||
MidiOutApi(void);
|
||||
virtual ~MidiOutApi(void);
|
||||
virtual RtMidi::Api getCurrentApi(void) = 0;
|
||||
virtual void openPort(unsigned int portNumber, const std::string portName) = 0;
|
||||
virtual void openVirtualPort(const std::string portName) = 0;
|
||||
virtual void closePort(void) = 0;
|
||||
virtual unsigned int getPortCount(void) = 0;
|
||||
virtual std::string getPortName(unsigned int portNumber) = 0;
|
||||
virtual void sendMessage(std::vector<unsigned char> *message) = 0;
|
||||
|
||||
MidiOutApi( void );
|
||||
virtual ~MidiOutApi( void );
|
||||
virtual RtMidi::Api getCurrentApi( void ) = 0;
|
||||
virtual void openPort( unsigned int portNumber, const std::string portName ) = 0;
|
||||
virtual void openVirtualPort( const std::string portName ) = 0;
|
||||
virtual void closePort( void ) = 0;
|
||||
virtual unsigned int getPortCount( void ) = 0;
|
||||
virtual std::string getPortName( unsigned int portNumber ) = 0;
|
||||
virtual void sendMessage( std::vector<unsigned char> *message ) = 0;
|
||||
protected:
|
||||
virtual void initialize(const std::string &clientName) = 0;
|
||||
|
||||
protected:
|
||||
virtual void initialize( const std::string& clientName ) = 0;
|
||||
|
||||
void *apiData_;
|
||||
bool connected_;
|
||||
std::string errorString_;
|
||||
void *apiData_;
|
||||
bool connected_;
|
||||
std::string errorString_;
|
||||
};
|
||||
|
||||
// **************************************************************** //
|
||||
@@ -423,24 +417,24 @@ class MidiOutApi
|
||||
//
|
||||
// **************************************************************** //
|
||||
|
||||
inline RtMidi::Api RtMidiIn :: getCurrentApi( void ) { return rtapi_->getCurrentApi(); }
|
||||
inline void RtMidiIn :: openPort( unsigned int portNumber, const std::string portName ) { return rtapi_->openPort( portNumber, portName ); }
|
||||
inline void RtMidiIn :: openVirtualPort( const std::string portName ) { return rtapi_->openVirtualPort( portName ); }
|
||||
inline void RtMidiIn :: closePort( void ) { return rtapi_->closePort(); }
|
||||
inline void RtMidiIn :: setCallback( RtMidiCallback callback, void *userData ) { return rtapi_->setCallback( callback, userData ); }
|
||||
inline void RtMidiIn :: cancelCallback( void ) { return rtapi_->cancelCallback(); }
|
||||
inline unsigned int RtMidiIn :: getPortCount( void ) { return rtapi_->getPortCount(); }
|
||||
inline std::string RtMidiIn :: getPortName( unsigned int portNumber ) { return rtapi_->getPortName( portNumber ); }
|
||||
inline void RtMidiIn :: ignoreTypes( bool midiSysex, bool midiTime, bool midiSense ) { return rtapi_->ignoreTypes( midiSysex, midiTime, midiSense ); }
|
||||
inline double RtMidiIn :: getMessage( std::vector<unsigned char> *message ) { return rtapi_->getMessage( message ); }
|
||||
inline RtMidi::Api RtMidiIn ::getCurrentApi(void) { return rtapi_->getCurrentApi(); }
|
||||
inline void RtMidiIn ::openPort(unsigned int portNumber, const std::string portName) { return rtapi_->openPort(portNumber, portName); }
|
||||
inline void RtMidiIn ::openVirtualPort(const std::string portName) { return rtapi_->openVirtualPort(portName); }
|
||||
inline void RtMidiIn ::closePort(void) { return rtapi_->closePort(); }
|
||||
inline void RtMidiIn ::setCallback(RtMidiCallback callback, void *userData) { return rtapi_->setCallback(callback, userData); }
|
||||
inline void RtMidiIn ::cancelCallback(void) { return rtapi_->cancelCallback(); }
|
||||
inline unsigned int RtMidiIn ::getPortCount(void) { return rtapi_->getPortCount(); }
|
||||
inline std::string RtMidiIn ::getPortName(unsigned int portNumber) { return rtapi_->getPortName(portNumber); }
|
||||
inline void RtMidiIn ::ignoreTypes(bool midiSysex, bool midiTime, bool midiSense) { return rtapi_->ignoreTypes(midiSysex, midiTime, midiSense); }
|
||||
inline double RtMidiIn ::getMessage(std::vector<unsigned char> *message) { return rtapi_->getMessage(message); }
|
||||
|
||||
inline RtMidi::Api RtMidiOut :: getCurrentApi( void ) { return rtapi_->getCurrentApi(); }
|
||||
inline void RtMidiOut :: openPort( unsigned int portNumber, const std::string portName ) { return rtapi_->openPort( portNumber, portName ); }
|
||||
inline void RtMidiOut :: openVirtualPort( const std::string portName ) { return rtapi_->openVirtualPort( portName ); }
|
||||
inline void RtMidiOut :: closePort( void ) { return rtapi_->closePort(); }
|
||||
inline unsigned int RtMidiOut :: getPortCount( void ) { return rtapi_->getPortCount(); }
|
||||
inline std::string RtMidiOut :: getPortName( unsigned int portNumber ) { return rtapi_->getPortName( portNumber ); }
|
||||
inline void RtMidiOut :: sendMessage( std::vector<unsigned char> *message ) { return rtapi_->sendMessage( message ); }
|
||||
inline RtMidi::Api RtMidiOut ::getCurrentApi(void) { return rtapi_->getCurrentApi(); }
|
||||
inline void RtMidiOut ::openPort(unsigned int portNumber, const std::string portName) { return rtapi_->openPort(portNumber, portName); }
|
||||
inline void RtMidiOut ::openVirtualPort(const std::string portName) { return rtapi_->openVirtualPort(portName); }
|
||||
inline void RtMidiOut ::closePort(void) { return rtapi_->closePort(); }
|
||||
inline unsigned int RtMidiOut ::getPortCount(void) { return rtapi_->getPortCount(); }
|
||||
inline std::string RtMidiOut ::getPortName(unsigned int portNumber) { return rtapi_->getPortName(portNumber); }
|
||||
inline void RtMidiOut ::sendMessage(std::vector<unsigned char> *message) { return rtapi_->sendMessage(message); }
|
||||
|
||||
// **************************************************************** //
|
||||
//
|
||||
@@ -449,225 +443,233 @@ inline void RtMidiOut :: sendMessage( std::vector<unsigned char> *message ) { re
|
||||
// **************************************************************** //
|
||||
|
||||
#if !defined(__LINUX_ALSA__) && !defined(__UNIX_JACK__) && !defined(__MACOSX_CORE__) && !defined(__WINDOWS_MM__) && !defined(__WINDOWS_KS__)
|
||||
#define __RTMIDI_DUMMY__
|
||||
#define __RTMIDI_DUMMY__
|
||||
#endif
|
||||
|
||||
#if defined(__MACOSX_CORE__)
|
||||
|
||||
class MidiInCore: public MidiInApi
|
||||
class MidiInCore : public MidiInApi
|
||||
{
|
||||
public:
|
||||
MidiInCore( const std::string clientName, unsigned int queueSizeLimit );
|
||||
~MidiInCore( void );
|
||||
RtMidi::Api getCurrentApi( void ) { return RtMidi::MACOSX_CORE; };
|
||||
void openPort( unsigned int portNumber, const std::string portName );
|
||||
void openVirtualPort( const std::string portName );
|
||||
void closePort( void );
|
||||
unsigned int getPortCount( void );
|
||||
std::string getPortName( unsigned int portNumber );
|
||||
public:
|
||||
MidiInCore(const std::string clientName, unsigned int queueSizeLimit);
|
||||
~MidiInCore(void);
|
||||
RtMidi::Api getCurrentApi(void) { return RtMidi::MACOSX_CORE; };
|
||||
void openPort(unsigned int portNumber, const std::string portName);
|
||||
void openVirtualPort(const std::string portName);
|
||||
void closePort(void);
|
||||
unsigned int getPortCount(void);
|
||||
std::string getPortName(unsigned int portNumber);
|
||||
|
||||
protected:
|
||||
void initialize( const std::string& clientName );
|
||||
protected:
|
||||
void initialize(const std::string &clientName);
|
||||
};
|
||||
|
||||
class MidiOutCore: public MidiOutApi
|
||||
class MidiOutCore : public MidiOutApi
|
||||
{
|
||||
public:
|
||||
MidiOutCore( const std::string clientName );
|
||||
~MidiOutCore( void );
|
||||
RtMidi::Api getCurrentApi( void ) { return RtMidi::MACOSX_CORE; };
|
||||
void openPort( unsigned int portNumber, const std::string portName );
|
||||
void openVirtualPort( const std::string portName );
|
||||
void closePort( void );
|
||||
unsigned int getPortCount( void );
|
||||
std::string getPortName( unsigned int portNumber );
|
||||
void sendMessage( std::vector<unsigned char> *message );
|
||||
public:
|
||||
MidiOutCore(const std::string clientName);
|
||||
~MidiOutCore(void);
|
||||
RtMidi::Api getCurrentApi(void) { return RtMidi::MACOSX_CORE; };
|
||||
void openPort(unsigned int portNumber, const std::string portName);
|
||||
void openVirtualPort(const std::string portName);
|
||||
void closePort(void);
|
||||
unsigned int getPortCount(void);
|
||||
std::string getPortName(unsigned int portNumber);
|
||||
void sendMessage(std::vector<unsigned char> *message);
|
||||
|
||||
protected:
|
||||
void initialize( const std::string& clientName );
|
||||
protected:
|
||||
void initialize(const std::string &clientName);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__UNIX_JACK__)
|
||||
|
||||
class MidiInJack: public MidiInApi
|
||||
class MidiInJack : public MidiInApi
|
||||
{
|
||||
public:
|
||||
MidiInJack( const std::string clientName, unsigned int queueSizeLimit );
|
||||
~MidiInJack( void );
|
||||
RtMidi::Api getCurrentApi( void ) { return RtMidi::UNIX_JACK; };
|
||||
void openPort( unsigned int portNumber, const std::string portName );
|
||||
void openVirtualPort( const std::string portName );
|
||||
void closePort( void );
|
||||
unsigned int getPortCount( void );
|
||||
std::string getPortName( unsigned int portNumber );
|
||||
public:
|
||||
MidiInJack(const std::string clientName, unsigned int queueSizeLimit);
|
||||
~MidiInJack(void);
|
||||
RtMidi::Api getCurrentApi(void) { return RtMidi::UNIX_JACK; };
|
||||
void openPort(unsigned int portNumber, const std::string portName);
|
||||
void openVirtualPort(const std::string portName);
|
||||
void closePort(void);
|
||||
unsigned int getPortCount(void);
|
||||
std::string getPortName(unsigned int portNumber);
|
||||
|
||||
protected:
|
||||
void initialize( const std::string& clientName );
|
||||
protected:
|
||||
void initialize(const std::string &clientName);
|
||||
};
|
||||
|
||||
class MidiOutJack: public MidiOutApi
|
||||
class MidiOutJack : public MidiOutApi
|
||||
{
|
||||
public:
|
||||
MidiOutJack( const std::string clientName );
|
||||
~MidiOutJack( void );
|
||||
RtMidi::Api getCurrentApi( void ) { return RtMidi::UNIX_JACK; };
|
||||
void openPort( unsigned int portNumber, const std::string portName );
|
||||
void openVirtualPort( const std::string portName );
|
||||
void closePort( void );
|
||||
unsigned int getPortCount( void );
|
||||
std::string getPortName( unsigned int portNumber );
|
||||
void sendMessage( std::vector<unsigned char> *message );
|
||||
public:
|
||||
MidiOutJack(const std::string clientName);
|
||||
~MidiOutJack(void);
|
||||
RtMidi::Api getCurrentApi(void) { return RtMidi::UNIX_JACK; };
|
||||
void openPort(unsigned int portNumber, const std::string portName);
|
||||
void openVirtualPort(const std::string portName);
|
||||
void closePort(void);
|
||||
unsigned int getPortCount(void);
|
||||
std::string getPortName(unsigned int portNumber);
|
||||
void sendMessage(std::vector<unsigned char> *message);
|
||||
|
||||
protected:
|
||||
void initialize( const std::string& clientName );
|
||||
protected:
|
||||
void initialize(const std::string &clientName);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__LINUX_ALSA__)
|
||||
|
||||
class MidiInAlsa: public MidiInApi
|
||||
class MidiInAlsa : public MidiInApi
|
||||
{
|
||||
public:
|
||||
MidiInAlsa( const std::string clientName, unsigned int queueSizeLimit );
|
||||
~MidiInAlsa( void );
|
||||
RtMidi::Api getCurrentApi( void ) { return RtMidi::LINUX_ALSA; };
|
||||
void openPort( unsigned int portNumber, const std::string portName );
|
||||
void openVirtualPort( const std::string portName );
|
||||
void closePort( void );
|
||||
unsigned int getPortCount( void );
|
||||
std::string getPortName( unsigned int portNumber );
|
||||
public:
|
||||
MidiInAlsa(const std::string clientName, unsigned int queueSizeLimit);
|
||||
~MidiInAlsa(void);
|
||||
RtMidi::Api getCurrentApi(void) { return RtMidi::LINUX_ALSA; };
|
||||
void openPort(unsigned int portNumber, const std::string portName);
|
||||
void openVirtualPort(const std::string portName);
|
||||
void closePort(void);
|
||||
unsigned int getPortCount(void);
|
||||
std::string getPortName(unsigned int portNumber);
|
||||
|
||||
protected:
|
||||
void initialize( const std::string& clientName );
|
||||
protected:
|
||||
void initialize(const std::string &clientName);
|
||||
};
|
||||
|
||||
class MidiOutAlsa: public MidiOutApi
|
||||
class MidiOutAlsa : public MidiOutApi
|
||||
{
|
||||
public:
|
||||
MidiOutAlsa( const std::string clientName );
|
||||
~MidiOutAlsa( void );
|
||||
RtMidi::Api getCurrentApi( void ) { return RtMidi::LINUX_ALSA; };
|
||||
void openPort( unsigned int portNumber, const std::string portName );
|
||||
void openVirtualPort( const std::string portName );
|
||||
void closePort( void );
|
||||
unsigned int getPortCount( void );
|
||||
std::string getPortName( unsigned int portNumber );
|
||||
void sendMessage( std::vector<unsigned char> *message );
|
||||
public:
|
||||
MidiOutAlsa(const std::string clientName);
|
||||
~MidiOutAlsa(void);
|
||||
RtMidi::Api getCurrentApi(void) { return RtMidi::LINUX_ALSA; };
|
||||
void openPort(unsigned int portNumber, const std::string portName);
|
||||
void openVirtualPort(const std::string portName);
|
||||
void closePort(void);
|
||||
unsigned int getPortCount(void);
|
||||
std::string getPortName(unsigned int portNumber);
|
||||
void sendMessage(std::vector<unsigned char> *message);
|
||||
|
||||
protected:
|
||||
void initialize( const std::string& clientName );
|
||||
protected:
|
||||
void initialize(const std::string &clientName);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__WINDOWS_MM__)
|
||||
|
||||
class MidiInWinMM: public MidiInApi
|
||||
class MidiInWinMM : public MidiInApi
|
||||
{
|
||||
public:
|
||||
MidiInWinMM( const std::string clientName, unsigned int queueSizeLimit );
|
||||
~MidiInWinMM( void );
|
||||
RtMidi::Api getCurrentApi( void ) { return RtMidi::WINDOWS_MM; };
|
||||
void openPort( unsigned int portNumber, const std::string portName );
|
||||
void openVirtualPort( const std::string portName );
|
||||
void closePort( void );
|
||||
unsigned int getPortCount( void );
|
||||
std::string getPortName( unsigned int portNumber );
|
||||
public:
|
||||
MidiInWinMM(const std::string clientName, unsigned int queueSizeLimit);
|
||||
~MidiInWinMM(void);
|
||||
RtMidi::Api getCurrentApi(void) { return RtMidi::WINDOWS_MM; };
|
||||
void openPort(unsigned int portNumber, const std::string portName);
|
||||
void openVirtualPort(const std::string portName);
|
||||
void closePort(void);
|
||||
unsigned int getPortCount(void);
|
||||
std::string getPortName(unsigned int portNumber);
|
||||
|
||||
protected:
|
||||
void initialize( const std::string& clientName );
|
||||
protected:
|
||||
void initialize(const std::string &clientName);
|
||||
};
|
||||
|
||||
class MidiOutWinMM: public MidiOutApi
|
||||
class MidiOutWinMM : public MidiOutApi
|
||||
{
|
||||
public:
|
||||
MidiOutWinMM( const std::string clientName );
|
||||
~MidiOutWinMM( void );
|
||||
RtMidi::Api getCurrentApi( void ) { return RtMidi::WINDOWS_MM; };
|
||||
void openPort( unsigned int portNumber, const std::string portName );
|
||||
void openVirtualPort( const std::string portName );
|
||||
void closePort( void );
|
||||
unsigned int getPortCount( void );
|
||||
std::string getPortName( unsigned int portNumber );
|
||||
void sendMessage( std::vector<unsigned char> *message );
|
||||
public:
|
||||
MidiOutWinMM(const std::string clientName);
|
||||
~MidiOutWinMM(void);
|
||||
RtMidi::Api getCurrentApi(void) { return RtMidi::WINDOWS_MM; };
|
||||
void openPort(unsigned int portNumber, const std::string portName);
|
||||
void openVirtualPort(const std::string portName);
|
||||
void closePort(void);
|
||||
unsigned int getPortCount(void);
|
||||
std::string getPortName(unsigned int portNumber);
|
||||
void sendMessage(std::vector<unsigned char> *message);
|
||||
|
||||
protected:
|
||||
void initialize( const std::string& clientName );
|
||||
protected:
|
||||
void initialize(const std::string &clientName);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__WINDOWS_KS__)
|
||||
|
||||
class MidiInWinKS: public MidiInApi
|
||||
class MidiInWinKS : public MidiInApi
|
||||
{
|
||||
public:
|
||||
MidiInWinKS( const std::string clientName, unsigned int queueSizeLimit );
|
||||
~MidiInWinKS( void );
|
||||
RtMidi::Api getCurrentApi( void ) { return RtMidi::WINDOWS_KS; };
|
||||
void openPort( unsigned int portNumber, const std::string portName );
|
||||
void openVirtualPort( const std::string portName );
|
||||
void closePort( void );
|
||||
unsigned int getPortCount( void );
|
||||
std::string getPortName( unsigned int portNumber );
|
||||
public:
|
||||
MidiInWinKS(const std::string clientName, unsigned int queueSizeLimit);
|
||||
~MidiInWinKS(void);
|
||||
RtMidi::Api getCurrentApi(void) { return RtMidi::WINDOWS_KS; };
|
||||
void openPort(unsigned int portNumber, const std::string portName);
|
||||
void openVirtualPort(const std::string portName);
|
||||
void closePort(void);
|
||||
unsigned int getPortCount(void);
|
||||
std::string getPortName(unsigned int portNumber);
|
||||
|
||||
protected:
|
||||
void initialize( const std::string& clientName );
|
||||
protected:
|
||||
void initialize(const std::string &clientName);
|
||||
};
|
||||
|
||||
class MidiOutWinKS: public MidiOutApi
|
||||
class MidiOutWinKS : public MidiOutApi
|
||||
{
|
||||
public:
|
||||
MidiOutWinKS( const std::string clientName );
|
||||
~MidiOutWinKS( void );
|
||||
RtMidi::Api getCurrentApi( void ) { return RtMidi::WINDOWS_KS; };
|
||||
void openPort( unsigned int portNumber, const std::string portName );
|
||||
void openVirtualPort( const std::string portName );
|
||||
void closePort( void );
|
||||
unsigned int getPortCount( void );
|
||||
std::string getPortName( unsigned int portNumber );
|
||||
void sendMessage( std::vector<unsigned char> *message );
|
||||
public:
|
||||
MidiOutWinKS(const std::string clientName);
|
||||
~MidiOutWinKS(void);
|
||||
RtMidi::Api getCurrentApi(void) { return RtMidi::WINDOWS_KS; };
|
||||
void openPort(unsigned int portNumber, const std::string portName);
|
||||
void openVirtualPort(const std::string portName);
|
||||
void closePort(void);
|
||||
unsigned int getPortCount(void);
|
||||
std::string getPortName(unsigned int portNumber);
|
||||
void sendMessage(std::vector<unsigned char> *message);
|
||||
|
||||
protected:
|
||||
void initialize( const std::string& clientName );
|
||||
protected:
|
||||
void initialize(const std::string &clientName);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__RTMIDI_DUMMY__)
|
||||
|
||||
class MidiInDummy: public MidiInApi
|
||||
class MidiInDummy : public MidiInApi
|
||||
{
|
||||
public:
|
||||
MidiInDummy( const std::string clientName, unsigned int queueSizeLimit ) : MidiInApi( queueSizeLimit ) { errorString_ = "MidiInDummy: This class provides no functionality."; RtMidi::error( RtError::WARNING, errorString_ ); };
|
||||
RtMidi::Api getCurrentApi( void ) { return RtMidi::RTMIDI_DUMMY; };
|
||||
void openPort( unsigned int portNumber, const std::string portName ) {};
|
||||
void openVirtualPort( const std::string portName ) {};
|
||||
void closePort( void ) {};
|
||||
unsigned int getPortCount( void ) { return 0; };
|
||||
std::string getPortName( unsigned int portNumber ) { return ""; };
|
||||
public:
|
||||
MidiInDummy(const std::string clientName, unsigned int queueSizeLimit) : MidiInApi(queueSizeLimit)
|
||||
{
|
||||
errorString_ = "MidiInDummy: This class provides no functionality.";
|
||||
RtMidi::error(RtError::WARNING, errorString_);
|
||||
};
|
||||
RtMidi::Api getCurrentApi(void) { return RtMidi::RTMIDI_DUMMY; };
|
||||
void openPort(unsigned int portNumber, const std::string portName){};
|
||||
void openVirtualPort(const std::string portName){};
|
||||
void closePort(void){};
|
||||
unsigned int getPortCount(void) { return 0; };
|
||||
std::string getPortName(unsigned int portNumber) { return ""; };
|
||||
|
||||
protected:
|
||||
void initialize( const std::string& clientName ) {};
|
||||
protected:
|
||||
void initialize(const std::string &clientName){};
|
||||
};
|
||||
|
||||
class MidiOutDummy: public MidiOutApi
|
||||
class MidiOutDummy : public MidiOutApi
|
||||
{
|
||||
public:
|
||||
MidiOutDummy( const std::string clientName ) { errorString_ = "MidiOutDummy: This class provides no functionality."; RtMidi::error( RtError::WARNING, errorString_ ); };
|
||||
RtMidi::Api getCurrentApi( void ) { return RtMidi::RTMIDI_DUMMY; };
|
||||
void openPort( unsigned int portNumber, const std::string portName ) {};
|
||||
void openVirtualPort( const std::string portName ) {};
|
||||
void closePort( void ) {};
|
||||
unsigned int getPortCount( void ) { return 0; };
|
||||
std::string getPortName( unsigned int portNumber ) { return ""; };
|
||||
void sendMessage( std::vector<unsigned char> *message ) {};
|
||||
public:
|
||||
MidiOutDummy(const std::string clientName)
|
||||
{
|
||||
errorString_ = "MidiOutDummy: This class provides no functionality.";
|
||||
RtMidi::error(RtError::WARNING, errorString_);
|
||||
};
|
||||
RtMidi::Api getCurrentApi(void) { return RtMidi::RTMIDI_DUMMY; };
|
||||
void openPort(unsigned int portNumber, const std::string portName){};
|
||||
void openVirtualPort(const std::string portName){};
|
||||
void closePort(void){};
|
||||
unsigned int getPortCount(void) { return 0; };
|
||||
std::string getPortName(unsigned int portNumber) { return ""; };
|
||||
void sendMessage(std::vector<unsigned char> *message){};
|
||||
|
||||
protected:
|
||||
void initialize( const std::string& clientName ) {};
|
||||
protected:
|
||||
void initialize(const std::string &clientName){};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,67 +11,65 @@
|
||||
#include <cstdlib>
|
||||
#include "RtMidi.h"
|
||||
|
||||
void usage( void ) {
|
||||
// Error function in case of incorrect command-line
|
||||
// argument specifications.
|
||||
std::cout << "\nuseage: cmidiin <port>\n";
|
||||
std::cout << " where port = the device to use (default = 0).\n\n";
|
||||
exit( 0 );
|
||||
void usage(void)
|
||||
{
|
||||
// Error function in case of incorrect command-line
|
||||
// argument specifications.
|
||||
std::cout << "\nuseage: cmidiin <port>\n";
|
||||
std::cout << " where port = the device to use (default = 0).\n\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void mycallback( double deltatime, std::vector< unsigned char > *message, void *userData )
|
||||
void mycallback(double deltatime, std::vector<unsigned char> *message, void *userData)
|
||||
{
|
||||
unsigned int nBytes = message->size();
|
||||
for ( unsigned int i=0; i<nBytes; i++ )
|
||||
std::cout << "Byte " << i << " = " << (int)message->at(i) << ", ";
|
||||
if ( nBytes > 0 )
|
||||
std::cout << "stamp = " << deltatime << std::endl;
|
||||
unsigned int nBytes = message->size();
|
||||
for (unsigned int i = 0; i < nBytes; i++)
|
||||
std::cout << "Byte " << i << " = " << (int)message->at(i) << ", ";
|
||||
if (nBytes > 0)
|
||||
std::cout << "stamp = " << deltatime << std::endl;
|
||||
}
|
||||
|
||||
// This function should be embedded in a try/catch block in case of
|
||||
// an exception. It offers the user a choice of MIDI ports to open.
|
||||
// It returns false if there are no ports available.
|
||||
bool chooseMidiPort( RtMidiIn *rtmidi );
|
||||
bool chooseMidiPort(RtMidiIn *rtmidi);
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
RtMidiIn *midiin = 0;
|
||||
RtMidiIn *midiin = 0;
|
||||
|
||||
// Minimal command-line check.
|
||||
if ( argc > 2 ) usage();
|
||||
// Minimal command-line check.
|
||||
if (argc > 2) usage();
|
||||
|
||||
// RtMidiIn constructor
|
||||
midiin = new RtMidiIn();
|
||||
|
||||
// RtMidiIn constructor
|
||||
midiin = new RtMidiIn();
|
||||
// Call function to select port.
|
||||
if (chooseMidiPort(midiin) == false) goto cleanup;
|
||||
|
||||
// Call function to select port.
|
||||
if ( chooseMidiPort( midiin ) == false ) goto cleanup;
|
||||
// Set our callback function. This should be done immediately after
|
||||
// opening the port to avoid having incoming messages written to the
|
||||
// queue instead of sent to the callback function.
|
||||
midiin->setCallback(&mycallback);
|
||||
|
||||
// Set our callback function. This should be done immediately after
|
||||
// opening the port to avoid having incoming messages written to the
|
||||
// queue instead of sent to the callback function.
|
||||
midiin->setCallback( &mycallback );
|
||||
// Don't ignore sysex, timing, or active sensing messages.
|
||||
midiin->ignoreTypes(false, false, false);
|
||||
|
||||
// Don't ignore sysex, timing, or active sensing messages.
|
||||
midiin->ignoreTypes( false, false, false );
|
||||
|
||||
std::cout << "\nReading MIDI input ... press <enter> to quit.\n";
|
||||
char input;
|
||||
std::cin.get(input);
|
||||
std::cout << "\nReading MIDI input ... press <enter> to quit.\n";
|
||||
char input;
|
||||
std::cin.get(input);
|
||||
std::cin.get(input);
|
||||
|
||||
cleanup:
|
||||
|
||||
delete midiin;
|
||||
|
||||
cleanup:
|
||||
|
||||
delete midiin;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool chooseMidiPort( RtMidiIn *rtmidi )
|
||||
bool chooseMidiPort(RtMidiIn *rtmidi)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
|
||||
std::cout << "\nWould you like to open a virtual input port? [y/N] ";
|
||||
|
||||
@@ -83,30 +81,35 @@ bool chooseMidiPort( RtMidiIn *rtmidi )
|
||||
}
|
||||
*/
|
||||
|
||||
std::string portName;
|
||||
unsigned int i = 0, nPorts = rtmidi->getPortCount();
|
||||
if ( nPorts == 0 ) {
|
||||
std::cout << "No input ports available!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
std::string portName;
|
||||
unsigned int i = 0, nPorts = rtmidi->getPortCount();
|
||||
if (nPorts == 0)
|
||||
{
|
||||
std::cout << "No input ports available!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( nPorts == 1 ) {
|
||||
std::cout << "\nOpening " << rtmidi->getPortName() << std::endl;
|
||||
}
|
||||
else {
|
||||
for ( i=0; i<nPorts; i++ ) {
|
||||
portName = rtmidi->getPortName(i);
|
||||
std::cout << " Input port #" << i << ": " << portName << '\n';
|
||||
}
|
||||
if (nPorts == 1)
|
||||
{
|
||||
std::cout << "\nOpening " << rtmidi->getPortName() << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < nPorts; i++)
|
||||
{
|
||||
portName = rtmidi->getPortName(i);
|
||||
std::cout << " Input port #" << i << ": " << portName << '\n';
|
||||
}
|
||||
|
||||
do {
|
||||
std::cout << "\nChoose a port number: ";
|
||||
std::cin >> i;
|
||||
} while ( i >= nPorts );
|
||||
}
|
||||
do
|
||||
{
|
||||
std::cout << "\nChoose a port number: ";
|
||||
std::cin >> i;
|
||||
} while (i >= nPorts);
|
||||
}
|
||||
|
||||
// std::getline( std::cin, keyHit ); // used to clear out stdin
|
||||
rtmidi->openPort( i );
|
||||
// std::getline( std::cin, keyHit ); // used to clear out stdin
|
||||
rtmidi->openPort(i);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user