ScummVM
sound.h
Go to the documentation of this file.
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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef GLK_SOUND_H
24 #define GLK_SOUND_H
25 
26 #include "glk/glk_types.h"
27 #include "audio/audiostream.h"
28 #include "audio/mixer.h"
29 #include "common/array.h"
30 
31 namespace Glk {
32 
33 #define GLK_MAXVOLUME 0x10000
34 
35 class Sounds;
36 
40 class SoundChannel {
41 private:
47 public:
50 public:
54  SoundChannel(Sounds *owner, uint volume);
55 
59  ~SoundChannel();
60 
64  uint play(uint soundNum, uint repeats = 1, uint notify = 0);
65 
69  void stop();
70 
74  void poll();
75 
83  void setVolume(uint volume, uint duration = 0, uint notify = 0);
84 
88  void pause();
89 
93  void unpause();
94 };
96 
100 class Sounds {
101  friend class SoundChannel;
102 private:
104 private:
108  void removeSound(schanid_t snd);
109 public:
110  ~Sounds();
111 
115  schanid_t create(uint rock = 0, uint volume = GLK_MAXVOLUME);
116 
120  schanid_t iterate(schanid_t chan, uint *rockptr = nullptr);
121 
125  void poll();
126 };
127 
128 } // End of namespace Glk
129 
130 #endif
array.h
Glk::SoundChannel::unpause
void unpause()
Unpause playback.
Definition: sound.cpp:181
Glk::SoundChannel::_handle
Audio::SoundHandle _handle
Definition: sound.h:45
Glk
Contains the necessary data structures andfunctions for adding to andreferring to the ID table(a very...
Definition: adrift.cpp:28
Glk::SoundChannel
Holds the data for a playing sound.
Definition: sound.h:40
Glk::Sounds::create
schanid_t create(uint rock=0, uint volume=GLK_MAXVOLUME)
Create a new channel.
Definition: sound.cpp:49
Common::Array
This class implements a dynamically sized container, which can be accessed similar to a regular C++ a...
Definition: array.h:45
Glk::SoundChannel::_rock
uint _rock
Definition: sound.h:48
Glk::Sounds::iterate
schanid_t iterate(schanid_t chan, uint *rockptr=nullptr)
Used to iterate over the current list of sound channels.
Definition: sound.cpp:55
Glk::SoundChannel::_owner
Sounds * _owner
Definition: sound.h:42
Glk::SoundChannel::_defaultVolume
uint _defaultVolume
Definition: sound.h:46
Glk::Sounds::removeSound
void removeSound(schanid_t snd)
Remove a sound from the sounds list.
Definition: sound.cpp:40
Glk::SoundChannel::~SoundChannel
~SoundChannel()
Destructor.
Definition: sound.cpp:84
Glk::SoundChannel::stop
void stop()
Stop playing sound.
Definition: sound.cpp:155
Glk::gidispatch_rock_t
Definition: glk_types.h:225
Glk::SoundChannel::pause
void pause()
Pause playback.
Definition: sound.cpp:177
Glk::Sounds::poll
void poll()
Poll for whether any playing sounds are finished.
Definition: sound.cpp:69
Glk::schanid_t
SoundChannel * schanid_t
Definition: sound.h:95
OPL::DOSBox::DBOPL::volume
Bitu volume
Definition: dbopl.h:66
Glk::Sounds::_sounds
Common::Array< schanid_t > _sounds
Definition: sound.h:103
Glk::Sounds::~Sounds
~Sounds()
Definition: sound.cpp:35
uint
unsigned int uint
Definition: scummsys.h:440
Glk::SoundChannel::setVolume
void setVolume(uint volume, uint duration=0, uint notify=0)
Change the volume.
Definition: sound.cpp:167
Glk::SoundChannel::_dispRock
gidispatch_rock_t _dispRock
Definition: sound.h:49
Glk::Sounds
Sound manager.
Definition: sound.h:100
Glk::SoundChannel::poll
void poll()
Poll for whether a playing sound was finished.
Definition: sound.cpp:159
glk_types.h
audiostream.h
Glk::SoundChannel::_soundNum
uint _soundNum
Definition: sound.h:43
Audio::SoundHandle
A SoundHandle instances corresponds to a specific sound being played via the mixer.
Definition: mixer.h:41
Glk::SoundChannel::_notify
uint _notify
Definition: sound.h:44
Glk::SoundChannel::SoundChannel
SoundChannel(Sounds *owner, uint volume)
Constructor.
Definition: sound.cpp:76
Glk::SoundChannel::play
uint play(uint soundNum, uint repeats=1, uint notify=0)
Play a sound.
Definition: sound.cpp:92
mixer.h