ScummVM API documentation
snd_dispatcher.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 QDENGINE_SYSTEM_SOUND_SND_DISPATCHER_H
23#define QDENGINE_SYSTEM_SOUND_SND_DISPATCHER_H
24
25#include "qdengine/system/sound/snd_sound.h"
26
27namespace QDEngine {
28
31public:
34
36 void quant();
38 bool play_sound(const sndSound *snd, bool loop, int vol = 255);
40 bool stop_sound(const sndSound *snd);
42 bool stop_sound(const sndHandle *handle);
48 bool set_sound_frequency(const sndHandle *snd, float coeff);
49
51 void set_volume(uint32 vol);
52
53 uint32 volume() const {
54 return _volume;
55 }
56
58 int volume_dB() const {
59 return _volume_dB;
60 }
61
62 void set_frequency_coeff(float coeff) {
63 _frequency_coeff = coeff;
64 update_frequency();
65 }
66 float frequency_coeff() const {
67 return _frequency_coeff;
68 }
69
71 static int convert_volume_to_dB(int vol);
72
79
81 void pause() {
82 _is_paused = true;
84 }
86 void resume() {
87 _is_paused = false;
89 }
91 bool is_paused() const {
92 return _is_paused;
93 }
94
96 bool is_enabled() const {
97 return _is_enabled;
98 }
100 void enable() {
101 _is_enabled = true;
102 }
104 void disable() {
105 _is_enabled = false;
106 stop_sounds();
107 }
108
109 void syncSoundSettings();
110
112 static inline sndDispatcher *get_dispatcher() {
113 return _dispatcher_ptr;
114 }
117 sndDispatcher *old_p = _dispatcher_ptr;
118 _dispatcher_ptr = p;
119 return old_p;
120 }
121
122protected:
123
126
127 bool update_frequency();
128
129private:
130
132 bool _is_enabled;
133
135
139 uint32 _volume;
140
142
146 int _volume_dB;
147
148 float _frequency_coeff;
149
151 bool _is_paused;
152
155 sound_list_t _sounds;
156
158 static sndDispatcher *_dispatcher_ptr;
159
160// Audio::SeekableAudioStream *_audioStream;
161};
162
163} // namespace QDEngine
164
165#endif // QDENGINE_SYSTEM_SOUND_SND_DISPATCHER_H
Диспетчер звуков на DirectSound.
Definition: snd_dispatcher.h:30
bool set_sound_frequency(const sndHandle *snd, float coeff)
Изменение частоты звука.
bool stop_sound(const sndHandle *handle)
Останавливает проигрывание звука.
void pause_sounds()
Ставит все играющие в данный момент звуки на паузу.
int volume_dB() const
Возвращает установленную громкость в децибелах.
Definition: snd_dispatcher.h:58
void stop_sounds()
Останавливает все звуки.
void enable()
Включает звук.
Definition: snd_dispatcher.h:100
bool is_paused() const
Возвращает true, если звуки поставлены на паузу.
Definition: snd_dispatcher.h:91
void set_volume(uint32 vol)
Изменение громкости, диапазон значений - [0, 255].
bool play_sound(const sndSound *snd, bool loop, int vol=255)
Запускает проигрывание звука.
bool is_enabled() const
Возвращает true, если звук выключен.
Definition: snd_dispatcher.h:96
void disable()
Выключает звук.
Definition: snd_dispatcher.h:104
sndSound::status_t sound_status(const sndHandle *handle) const
Возвращает состояние звука (играется/остановлен и т.д.).
void pause()
Ставит все звуки на паузу до вызова resume().
Definition: snd_dispatcher.h:81
static int convert_volume_to_dB(int vol)
Пересчет громкости в децибелы.
void resume_sounds()
Возобновляет проигрывание всех звуков, которые были поставлены на паузу.
static sndDispatcher * get_dispatcher()
Возвращает указатель на текущий диспетчер.
Definition: snd_dispatcher.h:112
bool stop_sound(const sndSound *snd)
Останавливает проигрывание звука.
static sndDispatcher * set_dispatcher(sndDispatcher *p)
Устанавливает указатель на текущий диспетчер.
Definition: snd_dispatcher.h:116
bool update_volume()
Обновление установки громкости.
void resume()
Возобновляет проигрывание всех звуков.
Definition: snd_dispatcher.h:86
sndSound::status_t sound_status(const sndSound *snd) const
Возвращает состояние звука (играется/остановлен и т.д.).
void quant()
Логический квант.
Класс для управления звуками.
Definition: snd_sound.h:34
Базовый класс для звуков.
Definition: snd_sound.h:41
status_t
Состояние звука.
Definition: snd_sound.h:47
Базовый класс для игровых ресурсов.
Definition: console.h:28