you have to use an instance of the audio player, there is actually one made for you when using the GameEngine. But you can not instanciate a new instance directly from it. you first have to make a derived class.
like this for example (i'm using it).
GameEngine.h
- Code: Select all
#ifndef GAMEENGINE_H
#define GAMEENGINE_H
#include "./s2d/s2d.h"
class GameEngine : public Engine
{
public:
GameEngine( void* userdata [] );
~GameEngine( void );
result Init( void );
void Free( void );
void Exec( void );
void Exec2( void );
void PreRender( void );
void Render( void );
void PostRender( void );
};
#endif
GameEngine.cpp
- Code: Select all
#include "GameEngine.h"
GameEngine::GameEngine( void* userdata [] ): Engine( userdata )
{
}
GameEngine::~GameEngine( void )
{
}
result GameEngine::Init( void )
{
return S2D_OK;
}
void GameEngine::Free( void )
{
}
void GameEngine::Exec( void )
{
}
void GameEngine::Exec2( void )
{
}
void GameEngine::PreRender( void )
{
}
void GameEngine::Render( void )
{
}
void GameEngine::PostRender( void )
{
}
add these files to your project and in your main cpp file "include" it.
then to make audio work :
- Code: Select all
//somewhere in your init code
//instance
AudioData* SomeSound = new AudioData();
//load a 16000khz, 16 bit signed mono raw pcm file (at least that's what i use and seems to work)
SomeSound ->LoadPCM(_LS("something.snd"));
//somewhere in your "game" loop
//Play the sound, g_pEng is an engine instance of the class above this. You can look up what the values are that are given here
g_pEng->m_pAudioPlayer->Play(SomeSound ,1,SomeSound ->GetSize(),255,false);
//When you quit your "game"
//at the end delete the some sound
SAFE_DELETE(SomeSound);