ScummVM API documentation
snd_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
23#ifndef QDENGINE_SYSTEM_SOUND_SND_SOUND_H
24#define QDENGINE_SYSTEM_SOUND_SND_SOUND_H
25
26#include "audio/mixer.h"
27
28namespace QDEngine {
29
30class wavSound;
31class qdNamedObject;
32
34class sndHandle {
35public:
36 sndHandle() { };
37 virtual ~sndHandle() { };
38};
39
41class sndSound {
42public:
43 explicit sndSound(const wavSound *snd, const sndHandle *h = NULL) : _sound(snd), _handle(h), _flags(0) {}
44 ~sndSound();
45
47 enum status_t {
54 };
55
58
60 const wavSound *sound() const {
61 return _sound;
62 }
64 const sndHandle *handle() const {
65 return _handle;
66 }
67
69 bool play();
71 bool stop(bool rewind = true);
73 void pause();
75 void resume();
77 bool is_paused() const {
78 if (_flags & SOUND_FLAG_PAUSED) return true;
79 else return false;
80 }
81
83 bool is_stopped() const;
84
86
92 bool set_volume(int vol);
93
94 bool change_frequency(float coeff = 1.0f);
95
100
103 _flags ^= SOUND_FLAG_LOOPING;
104 }
105
106private:
108 const wavSound *_sound;
110 const sndHandle *_handle;
111
114 enum {
115 SOUND_FLAG_LOOPING = 0x01,
116 SOUND_FLAG_PAUSED = 0x02
117 };
118
120 int _flags;
121
122 Audio::SoundHandle _audHandle;
123
124 byte _volume = 255;
125
126 bool _isStopped = false;
127};
128
129} // namespace QDEngine
130
131#endif // QDENGINE_SYSTEM_SOUND_SND_SOUND_H
Definition: mixer.h:49
Класс для управления звуками.
Definition: snd_sound.h:34
Базовый класс для звуков.
Definition: snd_sound.h:41
bool is_stopped() const
Возвращает true, если звук не проигрывается.
void pause()
Ставит звук на паузу.
bool set_volume(int vol)
Устанавливает громкость звука, параметр - в децибелах.
bool is_paused() const
Возвращает true, если звук на паузе.
Definition: snd_sound.h:77
bool play()
Запускает проигрывание звука.
const wavSound * sound() const
Возвращает указатель на данные звука.
Definition: snd_sound.h:60
const sndHandle * handle() const
Возвращает указатель на хэндл звука.
Definition: snd_sound.h:64
bool create_sound_buffer()
Создает DirectSoundBuffer.
bool stop(bool rewind=true)
Останавливает проигрывание звука.
bool release_sound_buffer()
Удаляет DirectSoundBuffer.
void toggle_looping()
Включает/выключает зацикливание звука.
Definition: snd_sound.h:102
status_t status() const
Возвращает состояние звука.
void resume()
Возобновляет проигрывание.
status_t
Состояние звука.
Definition: snd_sound.h:47
@ SOUND_STOPPED
звук не проигрывается
Definition: snd_sound.h:49
@ SOUND_PAUSED
звук приостановлен
Definition: snd_sound.h:51
@ SOUND_PLAYING
звук пригрывается
Definition: snd_sound.h:53
Звук из WAV файла.
Definition: wav_sound.h:32
Базовый класс для игровых ресурсов.
Definition: console.h:28