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 PINK_SOUND_H
23 #define PINK_SOUND_H
24 
25 #include "audio/mixer.h"
26 #include "audio/timestamp.h"
27 
28 #include "common/system.h"
29 
30 #include "pink/constants.h"
31 
32 namespace Pink {
33 
34 class Sound {
35 public:
36  ~Sound() { stop(); }
37 
38  void play(Common::SeekableReadStream *stream, Audio::Mixer::SoundType type, byte volume = 100, int8 balance = 0, bool isLoop = false);
39 
40  bool isPlaying() const { return g_system->getMixer()->isSoundHandleActive(_handle); }
41 
42  void stop() { g_system->getMixer()->stopHandle(_handle); }
43 
44  void pause(bool paused) { g_system->getMixer()->pauseHandle(_handle, paused); }
45 
46  uint64 getCurrentSample() const { return (uint64)g_system->getMixer()->getElapsedTime(_handle).msecs() * kSampleRate / 1000; }
47 
48 private:
49  Audio::SoundHandle _handle;
50 };
51 
52 } // End of namespace Pink
53 
54 #endif
virtual void pauseHandle(SoundHandle handle, bool paused)=0
Definition: sound.h:34
virtual Audio::Mixer * getMixer()=0
virtual bool isSoundHandleActive(SoundHandle handle)=0
Definition: stream.h:745
OSystem * g_system
Definition: archive.h:35
Definition: mixer.h:49
virtual void stopHandle(SoundHandle handle)=0
SoundType
Definition: mixer.h:62
int msecs() const
virtual Timestamp getElapsedTime(SoundHandle handle)=0