   DirectSound questions!
  C:\Documents and Settings\Owner\Desktop\AnoMaLY Engine\Sound.cpp(9) : error C2065: ''CLSID_IDirectMusicPerformance'' : undeclared identifierC:\Documents and Settings\Owner\Desktop\AnoMaLY Engine\Sound.cpp(25) : error C2065: ''CLSID_IDirectMusicLoader'' : undeclared identifierC:\Documents and Settings\Owner\Desktop\AnoMaLY Engine\Sound.cpp(32) : error C2065: ''CLSID_IDirectMusicSegment'' : undeclared identifierI''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 workingon 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 thisNULL,//no need for thishwnd,//our main window handle that was passed inDMUS_APATH_SHARED_STEREOPLUSREVERB,//audio path64,//64 channelsDMUS_AUDIOF_ALL,//all synthesizer featuresNULL );//default audio path//Time to create the loader object that will load all the sound filesCoCreateInstance( 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
  Also, I''m not too clear on what''s going on with DirectSound and DirectMusic. Is DirectSound obsolete? Some of the articles use DirectMusic for simple sounds, but I thought it was for music? I just need some clearing up.-Peter ;  Nobody knows anything about DirectSound/DirectMusic?-Peter   [edited by - PoLiSh_Peta on February 8, 2004 10:22:48 AM];  Maybe you''re missing a header file or something. Do you have "objbase.h" "dmusici.h" and "dsound.h" included? Are you linking to "dsound.lib"? I dunno if you need dsound.h, but if you don''t, try including it.DirectSound isn''t obsolete, but Microsoft suggests that you use the components of DirectX Audio to work with sounds now. In DirectSound, you need to parse the wave header, create buffers, and do even more work if you want to stream sounds. DirectX Audio handles most of everything, so you don''t have to do any of this.DirectX Audio has a performance object and a loader object, all you have to do is create segments and use these components to play sounds. It''s a lot easier this way. This is how DirectMusic is designed to work, but now it encompases WAV files so you can basically play WAV sounds with DirectMusic / DirectX Audio interfaces. What you''re doing now is using DirectMusic interfaces to play WAV sounds, which is what Microsoft recommends. ;  Thanks Weston.-Peter 