Colobot
sound.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see http://gnu.org/licenses
18  */
19 
25 #pragma once
26 
27 #include "math/vector.h"
28 
29 #include "common/logger.h"
30 
31 #include <string>
32 
36 const float MAXVOLUME = 100.0f;
37 
38 
44 enum Sound
45 {
46  SOUND_NONE = -1,
47  SOUND_CLICK = 0,
48  SOUND_BOUM = 1,
49  SOUND_EXPLO = 2,
50  SOUND_FLYh = 3,
51  SOUND_FLY = 4,
56  SOUND_ERROR = 9,
57  SOUND_CONVERT = 10,
58  SOUND_ENERGY = 11,
59  SOUND_PLOUF = 12,
60  SOUND_BLUP = 13,
61  SOUND_WARNING = 14,
62  SOUND_DERRICK = 15,
63  SOUND_LABO = 16,
64  SOUND_STATION = 17,
65  SOUND_REPAIR = 18,
66  SOUND_RESEARCH = 19,
68  SOUND_BURN = 21,
69  SOUND_TZOING = 22,
70  SOUND_GGG = 23,
71  SOUND_MANIP = 24,
72  SOUND_FIRE = 25,
73  SOUND_HUMAN1 = 26,
74  SOUND_STEPw = 27,
75  SOUND_SWIM = 28,
76  SOUND_RADAR = 29,
77  SOUND_BUILD = 30,
78  SOUND_ALARM = 31,
79  SOUND_SLIDE = 32,
80  SOUND_EXPLOi = 33,
85  SOUND_TREMBLE = 38,
86  SOUND_PSHHH = 39,
87  SOUND_NUCLEAR = 40,
88  SOUND_INFO = 41,
89  SOUND_OPEN = 42,
90  SOUND_CLOSE = 43,
91  SOUND_FACTORY = 44,
92  SOUND_EGG = 45,
93  SOUND_MOTORs = 46,
94  SOUND_MOTORi = 47,
95  SOUND_SHIELD = 48,
96  SOUND_FIREi = 49,
97  SOUND_GUNDEL = 50,
98  SOUND_PSHHH2 = 51,
99  SOUND_MESSAGE = 52,
100  SOUND_BOUMm = 53,
101  SOUND_BOUMv = 54,
102  SOUND_BOUMs = 55,
106  SOUND_STEPh = 59,
107  SOUND_STEPm = 60,
108  SOUND_POWERON = 61,
109  SOUND_POWEROFF = 62,
110  SOUND_AIE = 63,
111  SOUND_WAYPOINT = 64,
112  SOUND_RECOVER = 65,
113  SOUND_DEADi = 66,
114  SOUND_JOSTLE = 67,
115  SOUND_GFLAT = 68,
116  SOUND_DEADg = 69,
117  SOUND_DEADw = 70,
118  SOUND_FLYf = 71,
121  SOUND_THUMP = 74,
122  SOUND_TOUCH = 75,
123  SOUND_BLITZ = 76,
124  SOUND_MUSHROOM = 77,
125  SOUND_FIREp = 78,
128 // SOUND_MOTORd = 81, /*!< engine friction */
130 };
131 
132 
138 {
142 };
143 
144 
152 {
153 public:
154  CSoundInterface();
155  virtual ~CSoundInterface();
156 
159  virtual bool Create();
160 
164  void CacheAll();
165 
167  void AddMusicFiles();
168 
175  virtual bool Cache(Sound bSound, const std::string &bFile);
176 
182  virtual bool CacheMusic(const std::string &bFile);
183 
188  virtual bool IsCached(Sound bSound);
189 
194  virtual bool IsCachedMusic(const std::string &bFile);
195 
199  virtual bool GetEnable();
200 
204  virtual void SetAudioVolume(int volume);
205 
209  virtual int GetAudioVolume();
210 
214  virtual void SetMusicVolume(int volume);
215 
219  virtual int GetMusicVolume();
220 
225  virtual void SetListener(const Math::Vector &eye, const Math::Vector &lookat);
226 
230  virtual void FrameMove(float rTime);
231 
239  virtual int Play(Sound sound, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false);
240 
249  virtual int Play(Sound sound, const Math::Vector &pos, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false);
250 
255  virtual bool FlushEnvelope(int channel);
256 
265  virtual bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper);
266 
272  virtual bool Position(int channel, const Math::Vector &pos);
273 
279  virtual bool Frequency(int channel, float frequency);
280 
285  virtual bool Stop(int channel);
286 
290  virtual bool StopAll();
291 
296  virtual bool MuteAll(bool bMute);
297 
304  virtual bool PlayMusic(int rank, bool bRepeat, float fadeTime=2.0f);
305 
312  virtual bool PlayMusic(const std::string &filename, bool bRepeat, float fadeTime=2.0f);
313 
317  virtual bool RestartMusic();
318 
322  virtual void SuspendMusic();
323 
327  virtual void StopMusic(float fadeTime=2.0f);
328 
332  virtual bool IsPlayingMusic();
333 
338  virtual bool PlayPauseMusic(const std::string &filename, bool repeat);
339 
343  virtual void StopPauseMusic();
344 };
345 
virtual bool IsCached(Sound bSound)
Definition: sound.cpp:75
virtual bool MuteAll(bool bMute)
Definition: sound.cpp:156
Definition: sound.h:106
virtual bool Frequency(int channel, float frequency)
Definition: sound.cpp:141
Definition: sound.h:126
virtual void FrameMove(float rTime)
Definition: sound.cpp:112
Definition: sound.h:101
Definition: sound.h:50
Definition: sound.h:73
virtual bool PlayPauseMusic(const std::string &filename, bool repeat)
Definition: sound.cpp:189
Definition: sound.h:140
virtual bool Create()
Definition: sound.cpp:41
Definition: sound.h:53
virtual void SetListener(const Math::Vector &eye, const Math::Vector &lookat)
Definition: sound.cpp:108
Definition: sound.h:100
virtual bool FlushEnvelope(int channel)
Definition: sound.cpp:126
Definition: sound.h:105
Definition: sound.h:120
Definition: sound.h:104
Definition: sound.h:119
virtual void StopPauseMusic()
Definition: sound.cpp:194
virtual bool StopAll()
Definition: sound.cpp:151
void AddMusicFiles()
Definition: sound.cpp:57
virtual void SuspendMusic()
Definition: sound.cpp:176
virtual void SetAudioVolume(int volume)
Definition: sound.cpp:90
Definition: sound.h:81
virtual bool PlayMusic(int rank, bool bRepeat, float fadeTime=2.0f)
Definition: sound.cpp:161
Definition: sound.h:141
virtual bool IsCachedMusic(const std::string &bFile)
Definition: sound.cpp:80
virtual bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper)
Definition: sound.cpp:131
Definition: sound.h:127
Definition: sound.h:117
Definition: sound.h:83
Definition: sound.h:54
Definition: sound.h:129
Definition: sound.h:139
Definition: sound.h:52
void CacheAll()
Definition: sound.cpp:46
Definition: sound.h:78
virtual bool GetEnable()
Definition: sound.cpp:85
virtual bool Position(int channel, const Math::Vector &pos)
Definition: sound.cpp:136
Definition: sound.h:80
virtual bool Stop(int channel)
Definition: sound.cpp:146
Definition: sound.h:82
virtual int Play(Sound sound, float amplitude=1.0f, float frequency=1.0f, bool bLoop=false)
Definition: sound.cpp:116
const float MAXVOLUME
Definition: sound.h:36
virtual void SetMusicVolume(int volume)
Definition: sound.cpp:99
SoundNext
Enum representing operation that will be performend on a sound at given time.
Definition: sound.h:137
Definition: sound.h:84
virtual int GetAudioVolume()
Definition: sound.cpp:94
virtual void StopMusic(float fadeTime=2.0f)
Definition: sound.cpp:180
Definition: sound.h:98
Definition: sound.h:103
Definition: sound.h:74
Sound
Sound enum representing sound file.
Definition: sound.h:44
Definition: sound.h:72
Definition: sound.h:118
Definition: sound.h:67
Vector struct and related functions.
Definition: sound.h:125
Definition: sound.h:116
virtual bool RestartMusic()
Definition: sound.cpp:171
Class for logging information to file or console.
Definition: sound.h:93
Definition: sound.h:96
3D (3x1) vector
Definition: vector.h:52
virtual int GetMusicVolume()
Definition: sound.cpp:103
Definition: sound.h:55
virtual bool Cache(Sound bSound, const std::string &bFile)
Definition: sound.cpp:65
Definition: sound.h:107
Definition: sound.h:102
virtual bool IsPlayingMusic()
Definition: sound.cpp:184
Definition: sound.h:94
Sound plugin interface.
Definition: sound.h:151
virtual bool CacheMusic(const std::string &bFile)
Definition: sound.cpp:70