Colobot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
sound.h
Go to the documentation of this file.
1 // * This file is part of the COLOBOT source code
2 // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
3 // * Copyright (C) 2012, Polish Portal of Colobot (PPC)
4 // *
5 // * This program is free software: you can redistribute it and/or modify
6 // * it under the terms of the GNU General Public License as published by
7 // * the Free Software Foundation, either version 3 of the License, or
8 // * (at your option) any later version.
9 // *
10 // * This program is distributed in the hope that it will be useful,
11 // * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // * GNU General Public License for more details.
14 // *
15 // * You should have received a copy of the GNU General Public License
16 // * along with this program. If not, see http://www.gnu.org/licenses/.
17 
23 #pragma once
24 
25 #include "math/vector.h"
26 
27 #include "common/logger.h"
28 
29 #include <string>
30 
34 const float MAXVOLUME = 100.0f;
35 
36 
42 enum Sound
43 {
44  SOUND_NONE = -1,
45  SOUND_CLICK = 0,
46  SOUND_BOUM = 1,
47  SOUND_EXPLO = 2,
48  SOUND_FLYh = 3,
49  SOUND_FLY = 4,
54  SOUND_ERROR = 9,
55  SOUND_CONVERT = 10,
56  SOUND_ENERGY = 11,
57  SOUND_PLOUF = 12,
58  SOUND_BLUP = 13,
59  SOUND_WARNING = 14,
60  SOUND_DERRICK = 15,
61  SOUND_LABO = 16,
62  SOUND_STATION = 17,
63  SOUND_REPAIR = 18,
64  SOUND_RESEARCH = 19,
66  SOUND_BURN = 21,
67  SOUND_TZOING = 22,
68  SOUND_GGG = 23,
69  SOUND_MANIP = 24,
70  SOUND_FIRE = 25,
71  SOUND_HUMAN1 = 26,
72  SOUND_STEPw = 27,
73  SOUND_SWIM = 28,
74  SOUND_RADAR = 29,
75  SOUND_BUILD = 30,
76  SOUND_ALARM = 31,
77  SOUND_SLIDE = 32,
78  SOUND_EXPLOi = 33,
83  SOUND_TREMBLE = 38,
84  SOUND_PSHHH = 39,
85  SOUND_NUCLEAR = 40,
86  SOUND_INFO = 41,
87  SOUND_OPEN = 42,
88  SOUND_CLOSE = 43,
89  SOUND_FACTORY = 44,
90  SOUND_EGG = 45,
91  SOUND_MOTORs = 46,
92  SOUND_MOTORi = 47,
93  SOUND_SHIELD = 48,
94  SOUND_FIREi = 49,
95  SOUND_GUNDEL = 50,
96  SOUND_PSHHH2 = 51,
97  SOUND_MESSAGE = 52,
98  SOUND_BOUMm = 53,
99  SOUND_BOUMv = 54,
100  SOUND_BOUMs = 55,
104  SOUND_STEPh = 59,
105  SOUND_STEPm = 60,
106  SOUND_POWERON = 61,
107  SOUND_POWEROFF = 62,
108  SOUND_AIE = 63,
109  SOUND_WAYPOINT = 64,
110  SOUND_RECOVER = 65,
111  SOUND_DEADi = 66,
112  SOUND_JOSTLE = 67,
113  SOUND_GFLAT = 68,
114  SOUND_DEADg = 69,
115  SOUND_DEADw = 70,
116  SOUND_FLYf = 71,
119  SOUND_THUMP = 74,
120  SOUND_TOUCH = 75,
121  SOUND_BLITZ = 76,
122  SOUND_MUSHROOM = 77,
123  SOUND_FIREp = 78,
126 // SOUND_MOTORd = 81, /*!< engine friction */
128 };
129 
130 
136 {
140 };
141 
142 
150 {
151 public:
152  CSoundInterface();
153  virtual ~CSoundInterface();
154 
157  virtual bool Create();
158 
162  void CacheAll();
163 
165  void AddMusicFiles();
166 
173  virtual bool Cache(Sound bSound, const std::string &bFile);
174 
180  virtual bool CacheMusic(const std::string &bFile);
181 
185  virtual bool GetEnable();
186 
190  virtual void SetAudioVolume(int volume);
191 
195  virtual int GetAudioVolume();
196 
200  virtual void SetMusicVolume(int volume);
201 
205  virtual int GetMusicVolume();
206 
211  virtual void SetListener(const Math::Vector &eye, const Math::Vector &lookat);
212 
216  virtual void FrameMove(float rTime);
217 
225  virtual int Play(Sound sound, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false);
226 
235  virtual int Play(Sound sound, const Math::Vector &pos, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false);
236 
241  virtual bool FlushEnvelope(int channel);
242 
251  virtual bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper);
252 
258  virtual bool Position(int channel, const Math::Vector &pos);
259 
265  virtual bool Frequency(int channel, float frequency);
266 
271  virtual bool Stop(int channel);
272 
276  virtual bool StopAll();
277 
282  virtual bool MuteAll(bool bMute);
283 
290  virtual bool PlayMusic(int rank, bool bRepeat, float fadeTime=2.0f);
291 
298  virtual bool PlayMusic(const std::string &filename, bool bRepeat, float fadeTime=2.0f);
299 
303  virtual bool RestartMusic();
304 
308  virtual void SuspendMusic();
309 
313  virtual void StopMusic(float fadeTime=2.0f);
314 
318  virtual bool IsPlayingMusic();
319 
324  virtual bool PlayPauseMusic(const std::string &filename, bool repeat);
325 
329  virtual void StopPauseMusic();
330 };
331 
virtual bool MuteAll(bool bMute)
Definition: sound.cpp:144
Definition: sound.h:104
virtual bool Frequency(int channel, float frequency)
Definition: sound.cpp:129
Definition: sound.h:124
virtual void FrameMove(float rTime)
Definition: sound.cpp:100
Definition: sound.h:99
Definition: sound.h:48
Definition: sound.h:71
virtual bool PlayPauseMusic(const std::string &filename, bool repeat)
Definition: sound.cpp:177
Definition: sound.h:138
virtual bool Create()
Definition: sound.cpp:39
Definition: sound.h:51
virtual void SetListener(const Math::Vector &eye, const Math::Vector &lookat)
Definition: sound.cpp:96
Definition: sound.h:98
virtual bool FlushEnvelope(int channel)
Definition: sound.cpp:114
Definition: sound.h:103
Definition: sound.h:118
Definition: sound.h:102
Definition: sound.h:117
virtual void StopPauseMusic()
Definition: sound.cpp:182
virtual bool StopAll()
Definition: sound.cpp:139
void AddMusicFiles()
Definition: sound.cpp:55
virtual void SuspendMusic()
Definition: sound.cpp:164
virtual void SetAudioVolume(int volume)
Definition: sound.cpp:78
Definition: sound.h:79
virtual bool PlayMusic(int rank, bool bRepeat, float fadeTime=2.0f)
Definition: sound.cpp:149
Definition: sound.h:139
virtual bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper)
Definition: sound.cpp:119
Definition: sound.h:125
Definition: sound.h:115
Definition: sound.h:81
Definition: sound.h:52
Definition: sound.h:127
Definition: sound.h:137
Definition: sound.h:50
void CacheAll()
Definition: sound.cpp:44
Definition: sound.h:76
virtual bool GetEnable()
Definition: sound.cpp:73
virtual bool Position(int channel, const Math::Vector &pos)
Definition: sound.cpp:124
Definition: sound.h:78
virtual bool Stop(int channel)
Definition: sound.cpp:134
Definition: sound.h:80
virtual int Play(Sound sound, float amplitude=1.0f, float frequency=1.0f, bool bLoop=false)
Definition: sound.cpp:104
const float MAXVOLUME
Definition: sound.h:34
virtual void SetMusicVolume(int volume)
Definition: sound.cpp:87
SoundNext
Enum representing operation that will be performend on a sound at given time.
Definition: sound.h:135
Definition: sound.h:82
virtual int GetAudioVolume()
Definition: sound.cpp:82
virtual void StopMusic(float fadeTime=2.0f)
Definition: sound.cpp:168
Definition: sound.h:96
Definition: sound.h:101
Definition: sound.h:72
Sound
Sound enum representing sound file.
Definition: sound.h:42
Definition: sound.h:70
Definition: sound.h:116
Definition: sound.h:65
Vector struct and related functions.
Definition: sound.h:123
Definition: sound.h:114
virtual bool RestartMusic()
Definition: sound.cpp:159
Class for logging information to file or console.
Definition: sound.h:91
Definition: sound.h:94
3D (3x1) vector
Definition: vector.h:49
virtual int GetMusicVolume()
Definition: sound.cpp:91
Definition: sound.h:53
virtual bool Cache(Sound bSound, const std::string &bFile)
Definition: sound.cpp:63
Definition: sound.h:105
Definition: sound.h:100
virtual bool IsPlayingMusic()
Definition: sound.cpp:172
Definition: sound.h:92
Sound plugin interface.
Definition: sound.h:149
virtual bool CacheMusic(const std::string &bFile)
Definition: sound.cpp:68