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
|
|
|
|
|
2022-06-16 17:50:46 +00:00
|
|
|
#include <engine/shared/video.h>
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <engine/sound.h>
|
|
|
|
|
2022-05-29 13:51:38 +00:00
|
|
|
#include <SDL_audio.h>
|
2017-07-30 10:33:51 +00:00
|
|
|
|
2022-06-16 17:50:46 +00:00
|
|
|
class IEngineGraphics;
|
|
|
|
class IStorage;
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
class CSound : public IEngineSound
|
|
|
|
{
|
2022-06-26 20:00:18 +00:00
|
|
|
bool 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
|
|
|
IEngineGraphics *m_pGraphics;
|
|
|
|
IStorage *m_pStorage;
|
|
|
|
|
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
|
|
|
|
2022-06-26 20:04:28 +00:00
|
|
|
public:
|
2023-07-01 17:50:20 +00:00
|
|
|
CSound();
|
2022-06-26 20:04:28 +00:00
|
|
|
int Init() override;
|
|
|
|
int Update() override;
|
2022-09-16 14:31:36 +00:00
|
|
|
void Shutdown() override;
|
2022-06-26 20:04:28 +00:00
|
|
|
|
2022-06-26 20:00:18 +00:00
|
|
|
bool IsSoundEnabled() override { return m_SoundEnabled; }
|
2011-06-27 20:57:06 +00:00
|
|
|
|
2023-06-25 18:41:49 +00:00
|
|
|
int LoadWV(const char *pFilename, int StorageType = IStorage::TYPE_ALL) override;
|
2022-05-17 20:13:44 +00:00
|
|
|
int LoadWVFromMem(const void *pData, unsigned DataSize, bool FromEditor) override;
|
2023-06-25 18:41:49 +00:00
|
|
|
int LoadOpus(const char *pFilename, int StorageType = IStorage::TYPE_ALL) override;
|
2022-05-17 20:13:44 +00:00
|
|
|
int LoadOpusFromMem(const void *pData, unsigned DataSize, bool FromEditor) override;
|
|
|
|
void UnloadSample(int SampleID) override;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2022-05-17 20:13:44 +00:00
|
|
|
float GetSampleDuration(int SampleID) override; // in s
|
2014-10-11 11:55:13 +00:00
|
|
|
|
2022-05-17 20:13:44 +00:00
|
|
|
void SetChannel(int ChannelID, float Vol, float Pan) override;
|
2023-09-21 21:02:53 +00:00
|
|
|
void SetListenerPos(float x, float y) override;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2022-05-17 20:13:44 +00:00
|
|
|
void SetVoiceVolume(CVoiceHandle Voice, float Volume) override;
|
|
|
|
void SetVoiceFalloff(CVoiceHandle Voice, float Falloff) override;
|
|
|
|
void SetVoiceLocation(CVoiceHandle Voice, float x, float y) override;
|
2023-09-21 21:01:29 +00:00
|
|
|
void SetVoiceTimeOffset(CVoiceHandle Voice, float TimeOffset) override; // in s
|
2014-10-11 15:55:22 +00:00
|
|
|
|
2022-05-17 20:13:44 +00:00
|
|
|
void SetVoiceCircle(CVoiceHandle Voice, float Radius) override;
|
|
|
|
void SetVoiceRectangle(CVoiceHandle Voice, float Width, float Height) override;
|
2014-11-29 13:29:40 +00:00
|
|
|
|
2014-10-12 14:12:13 +00:00
|
|
|
CVoiceHandle Play(int ChannelID, int SampleID, int Flags, float x, float y);
|
2022-05-17 20:13:44 +00:00
|
|
|
CVoiceHandle PlayAt(int ChannelID, int SampleID, int Flags, float x, float y) override;
|
|
|
|
CVoiceHandle Play(int ChannelID, int SampleID, int Flags) override;
|
|
|
|
void Stop(int SampleID) override;
|
|
|
|
void StopAll() override;
|
|
|
|
void StopVoice(CVoiceHandle Voice) override;
|
2022-06-26 19:35:36 +00:00
|
|
|
bool IsPlaying(int SampleID) override;
|
2022-05-17 20:13:44 +00:00
|
|
|
|
|
|
|
ISoundMixFunc GetSoundMixFunc() override;
|
|
|
|
void PauseAudioDevice() override;
|
|
|
|
void UnpauseAudioDevice() override;
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|