ScummVM API documentation
qd_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 QDENGINE_QDCORE_QD_SOUND_H
23#define QDENGINE_QDCORE_QD_SOUND_H
24
25#include "qdengine/parser/xml_fwd.h"
26#include "qdengine/qdcore/qd_named_object.h"
27#include "qdengine/qdcore/qd_resource.h"
28#include "qdengine/qdcore/qd_sound_handle.h"
29
30#include "qdengine/system/sound/wav_sound.h"
31
32namespace QDEngine {
33
35class qdSound : public qdNamedObject, public qdResource {
36public:
37 qdSound();
38 ~qdSound();
39
40 int named_object_type() const {
41 return QD_NAMED_OBJECT_SOUND;
42 }
43
45 void load_script(const xml::tag *p);
47 bool save_script(Common::WriteStream &fh, int indent = 0) const;
48
54 }
57 return file_name();
58 }
59#ifdef __QD_DEBUG_ENABLE__
60 uint32 resource_data_size() const {
61 return _sound.data_length();
62 }
63#endif
64
66 const Common::Path file_name() const {
67 return _file_name;
68 }
70 void set_file_name(const Common::Path &fname) {
71 _file_name = fname;
72 }
73
75
79 bool play(const qdSoundHandle *handle = NULL, bool loop = false) const;
81
85 bool stop(const qdSoundHandle *handle = NULL) const;
86
88 bool set_frequency(const qdSoundHandle *handle, float frequency_coeff) const;
89
91 float length() const {
92 return _sound.length();
93 }
94
96 bool is_stopped(const qdSoundHandle *handle = NULL) const;
97
98 int volume() const {
99 return _volume;
100 }
101 void set_volume(int vol) {
102 _volume = vol;
103 }
104
105private:
106
107 Common::Path _file_name;
109 int _volume;
110 wavSound _sound;
111};
112
113typedef Std::list<qdSound *> qdSoundList;
114
115} // namespace QDEngine
116
117#endif // QDENGINE_QDCORE_QD_SOUND_H
Definition: path.h:52
Definition: stream.h:77
Поименованный объект.
Definition: qd_named_object.h:70
Definition: qd_resource.h:34
Класс для управления звуками.
Definition: qd_sound_handle.h:31
Звук.
Definition: qd_sound.h:35
const Common::Path file_name() const
Возвращает имя файла, в котором хранится звук.
Definition: qd_sound.h:66
bool play(const qdSoundHandle *handle=NULL, bool loop=false) const
Запускает проигрывание звука.
bool load_resource()
Загружает в память данные ресурса.
bool free_resource()
Выгружает из памяти данные ресурса.
bool stop(const qdSoundHandle *handle=NULL) const
Останавливает проигрывание звука.
int named_object_type() const
Возвращает тип объекта.
Definition: qd_sound.h:40
void load_script(const xml::tag *p)
Загрузка данных из скрипта.
bool set_frequency(const qdSoundHandle *handle, float frequency_coeff) const
Изменение частоты звука в frequency_coeff число раз.
const Common::Path resource_file() const
Возвращает имя файла, в котором хранится анимация.
Definition: qd_sound.h:56
bool is_stopped(const qdSoundHandle *handle=NULL) const
Возвращает true, если звук не проигрывается.
void set_resource_file(const Common::Path &file_name)
Устанавливает имя файла, в котором хранятся данные ресурса.
Definition: qd_sound.h:52
void set_file_name(const Common::Path &fname)
Устанавливает имя файла, в котором хранится звук.
Definition: qd_sound.h:70
float length() const
Возвращает длительность звука в секундах.
Definition: qd_sound.h:91
bool save_script(Common::WriteStream &fh, int indent=0) const
Запись данных в скрипт.
float length() const
Returns sound length in seconds.
Definition: wav_sound.h:38
XML тег.
Definition: xml_tag.h:33
Definition: list.h:39
Базовый класс для игровых ресурсов.
Definition: console.h:28