26 #include <fmod_errors.h>
40 SetValues(
"SoundSystem",
"Sound System",
true,
false);
54 soundsys->set3DSettings(1.0f, 3.28f, 1.0f);
60 SetValues(
"SoundSystem",
"Sound System",
true,
false);
71 for (
size_t i = 0; i <
sounds.size(); i++)
151 soundsys->set3DListenerAttributes(0, &pos, &vel, &forward, &up);
159 #ifndef DISABLE_SOUND
187 soundsys->set3DListenerAttributes(0, &pos, &vel, &forward, &up);
196 Report(
"Cleaning up unused sounds");
200 if (
sounds[index]->handles.size() == 0)
210 if (
sounds[i]->handles.size() == 0)
226 unsigned int length = 0;
228 data->
sound->getLength(&length, FMOD_TIMEUNIT_MS);
252 std::string full_filename1 =
"data/";
253 full_filename1.append(filename);
257#if (FMOD_VERSION >> 16 == 4)
258 FMOD_RESULT result =
soundsys->createSound(full_filename.c_str(), (FMOD_MODE)(FMOD_3D | FMOD_ACCURATETIME | FMOD_SOFTWARE | FMOD_LOOP_NORMAL), 0, &data->
sound);
261 FMOD_RESULT result =
soundsys->createSound(full_filename.c_str(), (FMOD_MODE)(FMOD_3D | FMOD_ACCURATETIME | FMOD_LOOP_NORMAL), 0, &data->
sound);
265 if (result != FMOD_OK)
267 std::string fmod_result = FMOD_ErrorString(result);
268 ReportError(
"Can't load file '" + filename +
"':\n" + fmod_result);
273 sounds.emplace_back(data);
288 std::string check =
sounds[i]->filename;
290 if (check == filename)
304 FMOD::Channel *channel = 0;
305#if (FMOD_VERSION >> 16 == 4)
306 FMOD_RESULT result =
soundsys->playSound(FMOD_CHANNEL_FREE, data->
sound,
true, &channel);
308 FMOD_RESULT result =
soundsys->playSound(data->
sound, 0,
true, &channel);
311 if (result != FMOD_OK || !channel)
327 if (
sounds[i]->filename == filename)
366 return (
int)
sounds.size();
396 for (
int j = 0; j <
sounds[i]->GetHandleCount(); j++)
398 if (
sounds[i]->handles[j]->IsPlaying() ==
true)
void GetDirection(Vector3 &front, Vector3 &top, bool global=false)
Vector3 GetPosition(bool relative=false)
const std::string & GetName()
virtual bool ReportError(const std::string &message)
virtual void Report(const std::string &message)
void SetValues(const std::string &type, const std::string &name, bool is_permanent, bool is_movable=true)
static void Stop_Profile(void)
static void Start_Profile(const char *name)
unsigned int SmoothFrames
Vector3 ToGlobal(const Vector3 &position)
unsigned long GetAverageTime()
std::string GetFilesystemPath(std::string filename)
unsigned long GetElapsedTime()
std::string VerifyFile(const std::string &filename)
void Cleanup(int index=-1)
bool ReportError(const std::string &message)
void SetListenerDirection(const Vector3 &front, const Vector3 &top)
void ShowPlayingSounds(bool verbose=true)
Vector3 listener_velocity
SoundData * GetSoundData(std::string filename)
void Report(const std::string &message)
void SetListenerPosition(const Vector3 &position)
Vector3 listener_position
std::vector< SoundData * > sounds
FMOD::System * GetFmodSystem()
bool IsLoaded(std::string filename)
unsigned int GetLength(SoundData *data)
SoundData * Load(const std::string &filename)
FMOD::Channel * Prepare(SoundData *data)
SoundSystem(Object *parent, FMOD::System *fmodsystem)
FMOD::Channel * GetChannel()
bool SBSIMPEXP enable_advanced_profiling
void SetCase(std::string &string, bool uppercase)
std::string ToString(int number)
std::string SetCaseCopy(std::string string, bool uppercase)
std::vector< FMOD::Channel * > channels
void RemoveChannel(FMOD::Channel *channel)
void AddHandle(Sound *handle)
void AddChannel(FMOD::Channel *channel)
std::vector< Sound * > handles
void RemoveHandle(Sound *handle)