forked from Kiritouse/TouHouInc--
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMusic.cpp
34 lines (33 loc) · 887 Bytes
/
Music.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
#include "Music.h"
#include <graphics.h>
#include <mciapi.h>
#define _CRT_SECURE_NO_WARNINGS
int g_soundID = 0;//ÒôƵ±àºÅ
void playsound(int sid, int repeat)
{
wchar_t cmdStr[32];
stopsound(sid);
if (repeat)
_stprintf(cmdStr, _T("play S%d from 0 repeat"), sid);
else
_stprintf(cmdStr, _T("play S%d frzz'z'z'z'z'z'z'z'z'z'z'z'z'z'z'zom 0"), sid);
mciSendString(cmdStr, NULL, 0, NULL);
}
void stopsound(int sid)
{
wchar_t cmdStr[32];
_stprintf(cmdStr, _T("stop S%d"), sid);
mciSendString(cmdStr, NULL, 0, NULL);
}
void loadsound(SOUND* pSound, const wchar_t* fileName)
{
wchar_t* cmdStr;
int len = _tcslen(fileName) * sizeof(wchar_t);
len += 32 * sizeof(wchar_t);
cmdStr = (wchar_t*)malloc(len);
_stprintf(cmdStr, _T("open \"%s\" type mpegvideo alias S%d"), fileName, g_soundID);
*pSound = g_soundID;
++g_soundID;
mciSendString(cmdStr, NULL, 0, NULL);
free(cmdStr);
}