ddnet/src/engine/client/sound.h

70 lines
2.3 KiB
C
Raw Normal View History

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>
2022-06-16 17:50:46 +00:00
class IEngineGraphics;
class IStorage;
2010-05-29 07:25:38 +00:00
class CSound : public IEngineSound
{
bool m_SoundEnabled;
SDL_AudioDeviceID m_Device;
2010-05-29 07:25:38 +00:00
public:
IEngineGraphics *m_pGraphics;
IStorage *m_pStorage;
int Init() override;
2010-05-29 07:25:38 +00:00
int Update() override;
int Shutdown() override;
int AllocID();
2010-05-29 07:25:38 +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);
static int DecodeOpus(int SampleID, const void *pData, unsigned DataSize);
2010-05-29 07:25:38 +00:00
bool IsSoundEnabled() override { return m_SoundEnabled; }
int LoadWV(const char *pFilename) override;
int LoadWVFromMem(const void *pData, unsigned DataSize, bool FromEditor) override;
int LoadOpus(const char *pFilename) override;
int LoadOpusFromMem(const void *pData, unsigned DataSize, bool FromEditor) override;
void UnloadSample(int SampleID) override;
2010-05-29 07:25:38 +00:00
float GetSampleDuration(int SampleID) override; // in s
void SetListenerPos(float x, float y) override;
void SetChannel(int ChannelID, float Vol, float Pan) override;
2010-05-29 07:25:38 +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;
void SetVoiceTimeOffset(CVoiceHandle Voice, float offset) override; // in s
void SetVoiceCircle(CVoiceHandle Voice, float Radius) override;
void SetVoiceRectangle(CVoiceHandle Voice, float Width, float Height) override;
2014-10-12 14:12:13 +00:00
CVoiceHandle Play(int ChannelID, int SampleID, int Flags, float x, float y);
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;
bool IsPlaying(int SampleID) override;
ISoundMixFunc GetSoundMixFunc() override;
void PauseAudioDevice() override;
void UnpauseAudioDevice() override;
2010-05-29 07:25:38 +00:00
};
#endif