DDraceNetwork Docs
sounds.h
Go to the documentation of this file.
1/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2/* If you are missing that file, acquire a complete release at teeworlds.com. */
3#ifndef GAME_CLIENT_COMPONENTS_SOUNDS_H
4#define GAME_CLIENT_COMPONENTS_SOUNDS_H
5
6#include <base/vmath.h>
8#include <engine/sound.h>
10
11class CSoundLoading : public IJob
12{
15
16public:
17 CSoundLoading(CGameClient *pGameClient, bool Render);
18 void Run() override;
19};
20
21class CSounds : public CComponent
22{
23 enum
24 {
26 };
28 {
34 std::shared_ptr<CSoundLoading> m_pSoundJob;
36
37 void UpdateChannels();
38 int GetSampleId(int SetId);
39
40 float m_GuiSoundVolume = -1.0f;
41 float m_GameSoundVolume = -1.0f;
42 float m_MapSoundVolume = -1.0f;
44
45public:
46 // sound channels
47 enum
48 {
54 };
55
56 virtual int Sizeof() const override { return sizeof(*this); }
57 virtual void OnInit() override;
58 virtual void OnReset() override;
59 virtual void OnStateChange(int NewState, int OldState) override;
60 virtual void OnRender() override;
61
62 void ClearQueue();
63 void Enqueue(int Channel, int SetId);
64 void Play(int Channel, int SetId, float Volume);
65 void PlayAt(int Channel, int SetId, float Volume, vec2 Position);
66 void PlayAndRecord(int Channel, int SetId, float Volume, vec2 Position);
67 void Stop(int SetId);
68 bool IsPlaying(int SetId);
69
70 ISound::CVoiceHandle PlaySample(int Channel, int SampleId, int Flags, float Volume);
71 ISound::CVoiceHandle PlaySampleAt(int Channel, int SampleId, int Flags, float Volume, vec2 Position);
72};
73
74#endif
Definition: component.h:20
Definition: gameclient.h:124
Definition: sounds.h:12
CGameClient * m_pGameClient
Definition: sounds.h:13
void Run() override
Definition: sounds.cpp:22
CSoundLoading(CGameClient *pGameClient, bool Render)
Definition: sounds.cpp:15
bool m_Render
Definition: sounds.h:14
Definition: sounds.h:22
std::shared_ptr< CSoundLoading > m_pSoundJob
Definition: sounds.h:34
virtual void OnInit() override
Definition: sounds.cpp:100
float m_GameSoundVolume
Definition: sounds.h:41
float m_MapSoundVolume
Definition: sounds.h:42
void Stop(int SetId)
Definition: sounds.cpp:205
void PlayAndRecord(int Channel, int SetId, float Volume, vec2 Position)
Definition: sounds.cpp:183
@ CHN_GUI
Definition: sounds.h:49
@ CHN_WORLD
Definition: sounds.h:51
@ CHN_GLOBAL
Definition: sounds.h:52
@ CHN_MUSIC
Definition: sounds.h:50
@ CHN_MAPSOUND
Definition: sounds.h:53
void UpdateChannels()
Definition: sounds.cpp:46
@ QUEUE_SIZE
Definition: sounds.h:25
void Play(int Channel, int SetId, float Volume)
Definition: sounds.cpp:195
float m_GuiSoundVolume
Definition: sounds.h:40
virtual void OnRender() override
Definition: sounds.cpp:135
bool IsPlaying(int SetId)
Definition: sounds.cpp:216
ISound::CVoiceHandle PlaySample(int Channel, int SampleId, int Flags, float Volume)
Definition: sounds.cpp:228
bool m_WaitForSoundJob
Definition: sounds.h:35
virtual void OnStateChange(int NewState, int OldState) override
Definition: sounds.cpp:129
int GetSampleId(int SetId)
Definition: sounds.cpp:78
void Enqueue(int Channel, int SetId)
Definition: sounds.cpp:170
float m_BackgroundMusicVolume
Definition: sounds.h:43
struct CSounds::QueueEntry m_aQueue[QUEUE_SIZE]
int64_t m_QueueWaitTime
Definition: sounds.h:33
ISound::CVoiceHandle PlaySampleAt(int Channel, int SampleId, int Flags, float Volume, vec2 Position)
Definition: sounds.cpp:239
virtual int Sizeof() const override
Definition: sounds.h:56
void PlayAt(int Channel, int SetId, float Volume, vec2 Position)
Definition: sounds.cpp:200
void ClearQueue()
Definition: sounds.cpp:163
int m_QueuePos
Definition: sounds.h:32
virtual void OnReset() override
Definition: sounds.cpp:120
Definition: jobs.h:20
Definition: sound.h:48
Definition: sounds.h:28
int m_Channel
Definition: sounds.h:29
int m_SetId
Definition: sounds.h:30