aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25/sfx
diff options
context:
space:
mode:
authorEugene Sandulenko2010-08-06 13:13:25 +0000
committerEugene Sandulenko2010-10-12 22:35:55 +0000
commit47904bc7b2992189bb554833f00a79ff0fea9fb8 (patch)
tree1cec51758c6741b970bd064fafee77607b9f884f /engines/sword25/sfx
parentca17def625154e5f758b797e4fc48c76b0566320 (diff)
downloadscummvm-rg350-47904bc7b2992189bb554833f00a79ff0fea9fb8.tar.gz
scummvm-rg350-47904bc7b2992189bb554833f00a79ff0fea9fb8.tar.bz2
scummvm-rg350-47904bc7b2992189bb554833f00a79ff0fea9fb8.zip
SWORD25: Mass-astyle.
svn-id: r53222
Diffstat (limited to 'engines/sword25/sfx')
-rw-r--r--engines/sword25/sfx/fmodexchannel.cpp120
-rw-r--r--engines/sword25/sfx/fmodexchannel.h29
-rw-r--r--engines/sword25/sfx/fmodexexception.h20
-rw-r--r--engines/sword25/sfx/fmodexresource.cpp70
-rw-r--r--engines/sword25/sfx/fmodexresource.h15
-rw-r--r--engines/sword25/sfx/fmodexsound.cpp530
-rw-r--r--engines/sword25/sfx/fmodexsound.h120
-rw-r--r--engines/sword25/sfx/soundengine.cpp5
-rw-r--r--engines/sword25/sfx/soundengine.h126
-rw-r--r--engines/sword25/sfx/soundengine_script.cpp159
10 files changed, 517 insertions, 677 deletions
diff --git a/engines/sword25/sfx/fmodexchannel.cpp b/engines/sword25/sfx/fmodexchannel.cpp
index 3fbec5b682..e8992e92a6 100644
--- a/engines/sword25/sfx/fmodexchannel.cpp
+++ b/engines/sword25/sfx/fmodexchannel.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -49,16 +49,14 @@
// Konstruktion / Destruktion
// -----------------------------------------------------------------------------
-BS_FMODExChannel::BS_FMODExChannel(FMOD_CHANNEL * ChannelPtr, FMOD_SOUND * SoundPtr) :
+BS_FMODExChannel::BS_FMODExChannel(FMOD_CHANNEL *ChannelPtr, FMOD_SOUND *SoundPtr) :
m_ChannelPtr(ChannelPtr),
- m_SoundPtr(SoundPtr)
-{
+ m_SoundPtr(SoundPtr) {
}
// -----------------------------------------------------------------------------
-BS_FMODExChannel::~BS_FMODExChannel()
-{
+BS_FMODExChannel::~BS_FMODExChannel() {
if (m_ChannelPtr) FMOD_Channel_Stop(m_ChannelPtr);
if (m_SoundPtr) FMOD_Sound_Release(m_SoundPtr);
}
@@ -73,125 +71,102 @@ BS_FMODExChannel::~BS_FMODExChannel()
// Diese Fehler werden daher von den folgenden Methoden ignoriert.
// -----------------------------------------------------------------------------
-namespace
-{
- bool IsImportantError(FMOD_RESULT Result)
- {
- return Result != FMOD_OK && Result != FMOD_ERR_INVALID_HANDLE && Result != FMOD_ERR_CHANNEL_STOLEN;
- }
+namespace {
+bool IsImportantError(FMOD_RESULT Result) {
+ return Result != FMOD_OK && Result != FMOD_ERR_INVALID_HANDLE && Result != FMOD_ERR_CHANNEL_STOLEN;
+}
}
// -----------------------------------------------------------------------------
// Setter
// -----------------------------------------------------------------------------
-bool BS_FMODExChannel::SetPaused(bool Paused)
-{
+bool BS_FMODExChannel::SetPaused(bool Paused) {
BS_ASSERT(m_ChannelPtr);
FMOD_RESULT Result = FMOD_Channel_SetPaused(m_ChannelPtr, Paused ? 1 : 0);
- if (IsImportantError(Result))
- {
+ if (IsImportantError(Result)) {
BS_FMODExException("FMOD_Channel_SetPaused()", Result).Log();
return false;
- }
- else
+ } else
return true;
}
// -----------------------------------------------------------------------------
-bool BS_FMODExChannel::SetVolume(float Volume)
-{
+bool BS_FMODExChannel::SetVolume(float Volume) {
BS_ASSERT(m_ChannelPtr);
FMOD_RESULT Result = FMOD_Channel_SetVolume(m_ChannelPtr, Volume);
- if (IsImportantError(Result))
- {
+ if (IsImportantError(Result)) {
BS_FMODExException("FMOD_Channel_SetVolume()", Result).Log();
return false;
- }
- else
+ } else
return true;
}
// -----------------------------------------------------------------------------
-bool BS_FMODExChannel::SetPanning(float Panning)
-{
+bool BS_FMODExChannel::SetPanning(float Panning) {
BS_ASSERT(m_ChannelPtr);
FMOD_RESULT Result = FMOD_Channel_SetPan(m_ChannelPtr, Panning);
- if (IsImportantError(Result))
- {
+ if (IsImportantError(Result)) {
BS_FMODExException("FMOD_Channel_SetPan()", Result).Log();
return false;
- }
- else
+ } else
return true;
}
// -----------------------------------------------------------------------------
-bool BS_FMODExChannel::SetLoop(bool Loop)
-{
+bool BS_FMODExChannel::SetLoop(bool Loop) {
BS_ASSERT(m_ChannelPtr);
FMOD_RESULT Result = FMOD_Channel_SetLoopCount(m_ChannelPtr, Loop ? -1 : 0);
- if (IsImportantError(Result))
- {
+ if (IsImportantError(Result)) {
BS_FMODExException("FMOD_Channel_SetLoopCount()", Result).Log();
return false;
- }
- else
+ } else
return true;
}
// -----------------------------------------------------------------------------
-bool BS_FMODExChannel::SetLoopPoints(unsigned int LoopStart, unsigned int LoopEnd)
-{
+bool BS_FMODExChannel::SetLoopPoints(unsigned int LoopStart, unsigned int LoopEnd) {
BS_ASSERT(m_ChannelPtr);
FMOD_RESULT Result = FMOD_Channel_SetLoopPoints(m_ChannelPtr, LoopStart, FMOD_TIMEUNIT_PCM, LoopEnd, FMOD_TIMEUNIT_PCM);
- if (IsImportantError(Result))
- {
+ if (IsImportantError(Result)) {
BS_FMODExException("FMOD_Channel_SetLoopPoints()", Result).Log();
return false;
- }
- else
+ } else
return true;
}
// -----------------------------------------------------------------------------
-bool BS_FMODExChannel::SetPosition(unsigned int Position)
-{
+bool BS_FMODExChannel::SetPosition(unsigned int Position) {
BS_ASSERT(m_ChannelPtr);
FMOD_RESULT Result = FMOD_Channel_SetPosition(m_ChannelPtr, Position, FMOD_TIMEUNIT_PCM);
- if (IsImportantError(Result))
- {
+ if (IsImportantError(Result)) {
BS_FMODExException("FMOD_Channel_SetPosition()", Result).Log();
return false;
- }
- else
+ } else
return true;
}
// -----------------------------------------------------------------------------
-bool BS_FMODExChannel::Stop()
-{
+bool BS_FMODExChannel::Stop() {
BS_ASSERT(m_ChannelPtr);
FMOD_RESULT Result = FMOD_Channel_Stop(m_ChannelPtr);
- if (IsImportantError(Result))
- {
+ if (IsImportantError(Result)) {
BS_FMODExException("FMOD_Channel_Stop()", Result).Log();
return false;
- }
- else
+ } else
return true;
}
@@ -199,34 +174,31 @@ bool BS_FMODExChannel::Stop()
// Getter
// -----------------------------------------------------------------------------
-float BS_FMODExChannel::GetVolume()
-{
+float BS_FMODExChannel::GetVolume() {
BS_ASSERT(m_ChannelPtr);
float Volume = 0;
FMOD_RESULT Result = FMOD_Channel_GetVolume(m_ChannelPtr, &Volume);
if (IsImportantError(Result)) BS_FMODExException("FMOD_Channel_GetVolume()", Result).Log();
-
+
return Volume;
}
// -----------------------------------------------------------------------------
-float BS_FMODExChannel::GetPanning()
-{
+float BS_FMODExChannel::GetPanning() {
BS_ASSERT(m_ChannelPtr);
float Panning = 0;
FMOD_RESULT Result = FMOD_Channel_GetPan(m_ChannelPtr, &Panning);
if (IsImportantError(Result)) BS_FMODExException("FMOD_Channel_GetPan()", Result).Log();
-
+
return Panning;
}
// -----------------------------------------------------------------------------
-unsigned int BS_FMODExChannel::GetPosition()
-{
+unsigned int BS_FMODExChannel::GetPosition() {
BS_ASSERT(m_ChannelPtr);
unsigned int Position = 0;
@@ -238,8 +210,7 @@ unsigned int BS_FMODExChannel::GetPosition()
// -----------------------------------------------------------------------------
-unsigned int BS_FMODExChannel::GetTime()
-{
+unsigned int BS_FMODExChannel::GetTime() {
BS_ASSERT(m_ChannelPtr);
unsigned int Time = 0;
@@ -251,8 +222,7 @@ unsigned int BS_FMODExChannel::GetTime()
// -----------------------------------------------------------------------------
-unsigned int BS_FMODExChannel::GetLoopStart()
-{
+unsigned int BS_FMODExChannel::GetLoopStart() {
BS_ASSERT(m_ChannelPtr);
unsigned int LoopStart = 0;
FMOD_RESULT Result = FMOD_Channel_GetLoopPoints(m_ChannelPtr, &LoopStart, FMOD_TIMEUNIT_PCM, 0, FMOD_TIMEUNIT_PCM);
@@ -263,8 +233,7 @@ unsigned int BS_FMODExChannel::GetLoopStart()
// -----------------------------------------------------------------------------
-unsigned int BS_FMODExChannel::GetLoopEnd()
-{
+unsigned int BS_FMODExChannel::GetLoopEnd() {
BS_ASSERT(m_ChannelPtr);
unsigned int LoopEnd = 0;
FMOD_RESULT Result = FMOD_Channel_GetLoopPoints(m_ChannelPtr, 0, FMOD_TIMEUNIT_PCM, &LoopEnd, FMOD_TIMEUNIT_PCM);
@@ -275,39 +244,36 @@ unsigned int BS_FMODExChannel::GetLoopEnd()
// -----------------------------------------------------------------------------
-bool BS_FMODExChannel::IsLooping()
-{
+bool BS_FMODExChannel::IsLooping() {
BS_ASSERT(m_ChannelPtr);
int LoopCount = 0;
FMOD_RESULT Result = FMOD_Channel_GetLoopCount(m_ChannelPtr, &LoopCount);
if (IsImportantError(Result)) BS_FMODExException("FMOD_Channel_GetLoopCount()", Result).Log();
-
+
return LoopCount == -1;
}
// -----------------------------------------------------------------------------
-bool BS_FMODExChannel::IsPaused()
-{
+bool BS_FMODExChannel::IsPaused() {
BS_ASSERT(m_ChannelPtr);
FMOD_BOOL Paused = 0;
FMOD_RESULT Result = FMOD_Channel_GetPaused(m_ChannelPtr, &Paused);
if (IsImportantError(Result)) BS_FMODExException("FMOD_Channel_GetPaused()", Result).Log();
-
+
return Paused != 0;
}
// -----------------------------------------------------------------------------
-bool BS_FMODExChannel::IsPlaying()
-{
+bool BS_FMODExChannel::IsPlaying() {
BS_ASSERT(m_ChannelPtr);
FMOD_BOOL Playing = 0;
FMOD_RESULT Result = FMOD_Channel_IsPlaying(m_ChannelPtr, &Playing);
- if (IsImportantError(Result)) BS_FMODExException("FMOD_Channel_IsPlaying()", Result).Log();
+ if (IsImportantError(Result)) BS_FMODExException("FMOD_Channel_IsPlaying()", Result).Log();
return Playing != 0;
}
diff --git a/engines/sword25/sfx/fmodexchannel.h b/engines/sword25/sfx/fmodexchannel.h
index 1cab70956b..9d8b64f3b4 100644
--- a/engines/sword25/sfx/fmodexchannel.h
+++ b/engines/sword25/sfx/fmodexchannel.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -52,10 +52,9 @@ struct FMOD_SOUND;
// Klassendefinition
// -----------------------------------------------------------------------------
-class BS_FMODExChannel
-{
+class BS_FMODExChannel {
public:
- BS_FMODExChannel(FMOD_CHANNEL * ChannelPtr, FMOD_SOUND * SoundPtr);
+ BS_FMODExChannel(FMOD_CHANNEL *ChannelPtr, FMOD_SOUND *SoundPtr);
virtual ~BS_FMODExChannel();
bool SetPaused(bool Paused);
@@ -66,19 +65,19 @@ public:
bool SetPosition(unsigned int Position);
bool Stop();
- float GetVolume();
- float GetPanning();
- unsigned int GetPosition();
- unsigned int GetTime();
- unsigned int GetLoopStart();
- unsigned int GetLoopEnd();
- bool IsLooping();
- bool IsPaused();
- bool IsPlaying();
+ float GetVolume();
+ float GetPanning();
+ unsigned int GetPosition();
+ unsigned int GetTime();
+ unsigned int GetLoopStart();
+ unsigned int GetLoopEnd();
+ bool IsLooping();
+ bool IsPaused();
+ bool IsPlaying();
private:
- FMOD_CHANNEL * m_ChannelPtr;
- FMOD_SOUND * m_SoundPtr;
+ FMOD_CHANNEL *m_ChannelPtr;
+ FMOD_SOUND *m_SoundPtr;
};
#endif
diff --git a/engines/sword25/sfx/fmodexexception.h b/engines/sword25/sfx/fmodexexception.h
index 7be4d6d978..05e6d82310 100644
--- a/engines/sword25/sfx/fmodexexception.h
+++ b/engines/sword25/sfx/fmodexexception.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -45,21 +45,19 @@
// Klassendefinition
// -----------------------------------------------------------------------------
-class BS_FMODExException
-{
+class BS_FMODExException {
public:
- BS_FMODExException(const char * Function_, FMOD_RESULT Result_) :
+ BS_FMODExException(const char *Function_, FMOD_RESULT Result_) :
Function(Function_),
Result(Result_) {}
- const char * Function;
- FMOD_RESULT Result;
+ const char *Function;
+ FMOD_RESULT Result;
- void Log()
- {
- BS_LOG_ERROR("Call to %s failed.", Function);
- BS_LOGLN(" FMOD error: %s(%d)", FMOD_ErrorString(Result), Result);
- }
+ void Log() {
+ BS_LOG_ERROR("Call to %s failed.", Function);
+ BS_LOGLN(" FMOD error: %s(%d)", FMOD_ErrorString(Result), Result);
+ }
};
#endif
diff --git a/engines/sword25/sfx/fmodexresource.cpp b/engines/sword25/sfx/fmodexresource.cpp
index 089458f9f5..2a987695bd 100644
--- a/engines/sword25/sfx/fmodexresource.cpp
+++ b/engines/sword25/sfx/fmodexresource.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -52,9 +52,8 @@
// Konstanten
// -----------------------------------------------------------------------------
-namespace
-{
- const unsigned int MAX_SAMPLE_SIZE = 100 * 1024; // Die Dateigröße in Byte ab der ein Sound als Stream abgespielt wird
+namespace {
+const unsigned int MAX_SAMPLE_SIZE = 100 * 1024; // Die Dateigröße in Byte ab der ein Sound als Stream abgespielt wird
}
// -----------------------------------------------------------------------------
@@ -62,29 +61,26 @@ namespace
// -----------------------------------------------------------------------------
-BS_FMODExResource::BS_FMODExResource(const std::string& FileName, FMOD_SYSTEM * FMOD, bool & Success) :
+BS_FMODExResource::BS_FMODExResource(const std::string &FileName, FMOD_SYSTEM *FMOD, bool &Success) :
m_SoundPtr(0),
m_SoundDataPtr(0),
- BS_Resource(FileName, BS_Resource::TYPE_SOUND)
-{
+ BS_Resource(FileName, BS_Resource::TYPE_SOUND) {
BS_ASSERT(FMOD);
// Von Misserfolg ausgehen
Success = false;
// Pointer auf den Package-Manager bekommen
- BS_PackageManager * PackagePtr = BS_Kernel::GetInstance()->GetPackage();
- if (!PackagePtr)
- {
+ BS_PackageManager *PackagePtr = BS_Kernel::GetInstance()->GetPackage();
+ if (!PackagePtr) {
BS_LOG_ERRORLN("Package manager not found.");
return;
}
// Datei laden
- unsigned int FileSize;
- char * FileDataPtr = (char*) PackagePtr->GetFile(GetFileName(), &FileSize);
- if (!FileDataPtr)
- {
+ unsigned int FileSize;
+ char *FileDataPtr = (char *) PackagePtr->GetFile(GetFileName(), &FileSize);
+ if (!FileDataPtr) {
BS_LOG_ERRORLN("File \"%s\" could not be loaded.", GetFileName().c_str());
return;
}
@@ -93,25 +89,22 @@ BS_FMODExResource::BS_FMODExResource(const std::string& FileName, FMOD_SYSTEM *
// Samples werden sofort intialisiert.
// Für Streams wird hingegen bei jedem Abspielen ein neuer Sound erstellt. Dieses Vorgehen ist notwendig, da FMOD Ex Samples beliebig oft
// gleichzeitig abspielen kann, Streams jedoch nur ein mal.
- if (FileSize <= MAX_SAMPLE_SIZE)
- {
+ if (FileSize <= MAX_SAMPLE_SIZE) {
FMOD_CREATESOUNDEXINFO ExInfo;
memset(&ExInfo, 0, sizeof(ExInfo));
ExInfo.cbsize = sizeof(ExInfo);
ExInfo.length = FileSize;
FMOD_RESULT Result = FMOD_System_CreateSound(FMOD, FileDataPtr,
- FMOD_CREATESAMPLE | FMOD_OPENMEMORY | FMOD_SOFTWARE | FMOD_2D | FMOD_LOOP_NORMAL,
- &ExInfo,
- &m_SoundPtr);
+ FMOD_CREATESAMPLE | FMOD_OPENMEMORY | FMOD_SOFTWARE | FMOD_2D | FMOD_LOOP_NORMAL,
+ &ExInfo,
+ &m_SoundPtr);
if (Result != FMOD_OK) BS_FMODExException("FMOD_System_CreateSound()", Result).Log();
Success = Result == FMOD_OK;
delete FileDataPtr;
- }
- else
- {
+ } else {
m_SoundDataPtr = FileDataPtr;
m_SoundDataSize = FileSize;
@@ -121,8 +114,7 @@ BS_FMODExResource::BS_FMODExResource(const std::string& FileName, FMOD_SYSTEM *
// -----------------------------------------------------------------------------
-BS_FMODExResource::~BS_FMODExResource()
-{
+BS_FMODExResource::~BS_FMODExResource() {
// Sound freigeben, solange des Soundsystem noch läuft.
// Sollte das Soundsystem beendet worden sein müssen und können Sounds nicht mehr freigegeben werden.
if (m_SoundPtr && BS_Kernel::GetInstance()->GetService("sfx")) FMOD_Sound_Release(m_SoundPtr);
@@ -133,26 +125,22 @@ BS_FMODExResource::~BS_FMODExResource()
// Abspielen
// -----------------------------------------------------------------------------
-BS_FMODExChannel * BS_FMODExResource::StartSound(FMOD_SYSTEM * FMOD)
-{
+BS_FMODExChannel *BS_FMODExResource::StartSound(FMOD_SYSTEM *FMOD) {
BS_ASSERT(FMOD);
- FMOD_CHANNEL * NewChannelPtr;
- FMOD_SOUND * NewSoundPtr = 0;
+ FMOD_CHANNEL *NewChannelPtr;
+ FMOD_SOUND *NewSoundPtr = 0;
// Sample können sofort abgespielt werden.
- if (m_SoundPtr)
- {
+ if (m_SoundPtr) {
FMOD_RESULT Result = FMOD_System_PlaySound(FMOD, FMOD_CHANNEL_FREE, m_SoundPtr, 1, &NewChannelPtr);
- if (Result != FMOD_OK)
- {
+ if (Result != FMOD_OK) {
BS_FMODExException("FMOD_System_PlaySound()", Result).Log();
return 0;
}
}
// Für Streams muss ein neuer Sound erstellt werden.
- else
- {
+ else {
FMOD_CREATESOUNDEXINFO ExInfo;
memset(&ExInfo, 0, sizeof(ExInfo));
ExInfo.cbsize = sizeof(ExInfo);
@@ -160,19 +148,17 @@ BS_FMODExChannel * BS_FMODExResource::StartSound(FMOD_SYSTEM * FMOD)
FMOD_RESULT Result;
Result = FMOD_System_CreateSound(FMOD,
- m_SoundDataPtr,
- FMOD_CREATESTREAM | FMOD_OPENMEMORY_POINT | FMOD_SOFTWARE | FMOD_2D | FMOD_LOOP_NORMAL,
- &ExInfo,
- &NewSoundPtr);
- if (Result != FMOD_OK)
- {
+ m_SoundDataPtr,
+ FMOD_CREATESTREAM | FMOD_OPENMEMORY_POINT | FMOD_SOFTWARE | FMOD_2D | FMOD_LOOP_NORMAL,
+ &ExInfo,
+ &NewSoundPtr);
+ if (Result != FMOD_OK) {
BS_FMODExException("FMOD_System_CreateSound()", Result).Log();
return 0;
}
Result = FMOD_System_PlaySound(FMOD, FMOD_CHANNEL_FREE, NewSoundPtr, 1, &NewChannelPtr);
- if (Result != FMOD_OK)
- {
+ if (Result != FMOD_OK) {
BS_FMODExException("FMOD_System_PlaySound()", Result).Log();
return 0;
}
diff --git a/engines/sword25/sfx/fmodexresource.h b/engines/sword25/sfx/fmodexresource.h
index c6fd03a5b4..b8a6a07e1f 100644
--- a/engines/sword25/sfx/fmodexresource.h
+++ b/engines/sword25/sfx/fmodexresource.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -54,18 +54,17 @@ struct FMOD_SYSTEM;
// Klassendefinition
// -----------------------------------------------------------------------------
-class BS_FMODExResource : public BS_Resource
-{
+class BS_FMODExResource : public BS_Resource {
public:
- BS_FMODExResource(const std::string& FileName, FMOD_SYSTEM * FMOD, bool & Success);
+ BS_FMODExResource(const std::string &FileName, FMOD_SYSTEM *FMOD, bool &Success);
virtual ~BS_FMODExResource();
- BS_FMODExChannel * StartSound(FMOD_SYSTEM * FMOD);
+ BS_FMODExChannel *StartSound(FMOD_SYSTEM *FMOD);
private:
- FMOD_SOUND * m_SoundPtr;
- char * m_SoundDataPtr;
- unsigned int m_SoundDataSize;
+ FMOD_SOUND *m_SoundPtr;
+ char *m_SoundDataPtr;
+ unsigned int m_SoundDataSize;
};
#endif
diff --git a/engines/sword25/sfx/fmodexsound.cpp b/engines/sword25/sfx/fmodexsound.cpp
index e51c1e9874..49c87b9073 100644
--- a/engines/sword25/sfx/fmodexsound.cpp
+++ b/engines/sword25/sfx/fmodexsound.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -59,82 +59,77 @@
// Konstanten und lokale Funktionen
// -----------------------------------------------------------------------------
-namespace
-{
- const float DEFAULT_MUSIC_VOLUME = 1.0f;
- const float DEFAULT_SPEECH_VOLUME = 1.0f;
- const float DEFAULT_SFX_VOLUME = 1.0f;
- const unsigned int SOUNDTYPE_COUNT = 3;
- const unsigned int INVALID_SOUND_HANDLE = 0xffffffff;
+namespace {
+const float DEFAULT_MUSIC_VOLUME = 1.0f;
+const float DEFAULT_SPEECH_VOLUME = 1.0f;
+const float DEFAULT_SFX_VOLUME = 1.0f;
+const unsigned int SOUNDTYPE_COUNT = 3;
+const unsigned int INVALID_SOUND_HANDLE = 0xffffffff;
- // -------------------------------------------------------------------------
-
- inline float NormalizePanning(float Panning)
- {
- bool Corrected = false;
- float Result = Panning;
- if (Result > 1.0f)
- {
- Result = 1.0f;
- Corrected = true;
- }
- if (Result < -1.0f)
- {
- Result = -1.0f;
- Corrected = true;
- }
-
- if (Corrected) BS_LOG_WARNINGLN("Tried to set an invalid panning value of %.2f. It was corrected to %.2f", Panning, Result);
+// -------------------------------------------------------------------------
- return Result;
+inline float NormalizePanning(float Panning) {
+ bool Corrected = false;
+ float Result = Panning;
+ if (Result > 1.0f) {
+ Result = 1.0f;
+ Corrected = true;
+ }
+ if (Result < -1.0f) {
+ Result = -1.0f;
+ Corrected = true;
}
- // -------------------------------------------------------------------------
+ if (Corrected) BS_LOG_WARNINGLN("Tried to set an invalid panning value of %.2f. It was corrected to %.2f", Panning, Result);
- inline float NormalizeVolume(float Volume)
- {
- bool Corrected = false;
- float Result = Volume;
- if (Result> 1.0f)
- {
- Result = 1.0f;
- Corrected = true;
- }
- if (Result < 0.0f)
- {
- Result = 0.0f;
- Corrected = true;
- }
+ return Result;
+}
- if (Corrected) BS_LOG_WARNINGLN("Tried to set an invalid volume value of %.2f. It was corrected to %.2f", Volume, Result);
+// -------------------------------------------------------------------------
- return Result;
+inline float NormalizeVolume(float Volume) {
+ bool Corrected = false;
+ float Result = Volume;
+ if (Result > 1.0f) {
+ Result = 1.0f;
+ Corrected = true;
+ }
+ if (Result < 0.0f) {
+ Result = 0.0f;
+ Corrected = true;
}
- // -------------------------------------------------------------------------
+ if (Corrected) BS_LOG_WARNINGLN("Tried to set an invalid volume value of %.2f. It was corrected to %.2f", Volume, Result);
- inline FMOD_SOUND_FORMAT BitsPerSampleToFMODExSoundFormat(unsigned int BitsPerSample)
- {
- switch (BitsPerSample)
- {
- case 8: return FMOD_SOUND_FORMAT_PCM8;
- case 16: return FMOD_SOUND_FORMAT_PCM16;
- case 24: return FMOD_SOUND_FORMAT_PCM24;
- case 32: return FMOD_SOUND_FORMAT_PCM32;
- default: return FMOD_SOUND_FORMAT_NONE;
- }
+ return Result;
+}
+
+// -------------------------------------------------------------------------
+
+inline FMOD_SOUND_FORMAT BitsPerSampleToFMODExSoundFormat(unsigned int BitsPerSample) {
+ switch (BitsPerSample) {
+ case 8:
+ return FMOD_SOUND_FORMAT_PCM8;
+ case 16:
+ return FMOD_SOUND_FORMAT_PCM16;
+ case 24:
+ return FMOD_SOUND_FORMAT_PCM24;
+ case 32:
+ return FMOD_SOUND_FORMAT_PCM32;
+ default:
+ return FMOD_SOUND_FORMAT_NONE;
}
}
+}
// -----------------------------------------------------------------------------
// Konstruktion / Destruktion
// -----------------------------------------------------------------------------
-BS_FMODExSound::BS_FMODExSound(BS_Kernel* pKernel) :
+BS_FMODExSound::BS_FMODExSound(BS_Kernel *pKernel) :
BS_SoundEngine(pKernel),
m_FMOD(0),
- m_NextHandle(1)
-{
+ m_NextHandle(1) {
// Lautstärkeneinstellungen auf die Standardwerte setzen
m_Volumes[MUSIC] = DEFAULT_MUSIC_VOLUME;
m_Volumes[SPEECH] = DEFAULT_SPEECH_VOLUME;
@@ -143,11 +138,9 @@ BS_FMODExSound::BS_FMODExSound(BS_Kernel* pKernel) :
// -----------------------------------------------------------------------------
-BS_FMODExSound::~BS_FMODExSound()
-{
+BS_FMODExSound::~BS_FMODExSound() {
// Alle noch spielenden Sounds stoppen und die Ressourcen freigeben
- for (PSM_ITER it = m_PlayingSoundsMap.begin(); it != m_PlayingSoundsMap.end(); ++it)
- {
+ for (PSM_ITER it = m_PlayingSoundsMap.begin(); it != m_PlayingSoundsMap.end(); ++it) {
if (it->second.ChannelPtr) delete it->second.ChannelPtr;
if (it->second.ResourcePtr) it->second.ResourcePtr->Release();
}
@@ -158,23 +151,20 @@ BS_FMODExSound::~BS_FMODExSound()
// -----------------------------------------------------------------------------
-BS_Service * BS_FMODExSound_CreateObject(BS_Kernel* pKernel) { return new BS_FMODExSound(pKernel); }
+BS_Service *BS_FMODExSound_CreateObject(BS_Kernel *pKernel) {
+ return new BS_FMODExSound(pKernel);
+}
// -----------------------------------------------------------------------------
-bool BS_FMODExSound::Init(unsigned int SampleRate, unsigned int Channels)
-{
+bool BS_FMODExSound::Init(unsigned int SampleRate, unsigned int Channels) {
// Eine Warnung ausgeben, wenn dieser Service schon initialisiert wurde.
// Allerdings wird trotzdem true zurückgegeben, weil kein Fehler aufgetreten ist, der Service ist noch benutzbar.
- if (m_FMOD)
- {
+ if (m_FMOD) {
BS_LOG_WARNINGLN("Tried to initialize again. Call ignored.");
return true;
- }
- else
- {
- try
- {
+ } else {
+ try {
// Die FMOD Ex mit den übergebenen Werte initialisieren
FMOD_RESULT Result = FMOD_System_Create(&m_FMOD);
if (Result != FMOD_OK) throw(BS_FMODExException("FMOD_System_Create()", Result));
@@ -186,20 +176,18 @@ bool BS_FMODExSound::Init(unsigned int SampleRate, unsigned int Channels)
if (Result != FMOD_OK) throw(BS_FMODExException("FMOD_System_Init()", Result));
}
- catch(BS_FMODExException Ex)
- {
+ catch (BS_FMODExException Ex) {
Ex.Log();
BS_LOG_ERRORLN("FMOD Ex could not be initialized.");
- if (m_FMOD)
- {
+ if (m_FMOD) {
FMOD_System_Release(m_FMOD);
m_FMOD = 0;
}
return false;
}
-
+
BS_LOGLN("FMOD Ex initialized. Sample rate: %d / Channels: %d", SampleRate, Channels);
return true;
}
@@ -207,8 +195,7 @@ bool BS_FMODExSound::Init(unsigned int SampleRate, unsigned int Channels)
// -----------------------------------------------------------------------------
-void BS_FMODExSound::Update()
-{
+void BS_FMODExSound::Update() {
BS_ASSERT(m_FMOD);
FMOD_RESULT Result = FMOD_System_Update(m_FMOD);
@@ -221,56 +208,51 @@ void BS_FMODExSound::Update()
// Sounds abspielen
// -----------------------------------------------------------------------------
-bool BS_FMODExSound::PlaySound(const std::string& FileName,
- SOUND_TYPES Type,
- float Volume,
- float Pan,
- bool Loop,
- int LoopStart, int LoopEnd,
- unsigned int Layer)
-{
+bool BS_FMODExSound::PlaySound(const std::string &FileName,
+ SOUND_TYPES Type,
+ float Volume,
+ float Pan,
+ bool Loop,
+ int LoopStart, int LoopEnd,
+ unsigned int Layer) {
return PlaySoundInternal(FileName, Type, Volume, Pan, Loop, LoopStart, LoopEnd, Layer, 0, 0) != 0;
}
// -----------------------------------------------------------------------------
-unsigned int BS_FMODExSound::PlaySoundEx(const std::string& FileName,
- SOUND_TYPES Type,
- float Volume,
- float Pan,
- bool Loop,
- int LoopStart, int LoopEnd,
- unsigned int Layer)
-{
+unsigned int BS_FMODExSound::PlaySoundEx(const std::string &FileName,
+ SOUND_TYPES Type,
+ float Volume,
+ float Pan,
+ bool Loop,
+ int LoopStart, int LoopEnd,
+ unsigned int Layer) {
return PlaySoundInternal(FileName, Type, Volume, Pan, Loop, LoopStart, LoopEnd, Layer, 0, 0);
}
// -------------------------------------------------------------------------
-FMOD_RESULT F_CALLBACK BS_FMODExSound::FMODExDynamicSoundSetPosCallback(FMOD_SOUND *sound, int subsound, unsigned int position, FMOD_TIMEUNIT postype)
-{
+FMOD_RESULT F_CALLBACK BS_FMODExSound::FMODExDynamicSoundSetPosCallback(FMOD_SOUND *sound, int subsound, unsigned int position, FMOD_TIMEUNIT postype) {
// In dynamischen Sounds wird nicht gesprungen, daher tut dieses Funktion nichts.
return FMOD_OK;
}
// -------------------------------------------------------------------------
-FMOD_RESULT F_CALLBACK BS_FMODExSound::FMODExDynamicSoundReadCallback(FMOD_SOUND *sound, void *data, unsigned int datalen)
-{
+FMOD_RESULT F_CALLBACK BS_FMODExSound::FMODExDynamicSoundReadCallback(FMOD_SOUND *sound, void *data, unsigned int datalen) {
// Handle auf das aktuelle Soundsystem holen, dies ist wohl dieses hier.
- BS_FMODExSound * t = reinterpret_cast<BS_FMODExSound *>(BS_Kernel::GetInstance()->GetSfx());
+ BS_FMODExSound *t = reinterpret_cast<BS_FMODExSound *>(BS_Kernel::GetInstance()->GetSfx());
// Handle auf den richtigen Sound holen, wurde als FMOD Ex Benutzerdaten gesetzt.
unsigned int Handle;
FMOD_RESULT Result = FMOD_Sound_GetUserData(sound, reinterpret_cast<void **>(&Handle));
- if (Result != FMOD_OK)
- {
+ if (Result != FMOD_OK) {
BS_FMODExException("FMOD_Sound_GetUserData()", Result).Log();
return FMOD_OK;
}
// Sounddaten holen und Callbackfunktion aufrufen.
- PlayingSoundData * PSD = t->GetPlayingSoundDataByHandle(Handle);
+ PlayingSoundData *PSD = t->GetPlayingSoundDataByHandle(Handle);
if (PSD) PSD->ReadCallback(PSD->UserData, data, datalen);
return FMOD_OK;
@@ -279,23 +261,20 @@ FMOD_RESULT F_CALLBACK BS_FMODExSound::FMODExDynamicSoundReadCallback(FMOD_SOUND
// -----------------------------------------------------------------------------
unsigned int BS_FMODExSound::PlayDynamicSoundEx(DynamicSoundReadCallback ReadCallback,
- void * UserData,
- SOUND_TYPES Type,
- unsigned int SampleRate,
- unsigned int BitsPerSample,
- unsigned int Channels,
- float Volume,
- float Pan,
- unsigned int Layer)
-{
+ void *UserData,
+ SOUND_TYPES Type,
+ unsigned int SampleRate,
+ unsigned int BitsPerSample,
+ unsigned int Channels,
+ float Volume,
+ float Pan,
+ unsigned int Layer) {
// Parameter überprüfen
- if (BitsPerSampleToFMODExSoundFormat(BitsPerSample) == FMOD_SOUND_FORMAT_NONE)
- {
+ if (BitsPerSampleToFMODExSoundFormat(BitsPerSample) == FMOD_SOUND_FORMAT_NONE) {
BS_LOG_ERRORLN("Cannot create a dynamic sound with %d bits per sample.", BitsPerSample);
return 0;
}
- if (Channels == 0 || Channels > 2)
- {
+ if (Channels == 0 || Channels > 2) {
BS_LOG_ERRORLN("Cannot create a dynamic sound with %d channels.", Channels);
return 0;
}
@@ -320,35 +299,33 @@ unsigned int BS_FMODExSound::PlayDynamicSoundEx(DynamicSoundReadCallback ReadCal
CreateSoundExInfo.format = BitsPerSampleToFMODExSoundFormat(BitsPerSample);
CreateSoundExInfo.pcmreadcallback = FMODExDynamicSoundReadCallback;
CreateSoundExInfo.pcmsetposcallback = FMODExDynamicSoundSetPosCallback;
- CreateSoundExInfo.userdata = reinterpret_cast<void *>(Handle);
+ CreateSoundExInfo.userdata = reinterpret_cast<void *>(Handle);
- FMOD_SOUND * FMODExSoundPtr;
+ FMOD_SOUND *FMODExSoundPtr;
FMOD_RESULT Result = FMOD_System_CreateSound(m_FMOD,
- 0,
- FMOD_2D | FMOD_OPENUSER | FMOD_LOOP_NORMAL | FMOD_HARDWARE | FMOD_CREATESTREAM,
- &CreateSoundExInfo,
- &FMODExSoundPtr);
- if (Result != FMOD_OK)
- {
+ 0,
+ FMOD_2D | FMOD_OPENUSER | FMOD_LOOP_NORMAL | FMOD_HARDWARE | FMOD_CREATESTREAM,
+ &CreateSoundExInfo,
+ &FMODExSoundPtr);
+ if (Result != FMOD_OK) {
BS_FMODExException("FMOD_System_CreateSound() from PlayDynamicSoundEx()", Result).Log();
return 0;
}
// Neu erstellten Sound einem Kanal zuweisen
- FMOD_CHANNEL * FMODExChannelPtr;
+ FMOD_CHANNEL *FMODExChannelPtr;
Result = FMOD_System_PlaySound(m_FMOD, FMOD_CHANNEL_FREE, FMODExSoundPtr, 1, &FMODExChannelPtr);
- if (Result != FMOD_OK)
- {
+ if (Result != FMOD_OK) {
BS_FMODExException("FMOD_System_PlaySound() from PlayDynamicSoundEx()", Result).Log();
return 0;
}
// FMOD Ex Kanal an einen BS_FMODExChannel binden und abspielen
- BS_FMODExChannel * ChannelPtr = new BS_FMODExChannel(FMODExChannelPtr, FMODExSoundPtr);
+ BS_FMODExChannel *ChannelPtr = new BS_FMODExChannel(FMODExChannelPtr, FMODExSoundPtr);
ChannelPtr->SetPaused(false);
// ChannelPtr in die PlayingSoundData-Struktur eintragen
- PlayingSoundData * PSD = GetPlayingSoundDataByHandle(Handle);
+ PlayingSoundData *PSD = GetPlayingSoundDataByHandle(Handle);
if (PSD) PSD->ChannelPtr = ChannelPtr;
return Handle;
@@ -356,70 +333,61 @@ unsigned int BS_FMODExSound::PlayDynamicSoundEx(DynamicSoundReadCallback ReadCal
// -----------------------------------------------------------------------------
-unsigned int BS_FMODExSound::PlaySoundInternal(const std::string& FileName,
- SOUND_TYPES Type,
- float Volume,
- float Pan,
- bool Loop,
- int LoopStart, int LoopEnd,
- unsigned int Layer,
- unsigned int Position,
- unsigned int Handle)
-{
+unsigned int BS_FMODExSound::PlaySoundInternal(const std::string &FileName,
+ SOUND_TYPES Type,
+ float Volume,
+ float Pan,
+ bool Loop,
+ int LoopStart, int LoopEnd,
+ unsigned int Layer,
+ unsigned int Position,
+ unsigned int Handle) {
BS_ASSERT(m_FMOD);
BS_ASSERT(Type < SOUNDTYPE_COUNT);
// Resource anfordern
- BS_Resource * ResourcePtr = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(FileName);
- if (!ResourcePtr)
- {
+ BS_Resource *ResourcePtr = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(FileName);
+ if (!ResourcePtr) {
BS_LOG_ERRORLN("Could not request resource \"%s\".", FileName.c_str());
return 0;
}
- if (ResourcePtr->GetType() != BS_Resource::TYPE_SOUND)
- {
+ if (ResourcePtr->GetType() != BS_Resource::TYPE_SOUND) {
BS_LOG_ERRORLN("Requested resource \"%s\" is not a sound.", FileName.c_str());
return 0;
}
- BS_FMODExResource * SoundResourcePtr = static_cast<BS_FMODExResource *>(ResourcePtr);
+ BS_FMODExResource *SoundResourcePtr = static_cast<BS_FMODExResource *>(ResourcePtr);
// Sound im Pause-Modus starten
- BS_FMODExChannel * ChannelPtr = SoundResourcePtr->StartSound(m_FMOD);
+ BS_FMODExChannel *ChannelPtr = SoundResourcePtr->StartSound(m_FMOD);
- if (ChannelPtr)
- {
- try
- {
+ if (ChannelPtr) {
+ try {
// Falls der Sound gelooped wird, Loop-Points setzen
- if (Loop)
- {
+ if (Loop) {
// Bestimmen, welche Loop-Points benutzt werden. Falls ein Loop-Point als Parameter nicht spezifiziert wurde (Wert -1),
// wird der Loop-Point von FMOD Ex benutzt.
unsigned int RealLoopStart = (LoopStart > 0) ? LoopStart : ChannelPtr->GetLoopStart();
unsigned int RealLoopEnd = (LoopEnd > 0) ? LoopEnd : ChannelPtr->GetLoopEnd();
// Loop-Points auf Gültigkeit überprüfen
- if (RealLoopStart > RealLoopEnd)
- {
+ if (RealLoopStart > RealLoopEnd) {
BS_LOG_ERRORLN("Loop start (%d) was placed after loop end (%d) for sound \"%s\".",
- RealLoopStart, RealLoopEnd,
- SoundResourcePtr->GetFileName().c_str());
+ RealLoopStart, RealLoopEnd,
+ SoundResourcePtr->GetFileName().c_str());
throw(0);
}
- if (RealLoopStart > ChannelPtr->GetLoopEnd())
- {
+ if (RealLoopStart > ChannelPtr->GetLoopEnd()) {
BS_LOG_ERRORLN("Loop start (%d) was placed after end (%d) of sound \"%s\".",
- RealLoopStart,
- ChannelPtr->GetLoopEnd(),
- SoundResourcePtr->GetFileName().c_str());
+ RealLoopStart,
+ ChannelPtr->GetLoopEnd(),
+ SoundResourcePtr->GetFileName().c_str());
throw(0);
}
- if (RealLoopEnd > ChannelPtr->GetLoopEnd())
- {
+ if (RealLoopEnd > ChannelPtr->GetLoopEnd()) {
BS_LOG_ERRORLN("Loop end (%d) was placed after end (%d) of sound \"%s\".",
- RealLoopEnd,
- ChannelPtr->GetLoopEnd(),
- SoundResourcePtr->GetFileName().c_str());
+ RealLoopEnd,
+ ChannelPtr->GetLoopEnd(),
+ SoundResourcePtr->GetFileName().c_str());
throw(0);
}
@@ -432,12 +400,10 @@ unsigned int BS_FMODExSound::PlaySoundInternal(const std::string& FileName,
if (!ChannelPtr->SetPanning(NormalizePanning(Pan))) throw(0);
if (!ChannelPtr->SetLoop(Loop)) throw(0);
if (!ChannelPtr->SetPosition(Position)) throw(0);
- }
- catch (...)
- {
+ } catch (...) {
delete ChannelPtr;
SoundResourcePtr->Release();
- return 0;
+ return 0;
}
unsigned int MyLoopStart = ChannelPtr->GetLoopStart();
@@ -452,9 +418,7 @@ unsigned int BS_FMODExSound::PlaySoundInternal(const std::string& FileName,
m_PlayingSoundsMap[NewHandle] = PlayingSoundData(SoundResourcePtr, ChannelPtr, Type, Layer, Volume);
return NewHandle;
- }
- else
- {
+ } else {
SoundResourcePtr->Release();
return 0;
}
@@ -464,17 +428,15 @@ unsigned int BS_FMODExSound::PlaySoundInternal(const std::string& FileName,
// Sonstige Methoden
// -----------------------------------------------------------------------------
-void BS_FMODExSound::SetVolume(float Volume, SOUND_TYPES Type)
-{
+void BS_FMODExSound::SetVolume(float Volume, SOUND_TYPES Type) {
BS_ASSERT(m_FMOD);
BS_ASSERT(Type < SOUNDTYPE_COUNT);
m_Volumes[Type] = NormalizeVolume(Volume);
// Alle Volumen der Sounds der Kategorie aktualisieren
PSM_CONST_ITER it = m_PlayingSoundsMap.begin();
- while (it != m_PlayingSoundsMap.end())
- {
- const PlayingSoundData & PSD = it->second;
+ while (it != m_PlayingSoundsMap.end()) {
+ const PlayingSoundData &PSD = it->second;
if (PSD.ChannelPtr && PSD.Type == Type) PSD.ChannelPtr->SetVolume(Volume * PSD.Volume);
++it;
@@ -483,8 +445,7 @@ void BS_FMODExSound::SetVolume(float Volume, SOUND_TYPES Type)
// -----------------------------------------------------------------------------
-float BS_FMODExSound::GetVolume(SOUND_TYPES Type)
-{
+float BS_FMODExSound::GetVolume(SOUND_TYPES Type) {
BS_ASSERT(m_FMOD);
BS_ASSERT(Type < SOUNDTYPE_COUNT);
return m_Volumes[Type];
@@ -492,17 +453,15 @@ float BS_FMODExSound::GetVolume(SOUND_TYPES Type)
// -----------------------------------------------------------------------------
-void BS_FMODExSound::PauseAll()
-{
+void BS_FMODExSound::PauseAll() {
BS_ASSERT(m_FMOD);
// Alle Sounds durchgehen und alle pausieren.
- // Diese werden dann markiert, damit ResumeAll() feststellen kann, welche Sounds mit PauseAll() pausiert wurden.
+ // Diese werden dann markiert, damit ResumeAll() feststellen kann, welche Sounds mit PauseAll() pausiert wurden.
// ResumeAll() setzt dann nur diejenigen fort, die nur über PauseAll() pausiert wurden.
PSM_ITER it = m_PlayingSoundsMap.begin();
- while (it != m_PlayingSoundsMap.end())
- {
- PlayingSoundData & PSD = it->second;
+ while (it != m_PlayingSoundsMap.end()) {
+ PlayingSoundData &PSD = it->second;
if (PSD.ChannelPtr) PSD.ChannelPtr->SetPaused(true);
PSD.PausedGlobal = true;
@@ -513,19 +472,16 @@ void BS_FMODExSound::PauseAll()
// -----------------------------------------------------------------------------
-void BS_FMODExSound::ResumeAll()
-{
+void BS_FMODExSound::ResumeAll() {
BS_ASSERT(m_FMOD);
// Alle Sounds durchgehen, die gloable Pause aufheben und diejenigen fortsetzen,
// die keine Pause mehr haben (weder explizit, über den Layer oder global).
PSM_ITER it = m_PlayingSoundsMap.begin();
- while (it != m_PlayingSoundsMap.end())
- {
- PlayingSoundData & PSD = it->second;
+ while (it != m_PlayingSoundsMap.end()) {
+ PlayingSoundData &PSD = it->second;
- if (PSD.PausedGlobal)
- {
+ if (PSD.PausedGlobal) {
PSD.PausedGlobal = false;
if (PSD.ChannelPtr && !PSD.PausedLayer && !PSD.Paused) PSD.ChannelPtr->SetPaused(false);
}
@@ -536,20 +492,17 @@ void BS_FMODExSound::ResumeAll()
// -----------------------------------------------------------------------------
-void BS_FMODExSound::PauseLayer(unsigned int Layer)
-{
+void BS_FMODExSound::PauseLayer(unsigned int Layer) {
BS_ASSERT(m_FMOD);
// Alle Sounds durchgehen und alle pausieren, die sich auf den angegebenen Layer befinden.
- // Diese werden dann markiert, damit ResumeLayer() feststellen kann, welche Sounds mit PauseLayer() pausiert wurden.
+ // Diese werden dann markiert, damit ResumeLayer() feststellen kann, welche Sounds mit PauseLayer() pausiert wurden.
// ResumeLayer() setzt dann nur diejenigen fort, die nur über PauseLayer() mit der entsprechenden Layer-Nummer pausiert wurden.
PSM_ITER it = m_PlayingSoundsMap.begin();
- while (it != m_PlayingSoundsMap.end())
- {
- PlayingSoundData & PSD = it->second;
+ while (it != m_PlayingSoundsMap.end()) {
+ PlayingSoundData &PSD = it->second;
- if (PSD.Layer == Layer)
- {
+ if (PSD.Layer == Layer) {
if (PSD.ChannelPtr) PSD.ChannelPtr->SetPaused(true);
PSD.PausedLayer = true;
}
@@ -560,19 +513,16 @@ void BS_FMODExSound::PauseLayer(unsigned int Layer)
// -----------------------------------------------------------------------------
-void BS_FMODExSound::ResumeLayer(unsigned int Layer)
-{
+void BS_FMODExSound::ResumeLayer(unsigned int Layer) {
BS_ASSERT(m_FMOD);
// Alle Sounds durchgehen, die Layer-Pause aufheben und diejenigen fortsetzen,
// die keine Pause mehr haben (weder explizit, über den Layer oder global).
PSM_ITER it = m_PlayingSoundsMap.begin();
- while (it != m_PlayingSoundsMap.end())
- {
- PlayingSoundData & PSD = it->second;
+ while (it != m_PlayingSoundsMap.end()) {
+ PlayingSoundData &PSD = it->second;
- if (PSD.PausedLayer && PSD.Layer == Layer)
- {
+ if (PSD.PausedLayer && PSD.Layer == Layer) {
PSD.PausedLayer = false;
if (PSD.ChannelPtr && !PSD.PausedGlobal && !PSD.Paused) PSD.ChannelPtr->SetPaused(false);
}
@@ -585,30 +535,26 @@ void BS_FMODExSound::ResumeLayer(unsigned int Layer)
// Sound Setter
// -----------------------------------------------------------------------------
-void BS_FMODExSound::SetSoundVolume(unsigned int Handle, float Volume)
-{
+void BS_FMODExSound::SetSoundVolume(unsigned int Handle, float Volume) {
BS_ASSERT(m_FMOD);
- PlayingSoundData * PSDPtr = GetPlayingSoundDataByHandle(Handle);
+ PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
if (PSDPtr) if (PSDPtr->ChannelPtr && PSDPtr->ChannelPtr->SetVolume(NormalizeVolume(Volume) * m_Volumes[PSDPtr->Type])) PSDPtr->Volume = Volume;
}
// -----------------------------------------------------------------------------
-void BS_FMODExSound::SetSoundPanning(unsigned int Handle, float Pan)
-{
+void BS_FMODExSound::SetSoundPanning(unsigned int Handle, float Pan) {
BS_ASSERT(m_FMOD);
- PlayingSoundData * PSDPtr = GetPlayingSoundDataByHandle(Handle);
+ PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
if (PSDPtr && PSDPtr->ChannelPtr) PSDPtr->ChannelPtr->SetPanning(NormalizePanning(Pan));
}
// -----------------------------------------------------------------------------
-void BS_FMODExSound::PauseSound(unsigned int Handle)
-{
+void BS_FMODExSound::PauseSound(unsigned int Handle) {
BS_ASSERT(m_FMOD);
- PlayingSoundData * PSDPtr = GetPlayingSoundDataByHandle(Handle);
- if (PSDPtr)
- {
+ PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
+ if (PSDPtr) {
PSDPtr->Paused = true;
if (PSDPtr->ChannelPtr) PSDPtr->ChannelPtr->SetPaused(true);
}
@@ -616,12 +562,10 @@ void BS_FMODExSound::PauseSound(unsigned int Handle)
// -----------------------------------------------------------------------------
-void BS_FMODExSound::ResumeSound(unsigned int Handle)
-{
+void BS_FMODExSound::ResumeSound(unsigned int Handle) {
BS_ASSERT(m_FMOD);
- PlayingSoundData * PSDPtr = GetPlayingSoundDataByHandle(Handle);
- if (PSDPtr)
- {
+ PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
+ if (PSDPtr) {
PSDPtr->Paused = false;
if (PSDPtr->ChannelPtr && !PSDPtr->PausedGlobal && !PSDPtr->PausedLayer) PSDPtr->ChannelPtr->SetPaused(false);
}
@@ -629,10 +573,9 @@ void BS_FMODExSound::ResumeSound(unsigned int Handle)
// -----------------------------------------------------------------------------
-void BS_FMODExSound::StopSound(unsigned int Handle)
-{
+void BS_FMODExSound::StopSound(unsigned int Handle) {
BS_ASSERT(m_FMOD);
- PlayingSoundData * PSDPtr = GetPlayingSoundDataByHandle(Handle);
+ PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
if (PSDPtr && PSDPtr->ChannelPtr) PSDPtr->ChannelPtr->Stop();
}
@@ -640,50 +583,45 @@ void BS_FMODExSound::StopSound(unsigned int Handle)
// Sound Getter
// -----------------------------------------------------------------------------
-bool BS_FMODExSound::IsSoundPaused(unsigned int Handle)
-{
+bool BS_FMODExSound::IsSoundPaused(unsigned int Handle) {
BS_ASSERT(m_FMOD);
- PlayingSoundData * PSDPtr = GetPlayingSoundDataByHandle(Handle);
+ PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
if (PSDPtr && PSDPtr->ChannelPtr) return PSDPtr->ChannelPtr->IsPaused();
return false;
}
// -----------------------------------------------------------------------------
-bool BS_FMODExSound::IsSoundPlaying(unsigned int Handle)
-{
+bool BS_FMODExSound::IsSoundPlaying(unsigned int Handle) {
BS_ASSERT(m_FMOD);
- PlayingSoundData * PSDPtr = GetPlayingSoundDataByHandle(Handle);
+ PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
if (PSDPtr && PSDPtr->ChannelPtr) return PSDPtr->ChannelPtr->IsPlaying();
return false;
}
// -----------------------------------------------------------------------------
-float BS_FMODExSound::GetSoundVolume(unsigned int Handle)
-{
+float BS_FMODExSound::GetSoundVolume(unsigned int Handle) {
BS_ASSERT(m_FMOD);
- PlayingSoundData * PSDPtr = GetPlayingSoundDataByHandle(Handle);
+ PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
if (PSDPtr) return PSDPtr->Volume;
return 0;
}
// -----------------------------------------------------------------------------
-float BS_FMODExSound::GetSoundPanning(unsigned int Handle)
-{
+float BS_FMODExSound::GetSoundPanning(unsigned int Handle) {
BS_ASSERT(m_FMOD);
- PlayingSoundData * PSDPtr = GetPlayingSoundDataByHandle(Handle);
+ PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
if (PSDPtr && PSDPtr->ChannelPtr) return PSDPtr->ChannelPtr->GetPanning();
return 0;
}
// -----------------------------------------------------------------------------
-float BS_FMODExSound::GetSoundTime(unsigned int Handle)
-{
+float BS_FMODExSound::GetSoundTime(unsigned int Handle) {
BS_ASSERT(m_FMOD);
- PlayingSoundData * PSDPtr = GetPlayingSoundDataByHandle(Handle);
+ PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
if (PSDPtr && PSDPtr->ChannelPtr) return static_cast<float>(PSDPtr->ChannelPtr->GetTime()) / 1000.0f;
return 0;
}
@@ -692,21 +630,17 @@ float BS_FMODExSound::GetSoundTime(unsigned int Handle)
// Hilfsmethoden
// -----------------------------------------------------------------------------
-void BS_FMODExSound::RemoveInactiveSounds()
-{
+void BS_FMODExSound::RemoveInactiveSounds() {
PSM_ITER it = m_PlayingSoundsMap.begin();
- while (it != m_PlayingSoundsMap.end())
- {
- if (!it->second.ChannelPtr || !it->second.ChannelPtr->IsPlaying())
- {
- PlayingSoundData & PSD = it->second;
+ while (it != m_PlayingSoundsMap.end()) {
+ if (!it->second.ChannelPtr || !it->second.ChannelPtr->IsPlaying()) {
+ PlayingSoundData &PSD = it->second;
delete PSD.ChannelPtr;
if (PSD.ResourcePtr) PSD.ResourcePtr->Release();
it = m_PlayingSoundsMap.erase(it);
- }
- else
+ } else
++it;
}
@@ -714,16 +648,15 @@ void BS_FMODExSound::RemoveInactiveSounds()
static size_t lastActiveChannels = 0;
if (m_PlayingSoundsMap.size() != lastActiveChannels)
{
- BS_LOGLN("Aktive Kanaele: %d", m_PlayingSoundsMap.size());
- lastActiveChannels = m_PlayingSoundsMap.size();
+ BS_LOGLN("Aktive Kanaele: %d", m_PlayingSoundsMap.size());
+ lastActiveChannels = m_PlayingSoundsMap.size();
}
*/
}
// -----------------------------------------------------------------------------
-BS_FMODExSound::PlayingSoundData * BS_FMODExSound::GetPlayingSoundDataByHandle(unsigned int Handle)
-{
+BS_FMODExSound::PlayingSoundData *BS_FMODExSound::GetPlayingSoundDataByHandle(unsigned int Handle) {
// Zum Soundhandle gehörige Daten in der Hash-Map finden
PSM_ITER it = m_PlayingSoundsMap.find(Handle);
// Falls die Daten nicht gefunden werden konnten, Fehler zurückgebene, ansonsten ein Pointer auf die Daten.
@@ -733,8 +666,7 @@ BS_FMODExSound::PlayingSoundData * BS_FMODExSound::GetPlayingSoundDataByHandle(u
// -----------------------------------------------------------------------------
-unsigned int BS_FMODExSound::CountPlayingDynamicSounds()
-{
+unsigned int BS_FMODExSound::CountPlayingDynamicSounds() {
unsigned int Result = 0;
for (PSM_CONST_ITER it = m_PlayingSoundsMap.begin(); it != m_PlayingSoundsMap.end(); ++it) if (!it->second.ResourcePtr) ++Result;
@@ -745,33 +677,28 @@ unsigned int BS_FMODExSound::CountPlayingDynamicSounds()
// Ressourcen-Verwaltung
// -----------------------------------------------------------------------------
-BS_Resource * BS_FMODExSound::LoadResource(const std::string& FileName)
-{
+BS_Resource *BS_FMODExSound::LoadResource(const std::string &FileName) {
BS_ASSERT(m_FMOD);
BS_ASSERT(CanLoadResource(FileName));
bool Success;
- BS_FMODExResource * ResourcePtr = new BS_FMODExResource(FileName, m_FMOD, Success);
+ BS_FMODExResource *ResourcePtr = new BS_FMODExResource(FileName, m_FMOD, Success);
if (Success)
return ResourcePtr;
- else
- {
+ else {
delete ResourcePtr;
return 0;
}
}
-bool BS_FMODExSound::CanLoadResource(const std::string& FileName)
-{
- if (FileName.size() >= 4)
- {
+bool BS_FMODExSound::CanLoadResource(const std::string &FileName) {
+ if (FileName.size() >= 4) {
std::string Extension(FileName.end() - 4, FileName.end());
- BS_String::ToLower(Extension);
+ BS_String::ToLower(Extension);
- return Extension == ".wav" ||
- Extension == ".ogg" ||
- Extension == ".mp3";
- }
- else
+ return Extension == ".wav" ||
+ Extension == ".ogg" ||
+ Extension == ".mp3";
+ } else
return false;
}
@@ -779,8 +706,7 @@ bool BS_FMODExSound::CanLoadResource(const std::string& FileName)
// Persistenz
// -----------------------------------------------------------------------------
-bool BS_FMODExSound::Persist(BS_OutputPersistenceBlock & Writer)
-{
+bool BS_FMODExSound::Persist(BS_OutputPersistenceBlock &Writer) {
BS_ASSERT(m_FMOD);
// Alle inaktiven Sounds entfernen, damit kein unnötiger Ballast gespeichert wird
@@ -798,12 +724,10 @@ bool BS_FMODExSound::Persist(BS_OutputPersistenceBlock & Writer)
// Informationen für jeden spielenden (nicht dynamischen) Sound speichern
PSM_CONST_ITER it = m_PlayingSoundsMap.begin();
- while (it != m_PlayingSoundsMap.end())
- {
- const PlayingSoundData & PSD = it->second;
+ while (it != m_PlayingSoundsMap.end()) {
+ const PlayingSoundData &PSD = it->second;
- if (PSD.ResourcePtr)
- {
+ if (PSD.ResourcePtr) {
// Handle speichern
Writer.Write(it->first);
@@ -831,15 +755,13 @@ bool BS_FMODExSound::Persist(BS_OutputPersistenceBlock & Writer)
// -----------------------------------------------------------------------------
-bool BS_FMODExSound::Unpersist(BS_InputPersistenceBlock & Reader)
-{
+bool BS_FMODExSound::Unpersist(BS_InputPersistenceBlock &Reader) {
BS_ASSERT(m_FMOD);
// Alle Sounds stoppen
PSM_ITER it = m_PlayingSoundsMap.begin();
- while (it != m_PlayingSoundsMap.end())
- {
- const PlayingSoundData & PSD = it->second;
+ while (it != m_PlayingSoundsMap.end()) {
+ const PlayingSoundData &PSD = it->second;
if (PSD.ChannelPtr) delete PSD.ChannelPtr;
if (PSD.ResourcePtr) PSD.ResourcePtr->Release();
++it;
@@ -847,7 +769,7 @@ bool BS_FMODExSound::Unpersist(BS_InputPersistenceBlock & Reader)
// Sound-Map leeren
m_PlayingSoundsMap.clear();
-
+
// Nächstes Handle laden
Reader.Read(m_NextHandle);
@@ -856,22 +778,21 @@ bool BS_FMODExSound::Unpersist(BS_InputPersistenceBlock & Reader)
Reader.Read(SoundCount);
// Informationen über jeden spielenden Sound einlesen und ihn mit den Parametern abspielen
- for (unsigned int i = 0; i < SoundCount; ++i)
- {
- unsigned int Handle;
- std::string FileName;
- unsigned int Type;
- unsigned int Layer;
-
- float Volume;
- float Pan;
- bool Loop;
- unsigned int LoopStart;
- unsigned int LoopEnd;
- unsigned int Position;
- bool Paused;
- bool PausedLayer;
- bool PausedGlobal;
+ for (unsigned int i = 0; i < SoundCount; ++i) {
+ unsigned int Handle;
+ std::string FileName;
+ unsigned int Type;
+ unsigned int Layer;
+
+ float Volume;
+ float Pan;
+ bool Loop;
+ unsigned int LoopStart;
+ unsigned int LoopEnd;
+ unsigned int Position;
+ bool Paused;
+ bool PausedLayer;
+ bool PausedGlobal;
Reader.Read(Handle);
Reader.Read(FileName);
@@ -888,12 +809,9 @@ bool BS_FMODExSound::Unpersist(BS_InputPersistenceBlock & Reader)
Reader.Read(PausedLayer);
Reader.Read(PausedGlobal);
- if (Reader.IsGood())
- {
+ if (Reader.IsGood()) {
PlaySoundInternal(FileName, (SOUND_TYPES) Type, Volume, Pan, Loop, LoopStart, LoopEnd, Layer, Position, Handle);
- }
- else
- {
+ } else {
return false;
}
}
diff --git a/engines/sword25/sfx/fmodexsound.h b/engines/sword25/sfx/fmodexsound.h
index 3b1a5f640a..a32d6bb4d8 100644
--- a/engines/sword25/sfx/fmodexsound.h
+++ b/engines/sword25/sfx/fmodexsound.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -60,54 +60,52 @@ struct FMOD_CHANNEL;
// Klassendefinition
// -----------------------------------------------------------------------------
-class BS_FMODExSound : public BS_SoundEngine
-{
+class BS_FMODExSound : public BS_SoundEngine {
public:
// -----------------------------------------------------------------------------
// Konstruktion / Destruktion
// -----------------------------------------------------------------------------
-
- BS_FMODExSound(BS_Kernel* pKernel);
+
+ BS_FMODExSound(BS_Kernel *pKernel);
virtual ~BS_FMODExSound();
- bool Init(unsigned int SampleRate, unsigned int Channels = 32);
- void Update();
- void SetVolume(float Volume, SOUND_TYPES Type);
- float GetVolume(SOUND_TYPES Type);
- void PauseAll();
- void ResumeAll();
- void PauseLayer(unsigned int Layer);
- void ResumeLayer(unsigned int Layer);
- bool PlaySound(const std::string& FileName, SOUND_TYPES Type, float Volume, float Pan, bool Loop, int LoopStart, int LoopEnd, unsigned int Layer);
- unsigned int PlaySoundEx(const std::string& FileName, SOUND_TYPES Type, float Volume, float Pan, bool Loop, int LoopStart, int LoopEnd, unsigned int Layer);
- unsigned int PlayDynamicSoundEx(DynamicSoundReadCallback ReadCallback, void * UserData, SOUND_TYPES Type, unsigned int SampleRate, unsigned int BitsPerSample, unsigned int Channels, float Volume = 1.0f, float Pan = 0.0f, unsigned int Layer = 0);
-
- void SetSoundVolume(unsigned int Handle, float Volume);
- void SetSoundPanning(unsigned int Handle, float Pan);
- void PauseSound(unsigned int Handle);
- void ResumeSound(unsigned int Handle);
- void StopSound(unsigned int Handle);
- bool IsSoundPaused(unsigned int Handle);
- bool IsSoundPlaying(unsigned int Handle);
- float GetSoundVolume(unsigned int Handle);
- float GetSoundPanning(unsigned int Handle);
- float GetSoundTime(unsigned int Handle);
-
- BS_Resource * LoadResource(const std::string& FileName);
- bool CanLoadResource(const std::string& FileName);
+ bool Init(unsigned int SampleRate, unsigned int Channels = 32);
+ void Update();
+ void SetVolume(float Volume, SOUND_TYPES Type);
+ float GetVolume(SOUND_TYPES Type);
+ void PauseAll();
+ void ResumeAll();
+ void PauseLayer(unsigned int Layer);
+ void ResumeLayer(unsigned int Layer);
+ bool PlaySound(const std::string &FileName, SOUND_TYPES Type, float Volume, float Pan, bool Loop, int LoopStart, int LoopEnd, unsigned int Layer);
+ unsigned int PlaySoundEx(const std::string &FileName, SOUND_TYPES Type, float Volume, float Pan, bool Loop, int LoopStart, int LoopEnd, unsigned int Layer);
+ unsigned int PlayDynamicSoundEx(DynamicSoundReadCallback ReadCallback, void *UserData, SOUND_TYPES Type, unsigned int SampleRate, unsigned int BitsPerSample, unsigned int Channels, float Volume = 1.0f, float Pan = 0.0f, unsigned int Layer = 0);
+
+ void SetSoundVolume(unsigned int Handle, float Volume);
+ void SetSoundPanning(unsigned int Handle, float Pan);
+ void PauseSound(unsigned int Handle);
+ void ResumeSound(unsigned int Handle);
+ void StopSound(unsigned int Handle);
+ bool IsSoundPaused(unsigned int Handle);
+ bool IsSoundPlaying(unsigned int Handle);
+ float GetSoundVolume(unsigned int Handle);
+ float GetSoundPanning(unsigned int Handle);
+ float GetSoundTime(unsigned int Handle);
+
+ BS_Resource *LoadResource(const std::string &FileName);
+ bool CanLoadResource(const std::string &FileName);
// -----------------------------------------------------------------------------
// Persistenz
// -----------------------------------------------------------------------------
-
- bool Persist(BS_OutputPersistenceBlock & Writer);
- bool Unpersist(BS_InputPersistenceBlock & Reader);
-
+
+ bool Persist(BS_OutputPersistenceBlock &Writer);
+ bool Unpersist(BS_InputPersistenceBlock &Reader);
+
private:
- struct PlayingSoundData
- {
+ struct PlayingSoundData {
PlayingSoundData() {};
- PlayingSoundData(BS_Resource * ResourcePtr_, BS_FMODExChannel * ChannelPtr_, SOUND_TYPES Type_, unsigned int Layer_, float Volume_, DynamicSoundReadCallback ReadCallback_ = 0, void * UserData_ = 0) :
+ PlayingSoundData(BS_Resource *ResourcePtr_, BS_FMODExChannel *ChannelPtr_, SOUND_TYPES Type_, unsigned int Layer_, float Volume_, DynamicSoundReadCallback ReadCallback_ = 0, void *UserData_ = 0) :
ResourcePtr(ResourcePtr_),
ChannelPtr(ChannelPtr_),
Type(Type_),
@@ -118,38 +116,38 @@ private:
Paused(false),
PausedLayer(false),
PausedGlobal(false)
- {}
-
- BS_Resource * ResourcePtr;
- BS_FMODExChannel * ChannelPtr;
- SOUND_TYPES Type;
- unsigned int Layer;
- DynamicSoundReadCallback ReadCallback;
- void * UserData;
-
- float Volume;
- bool Paused;
- bool PausedLayer;
- bool PausedGlobal;
+ {}
+
+ BS_Resource *ResourcePtr;
+ BS_FMODExChannel *ChannelPtr;
+ SOUND_TYPES Type;
+ unsigned int Layer;
+ DynamicSoundReadCallback ReadCallback;
+ void *UserData;
+
+ float Volume;
+ bool Paused;
+ bool PausedLayer;
+ bool PausedGlobal;
};
- typedef BS_Hashmap<unsigned int, PlayingSoundData> PSM;
- typedef BS_Hashmap<unsigned int, PlayingSoundData>::iterator PSM_ITER;
- typedef BS_Hashmap<unsigned int, PlayingSoundData>::const_iterator PSM_CONST_ITER;
+ typedef BS_Hashmap<unsigned int, PlayingSoundData> PSM;
+ typedef BS_Hashmap<unsigned int, PlayingSoundData>::iterator PSM_ITER;
+ typedef BS_Hashmap<unsigned int, PlayingSoundData>::const_iterator PSM_CONST_ITER;
PSM m_PlayingSoundsMap;
- FMOD_SYSTEM * m_FMOD;
- float m_Volumes[3];
- unsigned int m_NextHandle;
+ FMOD_SYSTEM *m_FMOD;
+ float m_Volumes[3];
+ unsigned int m_NextHandle;
- void RemoveInactiveSounds();
- PlayingSoundData * GetPlayingSoundDataByHandle(unsigned int Handle);
- unsigned int PlaySoundInternal(const std::string& FileName, SOUND_TYPES Type, float Volume, float Pan, bool Loop, int LoopStart, int LoopEnd, unsigned int Layer, unsigned int Handle, unsigned int Position);
- unsigned int CountPlayingDynamicSounds();
+ void RemoveInactiveSounds();
+ PlayingSoundData *GetPlayingSoundDataByHandle(unsigned int Handle);
+ unsigned int PlaySoundInternal(const std::string &FileName, SOUND_TYPES Type, float Volume, float Pan, bool Loop, int LoopStart, int LoopEnd, unsigned int Layer, unsigned int Handle, unsigned int Position);
+ unsigned int CountPlayingDynamicSounds();
static FMOD_RESULT F_CALLBACK FMODExDynamicSoundSetPosCallback(FMOD_SOUND *sound, int subsound, unsigned int position, FMOD_TIMEUNIT postype);
static FMOD_RESULT F_CALLBACK FMODExDynamicSoundReadCallback(FMOD_SOUND *sound, void *data, unsigned int datalen);
- static FMOD_RESULT F_CALLBACK DSPReadCallback(FMOD_DSP_STATE * dsp_state, float * inbuffer, float * outbuffer, unsigned int length, int inchannels, int outchannels);
+ static FMOD_RESULT F_CALLBACK DSPReadCallback(FMOD_DSP_STATE *dsp_state, float *inbuffer, float *outbuffer, unsigned int length, int inchannels, int outchannels);
};
#endif
diff --git a/engines/sword25/sfx/soundengine.cpp b/engines/sword25/sfx/soundengine.cpp
index 44847e5f62..c3d845ad50 100644
--- a/engines/sword25/sfx/soundengine.cpp
+++ b/engines/sword25/sfx/soundengine.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -42,8 +42,7 @@
// -----------------------------------------------------------------------------
-BS_SoundEngine::BS_SoundEngine(BS_Kernel * pKernel) : BS_ResourceService(pKernel)
-{
+BS_SoundEngine::BS_SoundEngine(BS_Kernel *pKernel) : BS_ResourceService(pKernel) {
if (!_RegisterScriptBindings())
BS_LOG_ERRORLN("Script bindings could not be registered.");
else
diff --git a/engines/sword25/sfx/soundengine.h b/engines/sword25/sfx/soundengine.h
index 35bab0c3d6..86efe4d3bd 100644
--- a/engines/sword25/sfx/soundengine.h
+++ b/engines/sword25/sfx/soundengine.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -67,7 +67,7 @@ public:
// -----------------------------------------------------------------------------
// Enums and Types
// -----------------------------------------------------------------------------
-
+
enum SOUND_TYPES {
MUSIC = 0,
SPEECH = 1,
@@ -76,29 +76,29 @@ public:
/**
* The callback function of PlayDynamicSoundEx
- * @param UserData User-specified pointer
- * @param Data Pointer to the data buffer
- * @param DataLength Length of the data to be written in bytes
+ * @param UserData User-specified pointer
+ * @param Data Pointer to the data buffer
+ * @param DataLength Length of the data to be written in bytes
*/
typedef void (*DynamicSoundReadCallback)(void *UserData, void *Data, unsigned int DataLength);
// -----------------------------------------------------------------------------
// Constructor / destructor
// -----------------------------------------------------------------------------
-
- BS_SoundEngine(BS_Kernel* pKernel);
+
+ BS_SoundEngine(BS_Kernel *pKernel);
virtual ~BS_SoundEngine() {};
// --------------------------------------------------------------
// THIS METHOD MUST BE IMPLEMENTED BY THE SOUND ENGINE
// --------------------------------------------------------------
- /**
+ /**
* Initialises the sound engine
- * @param SampleRate Specifies the sample rate to use.
- * @param Channels The maximum number of channels. The default is 32.
- * @return Returns true on success, otherwise false.
- * @remark Calls to other methods may take place only if this
+ * @param SampleRate Specifies the sample rate to use.
+ * @param Channels The maximum number of channels. The default is 32.
+ * @return Returns true on success, otherwise false.
+ * @remark Calls to other methods may take place only if this
* method was called successfully.
*/
virtual bool Init(unsigned int SampleRate, unsigned int Channels = 32) = 0;
@@ -112,17 +112,17 @@ public:
*/
virtual void Update() = 0;
- /**
+ /**
* Sets the default volume for the different sound types
- * @param Volume The default volume level (0 = off, 1 = full volume)
- * @param Type The SoundType whose volume is to be changed
+ * @param Volume The default volume level (0 = off, 1 = full volume)
+ * @param Type The SoundType whose volume is to be changed
*/
virtual void SetVolume(float Volume, SOUND_TYPES Type) = 0;
/**
* Specifies the default volume of different sound types
- * @param Type The SoundType
- * @return Returns the standard sound volume for the given type
+ * @param Type The SoundType
+ * @return Returns the standard sound volume for the given type
* (0 = off, 1 = full volume).
*/
virtual float GetVolume(SOUND_TYPES Type) = 0;
@@ -139,115 +139,115 @@ public:
/**
* Pauses all sounds of a given layer.
- * @param Layer The Sound Layer
+ * @param Layer The Sound Layer
*/
virtual void PauseLayer(unsigned int Layer) = 0;
/**
* Resumes all the sounds in a layer that was previously stopped with PauseLayer()
- * @param Layer The Sound Layer
+ * @param Layer The Sound Layer
*/
virtual void ResumeLayer(unsigned int Layer) = 0;
-
+
/**
* Plays a sound
- * @param FileName The filename of the sound to be played
- * @param Type The type of sound
- * @param Volume The volume of the sound (0 = off, 1 = full volume)
- * @param Pan Panning (-1 = full left, 1 = right)
- * @param Loop Indicates whether the sound should be looped
- * @param LoopStart Indicates the starting loop point. If a value less than 0 is passed, the start
+ * @param FileName The filename of the sound to be played
+ * @param Type The type of sound
+ * @param Volume The volume of the sound (0 = off, 1 = full volume)
+ * @param Pan Panning (-1 = full left, 1 = right)
+ * @param Loop Indicates whether the sound should be looped
+ * @param LoopStart Indicates the starting loop point. If a value less than 0 is passed, the start
* of the sound is used.
- * @param LoopEnd Indicates the ending loop point. If a avlue is passed less than 0, the end of
+ * @param LoopEnd Indicates the ending loop point. If a avlue is passed less than 0, the end of
* the sound is used.
- * @param Layer The sound layer
- * @return Returns true if the playback of the sound was started successfully.
- * @remark If more control is needed over the playing, eg. changing the sound parameters
+ * @param Layer The sound layer
+ * @return Returns true if the playback of the sound was started successfully.
+ * @remark If more control is needed over the playing, eg. changing the sound parameters
* for Volume and Panning, then PlaySoundEx should be used.
*/
virtual bool PlaySound(const Common::String &FileName, SOUND_TYPES Type, float Volume = 1.0f, float Pan = 0.0f, bool Loop = false, int LoopStart = -1, int LoopEnd = -1, unsigned int Layer = 0) = 0;
/**
* Plays a sound
- * @param Type The type of sound
- * @param Volume The volume of the sound (0 = off, 1 = full volume)
- * @param Pan Panning (-1 = full left, 1 = right)
- * @param Loop Indicates whether the sound should be looped
- * @param LoopStart Indicates the starting loop point. If a value less than 0 is passed, the start
+ * @param Type The type of sound
+ * @param Volume The volume of the sound (0 = off, 1 = full volume)
+ * @param Pan Panning (-1 = full left, 1 = right)
+ * @param Loop Indicates whether the sound should be looped
+ * @param LoopStart Indicates the starting loop point. If a value less than 0 is passed, the start
* of the sound is used.
- * @param LoopEnd Indicates the ending loop point. If a avlue is passed less than 0, the end of
+ * @param LoopEnd Indicates the ending loop point. If a avlue is passed less than 0, the end of
* the sound is used.
- * @param Layer The sound layer
- * @return Returns a handle to the sound. With this handle, the sound can be manipulated during playback.
- * @remark If more control is needed over the playing, eg. changing the sound parameters
+ * @param Layer The sound layer
+ * @return Returns a handle to the sound. With this handle, the sound can be manipulated during playback.
+ * @remark If more control is needed over the playing, eg. changing the sound parameters
* for Volume and Panning, then PlaySoundEx should be used.
*/
virtual unsigned int PlaySoundEx(const Common::String &FileName, SOUND_TYPES Type, float Volume = 1.0f, float Pan = 0.0f, bool Loop = false, int LoopStart = -1, int LoopEnd = -1, unsigned int Layer = 0) = 0;
/**
* Plays a sound generated at runtime
- * @param ReadCallback A pointer to a callback function that is called when sound data is needed.
+ * @param ReadCallback A pointer to a callback function that is called when sound data is needed.
* See the documentation for DynamicSoundReadCallback for more information.
- * @param UserData A pointer to the data. These are passed to the callback function each time.
+ * @param UserData A pointer to the data. These are passed to the callback function each time.
* If no such data is needed, this parameter can be set to NULL.
- * @param Type The type of sound
- * @param SampleRate The sample rate for the sound
- * @param BitsPerSample The size of the sample in bits. This statement is independant of the number of
+ * @param Type The type of sound
+ * @param SampleRate The sample rate for the sound
+ * @param BitsPerSample The size of the sample in bits. This statement is independant of the number of
* channels. Allowed values are 8, 16, 24, and 32.
- * @param Channels The number of channels. Allowed values are 1 and 2.
- * @param Volume The volume of the sound (0 = off, 1 = full volume)
- * @param Pan Panning (-1 = full left, 1 = right)
- * @param Layer The sound layer
- * @return Returns a handle to the sound. With this handle, the sound can be manipulated during playback.
- * @remark Dynamic sounds cannot be persisted.
+ * @param Channels The number of channels. Allowed values are 1 and 2.
+ * @param Volume The volume of the sound (0 = off, 1 = full volume)
+ * @param Pan Panning (-1 = full left, 1 = right)
+ * @param Layer The sound layer
+ * @return Returns a handle to the sound. With this handle, the sound can be manipulated during playback.
+ * @remark Dynamic sounds cannot be persisted.
*/
virtual unsigned int PlayDynamicSoundEx(DynamicSoundReadCallback ReadCallback, void *UserData, SOUND_TYPES Type, unsigned int SampleRate, unsigned int BitsPerSample, unsigned int Channels, float Volume = 1.0f, float Pan = 0.0f, unsigned int Layer = 0) = 0;
/**
* Sets the volume of a playing sound
- * @param Handle The sound handle
- * @param Volume The volume of the sound (0 = off, 1 = full volume)
+ * @param Handle The sound handle
+ * @param Volume The volume of the sound (0 = off, 1 = full volume)
*/
virtual void SetSoundVolume(unsigned int Handle, float Volume) = 0;
/**
* Sets the panning of a playing sound
- * @param Handle The sound handle
- * @param Pan Panning (-1 = full left, 1 = right)
+ * @param Handle The sound handle
+ * @param Pan Panning (-1 = full left, 1 = right)
*/
virtual void SetSoundPanning(unsigned int Handle, float Pan) = 0;
/**
* Pauses a playing sound
- * @param Handle The sound handle
+ * @param Handle The sound handle
*/
virtual void PauseSound(unsigned int Handle) = 0;
/**
* Resumes a paused sound
- * @param Handle The sound handle
+ * @param Handle The sound handle
*/
virtual void ResumeSound(unsigned int Handle) = 0;
/**
* Stops a playing sound
- * @param Handle The sound handle
- * @remark Calling this method invalidates the passed handle; it can no longer be used.
+ * @param Handle The sound handle
+ * @remark Calling this method invalidates the passed handle; it can no longer be used.
*/
virtual void StopSound(unsigned int Handle) = 0;
/**
* Returns whether a sound is paused
- * @param Handle The sound handle
- * @return Returns true if the sound is paused, false otherwise.
+ * @param Handle The sound handle
+ * @return Returns true if the sound is paused, false otherwise.
*/
virtual bool IsSoundPaused(unsigned int Handle) = 0;
-
+
/**
* Returns whether a sound is still playing.
- * @param Handle The sound handle
- * @return Returns true if the sound is playing, false otherwise.
+ * @param Handle The sound handle
+ * @return Returns true if the sound is playing, false otherwise.
*/
virtual bool IsSoundPlaying(unsigned int Handle) = 0;
diff --git a/engines/sword25/sfx/soundengine_script.cpp b/engines/sword25/sfx/soundengine_script.cpp
index 34188e9f05..ecffd2b42a 100644
--- a/engines/sword25/sfx/soundengine_script.cpp
+++ b/engines/sword25/sfx/soundengine_script.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -45,11 +45,10 @@
// -----------------------------------------------------------------------------
-static int Init(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int Init(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
if (lua_gettop(L) == 0)
@@ -57,18 +56,17 @@ static int Init(lua_State * L)
else if (lua_gettop(L) == 1)
lua_pushbooleancpp(L, pSfx->Init(static_cast<unsigned int>(luaL_checknumber(L, 1)), 32));
else
- lua_pushbooleancpp(L, pSfx->Init(static_cast<unsigned int>(luaL_checknumber(L, 1)), static_cast<unsigned int>(luaL_checknumber(L, 2))));
+ lua_pushbooleancpp(L, pSfx->Init(static_cast<unsigned int>(luaL_checknumber(L, 1)), static_cast<unsigned int>(luaL_checknumber(L, 2))));
return 1;
}
// -----------------------------------------------------------------------------
-static int Update(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int Update(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
pSfx->Update();
@@ -78,26 +76,24 @@ static int Update(lua_State * L)
// -----------------------------------------------------------------------------
-static int SetVolume(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int SetVolume(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
pSfx->SetVolume(static_cast<float>(luaL_checknumber(L, 1)),
- static_cast<BS_SoundEngine::SOUND_TYPES>(static_cast<unsigned int>(luaL_checknumber(L, 2))));
+ static_cast<BS_SoundEngine::SOUND_TYPES>(static_cast<unsigned int>(luaL_checknumber(L, 2))));
return 0;
}
// -----------------------------------------------------------------------------
-static int GetVolume(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int GetVolume(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
lua_pushnumber(L, pSfx->GetVolume(static_cast<BS_SoundEngine::SOUND_TYPES>(static_cast<unsigned int>(luaL_checknumber(L, 1)))));
@@ -107,11 +103,10 @@ static int GetVolume(lua_State * L)
// -----------------------------------------------------------------------------
-static int PauseAll(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int PauseAll(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
pSfx->PauseAll();
@@ -121,11 +116,10 @@ static int PauseAll(lua_State * L)
// -----------------------------------------------------------------------------
-static int ResumeAll(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int ResumeAll(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
pSfx->ResumeAll();
@@ -135,11 +129,10 @@ static int ResumeAll(lua_State * L)
// -----------------------------------------------------------------------------
-static int PauseLayer(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int PauseLayer(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
pSfx->PauseLayer(static_cast<int>(luaL_checknumber(L, 1)));
@@ -149,11 +142,10 @@ static int PauseLayer(lua_State * L)
// -----------------------------------------------------------------------------
-static int ResumeLayer(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int ResumeLayer(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
pSfx->ResumeLayer(static_cast<int>(luaL_checknumber(L, 1)));
@@ -163,8 +155,7 @@ static int ResumeLayer(lua_State * L)
// -----------------------------------------------------------------------------
-static void ProcessPlayParams(lua_State * L, std::string & FileName, BS_SoundEngine::SOUND_TYPES & Type, float & Volume, float & Pan, bool & Loop, int & LoopStart, int & LoopEnd, unsigned int & Layer)
-{
+static void ProcessPlayParams(lua_State *L, std::string &FileName, BS_SoundEngine::SOUND_TYPES &Type, float &Volume, float &Pan, bool &Loop, int &LoopStart, int &LoopEnd, unsigned int &Layer) {
FileName = luaL_checkstring(L, 1);
Type = static_cast<BS_SoundEngine::SOUND_TYPES>(static_cast<unsigned int>(luaL_checknumber(L, 2)));
@@ -188,11 +179,10 @@ static void ProcessPlayParams(lua_State * L, std::string & FileName, BS_SoundEng
else Layer = static_cast<unsigned int>(luaL_checknumber(L, 8));
}
-static int PlaySound(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int PlaySound(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
std::string FileName;
@@ -210,11 +200,10 @@ static int PlaySound(lua_State * L)
return 1;
}
-static int PlaySoundEx(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int PlaySoundEx(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
std::string FileName;
@@ -234,11 +223,10 @@ static int PlaySoundEx(lua_State * L)
// -----------------------------------------------------------------------------
-static int SetSoundVolume(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int SetSoundVolume(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
pSfx->SetSoundVolume(static_cast<unsigned int>(luaL_checknumber(L, 1)), static_cast<float>(luaL_checknumber(L, 2)));
@@ -248,11 +236,10 @@ static int SetSoundVolume(lua_State * L)
// -----------------------------------------------------------------------------
-static int SetSoundPanning(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int SetSoundPanning(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
pSfx->SetSoundPanning(static_cast<unsigned int>(luaL_checknumber(L, 1)), static_cast<float>(luaL_checknumber(L, 2)));
@@ -262,11 +249,10 @@ static int SetSoundPanning(lua_State * L)
// -----------------------------------------------------------------------------
-static int PauseSound(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int PauseSound(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
pSfx->PauseSound(static_cast<unsigned int>(luaL_checknumber(L, 1)));
@@ -276,11 +262,10 @@ static int PauseSound(lua_State * L)
// -----------------------------------------------------------------------------
-static int ResumeSound(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int ResumeSound(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
pSfx->ResumeSound(static_cast<unsigned int>(luaL_checknumber(L, 1)));
@@ -290,11 +275,10 @@ static int ResumeSound(lua_State * L)
// -----------------------------------------------------------------------------
-static int StopSound(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int StopSound(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
pSfx->StopSound(static_cast<unsigned int>(luaL_checknumber(L, 1)));
@@ -304,11 +288,10 @@ static int StopSound(lua_State * L)
// -----------------------------------------------------------------------------
-static int IsSoundPaused(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int IsSoundPaused(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
lua_pushbooleancpp(L, pSfx->IsSoundPaused(static_cast<unsigned int>(luaL_checknumber(L, 1))));
@@ -318,11 +301,10 @@ static int IsSoundPaused(lua_State * L)
// -----------------------------------------------------------------------------
-static int IsSoundPlaying(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int IsSoundPlaying(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
lua_pushbooleancpp(L, pSfx->IsSoundPlaying(static_cast<unsigned int>(luaL_checknumber(L, 1))));
@@ -332,11 +314,10 @@ static int IsSoundPlaying(lua_State * L)
// -----------------------------------------------------------------------------
-static int GetSoundVolume(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int GetSoundVolume(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
lua_pushnumber(L, pSfx->GetSoundVolume(static_cast<unsigned int>(luaL_checknumber(L, 1))));
@@ -346,11 +327,10 @@ static int GetSoundVolume(lua_State * L)
// -----------------------------------------------------------------------------
-static int GetSoundPanning(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int GetSoundPanning(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
lua_pushnumber(L, pSfx->GetSoundPanning(static_cast<unsigned int>(luaL_checknumber(L, 1))));
@@ -360,10 +340,9 @@ static int GetSoundPanning(lua_State * L)
// -----------------------------------------------------------------------------
-static const char * SFX_LIBRARY_NAME = "Sfx";
+static const char *SFX_LIBRARY_NAME = "Sfx";
-static const luaL_reg SFX_FUNCTIONS[] =
-{
+static const luaL_reg SFX_FUNCTIONS[] = {
"Init", Init,
"Update", Update,
"__SetVolume", SetVolume,
@@ -386,8 +365,7 @@ static const luaL_reg SFX_FUNCTIONS[] =
0, 0,
};
-static const lua_constant_reg SFX_CONSTANTS[] =
-{
+static const lua_constant_reg SFX_CONSTANTS[] = {
"MUSIC", BS_SoundEngine::MUSIC,
"SPEECH", BS_SoundEngine::SPEECH,
"SFX", BS_SoundEngine::SFX,
@@ -396,13 +374,12 @@ static const lua_constant_reg SFX_CONSTANTS[] =
// -----------------------------------------------------------------------------
-bool BS_SoundEngine::_RegisterScriptBindings()
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+bool BS_SoundEngine::_RegisterScriptBindings() {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_ScriptEngine * pScript = static_cast<BS_ScriptEngine *>(pKernel->GetService("script"));
+ BS_ScriptEngine *pScript = static_cast<BS_ScriptEngine *>(pKernel->GetService("script"));
BS_ASSERT(pScript);
- lua_State * L = static_cast<lua_State *>(pScript->GetScriptObject());
+ lua_State *L = static_cast<lua_State *>(pScript->GetScriptObject());
BS_ASSERT(L);
if (!BS_LuaBindhelper::AddFunctionsToLib(L, SFX_LIBRARY_NAME, SFX_FUNCTIONS)) return false;