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  * Additional copyright for this file:
8  * Copyright (C) 1995-1997 Presto Studios, Inc.
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  *
23  */
24 
25 #ifndef PEGASUS_SOUND_H
26 #define PEGASUS_SOUND_H
27 
28 #include "audio/mixer.h"
29 #include "common/str.h"
30 #include "pegasus/timers.h"
31 
32 namespace Audio {
33  class SeekableAudioStream;
34 }
35 
36 namespace Pegasus {
37 
38 class SoundFader;
39 
40 // Things you might want to do with sound:
41 // - Start it
42 // - Stop it
43 // - Loop it
44 // - Pause it
45 // - Set the volume
46 // - Set the pitch (rate)
47 // - Pan the sound
48 // - Change these settings dynamically over time
49 
50 class Sound {
51 public:
52  Sound();
53  ~Sound();
54 
55  // We only have one access point here because we should
56  // only be opening an AIFF file from a file name. We're
57  // not using the resource fork string resources.
58  void initFromAIFFFile(const Common::Path &fileName);
59 
60  // Unlike the original game, we're going to use a regular
61  // audio stream for sound spots. The original treated them
62  // as movies.
63  void initFromQuickTime(const Common::Path &fileName);
64 
65  void disposeSound();
66  bool isSoundLoaded() const;
67  void playSound();
68  void loopSound();
69  void playSoundSegment(uint32 start, uint32 end);
70  void stopSound();
71  void setVolume(const uint16 volume);
72  bool isPlaying();
73 
74  void attachFader(SoundFader *fader);
75 
76 protected:
78  Audio::SoundHandle _handle;
79  byte _volume;
80 
81  SoundFader *_fader;
82 };
83 
84 // TODO: Make this class follow TimeBase better
85 // Right now it's just a loose wrapper to plug callbacks
86 // into sounds. Since this is only used for spot sounds,
87 // I'm not too worried about it right now as its usage
88 // is very limited.
89 // At the very least, the regular TimeBase functions for
90 // setting/getting should be neutered.
91 class SoundTimeBase : public Sound, public TimeBase {
92 public:
93  SoundTimeBase();
94  ~SoundTimeBase() override {}
95 
96  void playSoundSegment(uint32 start, uint32 end);
97 
98 protected:
99  void updateTime() override;
100 
101 private:
102  bool _setToStart;
103 };
104 
105 } // End of namespace Pegasus
106 
107 #endif
Definition: sound.h:91
Definition: path.h:52
Definition: audiostream.h:212
Definition: timers.h:63
Definition: mixer.h:49
Definition: fader.h:109
Definition: sound.h:50
Definition: system.h:38
Definition: ai_action.h:33