diff options
-rw-r--r-- | src/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/app/app.cpp | 5 | ||||
-rw-r--r-- | src/app/app.h | 3 | ||||
-rw-r--r-- | src/app/main.cpp | 19 | ||||
-rw-r--r-- | src/common/logger.cpp | 134 | ||||
-rw-r--r-- | src/common/logger.h | 111 | ||||
-rw-r--r-- | src/common/singleton.h | 57 | ||||
-rw-r--r-- | src/plugins/plugin.h | 33 | ||||
-rw-r--r-- | src/sound/sound.cpp | 0 | ||||
-rw-r--r-- | src/sound/sound.h | 483 |
10 files changed, 680 insertions, 168 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 250120c..d7bd0bf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -31,6 +31,7 @@ app/app.cpp app/main.cpp app/system.cpp common/event.cpp +common/logger.cpp common/iman.cpp # common/metafile.cpp # common/misc.cpp @@ -118,7 +119,7 @@ graphics/opengl/glengine.cpp # script/cbottoken.cpp # script/cmdtoken.cpp # script/script.cpp -sound/sound.cpp +# sound/sound.cpp # ui/button.cpp # ui/check.cpp # ui/color.cpp diff --git a/src/app/app.cpp b/src/app/app.cpp index 4005707..68131fc 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -345,6 +345,11 @@ end: return m_exitCode; } +int CApplication::GetExitCode() +{ + return m_exitCode; +} + void CApplication::ParseEvent() { /* Event event; diff --git a/src/app/app.h b/src/app/app.h index e83652c..f776b10 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -60,6 +60,9 @@ public: //! Main event loop int Run(); + //! Returns the code to be returned at main() exit + int GetExitCode(); + protected: //! Cleans up before exit void Destroy(); diff --git a/src/app/main.cpp b/src/app/main.cpp index 54d305e..151cd20 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -19,6 +19,7 @@ #include "app/app.h" #include "app/system.h" +#include "common/logger.h" #include "common/misc.h" #include "common/restext.h" @@ -26,6 +27,10 @@ //! Entry point to the program int main(int argc, char *argv[]) { + CLogger logger; // Create the logger + + logger.Info("Colobot starting\n"); + CApplication app; // single instance of the application Error err = app.ParseArguments(argc, argv); @@ -34,8 +39,18 @@ int main(int argc, char *argv[]) SystemDialog(SDT_ERROR, "COLOBOT", "Invalid commandline arguments!\n"); } + int code = 0; + if (! app.Create()) - return 0; + { + code = app.GetExitCode(); + logger.Info("Didn't run main loop. Exiting with code %d\n", code); + return code; + } + + code = app.Run(); - return app.Run(); + logger.Info("Exiting with code %d\n", code); + return code; } + diff --git a/src/common/logger.cpp b/src/common/logger.cpp new file mode 100644 index 0000000..acd1d27 --- /dev/null +++ b/src/common/logger.cpp @@ -0,0 +1,134 @@ +// * This file is part of the COLOBOT source code +// * Copyright (C) 2012, Polish Portal of Colobot (PPC) +// * +// * This program is free software: you can redistribute it and/or modify +// * it under the terms of the GNU General Public License as published by +// * the Free Software Foundation, either version 3 of the License, or +// * (at your option) any later version. +// * +// * This program is distributed in the hope that it will be useful, +// * but WITHOUT ANY WARRANTY; without even the implied warranty of +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// * GNU General Public License for more details. +// * +// * You should have received a copy of the GNU General Public License +// * along with this program. If not, see http://www.gnu.org/licenses/. + +// logger.cpp + +#include <common/logger.h> + + +template<> CLogger* CSingleton<CLogger>::mInstance = 0; + + +CLogger& CLogger::GetInstance() +{ + assert(mInstance); + return *mInstance; +} + + +CLogger* CLogger::GetInstancePointer() +{ + assert(mInstance); + return mInstance; +} + + +CLogger::CLogger() +{ + mFile = NULL; + mLogLevel = LOG_INFO; +} + + +CLogger::~CLogger() +{ + Close(); +} + + +void CLogger::Log(LogType type, const char *str, va_list args) +{ + if (type < mLogLevel) + return; + + switch (type) { + case LOG_WARN: fprintf(IsOpened() ? mFile : stderr, "[WARN]: "); break; + case LOG_INFO: fprintf(IsOpened() ? mFile : stderr, "[INFO]: "); break; + case LOG_ERROR: fprintf(IsOpened() ? mFile : stderr, "[ERROR]: "); break; + default: break; + } + + vfprintf(IsOpened() ? mFile : stderr, str, args); +} + + +void CLogger::Info(const char *str, ...) +{ + va_list args; + va_start(args, str); + Log(LOG_INFO, str, args); + va_end(args); +} + + +void CLogger::Warn(const char *str, ...) +{ + va_list args; + va_start(args, str); + Log(LOG_WARN, str, args); + va_end(args); +} + + +void CLogger::Error(const char *str, ...) +{ + va_list args; + va_start(args, str); + Log(LOG_ERROR, str, args); + va_end(args); +} + + +void CLogger::Message(const char *str, ...) +{ + va_list args; + va_start(args, str); + Log(LOG_NONE, str, args); + va_end(args); +} + + +void CLogger::SetOutputFile(std::string filename) +{ + mFilename = filename; + Open(); +} + + +void CLogger::Open() +{ + mFile = fopen(mFilename.c_str(), "w"); + if (mFile == NULL) + fprintf(stderr, "Could not create file %s\n", mFilename.c_str()); +} + + +void CLogger::Close() +{ + if (IsOpened()) + fclose(mFile); +} + + +bool CLogger::IsOpened() +{ + return mFile != NULL; +} + + +void CLogger::SetLogLevel(LogType type) { + mLogLevel = type; +} diff --git a/src/common/logger.h b/src/common/logger.h new file mode 100644 index 0000000..1b3829c --- /dev/null +++ b/src/common/logger.h @@ -0,0 +1,111 @@ +// * This file is part of the COLOBOT source code +// * Copyright (C) 2012, Polish Portal of Colobot (PPC) +// * +// * This program is free software: you can redistribute it and/or modify +// * it under the terms of the GNU General Public License as published by +// * the Free Software Foundation, either version 3 of the License, or +// * (at your option) any later version. +// * +// * This program is distributed in the hope that it will be useful, +// * but WITHOUT ANY WARRANTY; without even the implied warranty of +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// * GNU General Public License for more details. +// * +// * You should have received a copy of the GNU General Public License +// * along with this program. If not, see http://www.gnu.org/licenses/. + +// logger.h + + +#pragma once + +#include <string> +#include <cstdarg> + +#include <common/singleton.h> + +/** + * @file common/logger.h + * @brief Class for loggin information to file or console + */ + + +/** + * \public + * \enum LogType common/logger.h + * \brief Enum representing log level +**/ +enum LogType +{ + LOG_INFO = 1, /*!< lowest level, information */ + LOG_WARN = 2, /*!< warning */ + LOG_ERROR = 3, /*!< error */ + LOG_NONE = 4 /*!< none level, used for custom messages */ +}; + + +/** +* @class CLogger +* +* @brief Class for loggin information to file or console +* +*/ +class CLogger : public CSingleton<CLogger> +{ + public: + CLogger(); + ~CLogger(); + + /** Write message to console or file + * @param const char str - message to write + * @param ... - additional arguments + */ + void Message(const char *str, ...); + + /** Write message to console or file with LOG_INFO level + * @param const char str - message to write + * @param ... - additional arguments + */ + void Info(const char *str, ...); + + /** Write message to console or file with LOG_WARN level + * @param const char str - message to write + * @param ... - additional arguments + */ + void Warn(const char *str, ...); + + /** Write message to console or file with LOG_ERROR level + * @param const char str - message to write + * @param ... - additional arguments + */ + void Error(const char *str, ...); + + /** Set output file to write logs to + * @param std::string filename - output file to write to + */ + void SetOutputFile(std::string filename); + + /** Set log level. Logs with level below will not be shown + * @param LogType level - minimum log level to write + */ + void SetLogLevel(LogType level); + + static CLogger& GetInstance(); + static CLogger* GetInstancePointer(); + + private: + std::string mFilename; + FILE *mFile; + LogType mLogLevel; + + void Open(); + void Close(); + bool IsOpened(); + void Log(LogType type, const char* str, va_list args); +}; + + +//! Global function to get Logger instance +inline CLogger* GetLogger() { + return CLogger::GetInstancePointer(); +} diff --git a/src/common/singleton.h b/src/common/singleton.h new file mode 100644 index 0000000..dc09645 --- /dev/null +++ b/src/common/singleton.h @@ -0,0 +1,57 @@ +// * This file is part of the COLOBOT source code +// * Copyright (C) 2012, Polish Portal of Colobot (PPC) +// * +// * This program is free software: you can redistribute it and/or modify +// * it under the terms of the GNU General Public License as published by +// * the Free Software Foundation, either version 3 of the License, or +// * (at your option) any later version. +// * +// * This program is distributed in the hope that it will be useful, +// * but WITHOUT ANY WARRANTY; without even the implied warranty of +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// * GNU General Public License for more details. +// * +// * You should have received a copy of the GNU General Public License +// * along with this program. If not, see http://www.gnu.org/licenses/. + +// singleton.h + + +#pragma once + +#include <cassert> + + +template<typename T> class CSingleton +{ + protected: + static T* mInstance; + + public: + static T& GetInstance() { + aserrt(mInstance); + return *mInstance; + } + + static T& GetInstancePointer() { + aserrt(mInstance); + return mInstance; + } + + static bool IsCreated() { + return mInstance != NULL; + } + + CSingleton() { + assert(!mInstance); + mInstance = static_cast<T *>(this); + } + + ~CSingleton() { + mInstance = NULL; + } + + private: + CSingleton& operator=(const CSingleton<T> &); + CSingleton(const CSingleton<T> &); +}; diff --git a/src/plugins/plugin.h b/src/plugins/plugin.h new file mode 100644 index 0000000..f238122 --- /dev/null +++ b/src/plugins/plugin.h @@ -0,0 +1,33 @@ +// * This file is part of the COLOBOT source code +// * Copyright (C) 2012, Polish Portal of Colobot (PPC) +// * +// * This program is free software: you can redistribute it and/or modify +// * it under the terms of the GNU General Public License as published by +// * the Free Software Foundation, either version 3 of the License, or +// * (at your option) any later version. +// * +// * This program is distributed in the hope that it will be useful, +// * but WITHOUT ANY WARRANTY; without even the implied warranty of +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// * GNU General Public License for more details. +// * +// * You should have received a copy of the GNU General Public License +// * along with this program. If not, see http://www.gnu.org/licenses/. + +// plugin.h + + +#pragma once + + +#define PLUGIN_INTERFACE(class_type, interface_type) \ + extern "C" interface_type* installPlugin() { return (interface_type *)new class_type(); } \ + extern "C" void uninstallPlugin(class_type *_class) { delete _class; } + + +class CPlugin { + public: + virtual char* PluginName() = 0; + virtual int PluginVersion() = 0; +}; + diff --git a/src/sound/sound.cpp b/src/sound/sound.cpp deleted file mode 100644 index e69de29..0000000 --- a/src/sound/sound.cpp +++ /dev/null diff --git a/src/sound/sound.h b/src/sound/sound.h index a2bfc76..598ffe3 100644 --- a/src/sound/sound.h +++ b/src/sound/sound.h @@ -1,165 +1,318 @@ -// * This file is part of the COLOBOT source code -// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch -// * Copyright (C) 2012, Polish Portal of Colobot (PPC) -// * -// * This program is free software: you can redistribute it and/or modify -// * it under the terms of the GNU General Public License as published by -// * the Free Software Foundation, either version 3 of the License, or -// * (at your option) any later version. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have received a copy of the GNU General Public License -// * along with this program. If not, see http://www.gnu.org/licenses/. - -// sound.h - -#pragma once - - -#include "math/vector.h" - - -class CInstanceManager; - -namespace Snd { - -const int MAXFILES = 200; -const int MAXSOUND = 32; -const int MAXVOLUME = 20; -const int MAXOPER = 4; - - -enum Sound -{ - SOUND_CLICK = 0, - SOUND_BOUM = 1, - SOUND_EXPLO = 2, - SOUND_FLYh = 3, // human - SOUND_FLY = 4, - SOUND_STEPs = 5, // smooth - SOUND_MOTORw = 6, // wheel - SOUND_MOTORt = 7, // tank - SOUND_MOTORr = 8, // roller - SOUND_ERROR = 9, - SOUND_CONVERT = 10, - SOUND_ENERGY = 11, - SOUND_PLOUF = 12, - SOUND_BLUP = 13, - SOUND_WARNING = 14, - SOUND_DERRICK = 15, - SOUND_LABO = 16, - SOUND_STATION = 17, - SOUND_REPAIR = 18, - SOUND_RESEARCH = 19, - SOUND_INSECTs = 20, // spider - SOUND_BURN = 21, - SOUND_TZOING = 22, - SOUND_GGG = 23, - SOUND_MANIP = 24, - SOUND_FIRE = 25, // shooting with fireball - SOUND_HUMAN1 = 26, // breathing - SOUND_STEPw = 27, // water - SOUND_SWIM = 28, - SOUND_RADAR = 29, - SOUND_BUILD = 30, - SOUND_ALARM = 31, // energy alarm - SOUND_SLIDE = 32, - SOUND_EXPLOi = 33, // insect - SOUND_INSECTa = 34, // ant - SOUND_INSECTb = 35, // bee - SOUND_INSECTw = 36, // worm - SOUND_INSECTm = 37, // mother - SOUND_TREMBLE = 38, - SOUND_PSHHH = 39, - SOUND_NUCLEAR = 40, - SOUND_INFO = 41, - SOUND_OPEN = 42, - SOUND_CLOSE = 43, - SOUND_FACTORY = 44, - SOUND_EGG = 45, - SOUND_MOTORs = 46, // submarine - SOUND_MOTORi = 47, // insect (legs) - SOUND_SHIELD = 48, - SOUND_FIREi = 49, // shooting with orgaball (insect) - SOUND_GUNDEL = 50, - SOUND_PSHHH2 = 51, // shield - SOUND_MESSAGE = 52, - SOUND_BOUMm = 53, // metal - SOUND_BOUMv = 54, // plant - SOUND_BOUMs = 55, // smooth - SOUND_EXPLOl = 56, // little - SOUND_EXPLOlp = 57, // little power - SOUND_EXPLOp = 58, // power - SOUND_STEPh = 59, // hard - SOUND_STEPm = 60, // metal - SOUND_POWERON = 61, - SOUND_POWEROFF = 62, - SOUND_AIE = 63, - SOUND_WAYPOINT = 64, - SOUND_RECOVER = 65, - SOUND_DEADi = 66, - SOUND_JOSTLE = 67, - SOUND_GFLAT = 68, - SOUND_DEADg = 69, // shooting death - SOUND_DEADw = 70, // drowning - SOUND_FLYf = 71, // reactor fail - SOUND_ALARMt = 72, // temperature alarm - SOUND_FINDING = 73, // finds a cache object - SOUND_THUMP = 74, - SOUND_TOUCH = 75, - SOUND_BLITZ = 76, - SOUND_MUSHROOM = 77, - SOUND_FIREp = 78, // shooting with phazer - SOUND_EXPLOg1 = 79, // impact gun 1 - SOUND_EXPLOg2 = 80, // impact gun 2 - SOUND_MOTORd = 81, // engine friction -}; - -enum SoundNext -{ - SOPER_CONTINUE = 1, - SOPER_STOP = 2, - SOPER_LOOP = 3, -}; - -struct SoundOper -{ - char bUsed; - float finalAmplitude; - float finalFrequency; - float totalTime; - float currentTime; - Snd::SoundNext nextOper; -}; - -struct SoundChannel -{ - char bUsed; // buffer used? - char bMute; // silence? - Snd::Sound type; // SOUND_* - int priority; // so great -> important - Math::Vector pos; // position in space - unsigned short uniqueStamp; // unique marker -// LPDIRECTSOUNDBUFFER soundBuffer; -// LPDIRECTSOUND3DBUFFER soundBuffer3D; - float startAmplitude; - float startFrequency; - float changeFrequency; - int initFrequency; - float volume; // 2D: volume 1..0 depending on position - float pan; // 2D: pan -1..+1 depending on position - Snd::SoundOper oper[MAXOPER]; -}; - - - -class CSound -{ - // TODO -}; - -}; // namespace Sound +// * This file is part of the COLOBOT source code
+// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
+// *
+// * This program is free software: you can redistribute it and/or modify
+// * it under the terms of the GNU General Public License as published by
+// * the Free Software Foundation, either version 3 of the License, or
+// * (at your option) any later version.
+// *
+// * This program is distributed in the hope that it will be useful,
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// * GNU General Public License for more details.
+// *
+// * You should have received a copy of the GNU General Public License
+// * along with this program. If not, see http://www.gnu.org/licenses/.
+
+// soundinterface.h
+
+/**
+ * @file sound/soundinterface.h
+ * @brief Sound plugin interface
+ */
+
+#pragma once
+
+#include <math/vector.h>
+
+#include <plugins/plugin.h>
+
+/*!
+ * Maximum possible audio volume
+ */
+#define MAXVOLUME 100
+
+
+/**
+ * \public
+ * \enum Sound sound/soundinterface.h
+ * \brief Sound enum representing sound file
+**/
+enum Sound
+{
+ SOUND_CLICK = 0,
+ SOUND_BOUM = 1,
+ SOUND_EXPLO = 2,
+ SOUND_FLYh = 3, /*!< human */
+ SOUND_FLY = 4,
+ SOUND_STEPs = 5, /*!< smooth */
+ SOUND_MOTORw = 6, /*!< wheel */
+ SOUND_MOTORt = 7, /*!< tank */
+ SOUND_MOTORr = 8, /*!< roller */
+ SOUND_ERROR = 9,
+ SOUND_CONVERT = 10,
+ SOUND_ENERGY = 11,
+ SOUND_PLOUF = 12,
+ SOUND_BLUP = 13,
+ SOUND_WARNING = 14,
+ SOUND_DERRICK = 15,
+ SOUND_LABO = 16,
+ SOUND_STATION = 17,
+ SOUND_REPAIR = 18,
+ SOUND_RESEARCH = 19,
+ SOUND_INSECTs = 20, /*!< spider */
+ SOUND_BURN = 21,
+ SOUND_TZOING = 22,
+ SOUND_GGG = 23,
+ SOUND_MANIP = 24,
+ SOUND_FIRE = 25, /*!< shooting with fireball */
+ SOUND_HUMAN1 = 26, /*!< breathing */
+ SOUND_STEPw = 27, /*!< water */
+ SOUND_SWIM = 28,
+ SOUND_RADAR = 29,
+ SOUND_BUILD = 30,
+ SOUND_ALARM = 31, /*!< energy alarm */
+ SOUND_SLIDE = 32,
+ SOUND_EXPLOi = 33, /*!< insect */
+ SOUND_INSECTa = 34, /*!< ant */
+ SOUND_INSECTb = 35, /*!< bee */
+ SOUND_INSECTw = 36, /*!< worm */
+ SOUND_INSECTm = 37, /*!< mother */
+ SOUND_TREMBLE = 38,
+ SOUND_PSHHH = 39,
+ SOUND_NUCLEAR = 40,
+ SOUND_INFO = 41,
+ SOUND_OPEN = 42,
+ SOUND_CLOSE = 43,
+ SOUND_FACTORY = 44,
+ SOUND_EGG = 45,
+ SOUND_MOTORs = 46, /*!< submarine */
+ SOUND_MOTORi = 47, /*!< insect (legs) */
+ SOUND_SHIELD = 48,
+ SOUND_FIREi = 49, /*!< shooting with orgaball (insect) */
+ SOUND_GUNDEL = 50,
+ SOUND_PSHHH2 = 51, /*!< shield */
+ SOUND_MESSAGE = 52,
+ SOUND_BOUMm = 53, /*!< metal */
+ SOUND_BOUMv = 54, /*!< plant */
+ SOUND_BOUMs = 55, /*!< smooth */
+ SOUND_EXPLOl = 56, /*!< little */
+ SOUND_EXPLOlp = 57, /*!< little power */
+ SOUND_EXPLOp = 58, /*!< power */
+ SOUND_STEPh = 59, /*!< hard */
+ SOUND_STEPm = 60, /*!< metal */
+ SOUND_POWERON = 61,
+ SOUND_POWEROFF = 62,
+ SOUND_AIE = 63,
+ SOUND_WAYPOINT = 64,
+ SOUND_RECOVER = 65,
+ SOUND_DEADi = 66,
+ SOUND_JOSTLE = 67,
+ SOUND_GFLAT = 68,
+ SOUND_DEADg = 69, /*!< shooting death */
+ SOUND_DEADw = 70, /*!< drowning */
+ SOUND_FLYf = 71, /*!< reactor fail */
+ SOUND_ALARMt = 72, /*!< temperature alarm */
+ SOUND_FINDING = 73, /*!< finds a cache object */
+ SOUND_THUMP = 74,
+ SOUND_TOUCH = 75,
+ SOUND_BLITZ = 76,
+ SOUND_MUSHROOM = 77,
+ SOUND_FIREp = 78, /*!< shooting with phazer */
+ SOUND_EXPLOg1 = 79, /*!< impact gun 1 */
+ SOUND_EXPLOg2 = 80, /*!< impact gun 2 */
+ SOUND_MOTORd = 81, /*!< engine friction */
+};
+
+
+/**
+ * \public
+ * \enum SoundNext sound/soundinterface.h
+ * \brief Enum representing operation that will be performend on a sound at given time
+**/
+enum SoundNext
+{
+ SOPER_CONTINUE = 1, /*!< continue playing */
+ SOPER_STOP = 2, /*!< stop playing */
+ SOPER_LOOP = 3, /*!< start over */
+};
+
+
+/**
+* @class CSoundInterface
+*
+* @brief Sound plugin interface
+*
+*/
+class CSoundInterface : public CPlugin
+{
+ public:
+ CSoundInterface() {
+ //CInstanceManager::getInstance().AddInstance(CLASS_SOUND, this);
+ //m_iMan->AddInstance(CLASS_SOUND, this);
+ };
+ virtual ~CSoundInterface() = 0;
+
+ /** Function to initialize sound device
+ * @param bool b3D - enable support for 3D sound
+ */
+ virtual bool Create(bool b3D) = 0;
+
+ /** Function called to cache all sound effect files.
+ * Function calls \link CSoundInterface::Cache() \endlink for each file
+ */
+ virtual void CacheAll() = 0;
+
+ /** Function called to cache sound effect file.
+ * This function is called by plugin interface for each file.
+ * @param Sound bSound - id of a file, will be used to identify sound files
+ * @param std::string bFile - file to load
+ * @return return true on success
+ */
+ virtual bool Cache(Sound bSound, std::string bFile) = 0;
+
+ /** Return if plugin is enabled
+ * @return return true if plugin is enabled
+ */
+ virtual bool RetEnable() = 0;
+
+ /** Change sound mode to 2D/3D
+ * @param bool bMode - true to enable 3D sound
+ */
+ virtual void SetSound3D(bool bMode) = 0;
+
+ /** Return if we use 3D sound
+ * @return true if we have 3D sound enabled
+ */
+ virtual bool RetSound3D() = 0;
+
+ /** Return if we have 3D sound capable card
+ * @return true for 3D sound support
+ */
+ virtual bool RetSound3DCap() = 0;
+
+ /** Change global sound volume
+ * @param int volume - range from 0 to MAXVOLUME
+ */
+ virtual void SetAudioVolume(int volume) = 0;
+
+ /** Return global sound volume
+ * @return global volume as int in range from 0 to MAXVOLUME
+ */
+ virtual int RetAudioVolume() = 0;
+
+ /** Set music volume
+ * @param int volume - range from 0 to MAXVOLUME
+ */
+ virtual void SetMusicVolume(int volume) = 0;
+
+ /** Return music volume
+ * @return music volume as int in range from 0 to MAXVOLUME
+ */
+ virtual int RetMusicVolume() = 0;
+
+ /** Set listener position
+ * @param Math::Vector eye - position of listener
+ * @param Math::Vector lookat - direction listener is looking at
+ */
+ virtual void SetListener(Math::Vector eye, Math::Vector lookat) = 0;
+
+ /** Update data each frame
+ * @param float rTime - time since last update
+ */
+ virtual void FrameMove(float rTime) = 0;
+
+ /** Play specific sound
+ * @param Sound sound - sound to play
+ * @param float amplitude - change amplitude of sound before playing
+ * @param float frequency - change sound frequency before playing (0.5 octave down, 2.0 octave up)
+ * @param bool bLoop - loop sound
+ * @return identifier of channel that sound will be played on
+ */
+ virtual int Play(Sound sound, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false) = 0;
+
+ /** Play specific sound
+ * @param Sound sound - sound to play
+ * @param Math:Vector pos - position of sound in space
+ * @param float amplitude - change amplitude of sound before playing
+ * @param float frequency - change sound frequency before playing (0.5 octave down, 2.0 octave up)
+ * @param bool bLoop - loop sound
+ * @return identifier of channel that sound will be played on
+ */
+ virtual int Play(Sound sound, Math::Vector pos, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false) = 0;
+
+ /** Remove all operations that would be made on sound in channel.
+ * @param int channel - channel to work on
+ * @return return true on success
+ */
+ virtual bool FlushEnvelope(int channel) = 0;
+
+ /** Add envelope to sound. Envelope is a operatino that will be performend on sound in future like changing frequency
+ * @param int channel - channel to work on
+ * @param float amplitude - change amplitude
+ * @param float frequency - change frequency
+ * @param float time - when to change (sample time)
+ * @param SoundNext oper - operation to perform
+ * @return return true on success
+ */
+ virtual bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper) = 0;
+
+ /** Set sound position in space
+ * @param int channel - channel to work on
+ * @param Math::Vector pos - new positino of a sound
+ * @return return true on success
+ */
+ virtual bool Position(int channel, Math::Vector pos) = 0;
+
+ /** Set sound frequency
+ * @param int channel - channel to work on
+ * @param float frequency - change sound frequency
+ * @return return true on success
+ */
+ virtual bool Frequency(int channel, float frequency) = 0;
+
+ /** Stop playing sound
+ * @param int channel - channel to work on
+ * @return return true on success
+ */
+ virtual bool Stop(int channel) = 0;
+
+ /** Stop playing all sounds
+ * @return return true on success
+ */
+ virtual bool StopAll() = 0;
+
+ /** Mute/unmute all sounds
+ * @param bool bMute
+ * @return return true on success
+ */
+ virtual bool MuteAll(bool bMute) = 0;
+
+ /** Start playing music
+ * @param int rank - track number
+ * @param bool bRepeat - repeat playing
+ * @return return true on success
+ */
+ virtual bool PlayMusic(int rank, bool bRepeat) = 0;
+
+ /** Restart music
+ * @return return true on success
+ */
+ virtual bool RestartMusic() = 0;
+
+ /** Susspend paying music
+ * @return return true on success
+ */
+ virtual void SuspendMusic() = 0;
+
+ /** Stop playing music
+ * @return return true on success
+ */
+ virtual void StopMusic() = 0;
+
+ /** Check if music if playing
+ * @return return true if music is playing
+ */
+ virtual bool IsPlayingMusic() = 0;
+};
|