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-2015, 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 "math/vector.h"
28 
29 #include "sound/sound_type.h"
30 
31 #include <string>
32 
36 const float MAXVOLUME = 100.0f;
37 
38 
44 {
46  SOPER_STOP = 2,
47  SOPER_LOOP = 3,
48 };
49 
50 
58 {
59 public:
61  virtual ~CSoundInterface();
62 
65  virtual bool Create();
66 
70  void CacheAll();
71 
73  void AddMusicFiles();
74 
81  virtual bool Cache(SoundType sound, const std::string &file);
82 
88  virtual bool CacheMusic(const std::string &file);
89 
94  virtual bool IsCached(SoundType sound);
95 
100  virtual bool IsCachedMusic(const std::string &file);
101 
105  virtual bool GetEnable();
106 
110  virtual void SetAudioVolume(int volume);
111 
115  virtual int GetAudioVolume();
116 
120  virtual void SetMusicVolume(int volume);
121 
125  virtual int GetMusicVolume();
126 
131  virtual void SetListener(const Math::Vector &eye, const Math::Vector &lookat);
132 
136  virtual void FrameMove(float rTime);
137 
145  virtual int Play(SoundType sound, float amplitude=1.0f, float frequency=1.0f, bool loop = false);
146 
155  virtual int Play(SoundType sound, const Math::Vector &pos, float amplitude=1.0f, float frequency=1.0f, bool loop = false);
156 
161  virtual bool FlushEnvelope(int channel);
162 
171  virtual bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper);
172 
178  virtual bool Position(int channel, const Math::Vector &pos);
179 
185  virtual bool Frequency(int channel, float frequency);
186 
191  virtual bool Stop(int channel);
192 
196  virtual bool StopAll();
197 
202  virtual bool MuteAll(bool mute);
203 
210  virtual bool PlayMusic(const std::string &filename, bool repeat, float fadeTime=2.0f);
211 
215  virtual bool RestartMusic();
216 
220  virtual void SuspendMusic();
221 
225  virtual void StopMusic(float fadeTime=2.0f);
226 
230  virtual bool IsPlayingMusic();
231 
237  virtual bool PlayPauseMusic(const std::string &filename, bool repeat);
238 
242  virtual void StopPauseMusic();
243 };
virtual bool Frequency(int channel, float frequency)
Definition: sound.cpp:141
virtual void FrameMove(float rTime)
Definition: sound.cpp:112
virtual bool PlayPauseMusic(const std::string &filename, bool repeat)
Definition: sound.cpp:184
Definition: sound.h:46
virtual bool Create()
Definition: sound.cpp:41
virtual void SetListener(const Math::Vector &eye, const Math::Vector &lookat)
Definition: sound.cpp:108
virtual bool FlushEnvelope(int channel)
Definition: sound.cpp:126
virtual int Play(SoundType sound, float amplitude=1.0f, float frequency=1.0f, bool loop=false)
Definition: sound.cpp:116
virtual bool IsCachedMusic(const std::string &file)
Definition: sound.cpp:80
virtual void StopPauseMusic()
Definition: sound.cpp:189
virtual bool StopAll()
Definition: sound.cpp:151
void AddMusicFiles()
Definition: sound.cpp:57
virtual bool MuteAll(bool mute)
Definition: sound.cpp:156
virtual void SuspendMusic()
Definition: sound.cpp:171
virtual void SetAudioVolume(int volume)
Definition: sound.cpp:90
virtual bool PlayMusic(const std::string &filename, bool repeat, float fadeTime=2.0f)
Definition: sound.cpp:161
Definition: sound.h:47
virtual bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper)
Definition: sound.cpp:131
virtual bool Cache(SoundType sound, const std::string &file)
Definition: sound.cpp:65
Definition: sound.h:45
void CacheAll()
Definition: sound.cpp:46
virtual bool GetEnable()
Definition: sound.cpp:85
virtual bool Position(int channel, const Math::Vector &pos)
Definition: sound.cpp:136
virtual bool Stop(int channel)
Definition: sound.cpp:146
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:43
virtual int GetAudioVolume()
Definition: sound.cpp:94
virtual void StopMusic(float fadeTime=2.0f)
Definition: sound.cpp:175
Vector struct and related functions.
virtual bool RestartMusic()
Definition: sound.cpp:166
3D (3x1) vector
Definition: vector.h:53
virtual int GetMusicVolume()
Definition: sound.cpp:103
virtual bool CacheMusic(const std::string &file)
Definition: sound.cpp:70
virtual bool IsPlayingMusic()
Definition: sound.cpp:179
Sound plugin interface.
Definition: sound.h:57
virtual bool IsCached(SoundType sound)
Definition: sound.cpp:75