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 
28 namespace QDEngine {
29 
30 class wavSound;
31 class qdNamedObject;
32 
34 class sndHandle {
35 public:
36  sndHandle() { };
37  virtual ~sndHandle() { };
38 };
39 
41 class sndSound {
42 public:
43  explicit sndSound(const wavSound *snd, const sndHandle *h = NULL) : _sound(snd), _handle(h), _flags(0) {}
44  ~sndSound();
45 
47  enum status_t {
53  SOUND_PLAYING
54  };
55 
57  status_t status() const;
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 
97  bool create_sound_buffer();
99  bool release_sound_buffer();
100 
102  void toggle_looping() {
103  _flags ^= SOUND_FLAG_LOOPING;
104  }
105 
106 private:
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  bool _isStopped = false;
125 };
126 
127 } // namespace QDEngine
128 
129 #endif // QDENGINE_SYSTEM_SOUND_SND_SOUND_H
звук не проигрывается
Definition: snd_sound.h:49
const sndHandle * handle() const
Возвращает указатель на хэндл звука.
Definition: snd_sound.h:64
Класс для управления звуками.
Definition: snd_sound.h:34
Звук из WAV файла.
Definition: wav_sound.h:32
Definition: mixer.h:49
Базовый класс для игровых ресурсов.
Definition: console.h:28
bool is_paused() const
Возвращает true, если звук на паузе.
Definition: snd_sound.h:77
Базовый класс для звуков.
Definition: snd_sound.h:41
const wavSound * sound() const
Возвращает указатель на данные звука.
Definition: snd_sound.h:60
void toggle_looping()
Включает/выключает зацикливание звука.
Definition: snd_sound.h:102
status_t
Состояние звука.
Definition: snd_sound.h:47
звук приостановлен
Definition: snd_sound.h:51