C:\Documents and Settings\Owner\Desktop\AnoMaLY Engine\Sound.cpp(9) : error C2065: ''CLSID_IDirectMusicPerformance'' : undeclared identifier
C:\Documents and Settings\Owner\Desktop\AnoMaLY Engine\Sound.cpp(25) : error C2065: ''CLSID_IDirectMusicLoader'' : undeclared identifier
C:\Documents and Settings\Owner\Desktop\AnoMaLY Engine\Sound.cpp(32) : error C2065: ''CLSID_IDirectMusicSegment'' : undeclared identifier
I''m getting these errors when I compile this ( did I forget to include something?
):
Also, is this a good way to work with sound or not? I''m working
on an engine, and I''m not sure how to go about doing the sound.
Any help would be appreciated!
#include "GlobalClass.h"
cSOUND::cSOUND( HWND hwnd )
{
//We need to initialize COM first.
CoInitialize( NULL );
//We gotta create the performance object.
CoCreateInstance( CLSID_IDirectMusicPerformance,
NULL,
CLSCTX_INPROC,
IID_IDirectMusicPerformance8,
( void** ) &Performance );
//Time to initialize the performance object.
Performance->InitAudio( NULL,//no need for this
NULL,//no need for this
hwnd,//our main window handle that was passed in
DMUS_APATH_SHARED_STEREOPLUSREVERB,//audio path
64,//64 channels
DMUS_AUDIOF_ALL,//all synthesizer features
NULL );//default audio path
//Time to create the loader object that will load all the sound files
CoCreateInstance( CLSID_IDirectMusicLoader,
NULL,
CLSCTX_INPROC,
IID_IDirectMusicLoader8,
( void** ) &Loader );
//We gotta create a music segment.
CoCreateInstance( CLSID_IDirectMusicSegment,
NULL,
CLSCTX_INPROC,
IID_IDirectMusicSegment8,
( void** ) &Segment);
//Make a function call to load the segment.
LoadSegment();
}
cSOUND::~cSOUND()
{
Performance->CloseDown();
Loader->Release();
Performance->Release();
Segment->Release();
CoUninitialize();
}
cSOUND::LoadSegment()
{
//Set the search directory to the directory the program is in.
char searchPath[ MAX_PATH ];
WCHAR wSearchPath[ MAX_PATH ];
GetCurrentDirectory(MAX_PATH, searchPath);
MultiByteToWideChar(CP_ACP, 0, searchPath, -1, wSearchPath, MAX_PATH);
Loader->SetSearchDirectory( GUID_DirectMusicAllTypes, wSearchPath, FALSE );
//Here''s where we would load a sound segment.
//Here''s an example.
char filename[ MAX_PATH ] = "test.wav";
WCHAR wFilename[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, filename, -1, wFilename, MAX_PATH);
Loader->LoadObjectFromFile( CLSID_DirectMusicSegment,
IID_IDirectMusicSegment8,
wFilename,
( void** ) &Segment);
//We''ll need the sound''s band to play the sound.
Segment->Download( Performance );
}
BOOL cSOUND::PlaySounds()
{
Performance->PlaySegmentEx( Segment, NULL, NULL, 0, 0, NULL, NULL, NULL );
return TRUE;
}
Here''s the header file just in case:
#ifndef Sound_H_
#define Sound_H_
class cSOUND
{
public:
//The constructor will initialize all the stuff. It will take a
//window handle parameter because we''ll need it.
cSOUND( HWND hwnd );
~cSOUND();
BOOL LoadSegment();
BOOL PlaySounds();
private:
//We need a localized window handle so we can initialize
//the performance object.
HWND hWnd;
//These are the objects we need to use DirectXAudio
//This is basically the main interface for the sound.
IDirectMusicPerformance8* Performance;
//This loads the music.
IDirectMusicLoader8* Loader;
//This is the music segment which will encapsulate all our sounds.
IDirectMusicSegment8* Segment;
};
#endif
There are two inevitabilities in life: death and failure.-PoLiSh