ScummVM API documentation
sound.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 STARK_RESOURCES_SOUND_H
23 #define STARK_RESOURCES_SOUND_H
24 
25 #include "audio/mixer.h"
26 
27 #include "common/path.h"
28 #include "common/str.h"
29 
30 #include "engines/stark/resources/object.h"
31 
32 namespace Audio {
33  class RewindableAudioStream;
34 }
35 
36 namespace Stark {
37 
38 namespace Formats {
39 class XRCReadStream;
40 }
41 
42 namespace Resources {
43 
47 class Sound : public Object {
48 public:
49  static const Type::ResourceType TYPE = Type::kSoundItem;
50 
51  enum SubType {
52  kSoundBackground = 3,
53  kSoundStock = 5
54  };
55 
56  enum SoundType {
57  kSoundTypeVoice = 0,
58  kSoundTypeEffect = 1,
59  kSoundTypeMusic = 2
60  };
61 
62  Sound(Object *parent, byte subType, uint16 index, const Common::String &name);
63  virtual ~Sound();
64 
65  // Resource API
66  void readData(Formats::XRCReadStream *stream) override;
67  void onPreDestroy() override;
68  void onGameLoop() override;
69  void saveLoadCurrent(ResourceSerializer *serializer) override;
70  void onEnginePause(bool pause) override;
71 
73  void play();
74 
76  bool isPlaying();
77 
79  void stop();
80 
82  uint32 getStockSoundType() const;
83 
85  void changeVolumePan(int32 volume, int32 pan, int32 duration);
86 
88  void setLooping(bool looping) { _looping = looping; }
89 
94  void setStopOnDestroy(bool stopOnDestroy);
95 
96 protected:
97  void printData() override;
98 
99  Audio::RewindableAudioStream *makeAudioStream();
100  Audio::Mixer::SoundType getMixerSoundType();
101 
102  Common::Path _filename;
103  Common::Path _archiveName;
104  uint32 _enabled;
105  bool _looping;
106  uint32 _field_64;
107  bool _loopIndefinitely;
108  uint32 _maxDuration;
109  bool _loadFromFile;
110  uint32 _stockSoundType;
111  Common::String _soundName;
112  uint32 _field_6C;
113  uint32 _soundType;
114  float _pan;
115  float _volume;
116  bool _shouldStopOnDestroy;
117 
118  int32 _fadeDurationRemaining;
119  float _fadeTargetVolume;
120  float _fadeTargetPan;
121 
122  Audio::SoundHandle _handle;
123 };
124 
125 } // End of namespace Resources
126 } // End of namespace Stark
127 
128 #endif // STARK_RESOURCES_SOUND_H
Definition: str.h:59
void setLooping(bool looping)
Definition: sound.h:88
Definition: sound.h:47
Definition: path.h:52
Definition: mixer.h:49
SoundType
Definition: mixer.h:62
Definition: console.h:27
Definition: object.h:143
Definition: audiostream.h:109
Definition: xrc.h:45
Definition: stateprovider.h:51
Definition: system.h:38