|
/*
____ _ ____ _____ _____ ______ __ __ _ ____ _
| _ \ | || _ \| __// __//_ _/ | \/ || || _ \ | |
| |_| || || |> /| _| | <__ | | | |\/| || || |_| || |
|____/ |_||_|\_\|____\\____/ |_| |_| |_||_||____/ |_|
////////////////////////////////////////////////////////////////////////
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Copyright (c) 2002-2003 by Carlos Jim�nez de Parga
All rights reserved.
For any suggestion or failure report, please contact me by:
e-mail: cjimenez@servitel.es
Note: I would appreciate very much if you could provide a brief description of your project,
as well as any report on bugs or errors. This will help me improve the code for the benefit of your
application and the other users
///////////////////////////////////////////////////////////////////////
Version: 2.1b
Module : CDMusicException.cpp
Purpose: Code implementation for the CDMusicException class
Created: CJP / 02-08-2002
History: CJP / 03-25-2003
Update: 09/20/2002
1. Improved class destructors
2. Check member variables for NULL values before performing an operation
3. Restructured the class system
4. Better method to enumerate and select MIDI ports
5. Adapted the external thread to a pure virtual function
6. SysEx reception and sending enabled
7. Added flexible conversion functions
8. Find out how to activate the Microsoft software synth.
9. Added DLS support
Update: 03/25/2003
10. Added exception handling
11. Fixed bugs with channel groups
12. Redesigned class hierarchy
13. DirectMidi wrapped in the directmidi namespace
14. UNICODE/MBCS support for instruments and ports
15. Added DELAY effect to software synthesizer ports
16. Project released under GNU (General Public License) terms
*/
#include "CDirectMidi.h"
using namespace directmidi;
// Constructor, passes the error parameters
CDMusicException::CDMusicException(LPCTSTR lpMemberFunc,HRESULT hr,int nLine) throw()
{
m_hrCode = hr;
m_nLine = nLine;
_tcscpy(m_strMethod,lpMemberFunc);
}
// Copies a defined message in the suitable member variable
void CDMusicException::CopyMsg(LPCTSTR strDefMsg)
{
_tcscpy(m_strMessage,strDefMsg);
}
// Obtains the error definition string in the m_strMessage member
void CDMusicException::ObtainErrorString()
{
switch(m_hrCode)
{
case DM_FAILED:
CopyMsg(_T("DM_FAILED: There has been an error during the " \
"object initialization sequence.\nThere is an internal member variable," \
"such as an interface pointer, that it is not assigned"));
break;
case DSERR_NODRIVER:
CopyMsg(_T("DSERR_NODRIVER: No sound driver is available for use, or the" \
"\ngiven GUID is not a valid DirectSound device ID"));
break;
case REGDB_E_CLASSNOTREG:
CopyMsg(_T("REGDB_E_CLASSNOTREG: The specified class is not registered in" \
"\nthe registration database or the register is corrupt"));
break;
case S_FALSE:
CopyMsg(_T("S_FALSE: Error in function call"));
break;
case E_NOINTERFACE:
CopyMsg(_T("E_NOINTERFACE: No object interface is available"));
break;
case E_OUTOFMEMORY:
CopyMsg(_T("E_OUTOFMEMORY: Insufficient memory to complete the task"));
break;
case DMUS_E_PORT_NOT_RENDER:
CopyMsg(_T("DMUS_E_PORT_NOT_RENDER: Fail to render port"));
break;
case DMUS_E_NOT_DOWNLOADED_TO_PORT:
CopyMsg(_T("DMUS_E_NOT_DOWNLOADED_TO_PORT: The object cannot be unloaded" \
"because it is not present on the port"));
break;
case E_NOTIMPL:
CopyMsg(_T("E_NOTIMPL: The method is not implemented. This value might be" \
"\nreturned if a driver does not support a feature necessary for the operation"));
break;
case E_FAIL:
CopyMsg(_T("E_FAIL: The method did not succeed"));
break;
case DMUS_E_LOADER_FAILEDOPEN:
CopyMsg(_T("DMUS_E_LOADER_FAILEDOPEN: File open failed because the file does not exist or is locked"));
break;
case DMUS_E_LOADER_FAILEDCREATE:
CopyMsg(_T("DMUS_E_LOADER_FAILEDCREATE: The object could not be found or created"));
break;
case DMUS_E_LOADER_FORMATNOTSUPPORTED:
CopyMsg(_T("DMUS_E_LOADER_FORMATNOTSUPPORTED: The object cannot be loaded because" \
"\nthe data format is not supported"));
break;
case DMUS_E_LOADER_NOCLASSID:
CopyMsg(_T("No class identifier was supplied in the object description"));
break;
case DMUS_E_INVALIDPATCH:
CopyMsg(_T("DMUS_E_INVALIDPATCH: No instrument in the collection matches the patch number"));
break;
case DMUS_E_NOT_INIT:
CopyMsg(_T("DMUS_E_NOT_INIT: A required object is not initialized or failed to initialize"));
break;
case DMUS_E_DMUSIC_RELEASED:
CopyMsg(_T("DMUS_E_DMUSIC_RELEASED: The operation cannot be performed because the final" \
"instance of the DirectMusic object was released. Ports cannot be used after final" \
"release of the DirectMusic object"));
break;
case DMUS_E_DSOUND_ALREADY_SET:
CopyMsg(_T("A DirectSound object has already been set"));
break;
case DMUS_E_DSOUND_NOT_SET:
CopyMsg(_T("The port could not be created because no DirectSound object has been specified"));
break;
case E_POINTER:
CopyMsg(_T("An invalid pointer, usually NULL, was passed as a parameter"));
break;
case E_INVALIDARG:
CopyMsg(_T("Invalid argument. Often, this error results from failing to initialize the" \
"dwSize member of a structure before passing it to the method"));
break;
case DMUS_E_INVALID_EVENT:
CopyMsg(_T("The event either is not a valid MIDI message or makes use of running" \
"status and cannot be packed into the buffer"));
break;
case DMUS_E_UNKNOWN_PROPERTY:
CopyMsg(_T("The property set or item is not implemented by this port"));
break;
default:
if (!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS
,NULL,m_hrCode, 0, m_strMessage, sizeof(m_strMessage) / sizeof(TCHAR), NULL))
CopyMsg(_T("Undefined error"));
}
}
// Obtains only the error definition
LPCTSTR CDMusicException::ErrorToString() throw()
{
ObtainErrorString();
return m_strMessage;
}
// Returns the error description
LPCTSTR CDMusicException::GetErrorDescription() throw()
{
ObtainErrorString();
// Get an error description using FormatMessage
wsprintf(m_strErrorBuf, _T("Error code: 0x%.8x \n%s\nMember function: %s \nLine: %d"),
m_hrCode, m_strMessage, m_strMethod,m_nLine);
return m_strErrorBuf; // Returns the string description
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I obtained my PhD degree in Computer Graphics at the National Distance Education University (UNED) in October 2019. I also hold a Ms. degree in Software Engineering and Computer Systems and a Bs. degree in Computer Science from the National Distance Education University (UNED).
I have been employed as a C++ software developer in several companies since year 2000.
I currently work as a Tutor-Professor of Symbolic Logic, Discrete Math and Java Object-Oriented Programming at UNED-Cartagena (Spain) since 2015.