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 
158  virtual bool Create(bool b3D);
159 
163  void CacheAll(std::string path);
164 
166  void AddMusicFiles(std::string path);
167 
174  virtual bool Cache(Sound bSound, std::string bFile);
175 
181  virtual bool CacheMusic(std::string bFile);
182 
186  virtual bool GetEnable();
187 
191  virtual void SetSound3D(bool bMode);
192 
196  virtual bool GetSound3D();
197 
201  virtual bool GetSound3DCap();
202 
206  virtual void SetAudioVolume(int volume);
207 
211  virtual int GetAudioVolume();
212 
216  virtual void SetMusicVolume(int volume);
217 
221  virtual int GetMusicVolume();
222 
227  virtual void SetListener(Math::Vector eye, Math::Vector lookat);
228 
232  virtual void FrameMove(float rTime);
233 
241  virtual int Play(Sound sound, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false);
242 
251  virtual int Play(Sound sound, Math::Vector pos, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false);
252 
257  virtual bool FlushEnvelope(int channel);
258 
267  virtual bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper);
268 
274  virtual bool Position(int channel, Math::Vector pos);
275 
281  virtual bool Frequency(int channel, float frequency);
282 
287  virtual bool Stop(int channel);
288 
292  virtual bool StopAll();
293 
298  virtual bool MuteAll(bool bMute);
299 
305  virtual bool PlayMusic(int rank, bool bRepeat);
306 
312  virtual bool PlayMusic(std::string filename, bool bRepeat);
313 
317  virtual bool RestartMusic();
318 
322  virtual void SuspendMusic();
323 
327  virtual void StopMusic();
328 
332  virtual bool IsPlayingMusic();
333 
334 protected:
335  std::string m_soundPath;
336 };
337 
virtual bool MuteAll(bool bMute)
Definition: sound.cpp:159
Definition: sound.h:104
virtual bool Frequency(int channel, float frequency)
Definition: sound.cpp:144
Definition: sound.h:124
virtual void FrameMove(float rTime)
Definition: sound.cpp:115
Definition: sound.h:99
void AddMusicFiles(std::string path)
Definition: sound.cpp:55
Definition: sound.h:48
Definition: sound.h:71
Definition: sound.h:138
Definition: sound.h:51
Definition: sound.h:98
virtual bool FlushEnvelope(int channel)
Definition: sound.cpp:129
Definition: sound.h:103
Definition: sound.h:118
Definition: sound.h:102
Definition: sound.h:117
void CacheAll(std::string path)
Definition: sound.cpp:44
virtual bool StopAll()
Definition: sound.cpp:154
virtual bool Position(int channel, Math::Vector pos)
Definition: sound.cpp:139
virtual void SuspendMusic()
Definition: sound.cpp:179
virtual void SetAudioVolume(int volume)
Definition: sound.cpp:93
Definition: sound.h:79
Definition: sound.h:139
virtual bool PlayMusic(int rank, bool bRepeat)
Definition: sound.cpp:164
virtual bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper)
Definition: sound.cpp:134
Definition: sound.h:125
Definition: sound.h:115
Definition: sound.h:81
Definition: sound.h:52
Definition: sound.h:127
Definition: sound.h:137
virtual bool GetSound3DCap()
Definition: sound.cpp:88
Definition: sound.h:50
Definition: sound.h:76
virtual bool GetEnable()
Definition: sound.cpp:74
Definition: sound.h:78
virtual bool Stop(int channel)
Definition: sound.cpp:149
Definition: sound.h:80
virtual int Play(Sound sound, float amplitude=1.0f, float frequency=1.0f, bool bLoop=false)
Definition: sound.cpp:119
const float MAXVOLUME
Definition: sound.h:34
virtual void SetMusicVolume(int volume)
Definition: sound.cpp:102
SoundNext
Enum representing operation that will be performend on a sound at given time.
Definition: sound.h:135
virtual bool Cache(Sound bSound, std::string bFile)
Definition: sound.cpp:64
Definition: sound.h:82
virtual int GetAudioVolume()
Definition: sound.cpp:97
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:174
Class for logging information to file or console.
Definition: sound.h:91
Definition: sound.h:94
3D (3x1) vector
Definition: vector.h:49
virtual bool Create(bool b3D)
Definition: sound.cpp:39
virtual int GetMusicVolume()
Definition: sound.cpp:106
Definition: sound.h:53
virtual bool GetSound3D()
Definition: sound.cpp:83
virtual void SetSound3D(bool bMode)
Definition: sound.cpp:79
virtual void StopMusic()
Definition: sound.cpp:183
Definition: sound.h:105
Definition: sound.h:100
virtual bool IsPlayingMusic()
Definition: sound.cpp:187
Definition: sound.h:92
virtual bool CacheMusic(std::string bFile)
Definition: sound.cpp:69
Sound plugin interface.
Definition: sound.h:149
virtual void SetListener(Math::Vector eye, Math::Vector lookat)
Definition: sound.cpp:111