-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsound.h
executable file
·48 lines (40 loc) · 1.24 KB
/
sound.h
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
#ifndef __SOUND_H__
#define __SOUND_H__
#include <windows.h>
#include <mmsystem.h>
void reportIfError(MCIERROR err) {
char errstr[1000];
if (err != 0) {
mciGetErrorString(err,errstr,1000);
MessageBox(NULL,errstr,"blah",MB_OK);
}
}
void openMidi(const char *file,const char *alias) {
char cmd[1000];
wsprintf(cmd,"open %s type sequencer alias %s",file,alias);
MCIERROR err = mciSendString(cmd,NULL,0,NULL);
reportIfError(err);
}
void openWav(const char *file,const char *alias) {
char cmd[1000];
wsprintf(cmd,"open %s alias %s %s",file,alias,"");
MCIERROR err = mciSendString(cmd,NULL,0,NULL);
reportIfError(err);
}
//you might want to define a separate playMidiRepeat function...just add repeat at the end of the command string.
void play(const char *alias,bool repeat=false) {
char cmd[1000];
wsprintf(cmd,"play %s %s %s",alias,"",repeat?"repeat":"");
MCIERROR err = mciSendString(cmd,NULL,0,NULL);
reportIfError(err);
}
void stop(const char *alias) {
char cmd[1000];
wsprintf(cmd,"stop %s %s %s",alias,"","");
MCIERROR err = mciSendString(cmd,NULL,0,NULL);
if (err != 0) {
mciGetErrorString(err,cmd,1000);
MessageBox(NULL,cmd,"blah",MB_OK);
}
}
#endif