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-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsitec.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 "sound/sound_type.h"
28 
29 #include <string>
30 
31 namespace Math
32 {
33 struct Vector;
34 } // namespace Math
35 
39 const float MAXVOLUME = 100.0f;
40 
41 
47 {
49  SOPER_STOP = 2,
50  SOPER_LOOP = 3,
51 };
52 
53 
61 {
62 public:
64  virtual ~CSoundInterface();
65 
68  virtual bool Create();
69 
73  void CacheAll();
74 
76  void CacheCommonMusic();
77 
84  virtual bool Cache(SoundType sound, const std::string &file);
85 
91  virtual bool CacheMusic(const std::string &file);
92 
97  virtual bool IsCached(SoundType sound);
98 
103  virtual bool IsCachedMusic(const std::string &file);
104 
108  virtual bool GetEnable();
109 
113  virtual void SetAudioVolume(int volume);
114 
118  virtual int GetAudioVolume();
119 
123  virtual void SetMusicVolume(int volume);
124 
128  virtual int GetMusicVolume();
129 
134  virtual void SetListener(const Math::Vector &eye, const Math::Vector &lookat);
135 
139  virtual void FrameMove(float rTime);
140 
148  virtual int Play(SoundType sound, float amplitude=1.0f, float frequency=1.0f, bool loop = false);
149 
158  virtual int Play(SoundType sound, const Math::Vector &pos, float amplitude=1.0f, float frequency=1.0f, bool loop = false);
159 
164  virtual bool FlushEnvelope(int channel);
165 
174  virtual bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper);
175 
181  virtual bool Position(int channel, const Math::Vector &pos);
182 
188  virtual bool Frequency(int channel, float frequency);
189 
194  virtual bool Stop(int channel);
195 
199  virtual bool StopAll();
200 
205  virtual bool MuteAll(bool mute);
206 
213  virtual bool PlayMusic(const std::string &filename, bool repeat, float fadeTime=2.0f);
214 
218  virtual bool RestartMusic();
219 
223  virtual void SuspendMusic();
224 
228  virtual void StopMusic(float fadeTime=2.0f);
229 
233  virtual bool IsPlayingMusic();
234 
240  virtual bool PlayPauseMusic(const std::string &filename, bool repeat);
241 
245  virtual void StopPauseMusic();
246 };
Definition: sound.h:49
Definition: sound.h:50
Definition: sound.h:48
const float MAXVOLUME
Definition: sound.h:39
Namespace for (new) math code.
Definition: device.h:39
SoundNext
Enum representing operation that will be performend on a sound at given time.
Definition: sound.h:46
SoundType
Enum representing sound file.
Definition: sound_type.h:34
3D (3x1) vector
Definition: vector.h:53
Defines the SoundType enum.
Sound plugin interface.
Definition: sound.h:60