ScummVM API documentation
SoundChannel.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * Copyright (C) 2006-2010 - Frictional Games
24  *
25  * This file is part of HPL1 Engine.
26  */
27 
28 #ifndef HPL_SOUND_CHANNEL_H
29 #define HPL_SOUND_CHANNEL_H
30 
31 #include "common/list.h"
32 #include "hpl1/engine/math/MathTypes.h"
33 
34 namespace hpl {
35 class iSoundData;
36 class cSoundManager;
37 
39 public:
40  virtual ~iSoundChannelCallback() = default;
41  virtual void OnPriorityRelease() = 0;
42 };
43 
44 //--------------------------------------------
45 
47 public:
48  iSoundChannel(iSoundData *apData, cSoundManager *apSoundManger) : mpData(apData) {
49  mbLooping = false;
50  mbPaused = true;
51  mbPositionRelative = false;
52 
53  mfSpeed = 1;
54  mfVolume = 1;
55  mfMaxDistance = 0;
56  mfMinDistance = 0;
57 
58  mpSoundManger = apSoundManger;
59 
60  mvVelocity = cVector3f(0, 0, 0);
61  mvPosition = cVector3f(0, 0, 0);
62  mvRelPosition = cVector3f(0, 0, 0);
63 
64  mbBlockable = false;
65  mfBlockVolumeMul = 1;
66 
67  mbAffectedByEnv = false;
68 
69  mlPriorityModifier = 0;
70 
71  mbStopUsed = false;
72 
73  mpCallback = NULL;
74 
75  mlId = 0;
76  }
77 
78  virtual ~iSoundChannel() {}
79 
80  virtual void Play() = 0;
81  virtual void Stop() = 0;
82 
83  virtual void SetPaused(bool abX) = 0;
84  virtual void SetSpeed(float afSpeed) = 0;
85  virtual void SetVolume(float afVolume) = 0;
86  virtual void SetLooping(bool abLoop) = 0;
87  virtual void SetPan(float afPan) = 0;
88  virtual void Set3D(bool ab3D) = 0;
89 
90  virtual void SetPriority(int alX) = 0;
91  virtual int GetPriority() = 0;
92 
93  void SetPriorityModifier(int alX) {
94  mlPriorityModifier = alX;
95  SetPriority(GetPriority());
96  }
97  int GetPriorityModifier() { return mlPriorityModifier; }
98 
99  virtual void SetPositionRelative(bool abRelative) = 0;
100  virtual void SetPosition(const cVector3f &avPos) = 0;
101  void SetRelPosition(const cVector3f &avPos) { mvRelPosition = avPos; }
102 
103  virtual void SetVelocity(const cVector3f &avVel) = 0;
104 
105  virtual void SetMinDistance(float fMin) = 0;
106  virtual void SetMaxDistance(float fMax) = 0;
107 
108  virtual bool IsPlaying() = 0;
109  virtual bool IsBufferUnderrun() = 0;
110  virtual double GetElapsedTime() = 0;
111  virtual double GetTotalTime() = 0;
112 
113  bool GetPaused() { return mbPaused; }
114  float GetSpeed() { return mfSpeed; }
115  float GetVolume() { return mfVolume; }
116  bool GetLooping() { return mbLooping; }
117  float GetPan() { return mfPan; }
118  bool Get3D() { return mb3D; }
119 
120  bool GetStopUsed() { return mbStopUsed; }
121 
122  bool GetBlockable() { return mbBlockable; }
123  void SetBlockable(bool abX) { mbBlockable = abX; }
124  void SetBlockVolumeMul(float afX) { mfBlockVolumeMul = afX; }
125  float GetBlockVolumeMul() { return mfBlockVolumeMul; }
126 
127  bool GetPositionRelative() { return mbPositionRelative; }
128 
129  const cVector3f &GetRelPosition() { return mvRelPosition; }
130  const cVector3f &GetPosition() { return mvPosition; }
131  const cVector3f &GetVelocity() { return mvVelocity; }
132 
133  float GetMinDistance() { return mfMinDistance; }
134  float GetMaxDistance() { return mfMaxDistance; }
135 
136  iSoundChannelCallback *GetCallBack() { return mpCallback; }
137  void SetCallBack(iSoundChannelCallback *apCallback) { mpCallback = apCallback; }
138 
139  int GetId() { return mlId; }
140  void SetId(int alX) { mlId = alX; }
141 
142  iSoundData *GetData() { return mpData; }
143 
144  // virtual void SetFiltering ( iFilter* apFilter, int alFlags ) = 0;
145  virtual void SetAffectedByEnv(bool abAffected) { mbAffectedByEnv = abAffected; }
146  virtual void SetFiltering(bool abEnabled, int alFlags) = 0;
147  virtual void SetFilterGain(float afGain) = 0;
148  virtual void SetFilterGainHF(float afGainHF) = 0;
149 
150 protected:
151  iSoundData *mpData;
152  cSoundManager *mpSoundManger;
153 
154  bool mbLooping;
155  bool mbPaused;
156  bool mbPositionRelative;
157  bool mb3D;
158 
159  float mfSpeed;
160  float mfVolume;
161  float mfPan;
162  float mfMaxDistance;
163  float mfMinDistance;
164 
165  cVector3f mvVelocity;
166  cVector3f mvPosition;
167  cVector3f mvRelPosition;
168 
169  bool mbBlockable;
170  float mfBlockVolumeMul;
171 
172  bool mbAffectedByEnv;
173 
174  int mlPriority;
175  int mlPriorityModifier;
176 
177  bool mbStopUsed;
178 
179  int mlId;
180 
181  iSoundChannelCallback *mpCallback;
182 };
183 
186 
187 } // namespace hpl
188 
189 #endif // HPL_SOUND_CHANNEL_H
Definition: AI.h:36
Definition: SoundChannel.h:38
Definition: list.h:44
Definition: SoundManager.h:39
Definition: SoundData.h:39
Definition: SoundChannel.h:46
Definition: list_intern.h:51