diff options
| author | Gary Scavone <gary@music.mcgill.ca> | 2013-12-27 21:44:34 -0800 |
|---|---|---|
| committer | Gary Scavone <gary@music.mcgill.ca> | 2013-12-27 21:44:34 -0800 |
| commit | ed94023c333c63a8b5713da1c5746ebbbe5b665b (patch) | |
| tree | 532b35df7f0598d8fd58d67091aca075adaaa75f /RtMidi.cpp | |
| parent | c80bfb62fe97c8d2176bd7f6d953682bf2c89384 (diff) | |
Changed RtError class to RtMidiError and embedded it in RtMidi.h
Diffstat (limited to 'RtMidi.cpp')
| -rw-r--r-- | RtMidi.cpp | 234 |
1 files changed, 117 insertions, 117 deletions
@@ -8,7 +8,7 @@ RtMidi WWW site: http://music.mcgill.ca/~gary/rtmidi/ RtMidi: realtime MIDI i/o C++ classes - Copyright (c) 2003-2012 Gary P. Scavone + Copyright (c) 2003-2014 Gary P. Scavone Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files @@ -36,7 +36,7 @@ */ /**********************************************************************/ -// RtMidi: Version 2.0.1 +// RtMidi: Version 2.1.0 #include "RtMidi.h" #include <sstream> @@ -71,19 +71,19 @@ void RtMidi :: getCompiledApi( std::vector<RtMidi::Api> &apis ) throw() #endif } -void RtMidi :: error( RtError::Type type, std::string errorString ) +void RtMidi :: error( RtMidiError::Type type, std::string errorString ) { - if (type == RtError::WARNING) { + if (type == RtMidiError::WARNING) { std::cerr << '\n' << errorString << "\n\n"; } - else if (type == RtError::DEBUG_WARNING) { + else if (type == RtMidiError::DEBUG_WARNING) { #if defined(__RTMIDI_DEBUG__) std::cerr << '\n' << errorString << "\n\n"; #endif } else { std::cerr << '\n' << errorString << "\n\n"; - throw RtError( errorString, type ); + throw RtMidiError( errorString, type ); } } @@ -134,7 +134,7 @@ RtMidiIn :: RtMidiIn( RtMidi::Api api, const std::string clientName, unsigned in // No compiled support for specified API value. Issue a debug // warning and continue as if no API was specified. - RtMidi::error( RtError::WARNING, "RtMidiIn: no compiled support for specified API argument!" ); + RtMidi::error( RtMidiError::WARNING, "RtMidiIn: no compiled support for specified API argument!" ); } // Iterate through the compiled APIs and return as soon as we find @@ -152,7 +152,7 @@ RtMidiIn :: RtMidiIn( RtMidi::Api api, const std::string clientName, unsigned in // definition __RTMIDI_DUMMY__ is automatically defined if no // API-specific definitions are passed to the compiler. But just in // case something weird happens, we'll print out an error message. - RtMidi::error( RtError::WARNING, "RtMidiIn: no compiled API support found ... critical error!!" ); + RtMidi::error( RtMidiError::WARNING, "RtMidiIn: no compiled API support found ... critical error!!" ); } RtMidiIn :: ~RtMidiIn() throw() @@ -208,7 +208,7 @@ RtMidiOut :: RtMidiOut( RtMidi::Api api, const std::string clientName ) // No compiled support for specified API value. Issue a debug // warning and continue as if no API was specified. - RtMidi::error( RtError::WARNING, "RtMidiOut: no compiled support for specified API argument!" ); + RtMidi::error( RtMidiError::WARNING, "RtMidiOut: no compiled support for specified API argument!" ); } // Iterate through the compiled APIs and return as soon as we find @@ -226,7 +226,7 @@ RtMidiOut :: RtMidiOut( RtMidi::Api api, const std::string clientName ) // definition __RTMIDI_DUMMY__ is automatically defined if no // API-specific definitions are passed to the compiler. But just in // case something weird happens, we'll print out an error message. - RtMidi::error( RtError::WARNING, "RtMidiOut: no compiled API support found ... critical error!!" ); + RtMidi::error( RtMidiError::WARNING, "RtMidiOut: no compiled API support found ... critical error!!" ); } RtMidiOut :: ~RtMidiOut() throw() @@ -257,13 +257,13 @@ void MidiInApi :: setCallback( RtMidiIn::RtMidiCallback callback, void *userData { if ( inputData_.usingCallback ) { errorString_ = "MidiInApi::setCallback: a callback function is already set!"; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); return; } if ( !callback ) { errorString_ = "RtMidiIn::setCallback: callback function value is invalid!"; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); return; } @@ -276,7 +276,7 @@ void MidiInApi :: cancelCallback() { if ( !inputData_.usingCallback ) { errorString_ = "RtMidiIn::cancelCallback: no callback function was set!"; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); return; } @@ -299,7 +299,7 @@ double MidiInApi :: getMessage( std::vector<unsigned char> *message ) if ( inputData_.usingCallback ) { errorString_ = "RtMidiIn::getNextMessage: a user callback is currently set for this port."; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); return 0.0; } @@ -537,7 +537,7 @@ void MidiInCore :: initialize( const std::string& clientName ) OSStatus result = MIDIClientCreate( CFStringCreateWithCString( NULL, clientName.c_str(), kCFStringEncodingASCII ), NULL, NULL, &client ); if ( result != noErr ) { errorString_ = "MidiInCore::initialize: error creating OS-X MIDI client object."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } // Save our api-specific connection information. @@ -552,7 +552,7 @@ void MidiInCore :: openPort( unsigned int portNumber, const std::string portName { if ( connected_ ) { errorString_ = "MidiInCore::openPort: a valid connection already exists!"; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); return; } @@ -560,14 +560,14 @@ void MidiInCore :: openPort( unsigned int portNumber, const std::string portName unsigned int nSrc = MIDIGetNumberOfSources(); if (nSrc < 1) { errorString_ = "MidiInCore::openPort: no MIDI input sources found!"; - RtMidi::error( RtError::NO_DEVICES_FOUND, errorString_ ); + RtMidi::error( RtMidiError::NO_DEVICES_FOUND, errorString_ ); } std::ostringstream ost; if ( portNumber >= nSrc ) { ost << "MidiInCore::openPort: the 'portNumber' argument (" << portNumber << ") is invalid."; errorString_ = ost.str(); - RtMidi::error( RtError::INVALID_PARAMETER, errorString_ ); + RtMidi::error( RtMidiError::INVALID_PARAMETER, errorString_ ); } MIDIPortRef port; @@ -578,7 +578,7 @@ void MidiInCore :: openPort( unsigned int portNumber, const std::string portName if ( result != noErr ) { MIDIClientDispose( data->client ); errorString_ = "MidiInCore::openPort: error creating OS-X MIDI input port."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } // Get the desired input source identifier. @@ -587,7 +587,7 @@ void MidiInCore :: openPort( unsigned int portNumber, const std::string portName MIDIPortDispose( port ); MIDIClientDispose( data->client ); errorString_ = "MidiInCore::openPort: error getting MIDI input source reference."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } // Make the connection. @@ -596,7 +596,7 @@ void MidiInCore :: openPort( unsigned int portNumber, const std::string portName MIDIPortDispose( port ); MIDIClientDispose( data->client ); errorString_ = "MidiInCore::openPort: error connecting OS-X MIDI input port."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } // Save our api-specific port information. @@ -616,7 +616,7 @@ void MidiInCore :: openVirtualPort( const std::string portName ) midiInputCallback, (void *)&inputData_, &endpoint ); if ( result != noErr ) { errorString_ = "MidiInCore::openVirtualPort: error creating virtual OS-X MIDI destination."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } // Save our api-specific connection information. @@ -774,8 +774,8 @@ std::string MidiInCore :: getPortName( unsigned int portNumber ) if ( portNumber >= MIDIGetNumberOfSources() ) { ost << "MidiInCore::getPortName: the 'portNumber' argument (" << portNumber << ") is invalid."; errorString_ = ost.str(); - RtMidi::error( RtError::WARNING, errorString_ ); - //RtMidi::error( RtError::INVALID_PARAMETER, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); + //RtMidi::error( RtMidiError::INVALID_PARAMETER, errorString_ ); return stringName; } @@ -816,7 +816,7 @@ void MidiOutCore :: initialize( const std::string& clientName ) OSStatus result = MIDIClientCreate( CFStringCreateWithCString( NULL, clientName.c_str(), kCFStringEncodingASCII ), NULL, NULL, &client ); if ( result != noErr ) { errorString_ = "MidiOutCore::initialize: error creating OS-X MIDI client object."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } // Save our api-specific connection information. @@ -844,9 +844,9 @@ std::string MidiOutCore :: getPortName( unsigned int portNumber ) if ( portNumber >= MIDIGetNumberOfDestinations() ) { ost << "MidiOutCore::getPortName: the 'portNumber' argument (" << portNumber << ") is invalid."; errorString_ = ost.str(); - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); return stringName; - //RtMidi::error( RtError::INVALID_PARAMETER, errorString_ ); + //RtMidi::error( RtMidiError::INVALID_PARAMETER, errorString_ ); } portRef = MIDIGetDestination( portNumber ); @@ -861,7 +861,7 @@ void MidiOutCore :: openPort( unsigned int portNumber, const std::string portNam { if ( connected_ ) { errorString_ = "MidiOutCore::openPort: a valid connection already exists!"; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); return; } @@ -869,14 +869,14 @@ void MidiOutCore :: openPort( unsigned int portNumber, const std::string portNam unsigned int nDest = MIDIGetNumberOfDestinations(); if (nDest < 1) { errorString_ = "MidiOutCore::openPort: no MIDI output destinations found!"; - RtMidi::error( RtError::NO_DEVICES_FOUND, errorString_ ); + RtMidi::error( RtMidiError::NO_DEVICES_FOUND, errorString_ ); } std::ostringstream ost; if ( portNumber >= nDest ) { ost << "MidiOutCore::openPort: the 'portNumber' argument (" << portNumber << ") is invalid."; errorString_ = ost.str(); - RtMidi::error( RtError::INVALID_PARAMETER, errorString_ ); + RtMidi::error( RtMidiError::INVALID_PARAMETER, errorString_ ); } MIDIPortRef port; @@ -887,7 +887,7 @@ void MidiOutCore :: openPort( unsigned int portNumber, const std::string portNam if ( result != noErr ) { MIDIClientDispose( data->client ); errorString_ = "MidiOutCore::openPort: error creating OS-X MIDI output port."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } // Get the desired output port identifier. @@ -896,7 +896,7 @@ void MidiOutCore :: openPort( unsigned int portNumber, const std::string portNam MIDIPortDispose( port ); MIDIClientDispose( data->client ); errorString_ = "MidiOutCore::openPort: error getting MIDI output destination reference."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } // Save our api-specific connection information. @@ -920,7 +920,7 @@ void MidiOutCore :: openVirtualPort( std::string portName ) if ( data->endpoint ) { errorString_ = "MidiOutCore::openVirtualPort: a virtual output port already exists!"; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); return; } @@ -931,7 +931,7 @@ void MidiOutCore :: openVirtualPort( std::string portName ) &endpoint ); if ( result != noErr ) { errorString_ = "MidiOutCore::initialize: error creating OS-X virtual MIDI source."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } // Save our api-specific connection information. @@ -954,7 +954,7 @@ void MidiOutCore :: sendMessage( std::vector<unsigned char> *message ) unsigned int nBytes = message->size(); if ( nBytes == 0 ) { errorString_ = "MidiOutCore::sendMessage: no data in message argument!"; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); return; } @@ -971,7 +971,7 @@ void MidiOutCore :: sendMessage( std::vector<unsigned char> *message ) sysexBuffer = new char[nBytes]; if ( sysexBuffer == NULL ) { errorString_ = "MidiOutCore::sendMessage: error allocating sysex message memory!"; - RtMidi::error( RtError::MEMORY_ERROR, errorString_ ); + RtMidi::error( RtMidiError::MEMORY_ERROR, errorString_ ); } // Copy data to buffer. @@ -987,13 +987,13 @@ void MidiOutCore :: sendMessage( std::vector<unsigned char> *message ) result = MIDISendSysex( &(data->sysexreq) ); if ( result != noErr ) { errorString_ = "MidiOutCore::sendMessage: error sending MIDI to virtual destinations."; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); } return; } else if ( nBytes > 3 ) { errorString_ = "MidiOutCore::sendMessage: message format problem ... not sysex but > 3 bytes?"; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); return; } @@ -1002,7 +1002,7 @@ void MidiOutCore :: sendMessage( std::vector<unsigned char> *message ) packet = MIDIPacketListAdd( &packetList, sizeof(packetList), packet, timeStamp, nBytes, (const Byte *) &message->at( 0 ) ); if ( !packet ) { errorString_ = "MidiOutCore::sendMessage: could not allocate packet list"; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } // Send to any destinations that may have connected to us. @@ -1010,7 +1010,7 @@ void MidiOutCore :: sendMessage( std::vector<unsigned char> *message ) result = MIDIReceived( data->endpoint, &packetList ); if ( result != noErr ) { errorString_ = "MidiOutCore::sendMessage: error sending MIDI to virtual destinations."; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); } } @@ -1019,7 +1019,7 @@ void MidiOutCore :: sendMessage( std::vector<unsigned char> *message ) result = MIDISend( data->port, data->destinationId, &packetList ); if ( result != noErr ) { errorString_ = "MidiOutCore::sendMessage: error sending MIDI message to port."; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); } } @@ -1344,7 +1344,7 @@ void MidiInAlsa :: initialize( const std::string& clientName ) if ( seq == NULL ) { s_seq = NULL; errorString_ = "MidiInAlsa::initialize: error creating ALSA sequencer client object."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } // Save our api-specific connection information. @@ -1362,7 +1362,7 @@ void MidiInAlsa :: initialize( const std::string& clientName ) if ( pipe(data->trigger_fds) == -1 ) { errorString_ = "MidiInAlsa::initialize: error creating pipe objects."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } // Create the input queue @@ -1441,23 +1441,23 @@ std::string MidiInAlsa :: getPortName( unsigned int portNumber ) // If we get here, we didn't find a match. errorString_ = "MidiInAlsa::getPortName: error looking for port name!"; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); return stringName; - //RtMidi::error( RtError::INVALID_PARAMETER, errorString_ ); + //RtMidi::error( RtMidiError::INVALID_PARAMETER, errorString_ ); } void MidiInAlsa :: openPort( unsigned int portNumber, const std::string portName ) { if ( connected_ ) { errorString_ = "MidiInAlsa::openPort: a valid connection already exists!"; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); return; } unsigned int nSrc = this->getPortCount(); if (nSrc < 1) { errorString_ = "MidiInAlsa::openPort: no MIDI input sources found!"; - RtMidi::error( RtError::NO_DEVICES_FOUND, errorString_ ); + RtMidi::error( RtMidiError::NO_DEVICES_FOUND, errorString_ ); } snd_seq_port_info_t *pinfo; @@ -1467,7 +1467,7 @@ void MidiInAlsa :: openPort( unsigned int portNumber, const std::string portName if ( portInfo( data->seq, pinfo, SND_SEQ_PORT_CAP_READ|SND_SEQ_PORT_CAP_SUBS_READ, (int) portNumber ) == 0 ) { ost << "MidiInAlsa::openPort: the 'portNumber' argument (" << portNumber << ") is invalid."; errorString_ = ost.str(); - RtMidi::error( RtError::INVALID_PARAMETER, errorString_ ); + RtMidi::error( RtMidiError::INVALID_PARAMETER, errorString_ ); } @@ -1495,7 +1495,7 @@ void MidiInAlsa :: openPort( unsigned int portNumber, const std::string portName if ( data->vport < 0 ) { errorString_ = "MidiInAlsa::openPort: ALSA error creating input port."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } } @@ -1505,7 +1505,7 @@ void MidiInAlsa :: openPort( unsigned int portNumber, const std::string portName // Make subscription if (snd_seq_port_subscribe_malloc( &data->subscription ) < 0) { errorString_ = "MidiInAlsa::openPort: ALSA error allocation port subscription."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } snd_seq_port_subscribe_set_sender(data->subscription, &sender); snd_seq_port_subscribe_set_dest(data->subscription, &receiver); @@ -1513,7 +1513,7 @@ void MidiInAlsa :: openPort( unsigned int portNumber, const std::string portName snd_seq_port_subscribe_free( data->subscription ); data->subscription = 0; errorString_ = "MidiInAlsa::openPort: ALSA error making port connection."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } } @@ -1538,7 +1538,7 @@ void MidiInAlsa :: openPort( unsigned int portNumber, const std::string portName data->subscription = 0; inputData_.doInput = false; errorString_ = "MidiInAlsa::openPort: error starting MIDI input thread!"; - RtMidi::error( RtError::THREAD_ERROR, errorString_ ); + RtMidi::error( RtMidiError::THREAD_ERROR, errorString_ ); } } @@ -1568,7 +1568,7 @@ void MidiInAlsa :: openVirtualPort( std::string portName ) if ( data->vport < 0 ) { errorString_ = "MidiInAlsa::openVirtualPort: ALSA error creating virtual port."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } } @@ -1599,7 +1599,7 @@ void MidiInAlsa :: openVirtualPort( std::string portName ) } inputData_.doInput = false; errorString_ = "MidiInAlsa::openPort: error starting MIDI input thread!"; - RtMidi::error( RtError::THREAD_ERROR, errorString_ ); + RtMidi::error( RtMidiError::THREAD_ERROR, errorString_ ); } } } @@ -1662,7 +1662,7 @@ void MidiOutAlsa :: initialize( const std::string& clientName ) if ( seq == NULL ) { s_seq = NULL; errorString_ = "MidiOutAlsa::initialize: error creating ALSA sequencer client object."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } // Save our api-specific connection information. @@ -1677,13 +1677,13 @@ void MidiOutAlsa :: initialize( const std::string& clientName ) if ( result < 0 ) { delete data; errorString_ = "MidiOutAlsa::initialize: error initializing MIDI event parser!\n\n"; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } data->buffer = (unsigned char *) malloc( data->bufferSize ); if ( data->buffer == NULL ) { delete data; errorString_ = "MidiOutAlsa::initialize: error allocating buffer memory!\n\n"; - RtMidi::error( RtError::MEMORY_ERROR, errorString_ ); + RtMidi::error( RtMidiError::MEMORY_ERROR, errorString_ ); } snd_midi_event_init( data->coder ); apiData_ = (void *) data; @@ -1720,8 +1720,8 @@ std::string MidiOutAlsa :: getPortName( unsigned int portNumber ) // If we get here, we didn't find a match. errorString_ = "MidiOutAlsa::getPortName: error looking for port name!"; - //RtMidi::error( RtError::INVALID_PARAMETER, errorString_ ); - RtMidi::error( RtError::WARNING, errorString_ ); + //RtMidi::error( RtMidiError::INVALID_PARAMETER, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); return stringName; } @@ -1729,14 +1729,14 @@ void MidiOutAlsa :: openPort( unsigned int portNumber, const std::string portNam { if ( connected_ ) { errorString_ = "MidiOutAlsa::openPort: a valid connection already exists!"; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); return; } unsigned int nSrc = this->getPortCount(); if (nSrc < 1) { errorString_ = "MidiOutAlsa::openPort: no MIDI output sources found!"; - RtMidi::error( RtError::NO_DEVICES_FOUND, errorString_ ); + RtMidi::error( RtMidiError::NO_DEVICES_FOUND, errorString_ ); } snd_seq_port_info_t *pinfo; @@ -1746,7 +1746,7 @@ void MidiOutAlsa :: openPort( unsigned int portNumber, const std::string portNam if ( portInfo( data->seq, pinfo, SND_SEQ_PORT_CAP_WRITE|SND_SEQ_PORT_CAP_SUBS_WRITE, (int) portNumber ) == 0 ) { ost << "MidiOutAlsa::openPort: the 'portNumber' argument (" << portNumber << ") is invalid."; errorString_ = ost.str(); - RtMidi::error( RtError::INVALID_PARAMETER, errorString_ ); + RtMidi::error( RtMidiError::INVALID_PARAMETER, errorString_ ); } snd_seq_addr_t sender, receiver; @@ -1760,7 +1760,7 @@ void MidiOutAlsa :: openPort( unsigned int portNumber, const std::string portNam SND_SEQ_PORT_TYPE_MIDI_GENERIC|SND_SEQ_PORT_TYPE_APPLICATION ); if ( data->vport < 0 ) { errorString_ = "MidiOutAlsa::openPort: ALSA error creating output port."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } } @@ -1770,7 +1770,7 @@ void MidiOutAlsa :: openPort( unsigned int portNumber, const std::string portNam if (snd_seq_port_subscribe_malloc( &data->subscription ) < 0) { snd_seq_port_subscribe_free( data->subscription ); errorString_ = "MidiOutAlsa::openPort: error allocation port subscribtion."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } snd_seq_port_subscribe_set_sender(data->subscription, &sender); snd_seq_port_subscribe_set_dest(data->subscription, &receiver); @@ -1779,7 +1779,7 @@ void MidiOutAlsa :: openPort( unsigned int portNumber, const std::string portNam if ( snd_seq_subscribe_port(data->seq, data->subscription) ) { snd_seq_port_subscribe_free( data->subscription ); errorString_ = "MidiOutAlsa::openPort: ALSA error making port connection."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } connected_ = true; @@ -1805,7 +1805,7 @@ void MidiOutAlsa :: openVirtualPort( std::string portName ) if ( data->vport < 0 ) { errorString_ = "MidiOutAlsa::openVirtualPort: ALSA error creating virtual port."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } } } @@ -1820,13 +1820,13 @@ void MidiOutAlsa :: sendMessage( std::vector<unsigned char> *message ) result = snd_midi_event_resize_buffer ( data->coder, nBytes); if ( result != 0 ) { errorString_ = "MidiOutAlsa::sendMessage: ALSA error resizing MIDI event buffer."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } free (data->buffer); data->buffer = (unsigned char *) malloc( data->bufferSize ); if ( data->buffer == NULL ) { errorString_ = "MidiOutAlsa::initialize: error allocating buffer memory!\n\n"; - RtMidi::error( RtError::MEMORY_ERROR, errorString_ ); + RtMidi::error( RtMidiError::MEMORY_ERROR, errorString_ ); } } @@ -1839,7 +1839,7 @@ void MidiOutAlsa :: sendMessage( std::vector<unsigned char> *message ) result = snd_midi_event_encode( data->coder, data->buffer, (long)nBytes, &ev ); if ( result < (int)nBytes ) { errorString_ = "MidiOutAlsa::sendMessage: event parsing error!"; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); return; } @@ -1847,7 +1847,7 @@ void MidiOutAlsa :: sendMessage( std::vector<unsigned char> *message ) result = snd_seq_event_output(data->seq, &ev); if ( result < 0 ) { errorString_ = "MidiOutAlsa::sendMessage: error sending MIDI message to port."; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); } snd_seq_drain_output(data->seq); } @@ -2011,7 +2011,7 @@ void MidiInWinMM :: initialize( const std::string& /*clientName*/ ) unsigned int nDevices = midiInGetNumDevs(); if ( nDevices == 0 ) { errorString_ = "MidiInWinMM::initialize: no MIDI input devices currently available."; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); } // Save our api-specific connection information. @@ -2025,21 +2025,21 @@ void MidiInWinMM :: openPort( unsigned int portNumber, const std::string /*portN { if ( connected_ ) { errorString_ = "MidiInWinMM::openPort: a valid connection already exists!"; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); return; } unsigned int nDevices = midiInGetNumDevs(); if (nDevices == 0) { errorString_ = "MidiInWinMM::openPort: no MIDI input sources found!"; - RtMidi::error( RtError::NO_DEVICES_FOUND, errorString_ ); + RtMidi::error( RtMidiError::NO_DEVICES_FOUND, errorString_ ); } std::ostringstream ost; if ( portNumber >= nDevices ) { ost << "MidiInWinMM::openPort: the 'portNumber' argument (" << portNumber << ") is invalid."; errorString_ = ost.str(); - RtMidi::error( RtError::INVALID_PARAMETER, errorString_ ); + RtMidi::error( RtMidiError::INVALID_PARAMETER, errorString_ ); } WinMidiData *data = static_cast<WinMidiData *> (apiData_); @@ -2050,7 +2050,7 @@ void MidiInWinMM :: openPort( unsigned int portNumber, const std::string /*portN CALLBACK_FUNCTION ); if ( result != MMSYSERR_NOERROR ) { errorString_ = "MidiInWinMM::openPort: error creating Windows MM MIDI input port."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } // Allocate and init the sysex buffers. @@ -2065,7 +2065,7 @@ void MidiInWinMM :: openPort( unsigned int portNumber, const std::string /*portN if ( result != MMSYSERR_NOERROR ) { midiInClose( data->inHandle ); errorString_ = "MidiInWinMM::openPort: error starting Windows MM MIDI input port (PrepareHeader)."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } // Register the buffer. @@ -2073,7 +2073,7 @@ void MidiInWinMM :: openPort( unsigned int portNumber, const std::string /*portN if ( result != MMSYSERR_NOERROR ) { midiInClose( data->inHandle ); errorString_ = "MidiInWinMM::openPort: error starting Windows MM MIDI input port (AddBuffer)."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } } @@ -2081,7 +2081,7 @@ void MidiInWinMM :: openPort( unsigned int portNumber, const std::string /*portN if ( result != MMSYSERR_NOERROR ) { midiInClose( data->inHandle ); errorString_ = "MidiInWinMM::openPort: error starting Windows MM MIDI input port."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } connected_ = true; @@ -2091,7 +2091,7 @@ void MidiInWinMM :: openVirtualPort( std::string portName ) { // This function cannot be implemented for the Windows MM MIDI API. errorString_ = "MidiInWinMM::openVirtualPort: cannot be implemented in Windows MM MIDI API!"; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); } void MidiInWinMM :: closePort( void ) @@ -2108,7 +2108,7 @@ void MidiInWinMM :: closePort( void ) if ( result != MMSYSERR_NOERROR ) { midiInClose( data->inHandle ); errorString_ = "MidiInWinMM::openPort: error closing Windows MM MIDI input port (midiInUnprepareHeader)."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } } @@ -2130,8 +2130,8 @@ std::string MidiInWinMM :: getPortName( unsigned int portNumber ) std::ostringstream ost; ost << "MidiInWinMM::getPortName: the 'portNumber' argument (" << portNumber << ") is invalid."; errorString_ = ost.str(); - //RtMidi::error( RtError::INVALID_PARAMETER, errorString_ ); - RtMidi::error( RtError::WARNING, errorString_ ); + //RtMidi::error( RtMidiError::INVALID_PARAMETER, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); return stringName; } @@ -2184,7 +2184,7 @@ void MidiOutWinMM :: initialize( const std::string& /*clientName*/ ) unsigned int nDevices = midiOutGetNumDevs(); if ( nDevices == 0 ) { errorString_ = "MidiOutWinMM::initialize: no MIDI output devices currently available."; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); } // Save our api-specific connection information. @@ -2205,8 +2205,8 @@ std::string MidiOutWinMM :: getPortName( unsigned int portNumber ) std::ostringstream ost; ost << "MidiOutWinMM::getPortName: the 'portNumber' argument (" << portNumber << ") is invalid."; errorString_ = ost.str(); - //RtMidi::error( RtError::INVALID_PARAMETER, errorString_ ); - RtMidi::error( RtError::WARNING, errorString_ ); + //RtMidi::error( RtMidiError::INVALID_PARAMETER, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); return stringName; } @@ -2228,21 +2228,21 @@ void MidiOutWinMM :: openPort( unsigned int portNumber, const std::string /*port { if ( connected_ ) { errorString_ = "MidiOutWinMM::openPort: a valid connection already exists!"; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); return; } unsigned int nDevices = midiOutGetNumDevs(); if (nDevices < 1) { errorString_ = "MidiOutWinMM::openPort: no MIDI output destinations found!"; - RtMidi::error( RtError::NO_DEVICES_FOUND, errorString_ ); + RtMidi::error( RtMidiError::NO_DEVICES_FOUND, errorString_ ); } std::ostringstream ost; if ( portNumber >= nDevices ) { ost << "MidiOutWinMM::openPort: the 'portNumber' argument (" << portNumber << ") is invalid."; errorString_ = ost.str(); - RtMidi::error( RtError::INVALID_PARAMETER, errorString_ ); + RtMidi::error( RtMidiError::INVALID_PARAMETER, errorString_ ); } WinMidiData *data = static_cast<WinMidiData *> (apiData_); @@ -2253,7 +2253,7 @@ void MidiOutWinMM :: openPort( unsigned int portNumber, const std::string /*port CALLBACK_NULL ); if ( result != MMSYSERR_NOERROR ) { errorString_ = "MidiOutWinMM::openPort: error creating Windows MM MIDI output port."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } connected_ = true; @@ -2273,7 +2273,7 @@ void MidiOutWinMM :: openVirtualPort( std::string portName ) { // This function cannot be implemented for the Windows MM MIDI API. errorString_ = "MidiOutWinMM::openVirtualPort: cannot be implemented in Windows MM MIDI API!"; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); } void MidiOutWinMM :: sendMessage( std::vector<unsigned char> *message ) @@ -2281,7 +2281,7 @@ void MidiOutWinMM :: sendMessage( std::vector<unsigned char> *message ) unsigned int nBytes = static_cast<unsigned int>(message->size()); if ( nBytes == 0 ) { errorString_ = "MidiOutWinMM::sendMessage: message argument is empty!"; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); return; } @@ -2293,7 +2293,7 @@ void MidiOutWinMM :: sendMessage( std::vector<unsigned char> *message ) char *buffer = (char *) malloc( nBytes ); if ( buffer == NULL ) { errorString_ = "MidiOutWinMM::sendMessage: error allocating sysex message memory!"; - RtMidi::error( RtError::MEMORY_ERROR, errorString_ ); + RtMidi::error( RtMidiError::MEMORY_ERROR, errorString_ ); } // Copy data to buffer. @@ -2308,7 +2308,7 @@ void MidiOutWinMM :: sendMessage( std::vector<unsigned char> *message ) if ( result != MMSYSERR_NOERROR ) { free( buffer ); errorString_ = "MidiOutWinMM::sendMessage: error preparing sysex header."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } // Send the message. @@ -2316,7 +2316,7 @@ void MidiOutWinMM :: sendMessage( std::vector<unsigned char> *message ) if ( result != MMSYSERR_NOERROR ) { free( buffer ); errorString_ = "MidiOutWinMM::sendMessage: error sending sysex message."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } // Unprepare the buffer and MIDIHDR. @@ -2329,7 +2329,7 @@ void MidiOutWinMM :: sendMessage( std::vector<unsigned char> *message ) // Make sure the message size isn't too big. if ( nBytes > 3 ) { errorString_ = "MidiOutWinMM::sendMessage: message size is greater than 3 bytes (and not sysex)!"; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); return; } @@ -2345,7 +2345,7 @@ void MidiOutWinMM :: sendMessage( std::vector<unsigned char> *message ) result = midiOutShortMsg( data->outHandle, packet ); if ( result != MMSYSERR_NOERROR ) { errorString_ = "MidiOutWinMM::sendMessage: error sending MIDI message."; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } } } @@ -3158,7 +3158,7 @@ void MidiInWinKS :: openPort( unsigned int portNumber, const std::string portNam std::stringstream ost; ost << "MidiInWinKS::openPort: the 'portNumber' argument (" << portNumber << ") is invalid."; errorString_ = ost.str(); - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); } CKsMidiCapFilter* pFilter = data->m_pCaptureEnum->m_Filters[portNumber]; @@ -3168,7 +3168,7 @@ void MidiInWinKS :: openPort( unsigned int portNumber, const std::string portNam std::stringstream ost; ost << "MidiInWinKS::openPort: KS error opening port (could not create pin)"; errorString_ = ost.str(); - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); } data->m_pPin->SetState(KSSTATE_RUN); @@ -3179,7 +3179,7 @@ void MidiInWinKS :: openPort( unsigned int portNumber, const std::string portNam std::stringstream ost; ost << "MidiInWinKS::initialize: Could not create input thread : Windows error " << GetLastError() << std::endl;; errorString_ = ost.str(); - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); } connected_ = true; @@ -3189,7 +3189,7 @@ void MidiInWinKS :: openVirtualPort( const std::string portName ) { // This function cannot be implemented for the Windows KS MIDI API. errorString_ = "MidiInWinKS::openVirtualPort: cannot be implemented in Windows KS MIDI API!"; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); } unsigned int MidiInWinKS :: getPortCount() @@ -3206,7 +3206,7 @@ std::string MidiInWinKS :: getPortName(unsigned int portNumber) std::stringstream ost; ost << "MidiInWinKS::getPortName: the 'portNumber' argument (" << portNumber << ") is invalid."; errorString_ = ost.str(); - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); } CKsMidiCapFilter* pFilter = data->m_pCaptureEnum->m_Filters[portNumber]; @@ -3274,7 +3274,7 @@ void MidiOutWinKS :: openPort( unsigned int portNumber, const std::string portNa std::stringstream ost; ost << "MidiOutWinKS::openPort: the 'portNumber' argument (" << portNumber << ") is invalid."; errorString_ = ost.str(); - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); } CKsMidiRenFilter* pFilter = data->m_pRenderEnum->m_Filters[portNumber]; @@ -3284,7 +3284,7 @@ void MidiOutWinKS :: openPort( unsigned int portNumber, const std::string portNa std::stringstream ost; ost << "MidiOutWinKS::openPort: KS error opening port (could not create pin)"; errorString_ = ost.str(); - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); } data->m_pPin->SetState(KSSTATE_RUN); @@ -3295,7 +3295,7 @@ void MidiOutWinKS :: openVirtualPort( const std::string portName ) { // This function cannot be implemented for the Windows KS MIDI API. errorString_ = "MidiOutWinKS::openVirtualPort: cannot be implemented in Windows KS MIDI API!"; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); } unsigned int MidiOutWinKS :: getPortCount() @@ -3313,7 +3313,7 @@ std::string MidiOutWinKS :: getPortName( unsigned int portNumber ) std::stringstream ost; ost << "MidiOutWinKS::getPortName: the 'portNumber' argument (" << portNumber << ") is invalid."; errorString_ = ost.str(); - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); } CKsMidiRenFilter* pFilter = data->m_pRenderEnum->m_Filters[portNumber]; @@ -3351,14 +3351,14 @@ void MidiOutWinKS :: sendMessage(std::vector<unsigned char>* pMessage) std::stringstream ost; ost << "KsMidiInput::Write: MIDI buffer too small. Required " << pos + iNumMidiBytes << " bytes, only has " << data->m_Buffer.size(); errorString_ = ost.str(); - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); } if ( data->m_pPin == NULL ) { std::stringstream ost; ost << "MidiOutWinKS::sendMessage: port is not open"; errorString_ = ost.str(); - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); } memcpy(&data->m_Buffer[pos], &msg[0], iNumMidiBytes); @@ -3476,7 +3476,7 @@ void MidiInJack :: initialize( const std::string& clientName ) // Initialize JACK client if (( data->client = jack_client_open( clientName.c_str(), JackNullOption, NULL )) == 0) { errorString_ = "MidiInJack::initialize: JACK server not running?"; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); return; } @@ -3506,7 +3506,7 @@ void MidiInJack :: openPort( unsigned int portNumber, const std::string portName if ( data->port == NULL) { errorString_ = "MidiInJack::openVirtualPort: JACK error creating virtual port"; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } // Connecting to the output @@ -3524,7 +3524,7 @@ void MidiInJack :: openVirtualPort( const std::string portName ) if ( data->port == NULL ) { errorString_ = "MidiInJack::openVirtualPort: JACK error creating virtual port"; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } } @@ -3558,14 +3558,14 @@ std::string MidiInJack :: getPortName( unsigned int portNumber ) // Check port validity if ( ports == NULL ) { errorString_ = "MidiInJack::getPortName: no ports available!"; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); return retStr; } if ( ports[portNumber] == NULL ) { ost << "MidiInJack::getPortName: the 'portNumber' argument (" << portNumber << ") is invalid."; errorString_ = ost.str(); - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); } else retStr.assign( ports[portNumber] ); @@ -3625,7 +3625,7 @@ void MidiOutJack :: initialize( const std::string& clientName ) // Initialize JACK client if (( data->client = jack_client_open( clientName.c_str(), JackNullOption, NULL )) == 0) { errorString_ = "MidiOutJack::initialize: JACK server not running?"; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); return; } @@ -3661,7 +3661,7 @@ void MidiOutJack :: openPort( unsigned int portNumber, const std::string portNam if ( data->port == NULL ) { errorString_ = "MidiOutJack::openVirtualPort: JACK error creating virtual port"; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } // Connecting to the output @@ -3679,7 +3679,7 @@ void MidiOutJack :: openVirtualPort( const std::string portName ) if ( data->port == NULL ) { errorString_ = "MidiOutJack::openVirtualPort: JACK error creating virtual port"; - RtMidi::error( RtError::DRIVER_ERROR, errorString_ ); + RtMidi::error( RtMidiError::DRIVER_ERROR, errorString_ ); } } @@ -3714,14 +3714,14 @@ std::string MidiOutJack :: getPortName( unsigned int portNumber ) // Check port validity if ( ports == NULL) { errorString_ = "MidiOutJack::getPortName: no ports available!"; - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); return retStr; } if ( ports[portNumber] == NULL) { ost << "MidiOutJack::getPortName: the 'portNumber' argument (" << portNumber << ") is invalid."; errorString_ = ost.str(); - RtMidi::error( RtError::WARNING, errorString_ ); + RtMidi::error( RtMidiError::WARNING, errorString_ ); } else retStr.assign( ports[portNumber] ); |
