1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef QDENGINE_QDCORE_QD_SOUND_H
#define QDENGINE_QDCORE_QD_SOUND_H
#include "qdengine/parser/xml_fwd.h"
#include "qdengine/qdcore/qd_named_object.h"
#include "qdengine/qdcore/qd_resource.h"
#include "qdengine/qdcore/qd_sound_handle.h"
#include "qdengine/system/sound/wav_sound.h"
namespace QDEngine {
//! Звук.
class qdSound : public qdNamedObject, public qdResource {
public:
qdSound();
~qdSound();
int named_object_type() const {
return QD_NAMED_OBJECT_SOUND;
}
//! Загрузка данных из скрипта.
void load_script(const xml::tag *p);
//! Запись данных в скрипт.
bool save_script(Common::WriteStream &fh, int indent = 0) const;
bool load_resource();
bool free_resource();
//! Устанавливает имя файла, в котором хранятся данные ресурса.
void set_resource_file(const Common::Path file_name) {
set_file_name(file_name);
}
//! Возвращает имя файла, в котором хранится анимация.
const Common::Path resource_file() const {
return file_name();
}
#ifdef __QD_DEBUG_ENABLE__
uint32 resource_data_size() const {
return _sound.data_length();
}
#endif
//! Возвращает имя файла, в котором хранится звук.
const Common::Path file_name() const {
return _file_name;
}
//! Устанавливает имя файла, в котором хранится звук.
void set_file_name(const Common::Path fname) {
_file_name = fname;
}
//! Запускает проигрывание звука.
/**
handle нужен для дальнейшего управления звуком и отслеживания его состояния,
start_position - начальная позиция при запуске звука, значения - [0.0, 1.0]
*/
bool play(const qdSoundHandle *handle = NULL, bool loop = false) const;
//! Останавливает проигрывание звука.
/**
Если handle нулевой - то выключится первый попавшийся активный звук с данными
из sound_, если ненулевой - первый соответствующий этому хэндлу.
*/
bool stop(const qdSoundHandle *handle = NULL) const;
//! Изменение частоты звука в frequency_coeff число раз.
bool set_frequency(const qdSoundHandle *handle, float frequency_coeff) const;
//! Возвращает длительность звука в секундах.
float length() const {
return _sound.length();
}
//! Возвращает true, если звук не проигрывается.
bool is_stopped(const qdSoundHandle *handle = NULL) const;
int volume() const {
return _volume;
}
void set_volume(int vol) {
_volume = vol;
}
private:
Common::Path _file_name;
//! Sound volume, [0, 255].
int _volume;
wavSound _sound;
};
typedef Std::list<qdSound *> qdSoundList;
} // namespace QDEngine
#endif // QDENGINE_QDCORE_QD_SOUND_H
|