zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Sound.hxx
Go to the documentation of this file.
1 /* This file is part of the Zenipex Library (zenilib).
2  * Copyright (C) 2011 Mitchell Keith Bloch (bazald).
3  *
4  * zenilib is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * zenilib is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with zenilib. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef ZENI_SOUND_HXX
19 #define ZENI_SOUND_HXX
20 
21 // HXXed below
22 #include <Zeni/Sound_Source.h>
23 
24 #include <Zeni/Sound.h>
25 
26 #include <Zeni/Define.h>
27 
28 namespace Zeni {
29 
31  return *m_sound_renderer;
32  }
33 
34  float Sound::get_listener_gain() const {
35  return m_listener_gain;
36  }
37 
38  bool Sound::is_listener_muted() const {
39  return m_listener_muted;
40  }
41 
42  void Sound::set_BGM_pitch(const float & pitch) {
43 #ifdef DISABLE_AL
44  get_BGM_Source().set_pitch(pitch);
45 #else
46  init_BGM_Sound_Stream_AL();
47  if(m_bgm)
48  m_bgm->set_pitch(pitch);
49 #endif
50  }
51 
52  void Sound::set_BGM_gain(const float &gain) {
53 #ifdef DISABLE_AL
54  get_BGM_Source().set_gain(gain);
55 #else
56  init_BGM_Sound_Stream_AL();
57  if(m_bgm)
58  m_bgm->set_gain(gain);
59 #endif
60  }
61 
62  void Sound::set_BGM_looping(const bool &looping) {
63 #ifdef DISABLE_AL
64  get_BGM_Source().set_looping(looping);
65 #else
66  init_BGM_Sound_Stream_AL();
67  if(m_bgm)
68  m_bgm->set_looping(looping);
69 #endif
70  }
71 
72  void Sound::set_BGM_time(const float &time) {
73 #ifdef DISABLE_AL
74  get_BGM_Source().set_time(time);
75 #else
76  init_BGM_Sound_Stream_AL();
77  if(m_bgm)
78  m_bgm->set_time(time);
79 #endif
80  }
81 
82  void Sound::update() {
83 #ifndef DISABLE_AL
84  init_BGM_Sound_Stream_AL();
85  if(m_bgm)
86  m_bgm->update();
87 #endif
88  }
89 
91 #ifdef DISABLE_AL
92  return get_BGM_Source().get_pitch();
93 #else
94  init_BGM_Sound_Stream_AL();
95  return m_bgm ? m_bgm->get_pitch() : ZENI_DEFAULT_PITCH;
96 #endif
97  }
98 
100 #ifdef DISABLE_AL
101  return get_BGM_Source().get_gain();
102 #else
103  init_BGM_Sound_Stream_AL();
104  return m_bgm ? m_bgm->get_gain() : ZENI_DEFAULT_GAIN;
105 #endif
106  }
107 
109 #ifdef DISABLE_AL
110  return get_BGM_Source().is_looping();
111 #else
112  init_BGM_Sound_Stream_AL();
113  return m_bgm ? m_bgm->is_looping() : false;
114 #endif
115  }
116 
118 #ifdef DISABLE_AL
119  return get_BGM_Source().get_time();
120 #else
121  init_BGM_Sound_Stream_AL();
122  return m_bgm ? m_bgm->get_time() : 0.0f;
123 #endif
124  }
125 
127 #ifdef DISABLE_AL
128  return get_BGM_Source().is_playing();
129 #else
130  init_BGM_Sound_Stream_AL();
131  return m_bgm ? m_bgm->is_playing() : false;
132 #endif
133  }
134 
136 #ifdef DISABLE_AL
137  return get_BGM_Source().is_paused();
138 #else
139  init_BGM_Sound_Stream_AL();
140  return m_bgm ? m_bgm->is_paused() : false;
141 #endif
142  }
143 
145 #ifdef DISABLE_AL
146  return get_BGM_Source().is_stopped();
147 #else
148  init_BGM_Sound_Stream_AL();
149  return m_bgm ? m_bgm->is_stopped() : true;
150 #endif
151  }
152 
154 #ifdef DISABLE_AL
155  get_BGM_Source().play();
156 #else
157  init_BGM_Sound_Stream_AL();
158  if(m_bgm)
159  m_bgm->play();
160 #endif
161  }
162 
164 #ifdef DISABLE_AL
165  get_BGM_Source().pause();
166 #else
167  init_BGM_Sound_Stream_AL();
168  if(m_bgm)
169  m_bgm->pause();
170 #endif
171  }
172 
174 #ifdef DISABLE_AL
175  get_BGM_Source().stop();
176 #else
177  init_BGM_Sound_Stream_AL();
178  if(m_bgm)
179  m_bgm->stop();
180 #endif
181  }
182 
183 }
184 
185 #include <Zeni/Undefine.h>
186 
187 #include <Zeni/Sound_Source.hxx>
188 
189 #endif
float get_BGM_gain()
Get the gain.
Definition: Sound.hxx:99
void stop_BGM()
Stop BackGround Music.
Definition: Sound.hxx:173
float get_BGM_time()
Get the current position in the BGM, offset in seconds.
Definition: Sound.hxx:117
float get_BGM_pitch()
Get the pitch.
Definition: Sound.hxx:90
#define ZENI_DEFAULT_PITCH
Definition: Define.h:54
Sound_Renderer & get_Renderer()
Get the current Sound_Renderer.
Definition: Sound.hxx:30
float get_gain() const
Get the gain.
bool stopped_BGM()
Check to see if BackGround Music is stopped.
Definition: Sound.hxx:144
#define ZENI_DEFAULT_GAIN
Definition: Define.h:55
float get_pitch() const
Get the pitch.
bool is_BGM_looping()
Check to see if the BGM is set to loop back to the start once it is done playing. ...
Definition: Sound.hxx:108
void set_time(const float &time)
Set the current position in the Sound_Buffer, offset in seconds.
void pause()
Pause the Sound_Source.
bool is_looping() const
Check to see if the Sound_Buffer is set to loop back to the start once it is done playing...
void play_BGM()
Begin Playing BackGround Music.
Definition: Sound.hxx:153
void set_BGM_time(const float &time)
Set the current position in the BGM, offset in seconds.
Definition: Sound.hxx:72
void set_gain(const float &gain=ZENI_DEFAULT_GAIN)
Set the gain.
float get_time() const
Get the current position in the Sound_Buffer, offset in seconds.
void stop()
Stop the Sound_Source. (Essentially the same as pause but resets the current time.)
bool playing_BGM()
Check to see if BackGround Music is playing.
Definition: Sound.hxx:126
void set_BGM_pitch(const float &pitch)
Set the pitch.
Definition: Sound.hxx:42
void set_BGM_looping(const bool &looping)
Set whether the BGM should loop back to the start once it is done playing.
Definition: Sound.hxx:62
void play()
Begin playing or unpause the Sound_Source.
bool is_listener_muted() const
Is the listener muted.
Definition: Sound.hxx:38
bool is_playing() const
Check to see if the Sound_Source is playing.
void pause_BGM()
Pause BackGround Music.
Definition: Sound.hxx:163
bool is_stopped() const
Check to see if the Sound_Source is stopped.
bool is_paused() const
Check to see if the Sound_Source is paused.
void set_looping(const bool &looping)
Set whether the Sound_Buffer should loop back to the start once it is done playing.
void set_pitch(const float &pitch=ZENI_DEFAULT_PITCH)
Set the pitch.
void update()
Update background music, as needed.
Definition: Sound.hxx:82
bool paused_BGM()
Check to see if BackGround Music is paused.
Definition: Sound.hxx:135
float get_listener_gain() const
Get the listener gain.
Definition: Sound.hxx:34
void set_BGM_gain(const float &gain)
Set the gain.
Definition: Sound.hxx:52