Initial commit: ROW Client source code
Game client codebase including: - CharacterActionControl: Character and creature management - GlobalScript: Network, items, skills, quests, utilities - RYLClient: Main client application with GUI and event handlers - Engine: 3D rendering engine (RYLGL) - MemoryManager: Custom memory allocation - Library: Third-party dependencies (DirectX, boost, etc.) - Tools: Development utilities 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
111
Tools/SoundLib/DMusic_OggLoader.h
Normal file
111
Tools/SoundLib/DMusic_OggLoader.h
Normal file
@@ -0,0 +1,111 @@
|
||||
|
||||
#ifndef _DMusic_OggLoader_H_
|
||||
#define _DMusic_OggLoader_H_
|
||||
|
||||
#include "STL.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <dmusici.h>
|
||||
|
||||
struct SObjRef;
|
||||
class COGGFile;
|
||||
struct SWaveHeader;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
class COggStream : public IStream, public IDirectMusicGetLoader
|
||||
{
|
||||
public:
|
||||
COggStream();
|
||||
~COggStream();
|
||||
|
||||
HRESULT Attach( LPCTSTR tzFile, IDirectMusicLoader * pLoader );
|
||||
void Detach();
|
||||
|
||||
MUSIC_TIME GetMusicTime();
|
||||
|
||||
//IUnknown methods
|
||||
STDMETHODIMP QueryInterface( REFIID iid, void ** ppv );
|
||||
STDMETHODIMP_(ULONG) AddRef();
|
||||
STDMETHODIMP_(ULONG) Release();
|
||||
|
||||
//IDirectMusicGetLoader
|
||||
STDMETHODIMP GetLoader( IDirectMusicLoader ** ppLoader );
|
||||
|
||||
//IStream methods
|
||||
STDMETHODIMP Read( void * pv, ULONG cb, ULONG * pcb );
|
||||
STDMETHODIMP Seek( LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER * plibNewPosition );
|
||||
STDMETHODIMP Clone( IStream ** ppstm );
|
||||
|
||||
//구현할 필요가 없는 것들...
|
||||
STDMETHODIMP Write( const void *, ULONG, ULONG * ) { return E_NOTIMPL; }
|
||||
STDMETHODIMP SetSize( ULARGE_INTEGER ) { return E_NOTIMPL; }
|
||||
STDMETHODIMP CopyTo( IStream *, ULARGE_INTEGER, ULARGE_INTEGER *, ULARGE_INTEGER * ) { return E_NOTIMPL; }
|
||||
STDMETHODIMP Commit( DWORD ) { return E_NOTIMPL; }
|
||||
STDMETHODIMP Revert() { return E_NOTIMPL; }
|
||||
STDMETHODIMP LockRegion( ULARGE_INTEGER, ULARGE_INTEGER, DWORD ) { return E_NOTIMPL; }
|
||||
STDMETHODIMP UnlockRegion( ULARGE_INTEGER, ULARGE_INTEGER, DWORD ) { return E_NOTIMPL; }
|
||||
STDMETHODIMP Stat( STATSTG *, DWORD ) { return E_NOTIMPL; }
|
||||
|
||||
private:
|
||||
LONG m_cRef; //COM Reference Count
|
||||
IDirectMusicLoader * m_pLoader; //Owning loader object
|
||||
COGGFile * m_pOggFile;
|
||||
|
||||
SWaveHeader * m_pWaveHeader;
|
||||
DWORD m_TotalWaveBytes;
|
||||
long m_SeekPos; //OGG 데이터 앞에 헤더를 붙여서 관리해야 하므로 Seek포인터를 따로 만듬.
|
||||
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
class CDMusic_OggLoader : public IDirectMusicLoader8
|
||||
{
|
||||
public:
|
||||
CDMusic_OggLoader();
|
||||
~CDMusic_OggLoader();
|
||||
|
||||
HRESULT Init();
|
||||
void UnInit();
|
||||
|
||||
//IUnknown methods
|
||||
STDMETHODIMP QueryInterface( REFIID iid, void ** ppv );
|
||||
STDMETHODIMP_(ULONG) AddRef();
|
||||
STDMETHODIMP_(ULONG) Release();
|
||||
|
||||
//IDirectMusicLoader methods
|
||||
STDMETHODIMP GetObject( LPDMUS_OBJECTDESC pDesc, REFIID riid, LPVOID FAR * ppv );
|
||||
STDMETHODIMP SetSearchDirectory( REFGUID rguidClass, WCHAR * pwzPath, BOOL fClear );
|
||||
STDMETHODIMP_(void) CollectGarbage();
|
||||
STDMETHODIMP ReleaseObjectByUnknown( IUnknown * pObject );
|
||||
STDMETHODIMP LoadObjectFromFile( REFGUID, REFIID, WCHAR *, void ** );
|
||||
|
||||
//구현할 필요가 없는 것들...
|
||||
STDMETHODIMP SetObject( LPDMUS_OBJECTDESC ) { return E_NOTIMPL; }
|
||||
STDMETHODIMP ScanDirectory( REFGUID, WCHAR *, WCHAR * ) { return E_NOTIMPL; }
|
||||
STDMETHODIMP CacheObject( IDirectMusicObject * ) { return E_NOTIMPL; }
|
||||
STDMETHODIMP ReleaseObject( IDirectMusicObject * ) { return E_NOTIMPL; }
|
||||
STDMETHODIMP ClearCache( REFGUID ) { return E_NOTIMPL; }
|
||||
STDMETHODIMP EnableCache( REFGUID, BOOL ) { return E_NOTIMPL; }
|
||||
STDMETHODIMP EnumObject( REFGUID, DWORD, LPDMUS_OBJECTDESC ) { return E_NOTIMPL; }
|
||||
|
||||
private:
|
||||
typedef list<SObjRef> LIST_OBJREF;
|
||||
|
||||
LONG m_cRef; //COM Reference count
|
||||
std::wstring * m_pstrSearchPath;
|
||||
LIST_OBJREF * m_pObjList; //List of already loaded objects (the cache.)
|
||||
|
||||
protected:
|
||||
SObjRef * FindCacheObject( LPDMUS_OBJECTDESC pDesc );
|
||||
STDMETHODIMP CreateFromFile( IDirectMusicObject * pObject, WCHAR * wszFileName, MUSIC_TIME * pMusicTime );
|
||||
STDMETHODIMP CreateFromStream( IDirectMusicObject * pObject, IStream * pStream );
|
||||
STDMETHODIMP AddToList( IDirectMusicObject * pObject, LPDMUS_OBJECTDESC pDesc );
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
||||
65
Tools/SoundLib/DirectMusic.h
Normal file
65
Tools/SoundLib/DirectMusic.h
Normal file
@@ -0,0 +1,65 @@
|
||||
|
||||
#ifndef _DirectMusic_H_
|
||||
#define _DirectMusic_H_
|
||||
|
||||
#include "SoundGlobal.h"
|
||||
#include "STL.h"
|
||||
|
||||
class CMusicBuffer;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
class CDirectMusic
|
||||
{
|
||||
private:
|
||||
CDirectMusic( const CDirectMusic & ); //»ç¿ë ¸øÇϵµ·Ï ¸·¾Æ³õÀ½.
|
||||
CDirectMusic & operator=( const CDirectMusic & );
|
||||
|
||||
protected:
|
||||
CDirectMusic();
|
||||
|
||||
protected:
|
||||
IDirectMusicLoader8 * m_pWavLoader;
|
||||
IDirectMusicLoader8 * m_pOggLoader;
|
||||
IDirectMusicPerformance8 * m_pPerformance;
|
||||
bool m_bCOMInitialized;
|
||||
|
||||
IDirectSound3DListener * m_pDSListener;
|
||||
|
||||
typedef std::set<CMusicBuffer*> MUSICBUFFERS;
|
||||
|
||||
MUSICBUFFERS * m_pMusicBuffers;
|
||||
|
||||
protected:
|
||||
void ClearMusicBuffers();
|
||||
void Get3DListener();
|
||||
|
||||
public:
|
||||
static CDirectMusic & GetInstance();
|
||||
~CDirectMusic();
|
||||
|
||||
void Create( HWND, DWORD dwPChannels = 128 );
|
||||
void Destroy();
|
||||
|
||||
void SetSearchDirectory( const char * );
|
||||
void CollectGarbage();
|
||||
|
||||
void SetDoppler( D3DVALUE distance, D3DVALUE doppler );
|
||||
void SetRolloff( D3DVALUE rolloff );
|
||||
void Set3DOrientation( D3DVALUE xFront, D3DVALUE yFront, D3DVALUE zFront
|
||||
, D3DVALUE xTop, D3DVALUE yTop, D3DVALUE zTop );
|
||||
void SetVelocity( D3DVALUE x, D3DVALUE y, D3DVALUE z );
|
||||
void SetPosition( D3DVALUE x, D3DVALUE y, D3DVALUE z );
|
||||
|
||||
CMusicBuffer & NewMusicBuffer();
|
||||
void DeleteMusicBuffer( CMusicBuffer & musicBuffer );
|
||||
|
||||
IDirectMusicLoader8 * GetWavLoader() { return m_pWavLoader; }
|
||||
IDirectMusicLoader8 * GetOggLoader() { return m_pOggLoader; }
|
||||
IDirectMusicPerformance8 * GetPerformance() { return m_pPerformance; }
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
||||
57
Tools/SoundLib/DirectSound.h
Normal file
57
Tools/SoundLib/DirectSound.h
Normal file
@@ -0,0 +1,57 @@
|
||||
|
||||
#ifndef _DirectSound_H_
|
||||
#define _DirectSound_H_
|
||||
|
||||
#include "SoundGlobal.h"
|
||||
#include "STL.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
// 다이렉트 사운드 객체
|
||||
|
||||
class CDirectSound
|
||||
{
|
||||
IDirectSound8 * m_pDSound;
|
||||
IDirectSound3DListener * m_p3DListener;
|
||||
bool m_bDSoundCreated;
|
||||
|
||||
typedef std::vector<ISoundObject*> SOUNDBUFFERLIST;
|
||||
SOUNDBUFFERLIST * m_pSoundBufferList;
|
||||
|
||||
private:
|
||||
CDirectSound( const CDirectSound & ); //사용하지 못하도록 막아놨음.
|
||||
CDirectSound & operator=( const CDirectSound & );
|
||||
|
||||
protected:
|
||||
IDirectSound3DListener * Get3DListenerInterface();
|
||||
CDirectSound();
|
||||
void SetPrimaryBufferFormat( DWORD, DWORD, DWORD );
|
||||
|
||||
public:
|
||||
static CDirectSound & GetInstance();
|
||||
~CDirectSound();
|
||||
|
||||
void Create( IDirectSound8 * );
|
||||
void Create( HWND,
|
||||
DWORD,
|
||||
DWORD dwPrimaryChannels = 2,
|
||||
DWORD dwPrimaryFreq = 22050,
|
||||
DWORD dwPrimaryBitRate = 16 );
|
||||
void Destroy();
|
||||
|
||||
void Enable3DSound(); //처음에는 Disable된 상태임
|
||||
|
||||
void SetDoppler( D3DVALUE distance, D3DVALUE doppler );
|
||||
void SetRolloff( D3DVALUE rolloff );
|
||||
void Set3DOrientation( D3DVALUE xFront, D3DVALUE yFront, D3DVALUE zFront
|
||||
, D3DVALUE xTop, D3DVALUE yTop, D3DVALUE zTop );
|
||||
void SetVelocity( D3DVALUE x, D3DVALUE y, D3DVALUE z );
|
||||
void SetPosition( D3DVALUE x, D3DVALUE y, D3DVALUE z );
|
||||
|
||||
void RegisterSoundBuffer( ISoundObject * ); //사운드 버퍼를 제 때에 파괴해주기 위해 등록을 함.(파괴와 동시에 할당됐던 메모리를 반환함)
|
||||
|
||||
IDirectSound8 * GetDS() { return m_pDSound; }
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
||||
63
Tools/SoundLib/MusicBuffer.h
Normal file
63
Tools/SoundLib/MusicBuffer.h
Normal file
@@ -0,0 +1,63 @@
|
||||
|
||||
#ifndef _MusicBuffer_H_
|
||||
#define _MusicBuffer_H_
|
||||
|
||||
#include "SoundObject.h"
|
||||
#include "SoundGlobal.h"
|
||||
#include "STL.h"
|
||||
|
||||
|
||||
typedef struct _DS3DBUFFER DS3DBUFFER;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
class CMusicBuffer : public ISoundObject
|
||||
{
|
||||
protected:
|
||||
IDirectMusicSegment8 * m_pSegment;
|
||||
IDirectMusicAudioPath8* m_pAudioPath;
|
||||
IDirectSound3DBuffer * m_pDS3DBuffer;
|
||||
DS3DBUFFER * m_p3DBufferParam;
|
||||
CDirectMusic * m_pDMusic;
|
||||
|
||||
string * m_pstrFilename;
|
||||
|
||||
protected:
|
||||
CMusicBuffer();
|
||||
virtual ~CMusicBuffer();
|
||||
|
||||
friend CMusicBuffer * NewMusicBuffer();
|
||||
friend void DeleteMusicBuffer( CMusicBuffer * );
|
||||
|
||||
public:
|
||||
void Create( const char * szFilename, bool b3D = false );
|
||||
void Destroy();
|
||||
|
||||
int Play( bool bLoop );
|
||||
void Play( DWORD dwIndex, bool bLoop );
|
||||
void Stop( unsigned );
|
||||
void StopAll();
|
||||
void Reset( unsigned );
|
||||
void ResetAll();
|
||||
HANDLE GetEventNotify() { return 0; }
|
||||
void HandleNotification() {}
|
||||
bool IsAllPlaying();
|
||||
bool IsAllFree();
|
||||
bool IsPlaying( unsigned );
|
||||
|
||||
void Download();
|
||||
|
||||
DWORD GetMemoryUse();
|
||||
bool IsSameFile( const char * );
|
||||
const char * GetFilename();
|
||||
|
||||
eSndObjType GetType() { return SNDOBJTYPE_MUSICBUFFER; }
|
||||
|
||||
void SetPosition( DWORD dwIndex, D3DVALUE x, D3DVALUE y, D3DVALUE z );
|
||||
void SetDistance( DWORD dwIndex, D3DVALUE minDistance, D3DVALUE maxDistance );
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
||||
44
Tools/SoundLib/OggFile.h
Normal file
44
Tools/SoundLib/OggFile.h
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
#ifndef _OggFile_H_
|
||||
#define _OggFile_H_
|
||||
|
||||
#include "SoundFile.h"
|
||||
|
||||
struct OggVorbis_File;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
class COGGFile : public ISoundFile
|
||||
{
|
||||
FILE * m_fp;
|
||||
OggVorbis_File* m_pVF;
|
||||
char * m_pszFilename;
|
||||
|
||||
DWORD m_dwAvgBytesPerSec;
|
||||
|
||||
public:
|
||||
COGGFile();
|
||||
COGGFile( const char * );
|
||||
~COGGFile();
|
||||
|
||||
void Create( const char * );
|
||||
void Destroy();
|
||||
WORD GetBitsPerSample();
|
||||
DWORD GetSamplePerSec();
|
||||
WORD GetChannelCount();
|
||||
DWORD GetSize();
|
||||
void Reset();
|
||||
size_t Read( void * pBuf, size_t readSize );
|
||||
size_t ReadWhole( void * pBuf );
|
||||
|
||||
DWORD SeekWaveData( DWORD offset, eSeekPos );
|
||||
|
||||
double GetTotalTime();
|
||||
|
||||
const char * GetFilename();
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
||||
12
Tools/SoundLib/STL.h
Normal file
12
Tools/SoundLib/STL.h
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
#ifndef _STL_H_
|
||||
#define _STL_H_
|
||||
|
||||
#pragma warning(disable:4786) //STL의 쓸데없는 Warning을 없애기 위한..
|
||||
|
||||
#include <set>
|
||||
#include <map>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#endif
|
||||
65
Tools/SoundLib/SoundBuffer.h
Normal file
65
Tools/SoundLib/SoundBuffer.h
Normal file
@@ -0,0 +1,65 @@
|
||||
|
||||
#ifndef _SoundBuffer_H_
|
||||
#define _SoundBuffer_H_
|
||||
|
||||
#include "SoundObject.h"
|
||||
#include "SoundGlobal.h"
|
||||
#include "STL.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
class CSoundBuffer : public ISoundObject
|
||||
{
|
||||
protected:
|
||||
IDirectSoundBuffer8 * m_pDSBuffer8;
|
||||
IDirectSoundBuffer ** m_apDSBuffer;
|
||||
IDirectSound3DBuffer** m_ap3DBuffer;
|
||||
ISoundFile * m_pSoundFile;
|
||||
DWORD m_dwDSBufferSize;
|
||||
DWORD m_dwNumBuffers;
|
||||
|
||||
private:
|
||||
CSoundBuffer( const CSoundBuffer & ); //사용하지 못하도록 막아놨음.
|
||||
CSoundBuffer & operator=( const CSoundBuffer & );
|
||||
|
||||
protected:
|
||||
bool Restore( IDirectSoundBuffer* );
|
||||
void FillBufferWithSound( IDirectSoundBuffer * );
|
||||
IDirectSound3DBuffer * Get3DBufferInterface( DWORD dwIndex );
|
||||
int GetFreeBuffer();
|
||||
|
||||
public:
|
||||
CSoundBuffer();
|
||||
CSoundBuffer( IDirectSound8 *, ISoundFile *, bool b3DSound, DWORD dwNumBuffers = 10 );
|
||||
CSoundBuffer( IDirectSound8 *, const char *, bool b3DSound, DWORD dwNumBuffers = 10 );
|
||||
virtual ~CSoundBuffer();
|
||||
|
||||
virtual void Create( IDirectSound8 *, ISoundFile *, bool b3DSound, DWORD dwNumBuffers = 10, DWORD dwAddFlag = 0 );
|
||||
virtual void Create( IDirectSound8 *, const char *, bool b3DSound, DWORD dwNumBuffers = 10, DWORD dwAddFlag = 0 );
|
||||
virtual void Destroy();
|
||||
virtual int Play( bool bLoop );
|
||||
virtual void Play( DWORD dwIndex, bool bLoop );
|
||||
virtual void Stop( unsigned );
|
||||
virtual void StopAll();
|
||||
virtual void Reset( unsigned );
|
||||
virtual void ResetAll();
|
||||
virtual HANDLE GetEventNotify() { return 0; }
|
||||
virtual void HandleNotification() {}
|
||||
virtual bool IsAllPlaying();
|
||||
virtual bool IsAllFree();
|
||||
virtual bool IsPlaying( unsigned );
|
||||
|
||||
virtual DWORD GetMemoryUse();
|
||||
virtual bool IsSameFile( const char * );
|
||||
virtual const char * GetFilename();
|
||||
|
||||
virtual eSndObjType GetType() { return SNDOBJTYPE_SOUNDBUFFER; }
|
||||
|
||||
void SetPosition( DWORD dwIndex, D3DVALUE x, D3DVALUE y, D3DVALUE z );
|
||||
void SetDistance( DWORD dwIndex, D3DVALUE minDistance, D3DVALUE maxDistance );
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
||||
45
Tools/SoundLib/SoundFile.h
Normal file
45
Tools/SoundLib/SoundFile.h
Normal file
@@ -0,0 +1,45 @@
|
||||
|
||||
#ifndef _SoundFile_H_
|
||||
#define _SoundFile_H_
|
||||
|
||||
typedef unsigned long DWORD;
|
||||
typedef unsigned short WORD;
|
||||
typedef unsigned int size_t;
|
||||
typedef struct _iobuf FILE;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
class ISoundFile
|
||||
{
|
||||
public:
|
||||
enum eSeekPos
|
||||
{
|
||||
seek_begin,
|
||||
seek_current,
|
||||
seek_end
|
||||
};
|
||||
|
||||
public:
|
||||
static ISoundFile * CreateSoundFileInstance( const char * szFilename );
|
||||
|
||||
public:
|
||||
virtual ~ISoundFile() {}
|
||||
|
||||
virtual void Create( const char * ) = 0;
|
||||
virtual void Destroy() = 0;
|
||||
virtual WORD GetBitsPerSample() = 0;
|
||||
virtual DWORD GetSamplePerSec() = 0;
|
||||
virtual WORD GetChannelCount() = 0;
|
||||
virtual DWORD GetSize() = 0;
|
||||
virtual void Reset() = 0;
|
||||
virtual size_t Read( void * pBuf, size_t readSize ) = 0;
|
||||
virtual size_t ReadWhole( void * pBuf ) = 0;
|
||||
|
||||
virtual const char * GetFilename() = 0;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#endif
|
||||
47
Tools/SoundLib/SoundGlobal.h
Normal file
47
Tools/SoundLib/SoundGlobal.h
Normal file
@@ -0,0 +1,47 @@
|
||||
|
||||
#ifndef _SoundGlobal_H_
|
||||
#define _SoundGlobal_H_
|
||||
|
||||
//#pragma warning( disable:6311 )
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
typedef struct HWND__* HWND;
|
||||
typedef unsigned long DWORD;
|
||||
typedef void * HANDLE;
|
||||
typedef float D3DVALUE;
|
||||
|
||||
#define WAVEFILEEXT ".wav"
|
||||
#define WAVEFILEEXT2 ".mnd"
|
||||
#define OGGFILEEXT ".ogg"
|
||||
#define FAKEFILEEXT ".z3s"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
struct IDirectSound8;
|
||||
struct IDirectSound3DListener;
|
||||
struct IDirectSound8;
|
||||
struct IDirectSoundBuffer8;
|
||||
struct IDirectSoundBuffer;
|
||||
struct IDirectSound3DBuffer;
|
||||
struct IDirectMusicSegment8;
|
||||
struct IDirectMusicLoader8;
|
||||
struct IDirectMusicPerformance8;
|
||||
typedef struct IDirectMusicAudioPath IDirectMusicAudioPath8;
|
||||
class ISoundFile;
|
||||
class ISoundObject;
|
||||
class CDirectMusic;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
void SNDError( const char * Msg, ... );
|
||||
void SNDError_Debug( const char * Msg, ... );
|
||||
bool IsFileExist2( const char * szFilename );
|
||||
bool IsWaveFile( const char * szFilename );
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
||||
114
Tools/SoundLib/SoundManager.h
Normal file
114
Tools/SoundLib/SoundManager.h
Normal file
@@ -0,0 +1,114 @@
|
||||
|
||||
|
||||
#ifndef _SoundManager_H_
|
||||
#define _SoundManager_H_
|
||||
|
||||
#include "STL.h"
|
||||
#include "SoundGlobal.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
// 전방 참조
|
||||
|
||||
#define DSSCL_NORMAL 0x00000001
|
||||
#define DSSCL_PRIORITY 0x00000002
|
||||
#define DSSCL_EXCLUSIVE 0x00000003
|
||||
#define DSSCL_WRITEPRIMARY 0x00000004
|
||||
|
||||
class ISoundObject;
|
||||
class CSoundBuffer;
|
||||
class CDirectSound;
|
||||
class CDirectMusic;
|
||||
class IStreamHandler;
|
||||
struct CompareResource;
|
||||
typedef struct HWND__* HWND;
|
||||
typedef unsigned long DWORD;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
// 기본적으로 메모리 사용 한계는 5MB로 잡혀있음.
|
||||
|
||||
class CSoundManager
|
||||
{
|
||||
public:
|
||||
typedef void (*REPORTFUNC)( const char * );
|
||||
|
||||
public:
|
||||
enum eState
|
||||
{
|
||||
STATE_USING,
|
||||
STATE_UNUSE,
|
||||
STATE_DELETED
|
||||
};
|
||||
|
||||
struct Resource
|
||||
{
|
||||
int used; //몇 번이나 사용 됐는가?
|
||||
DWORD time; //사용이 시작 시간 또는 사용이 끝난 시각 또는 폐기된 시각
|
||||
ISoundObject * pSndBuf;
|
||||
eState state;
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
typedef map<string, Resource*> RESOURCES; //Using, Unuse 리스트들에서 Resource를 참조해야 하므로 여기에 Resource의 포인터로 저장함.
|
||||
typedef set<Resource*> RESLIST;
|
||||
|
||||
|
||||
protected:
|
||||
CDirectSound & m_DSound;
|
||||
CDirectMusic & m_DMusic;
|
||||
|
||||
bool m_bDSoundEnable;
|
||||
bool m_bDMusicEnable;
|
||||
|
||||
CompareResource * m_pComparer;
|
||||
|
||||
RESOURCES * m_pResources;
|
||||
RESLIST * m_pUsingList;
|
||||
RESLIST * m_pUnuseList;
|
||||
RESLIST * m_pDeletedList;
|
||||
|
||||
IStreamHandler* m_pStreamUpdater;
|
||||
|
||||
REPORTFUNC ReportFunc; //디버그용 리포트 함수
|
||||
|
||||
protected:
|
||||
CSoundManager();
|
||||
|
||||
void Caching();
|
||||
RESLIST * GetListOfState( eState );
|
||||
eState GetStateOfList( RESLIST * );
|
||||
void MoveResourceTo( Resource &, RESLIST * );
|
||||
void CreateSoundBuffer( Resource &, const char *, bool, bool, int, DWORD );
|
||||
Resource & AddResource( const char * szFilename, bool b3DSound, bool bStream, int, DWORD );
|
||||
void UseResource( Resource & res );
|
||||
void UnuseResource( Resource & res );
|
||||
|
||||
public:
|
||||
//--------------인터페이스---------------//
|
||||
static CSoundManager & GetInstance();
|
||||
~CSoundManager();
|
||||
|
||||
void Create( HWND, DWORD = DSSCL_PRIORITY );
|
||||
void Destroy();
|
||||
|
||||
void SetMemoryLimit( DWORD limit ) {}
|
||||
void SetReportFunc( REPORTFUNC func ) { ReportFunc = func; } //디버그용
|
||||
|
||||
CDirectSound & GetDirectSound();
|
||||
CDirectMusic & GetDirectMusic() { return m_DMusic; }
|
||||
DWORD GetMemoryUse() {}
|
||||
ISoundObject & GetBuffer( const char * szFilename,
|
||||
bool b3DSound = false,
|
||||
bool bStream = false,
|
||||
int nBuf = 10,
|
||||
DWORD dwAddFlag = 0 );
|
||||
bool ReleaseBuffer( ISoundObject & ) { return false; }
|
||||
|
||||
void Update(); //StreamBuffer를 하나라도 쓸 경우에만..
|
||||
//----------------------------------------//
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
||||
39
Tools/SoundLib/SoundObj_None.h
Normal file
39
Tools/SoundLib/SoundObj_None.h
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
#ifndef _SoundObj_None_H_
|
||||
#define _SoundObj_None_H_
|
||||
|
||||
#include "SoundObject.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
class CSoundObj_None : public ISoundObject
|
||||
{
|
||||
public:
|
||||
void Destroy() {}
|
||||
|
||||
int Play( bool bLoop ) { return 0; }
|
||||
void Play( DWORD dwIndex, bool bLoop ) {}
|
||||
void Stop( unsigned ) {}
|
||||
void StopAll() {}
|
||||
void Reset( unsigned ) {}
|
||||
void ResetAll() {}
|
||||
HANDLE GetEventNotify() { return 0; }
|
||||
void HandleNotification() {}
|
||||
bool IsAllPlaying() { return false; }
|
||||
bool IsAllFree() { return true; }
|
||||
bool IsPlaying( unsigned ) { return false; }
|
||||
|
||||
DWORD GetMemoryUse() { return 0; }
|
||||
bool IsSameFile( const char * ) { return false; }
|
||||
const char * GetFilename() { return 0; }
|
||||
|
||||
eSndObjType GetType() { return SNDOBJTYPE_SOUNDOBJNONE; }
|
||||
|
||||
void SetPosition( DWORD dwIndex, D3DVALUE x, D3DVALUE y, D3DVALUE z ) {}
|
||||
void SetDistance( DWORD dwIndex, D3DVALUE minDistance, D3DVALUE maxDistance ) {}
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
||||
49
Tools/SoundLib/SoundObject.h
Normal file
49
Tools/SoundLib/SoundObject.h
Normal file
@@ -0,0 +1,49 @@
|
||||
|
||||
#ifndef _SoundObject_H_
|
||||
#define _SoundObject_H_
|
||||
|
||||
#include "SoundGlobal.h"
|
||||
|
||||
enum eSndObjType
|
||||
{
|
||||
SNDOBJTYPE_SOUNDBUFFER,
|
||||
SNDOBJTYPE_STREAMBUFFER,
|
||||
SNDOBJTYPE_MUSICBUFFER,
|
||||
SNDOBJTYPE_SOUNDOBJNONE
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
class ISoundObject
|
||||
{
|
||||
public:
|
||||
virtual ~ISoundObject() {}
|
||||
|
||||
virtual void Destroy() = 0;
|
||||
|
||||
virtual int Play( bool bLoop ) = 0;
|
||||
virtual void Play( DWORD dwIndex, bool bLoop ) = 0;
|
||||
virtual void Stop( unsigned ) = 0;
|
||||
virtual void StopAll() = 0;
|
||||
virtual void Reset( unsigned ) = 0;
|
||||
virtual void ResetAll() = 0;
|
||||
virtual HANDLE GetEventNotify() { return 0; }
|
||||
virtual void HandleNotification() {}
|
||||
virtual bool IsAllPlaying() = 0;
|
||||
virtual bool IsAllFree() = 0;
|
||||
virtual bool IsPlaying( unsigned ) = 0;
|
||||
|
||||
virtual DWORD GetMemoryUse() = 0;
|
||||
virtual bool IsSameFile( const char * ) = 0;
|
||||
virtual const char * GetFilename() = 0;
|
||||
|
||||
virtual eSndObjType GetType() = 0;
|
||||
|
||||
virtual void SetPosition( DWORD dwIndex, D3DVALUE x, D3DVALUE y, D3DVALUE z ) = 0;
|
||||
virtual void SetDistance( DWORD dwIndex, D3DVALUE minDistance, D3DVALUE maxDistance ) = 0;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
||||
46
Tools/SoundLib/StreamBuffer.h
Normal file
46
Tools/SoundLib/StreamBuffer.h
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
#ifndef _StreamBuffer_H_
|
||||
#define _StreamBuffer_H_
|
||||
|
||||
#include "SoundBuffer.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
class CStreamBuffer : public CSoundBuffer
|
||||
{
|
||||
protected:
|
||||
DWORD m_dwLastPlayPos;
|
||||
DWORD m_dwPlayProgress;
|
||||
DWORD m_dwNotifySize;
|
||||
DWORD m_dwNextWriteOffset;
|
||||
HANDLE m_hNotificationEvent;
|
||||
bool m_bFillNextNotificationWithSilence;
|
||||
bool m_bLoopPlay;
|
||||
|
||||
private:
|
||||
CStreamBuffer( const CStreamBuffer & ); //사용하지 못하도록 막아놨음.
|
||||
CStreamBuffer & operator=( const CStreamBuffer & );
|
||||
|
||||
public:
|
||||
CStreamBuffer();
|
||||
CStreamBuffer( IDirectSound8 *, ISoundFile *, bool b3DSound, DWORD dwNumBuffers = 10 );
|
||||
CStreamBuffer( IDirectSound8 *, const char *, bool b3DSound, DWORD dwNumBuffers = 10 );
|
||||
~CStreamBuffer();
|
||||
|
||||
void Create( IDirectSound8 *, ISoundFile *, bool b3DSound, DWORD dwNumBuffers = 10, DWORD dwAddFlag = 0 );
|
||||
void Create( IDirectSound8 *, const char *, bool b3DSound, DWORD dwNumBuffers = 10, DWORD dwAddFlag = 0 );
|
||||
void Destroy();
|
||||
int Play( bool bLoop );
|
||||
void Play( DWORD dwIndex, bool bLoop );
|
||||
void Reset( unsigned );
|
||||
void ResetAll();
|
||||
HANDLE GetEventNotify() { return m_hNotificationEvent; }
|
||||
void HandleNotification();
|
||||
|
||||
eSndObjType GetType() { return SNDOBJTYPE_STREAMBUFFER; }
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
||||
91
Tools/SoundLib/StreamHandler.h
Normal file
91
Tools/SoundLib/StreamHandler.h
Normal file
@@ -0,0 +1,91 @@
|
||||
|
||||
#ifndef _StreamHandler_H_
|
||||
#define _StreamHandler_H_
|
||||
|
||||
#include "STL.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Àü¹æ ÂüÁ¶
|
||||
|
||||
class CStreamBuffer;
|
||||
|
||||
typedef unsigned long DWORD;
|
||||
typedef void * HANDLE;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
class IStreamHandler
|
||||
{
|
||||
public:
|
||||
virtual ~IStreamHandler() {}
|
||||
|
||||
virtual void Create() = 0;
|
||||
virtual void Destroy() = 0;
|
||||
virtual void Add( CStreamBuffer & ) = 0;
|
||||
virtual void Remove( CStreamBuffer & ) = 0;
|
||||
virtual void Update() = 0;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
class CStreamHandler : public IStreamHandler
|
||||
{
|
||||
public:
|
||||
typedef vector<HANDLE> HANDLES;
|
||||
typedef vector<CStreamBuffer*> STREAMBUFFERS;
|
||||
|
||||
protected:
|
||||
HANDLES * m_pHandles;
|
||||
STREAMBUFFERS * m_pStreamBuffers;
|
||||
DWORD m_dwNotifyThreadID;
|
||||
HANDLE m_hNotifyThread;
|
||||
|
||||
friend DWORD __stdcall NotificationProc( void * );
|
||||
|
||||
void UpdateStreamHandles();
|
||||
|
||||
public:
|
||||
CStreamHandler();
|
||||
~CStreamHandler();
|
||||
|
||||
void Create();
|
||||
void Destroy();
|
||||
|
||||
void Add( CStreamBuffer & );
|
||||
void Remove( CStreamBuffer & );
|
||||
void Update() {}
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
class CStreamUpdater : public IStreamHandler
|
||||
{
|
||||
public:
|
||||
typedef vector<HANDLE> HANDLES;
|
||||
typedef vector<CStreamBuffer*> STREAMBUFFERS;
|
||||
|
||||
protected:
|
||||
HANDLES * m_pHandles;
|
||||
STREAMBUFFERS * m_pStreamBuffers;
|
||||
|
||||
public:
|
||||
CStreamUpdater();
|
||||
~CStreamUpdater();
|
||||
|
||||
void Create();
|
||||
void Destroy();
|
||||
|
||||
void Add( CStreamBuffer & );
|
||||
void Remove( CStreamBuffer & );
|
||||
|
||||
void Update();
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
||||
37
Tools/SoundLib/WavFile.h
Normal file
37
Tools/SoundLib/WavFile.h
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
#ifndef _WavFile_H_
|
||||
#define _WavFile_H_
|
||||
|
||||
#include "SoundFile.h"
|
||||
|
||||
class CWaveFile;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
class CWavFile : public ISoundFile
|
||||
{
|
||||
CWaveFile * m_pWaveFile;
|
||||
char * m_pszFilename;
|
||||
|
||||
public:
|
||||
CWavFile();
|
||||
CWavFile( const char * );
|
||||
~CWavFile();
|
||||
|
||||
void Create( const char * );
|
||||
void Destroy();
|
||||
WORD GetBitsPerSample();
|
||||
DWORD GetSamplePerSec();
|
||||
WORD GetChannelCount();
|
||||
DWORD GetSize();
|
||||
void Reset();
|
||||
size_t Read( void * pBuf, size_t readSize );
|
||||
size_t ReadWhole( void * pBuf );
|
||||
|
||||
const char * GetFilename();
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
||||
64
Tools/SoundLib/Wave.h
Normal file
64
Tools/SoundLib/Wave.h
Normal file
@@ -0,0 +1,64 @@
|
||||
|
||||
#ifndef _Wave_H_
|
||||
#define _Wave_H_
|
||||
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#include <mmreg.h>
|
||||
|
||||
|
||||
#define WAVEFILE_READ 1
|
||||
#define WAVEFILE_WRITE 2
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Miscellaneous helper functions
|
||||
//-----------------------------------------------------------------------------
|
||||
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
|
||||
#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }
|
||||
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CWaveFile
|
||||
// Desc: Encapsulates reading or writing sound data to or from a wave file
|
||||
//-----------------------------------------------------------------------------
|
||||
class CWaveFile
|
||||
{
|
||||
public:
|
||||
WAVEFORMATEX* m_pwfx; // Pointer to WAVEFORMATEX structure
|
||||
HMMIO m_hmmio; // MM I/O handle for the WAVE
|
||||
MMCKINFO m_ck; // Multimedia RIFF chunk
|
||||
MMCKINFO m_ckRiff; // Use in opening a WAVE file
|
||||
DWORD m_dwSize; // The size of the wave file
|
||||
MMIOINFO m_mmioinfoOut;
|
||||
DWORD m_dwFlags;
|
||||
BOOL m_bIsReadingFromMemory;
|
||||
BYTE* m_pbData;
|
||||
BYTE* m_pbDataCur;
|
||||
ULONG m_ulDataSize;
|
||||
|
||||
protected:
|
||||
HRESULT ReadMMIO();
|
||||
HRESULT WriteMMIO( WAVEFORMATEX *pwfxDest );
|
||||
|
||||
public:
|
||||
CWaveFile();
|
||||
~CWaveFile();
|
||||
|
||||
HRESULT Open( LPTSTR strFileName, WAVEFORMATEX* pwfx, DWORD dwFlags );
|
||||
HRESULT OpenFromMemory( BYTE* pbData, ULONG ulDataSize, WAVEFORMATEX* pwfx, DWORD dwFlags );
|
||||
HRESULT Close();
|
||||
|
||||
HRESULT Read( BYTE* pBuffer, DWORD dwSizeToRead, DWORD* pdwSizeRead );
|
||||
HRESULT Write( UINT nSizeToWrite, BYTE* pbData, UINT* pnSizeWrote );
|
||||
LONG Seek( LONG offset, int Origin );
|
||||
|
||||
DWORD GetSize();
|
||||
HRESULT ResetFile();
|
||||
WAVEFORMATEX* GetFormat() { return m_pwfx; };
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user