📄 audio.h
字号:
// Icer Game Engine v1.0
// Http://www.ngame2000.com
//
//Author:杨冰(源代码之光)
// E-mail: iceryeah2000@163.com
// QQ : 7746642
//
//Module:声音集合类
//
//Create:2003-3-16
//Updata:2003-3-23
//
//Describe:提供声音本身功能函数,比如播放声音等函数。
//Remark: 2003-3-23:Completing all codes
// 2003-4-21:Added WCHAR translate to LPCTSTR,then we can use char directly
#pragma once
#define MUSIC_LOOP -1 //循环标示
#define MUSICTYPE_MP3 1 //文件为mp3
#define MUSICTYPE_NORMAL 2 //文件为WAV/MIDI
class CAudio
{
public:
CAudio(void);
~CAudio(void);
//调入某一音乐文件,参数2可指定音乐格式,参数3指定是否为3d音乐
bool Load(LPCTSTR strFile,DWORD dwType = MUSICTYPE_NORMAL,bool b3DSound = false);
bool Free(void); //释放资源
bool Play(void); //播放
void SetRepeats(DWORD dwRepeats); //当参数为MUSIC_LOOP,循环播放
void Stop(void); //停止
public:
DWORD GetType(void) {return m_dwType;} //获取音乐格式
bool Get3DSound(void) {return m_b3DSound;} //获取是否为3D音乐
DWORD GetRepeats(void) {return m_dwRepeats;} //获取重复次数
bool GetLoopState(void) {return m_bLoop;} //获取是否为循环播放
void SetVolume(long lVolume); //设置音量,参数1取值在-9600~0
long GetVolume(void) {return m_lVolume;}
void SetPos(float fX, float fY, float fZ); //设置声源位置
void SetListenerPos(float fX, float fY, float fZ); //设置收听者位置
IDirectMusicPerformance8* GetPerformance(void) {return m_pPerformance;}
IDirectMusicSegment8* GetSegment(void) {return m_pSegment;}
private:
IDirectMusicLoader8* m_pLoader;
IDirectMusicPerformance8* m_pPerformance;
IDirectMusicSegment8* m_pSegment;
IDirectMusicAudioPath8* m_p3DAudioPath;
IDirectSound3DBuffer8* m_pDSB;
IDirectSound3DListener8* m_pListener;
IMultiMediaStream* m_pMMStreamMp3; //Mp3流
IBasicAudio* m_pBAudioMp3;
IMediaSeeking* m_pMSeekMp3;
DWORD m_dwRepeats; //重复次数
bool m_bLoop; //是否循环播放
bool m_b3DSound;
long m_lVolume;
DWORD m_dwType; //文件类型(MP3,WAV,MIDI)
bool LoadNormalAudio(WCHAR* wstrFile); //调用WAV,MIDI格式
bool LoadMP3Audio(WCHAR* wstrFile); //调用Mp3格式
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -