⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 audiomanager.h

📁 游戏音频程序设计-Beginning.Game.Audio.Programming
💻 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

#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"

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

  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();

  // 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); }
protected:
  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 + -