2010-11-20 10:37:14 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
2010-05-29 07:25:38 +00:00
|
|
|
#ifndef ENGINE_CLIENT_SOUND_H
|
|
|
|
#define ENGINE_CLIENT_SOUND_H
|
|
|
|
|
Make sure headers compile standalone
Not planning to do this automatically, but at least cleaning it up once
provides some benefit. Every header should include what it uses.
$ for i in src/**/*.h; do j=${i#"src/"}; echo $j; echo "#include <$j>\nint main() { return 0; }" | /usr/bin/c++ -DCONF_OPENSSL -DCONF_SQL -DCONF_VIDEORECORDER -DCONF_WAVPACK_CLOSE_FILE -DCONF_WAVPACK_OPEN_FILE_INPUT_EX -DGAME_RELEASE_VERSION=\"15.0.5\" -DGLEW_STATIC -D_FORTIFY_SOURCE=2 -I/usr/include/freetype2 -I/usr/include/opus -I/usr/include/SDL2 -I/usr/include/wavpack -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -Isrc -I/usr/include/mysql -I/home/deen/sys/include/ -O2 -g -DNDEBUG -fdiagnostics-color=always -fstack-protector-all -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wformat=2 -Wno-nullability-completeness -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wrestrict -std=gnu++11 -o /dev/null -x c++ -; done
Ignored: tuning.h, variables.h, config_common.h, mapitems_ex_types.h, mapbugs_list.h, protocol7.h, teehistorian_ex_chunks.h, protocol_ex_msgs.h, config.h, config_variables.h, external, keynames.h
2020-09-26 08:23:33 +00:00
|
|
|
#include <engine/graphics.h>
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <engine/sound.h>
|
Make sure headers compile standalone
Not planning to do this automatically, but at least cleaning it up once
provides some benefit. Every header should include what it uses.
$ for i in src/**/*.h; do j=${i#"src/"}; echo $j; echo "#include <$j>\nint main() { return 0; }" | /usr/bin/c++ -DCONF_OPENSSL -DCONF_SQL -DCONF_VIDEORECORDER -DCONF_WAVPACK_CLOSE_FILE -DCONF_WAVPACK_OPEN_FILE_INPUT_EX -DGAME_RELEASE_VERSION=\"15.0.5\" -DGLEW_STATIC -D_FORTIFY_SOURCE=2 -I/usr/include/freetype2 -I/usr/include/opus -I/usr/include/SDL2 -I/usr/include/wavpack -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -Isrc -I/usr/include/mysql -I/home/deen/sys/include/ -O2 -g -DNDEBUG -fdiagnostics-color=always -fstack-protector-all -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wformat=2 -Wno-nullability-completeness -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wrestrict -std=gnu++11 -o /dev/null -x c++ -; done
Ignored: tuning.h, variables.h, config_common.h, mapitems_ex_types.h, mapbugs_list.h, protocol7.h, teehistorian_ex_chunks.h, protocol_ex_msgs.h, config.h, config_variables.h, external, keynames.h
2020-09-26 08:23:33 +00:00
|
|
|
#include <engine/storage.h>
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2017-07-30 10:33:51 +00:00
|
|
|
#include "SDL.h"
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
class CSound : public IEngineSound
|
|
|
|
{
|
2011-06-27 20:57:06 +00:00
|
|
|
int m_SoundEnabled;
|
2017-07-30 10:33:51 +00:00
|
|
|
SDL_AudioDeviceID m_Device;
|
2011-06-27 20:57:06 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
public:
|
|
|
|
IEngineGraphics *m_pGraphics;
|
|
|
|
IStorage *m_pStorage;
|
|
|
|
|
|
|
|
virtual int Init();
|
|
|
|
|
|
|
|
int Update();
|
|
|
|
int Shutdown();
|
2011-02-12 10:40:36 +00:00
|
|
|
int AllocID();
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2011-02-12 10:40:36 +00:00
|
|
|
static void RateConvert(int SampleID);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
// TODO: Refactor: clean this mess up
|
2014-10-11 12:50:16 +00:00
|
|
|
static int DecodeWV(int SampleID, const void *pData, unsigned DataSize);
|
2014-10-27 15:23:53 +00:00
|
|
|
static int DecodeOpus(int SampleID, const void *pData, unsigned DataSize);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2011-06-27 20:57:06 +00:00
|
|
|
virtual bool IsSoundEnabled() { return m_SoundEnabled != 0; }
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual int LoadWV(const char *pFilename);
|
2014-10-24 23:23:39 +00:00
|
|
|
virtual int LoadWVFromMem(const void *pData, unsigned DataSize, bool FromEditor);
|
2014-10-27 15:23:53 +00:00
|
|
|
virtual int LoadOpus(const char *pFilename);
|
|
|
|
virtual int LoadOpusFromMem(const void *pData, unsigned DataSize, bool FromEditor);
|
2014-10-11 11:38:08 +00:00
|
|
|
virtual void UnloadSample(int SampleID);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2014-10-11 11:55:13 +00:00
|
|
|
virtual float GetSampleDuration(int SampleID); // in s
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void SetListenerPos(float x, float y);
|
2011-02-12 10:40:36 +00:00
|
|
|
virtual void SetChannel(int ChannelID, float Vol, float Pan);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2014-10-12 14:12:13 +00:00
|
|
|
virtual void SetVoiceVolume(CVoiceHandle Voice, float Volume);
|
2014-11-29 13:29:40 +00:00
|
|
|
virtual void SetVoiceFalloff(CVoiceHandle Voice, float Falloff);
|
2014-10-12 14:12:13 +00:00
|
|
|
virtual void SetVoiceLocation(CVoiceHandle Voice, float x, float y);
|
2014-10-18 13:21:13 +00:00
|
|
|
virtual void SetVoiceTimeOffset(CVoiceHandle Voice, float offset); // in s
|
2014-10-11 15:55:22 +00:00
|
|
|
|
2014-11-29 13:29:40 +00:00
|
|
|
virtual void SetVoiceCircle(CVoiceHandle Voice, float Radius);
|
|
|
|
virtual void SetVoiceRectangle(CVoiceHandle Voice, float Width, float Height);
|
|
|
|
|
2014-10-12 14:12:13 +00:00
|
|
|
CVoiceHandle Play(int ChannelID, int SampleID, int Flags, float x, float y);
|
|
|
|
virtual CVoiceHandle PlayAt(int ChannelID, int SampleID, int Flags, float x, float y);
|
|
|
|
virtual CVoiceHandle Play(int ChannelID, int SampleID, int Flags);
|
2011-04-13 18:00:54 +00:00
|
|
|
virtual void Stop(int SampleID);
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void StopAll();
|
2014-10-18 13:21:13 +00:00
|
|
|
virtual void StopVoice(CVoiceHandle Voice);
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|