ScummVM API documentation
track.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef GRIM_SOUNDTRACK_H
23 #define GRIM_SOUNDTRACK_H
24 
25 #include "audio/mixer.h"
26 #include "audio/timestamp.h"
27 
28 #include "math/vector3d.h"
29 
30 namespace Common {
31  class String;
32 }
33 
34 namespace Audio {
35  class AudioStream;
36  class SoundHandle;
37 }
38 
39 namespace Grim {
40 
41 class SaveGame;
42 
46 class SoundTrack {
47 public:
48  enum FadeMode {
49  FadeNone,
50  FadeIn,
51  FadeOut
52  };
53 protected:
54  Common::String _soundName;
55  Audio::AudioStream *_stream;
56  Audio::SoundHandle *_handle;
57  Audio::Mixer::SoundType _soundType;
58  DisposeAfterUse::Flag _disposeAfterPlaying;
59  bool _paused;
60  bool _positioned;
61  Math::Vector3d _pos;
62  FadeMode _fadeMode;
63  float _fade;
64  float _attenuation;
65  int _balance;
66  int _volume;
67  int _sync;
68 public:
69  SoundTrack();
70  virtual ~SoundTrack();
71  virtual bool openSound(const Common::String &filename, const Common::String &voiceName, const Audio::Timestamp *start = nullptr) = 0;
72  virtual bool isPlaying() = 0;
73  virtual bool play();
74  virtual void pause();
75  virtual void stop();
76 
77  void fadeIn() { _fadeMode = FadeIn; }
78  void fadeOut() { _fadeMode = FadeOut; }
79  void setFadeMode(FadeMode fadeMode) { _fadeMode = fadeMode; }
80  void setFade(float fade);
81  float getFade() const { return _fade; }
82  FadeMode getFadeMode() const { return _fadeMode; }
83  void setBalance(int balance);
84  void setVolume(int volume);
85  void setPosition(bool positioned, const Math::Vector3d &pos = Math::Vector3d());
86  void updatePosition();
87  void setSync(int sync) { _sync = sync; }
88  int getEffectiveVolume();
89  int getVolume() const { return _volume; }
90  int getBalance() const { return _balance; }
91  int getSync() const { return _sync; }
92  virtual Audio::Timestamp getPos() = 0;
93  Common::String getSoundName();
94  void setSoundName(const Common::String &name);
95  virtual bool hasLooped() { return false; }
96  virtual void setLooping(bool looping) { }
97  virtual bool isLooping() const { return false; }
98  bool isPaused() const { return _paused; }
99  bool isPositioned() const { return _positioned; }
100  Math::Vector3d getWorldPos() const { return _pos; }
101  Audio::Mixer::SoundType getSoundType() const { return _soundType; }
102 };
103 
104 }
105 
106 #endif
Definition: str.h:59
Definition: timestamp.h:83
Definition: actor.h:33
Definition: mixer.h:49
SoundType
Definition: mixer.h:62
Definition: algorithm.h:29
Definition: audiostream.h:50
Definition: track.h:46
Definition: system.h:38