DirectAudio and Volume and Balance
Hello
i can´t good speak english, pleas ignore my gramma...
i hav a lot of problems with my DirectAudioCLass.
i will edit the volume, and balance...
i only use DirectMusik interfaces in my source code...
can i use any methode to edit volume and balance like
SetPan() from DIrectSOundBUffer..
..
i post my source codes: pleas ignor that i not use the ungarische notazion because the DirectX SDK names all attribut as global.....thats all:-)
thank you very mutch!!!!!
my source:
//////
///Header-datei
////Comments all in german.sorry
////////////////////////////////
#ifndef _Sound_
#define _Sound_
#include
#include
const float CSOUND_VERSION = 1.2f;
class CSound
{
private:
IDirectMusicLoader8 *g_pLoader;
IDirectMusicPerformance8 *g_pPerformance;
IDirectMusicSegment8 *g_pMusik;
IDirectMusicSegment8 *g_pSound[10];
//3Dversuche
IDirectMusicAudioPath8 **g_p3DAudiopath;
IDirectMusicAudioPath8 * g_Audiopath;
LPDIRECTSOUND8 LPDS;
LPDIRECTSOUNDBUFFER ppDSBuffer;
DWORD dwMaxSound;//MaximaleSounds......
char *bgMusic;//Hintergrund Musik
char *sndEffects[10];//soundeffekteMaximal 10
public:
CSound();
~CSound();
BOOL InizialDSound();/////inizialisiert DS
void LoadDSound(char*);/////läd musik dateien
void LoadSong(char*, int);//////Läd sound dateien
void PlayDSound();///////spielt musik dateien ab..
void PlaySong(int);/////////spielt sound dateien ab...
DWORD DestroyDSound();////////löscht dan den ganzen sumsese
};
#endif
////////////////
////Cpp-file
////////////
#include "Sound.h"
//////////////////////////////////////////////////////////
////Konstruktor//////////////////////////////////////////
////////////////////////////////////////////////////////
CSound::CSound()
{
g_pLoader = NULL;
g_pPerformance = NULL;
g_pMusik = NULL;
ppDSBuffer = NULL;
LPDS = NULL;
//nrEffects = 0;
}
////jetz steh ich hier und warte und seh nirgends ein interface///
//
////////////////////////////////////////////////////
/////////////Destruktor////////////////////////////
//////////////////////////////////////////////////
CSound::~CSound()
{
DestroyDSound();
}
///////////////////////////////////////////////////
/////InitFunktionen///////////////////////////////
/////////////////////////////////////////////////
BOOL CSound::InizialDSound()
{
CoInitialize(NULL);
if ( FAILED(CoCreateInstance(CLSID_DirectMusicLoader, NULL,
CLSCTX_INPROC, IID_IDirectMusicLoader8,
(void**)&g_pLoader)))
return false;
if ( FAILED(CoCreateInstance(CLSID_DirectMusicPerformance, NULL,
CLSCTX_INPROC, IID_IDirectMusicPerformance8,
(void**)&g_pPerformance )))
return false;
/*
/////////////////////////////////////////////////////////////////////////
///////////////////////////////////DIeser 3DANsatz///////////////////////
////////////////////////////////////////////////////////////////////////
g_pPerformance->GetDefaultAudioPath (g_p3DAudiopath) ;//audiopath wichtig für diesen schrott
IDirectSound3DListener8 *pListener;
g_Audiopath->GetObjectInPath(0, DMUS_PATH_PRIMARY_BUFFER,
0, GUID_All_Objects, 0, IID_IDirectSound3DListener,
(void **)&pListener);
/////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
*/
g_pPerformance->InitAudio
(
NULL,
NULL,
NULL, // muss wohl das hWnd setzen.oder?
DMUS_APATH_DYNAMIC_STEREO,
64, // reicht doch.oder?????
DMUS_AUDIOF_ALL, //alles was DS kann reicht das????
NULL //wenn da irgendwas spezielles hin raus damit
);
WCHAR wstrSearchPath[MAX_PATH];
MultiByteToWideChar( CP_ACP, 0,"c:\\", -1, ////wo befindet sich musik ????
wstrSearchPath, MAX_PATH );
g_pLoader->SetSearchDirectory(
GUID_DirectMusicAllTypes, //alle type können geladen werden
wstrSearchPath, //pfadangabe
FALSE //die daten befinden sich sicher in einem ordner
);
return true;
}
/////////////////////////////////////////////////////////////
//////////LoadBackroundMusikFunktion////////////////////////
///////////////////////////////////////////////////////////
void CSound::LoadDSound(char* p_Name)
{
//ppDSBuffer->GetPan(870);//870 oder 10000 sind extremwerte
ppDSBuffer->SetPan(870);//-2173 oder 870 sind extremwere
WCHAR wstrFileName[MAX_PATH];
MultiByteToWideChar( CP_ACP, 0,p_Name, -1, ////wo befinden sich die wav´s ????
wstrFileName, MAX_PATH );
if (FAILED(g_pLoader->LoadObjectFromFile(
CLSID_DirectMusicSegment,
IID_IDirectMusicSegment8,
wstrFileName,
(LPVOID*) &g_pMusik)))//p_pSegment
{
MessageBox( NULL, "Fehler beim Laden der Datei",
"LoadDMusik", MB_OK );
}
}
////////////////////////////////////////////////////////////////////
///////////////////LoadSoundFunktion/////////////////////////////////------------------------------------------------------>noch machen
////////////////////////////////////////////////////////////////////
void CSound::LoadSong(char* p_Name, int nrEffects)
{
HRESULT GetPan(870);//870 oder 10000 sind extremwerte
HRESULT SetPan(-2173);//-2173 oder 870 sind extremwere
if(nrEffects >= 10)
{
MessageBox(NULL,"Max-Anzahl an sound erreicht!","LoadSound", MB_OK );
return;
}
WCHAR wstrFileName[MAX_PATH];
MultiByteToWideChar(CP_ACP,0,p_Name,-1,wstrFileName,MAX_PATH);
if (FAILED(g_pLoader->LoadObjectFromFile(
CLSID_DirectMusicSegment,
IID_IDirectMusicSegment8,
wstrFileName,
(LPVOID*) &g_pSound[nrEffects])))
{
MessageBox( NULL, "Fehler beim Laden der Datei",
"LoadSound", MB_OK );
}
g_pSound[nrEffects]->Download( g_pPerformance );
sndEffects[nrEffects] = strdup(p_Name);
//nrEffects++;
}
/////////////////////////////////////////////////////////////////////
////PlayFunktion////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
void CSound:layDSound()
{
g_pMusik->Download( g_pPerformance );
HRESULT GetPan(10000);//870 oder 10000 sind extremwerte
// HRESULT SetPan(870);//-2173 oder 870 sind extremwere
g_pPerformance->PlaySegmentEx(
g_pMusik,
NULL,
NULL,
DMUS_SEGF_SECONDARY,
0,
NULL,
NULL,
NULL
);
}
//////////////////////////////////////////////////////////////////////////
///////////PlaySong///////////////////////////////////////////////////////------------------>machen
//////////////////////////////////////////////////////////////////////////
void CSound:laySong(int nrEffects)
{
// g_pMusik->Download( g_pPerformance );
HRESULT GetPan(870);//870 oder 10000 sind extremwerte
HRESULT SetPan(870);//-2173 oder 870 sind extremwere
g_pPerformance->PlaySegmentEx(
g_pSound[nrEffects],
NULL,
NULL,
DMUS_SEGF_SECONDARY,
0,
NULL,
NULL,
NULL
);
}
///////////////////////////////////////////////////////////////////////
///LöschFUnktion//////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
DWORD CSound::DestroyDSound()
{
int i=0;
g_pPerformance->Stop(NULL,NULL,0,0);
g_pPerformance->CloseDown();
g_pPerformance->Release();
g_pPerformance = NULL;
g_pLoader->Release();
g_pLoader = NULL;
/*
g_pMusik->Release();
g_pMusik = NULL;
*//* while (i<=nrEffects)
{
g_pSound->Release();
g_pSound = NULL;
i++;
} ;*/
return 0;
}
</i>
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement