P
@Volkard
Wusste noch garnicht das das hier dein Wohnzimmer ist
Naja, hier mal meine Klasse:
fmod.h :
#include <fmod.h>
#include <fmod_errors.h>
class CFmod
{
public:
bool Stop();
bool Play();//-1 bei error
bool Load(const char * Path, bool bplay);//läd die Mp3, entweder entpackt sie auf die Festplatte, oder läd sie direkt in den arbeitspeicher
bool InitFmod(HWND Wnd, unsigned int soundchannel);
CFmod();
virtual ~CFmod();
protected:
bool start; // sicherstellen das init aufgerufen wird.
unsigned int channel;
FSOUND_STREAM* m_stream;//fmod variable für das handeln der mp3 datei
char * data; // für die gelandenen daten.
HWND hWnd;// window handle
};
fmod.cpp
#include "Fmod.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Konstruktion/Destruktion
//////////////////////////////////////////////////////////////////////
CFmod::CFmod()
{
hWnd = NULL;
m_stream = NULL;
data = NULL;
channel = 0;
start = false;
}
CFmod::~CFmod()
{
delete [] data;
}
bool CFmod::Load(const char *Path, bool bplay)
{
if(start)
{
if(data!=NULL)
{
delete[] data;
data=NULL;
}
if(bplay)
{
FILE* datei;
int length;
m_stream=NULL;
datei=fopen(Path,"r");
fseek(datei, 0, SEEK_END);
length = ftell(datei);
fseek(datei, 0, SEEK_SET);
data=new char[length];
fread(data, length, 1, datei);
fclose(datei);
m_stream = FSOUND_Stream_OpenFile(data, FSOUND_NORMAL /*| FSOUND_LOOP_NORMAL*/ | FSOUND_2D /*/| FSOUND_MPEGACCURATEFSOUND_LOADMEMORY*/, length);
}
else
{
m_stream = FSOUND_Stream_OpenFile(Path, FSOUND_NORMAL /*| FSOUND_LOOP_NORMAL*/ | FSOUND_2D | FSOUND_MPEGACCURATE, 0);
}
if(!m_stream)
{
m_stream=NULL;
return false;
}
else
return true;
}
}
bool CFmod::Play()//hm, spielt
{
if(start)
{
if(m_stream != NULL)
{
channel = FSOUND_Stream_Play(channel, m_stream);
if (channel < 0)
return false;
else
return true;
}
}
}
bool CFmod::InitFmod(HWND Wnd, unsigned int soundchannel)//Initialisiert FMOD
{
start = true;
hWnd = Wnd;
channel = soundchannel;
int outputfreq = 44100;
int setting_output=0;
int setting_driver=0;
int setting_mixer=0;
setting_output = FSOUND_OUTPUT_DSOUND;
FSOUND_SetBufferSize(200);
FSOUND_SetOutput(setting_output);
FSOUND_SetDriver(setting_driver);
FSOUND_SetMixer(setting_mixer);
FSOUND_SetHWND(hWnd);
FSOUND_Init(outputfreq,128, 0);
if (FSOUND_GetVersion() < FMOD_VERSION)
{
MessageBox(hWnd, FMOD_ErrorString(FSOUND_GetError()),"FMOD FEHLER",MB_OK);
}
if (!FSOUND_Init(44100, 32, FSOUND_INIT_GLOBALFOCUS))
{
MessageBox(hWnd, FMOD_ErrorString(FSOUND_GetError()),"FMOD FEHLER",MB_OK);
return false;
exit(1);
}
return true;
}
bool CFmod::Stop()
{
return FSOUND_Stream_Stop(m_stream);
}
So, das ist meine Klasse, musst noch die fmodvc.lib inkludieren, und die
dll laden. sonst nix.
Devil
[ Dieser Beitrag wurde am 14.11.2002 um 18:48 Uhr von devil81 editiert. ]