-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyMidiBase.cpp
56 lines (45 loc) · 1.01 KB
/
MyMidiBase.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <string>
#include <stdio.h>
#include "DirectMidi/CDirectMidi.h"
#include "MyMidi.h"
#pragma comment (lib,"dxguid.lib") // guid definitions
#pragma comment (lib,"winmm.lib")
#pragma comment (lib,"dsound.lib")
#pragma comment (lib,"dxerr8.lib")
using namespace std;
using namespace directmidi;
bool gInitialized = false;
CDirectMusic gDMusic;
string gLastError;
int MyMidi_Init ()
{
if (gInitialized) return 0;
gInitialized = true;
try
{
gDMusic.Initialize();
return 1;
}
catch (CDMusicException& e)
{
MyMidi_SetLastError(__FUNCTION__, e.GetErrorDescription());
}
return 0;
}
const char* MyMidi_GetLastError ()
{
static string buffer = "";
buffer = gLastError;
return buffer.c_str();
}
void MyMidi_ResetLastError ()
{
gLastError = "OK";
}
void MyMidi_SetLastError (const char* source, const char* description)
{
gLastError = source;
gLastError += ": ";
gLastError += description;
printf("MyMidi Error in %s: %s\n", source, description);
}