📄 audiomanager.h
字号:
// AudioManager.h: interface for the CAudioManager class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_AUDIOMANAGER_H__4F8006D7_B974_48C4_9E08_262617786C8D__INCLUDED_)
#define AFX_AUDIOMANAGER_H__4F8006D7_B974_48C4_9E08_262617786C8D__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#pragma warning(disable: 4786)
#include <windows.h>
#include <mmreg.h>
#include <dmusicc.h>
#include <dmusici.h>
#include <dsound.h>
#include "dxutil.h"
#include <dshow.h>
#include "ErrorHandling.h"
#include "SoundEffect.h"
#include "MIDIMusic.h"
#include "WAVFile.h"
#include "Mixer.h"
#include "NotificationHandler.h"
#include "MP3AudioTag.h"
#include "MP3.h"
#include "TrackedMusic.h"
#include "DynamicMusic.h"
#include "AudioScript.h"
#include "3DSoundEffect.h"
#include "3DSoundListener.h"
namespace AudioEngine {
class CAudioManager
{
public:
enum { NUMCHANNELS = 128 };
CAudioManager();
virtual ~CAudioManager();
void Init(HWND hwnd, bool stereo = true, int perfchannels = NUMCHANNELS);
void UnInit();
// loading routines
CSoundPtr LoadSound(std::string filename); // from disk
CSoundPtr LoadSound(const CWAVFile &wavfile); // from a WAV file class
CSoundPtr LoadSound(unsigned char *data, int datalen); // from memory
CSoundPtr LoadSound(HMODULE hmod, char *type, WORD resID); // from resources
CSoundPtr LoadMIDI(std::string filename); // from disk
CSoundPtr LoadMIDI(unsigned char *data, int datalen); // from memory
CSoundPtr LoadMIDI(HMODULE hmod, char *type, WORD resID); // from resources
CSoundPtr LoadMP3(std::string filename); // from disk
CSoundPtr LoadOggVorbis(std::string filename); // from disk
CSoundPtr LoadTrackedMusic(std::string filename); // from disk
CSoundPtr LoadDynamicMusic(std::string filename); // from disk
CSoundPtr LoadDynamicMusic(unsigned char *data, int datalen); // from memory
CSoundPtr LoadDynamicMusic(HMODULE hmod, char *type, WORD resID); // from resources
CAudioScriptPtr LoadScript(std::string filename, std::string name = ""); // from disk
CAudioScriptPtr LoadScript(unsigned char *data, int datalen, std::string name = ""); // from memory
CAudioScriptPtr LoadScript(HMODULE hmod, char *type, WORD resID, std::string name = ""); // from resources
CSoundPtr Load3DSound(std::string filename); // from disk
CSoundPtr Load3DSound(const CWAVFile &wavfile); // from a WAV file class
CSoundPtr Load3DSound(unsigned char *data, int datalen); // from memory
CSoundPtr Load3DSound(HMODULE hmod, char *type, WORD resID); // from resources
CMP3AudioTag GetMP3AudioTag(std::string filename);
void SetSearchDirectory(std::string dirname);
// volume control
void SetVolume(const CVolume &vol);
CVolume GetVolume();
CMixer &GetMixer() { return(m_Mixer); }
// tempo control (note: doesn't work on MP3 or OGG files)
void SetMasterTempoScaleFactor(float value);
float GetMasterTempoScaleFactor();
// groove level control
void SetPerformanceGrooveLevelModifier(int value);
int GetPerformanceGrooveLevelModifier();
// this is for the CSound objects
IDirectMusicPerformance8* GetPerformance() { return(m_Performance); }
// notification handling
void DispatchNotificationMessages(); // call this once per frame in your game
void SetNotificationHandler(CNotificationHandler *handler) { m_NotificationHandler = handler; }
CNotificationHandler *GetNotificationHandler() { return(m_NotificationHandler); }
HANDLE GetNotificationEvent() { return(m_NotificationEvent); }
C3DSoundListener &GetListener() { return(m_Listener); }
void Commit3DSoundParameters() { GetListener().m_Listener->CommitDeferredSettings(); }
protected:
C3DSoundListener m_Listener;
void LoadSegmentFromDisk(CDirectMusicSegment *dest, std::string filename);
void LoadSegmentFromMemory(CDirectMusicSegment *dest, unsigned char *data, int datalen);
void LoadSegmentFromResource(CDirectMusicSegment *dest, HMODULE hmod, char *type, WORD resID);
CMixer m_Mixer;
bool m_InitGood;
IDirectMusicLoader8* m_Loader;
IDirectMusicPerformance8* m_Performance;
CNotificationHandler *m_NotificationHandler;
HANDLE m_NotificationEvent;
};
// client app implements this
extern CAudioManager *GetAudioManager();
} // namespace
#endif // !defined(AFX_AUDIOMANAGER_H__4F8006D7_B974_48C4_9E08_262617786C8D__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -