zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Sound.h
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 
34 #ifndef ZENI_SOUND_H
35 #define ZENI_SOUND_H
36 
37 #include <Zeni/Error.h>
38 #include <Zeni/Singleton.h>
39 #include <Zeni/Sound_Buffer.h>
40 #include <Zeni/Sound_Renderer.h>
41 #include <Zeni/Sound_Stream_AL.h>
42 
43 #include <Zeni/Define.h>
44 
45 namespace Zeni {
46 
47  class ZENI_AUDIO_DLL Sound;
48 
49 #ifdef _WINDOWS
50  ZENI_AUDIO_EXT template class ZENI_AUDIO_DLL Singleton<Sound>;
51 #endif
52 
53  class ZENI_AUDIO_DLL Sound : public Singleton<Sound> {
54  friend class Singleton<Sound>;
55 
56  static Sound * create();
57 
58  // Undefined
59  Sound(const Sound &);
60  Sound & operator=(const Sound &);
61 
62  Sound();
63  virtual ~Sound();
64 
65  public:
66  inline Sound_Renderer & get_Renderer();
67 
68  // Listener Functions
69  void set_listener_position(const Point3f &position);
70  void set_listener_velocity(const Vector3f &velocity);
71  void set_listener_forward_and_up(const Vector3f &forward, const Vector3f &up);
72  void set_listener_gain(const float &gain);
73  void set_listener_muted(const bool &muted);
74 
75  Point3f get_listener_position() const;
76  Vector3f get_listener_velocity() const;
77  std::pair<Vector3f, Vector3f> get_listener_forward_and_up() const;
78  inline float get_listener_gain() const;
79  inline bool is_listener_muted() const;
80 
81  // BackGround Music Functions
82  void set_BGM(const String &filename);
83 
84  // BackGround Music Getter Functions
85  inline bool playing_BGM();
86  inline bool paused_BGM();
87  inline bool stopped_BGM();
88  inline float get_BGM_pitch();
89  inline float get_BGM_gain();
90  inline bool is_BGM_looping();
91  inline float get_BGM_time();
92 
93  // BackGround Music Setter Functions
94  inline void play_BGM();
95  inline void pause_BGM();
96  inline void stop_BGM();
97  inline void set_BGM_pitch(const float &pitch);
98  inline void set_BGM_gain(const float &gain);
99  inline void set_BGM_looping(const bool &looping);
100  inline void set_BGM_time(const float &time);
101 
102  Sound_Buffer & get_Hello_World_Buffer() const;
103 
104  inline void update();
105 
106  private:
107  Sound_Renderer *m_sound_renderer;
108  mutable Sound_Buffer *m_hello_world_buffer;
109 
110  String m_bgmusic;
111 #ifdef DISABLE_AL
112  Sound_Source & get_BGM_Source() const;
113  mutable Sound_Buffer *m_bgm;
114 #else
115  void init_BGM_Sound_Stream_AL() const;
116  mutable Sound_Stream_AL *m_bgm;
117 #endif
118 
119  float m_listener_gain;
120  bool m_listener_muted;
121  };
122 
123  ZENI_AUDIO_DLL Sound & get_Sound();
124 
125  struct ZENI_AUDIO_DLL Sound_Init_Failure {
126  Sound_Init_Failure() : msg("Zeni Sound Failed to Initialize Correctly") {}
128  };
129 
130 }
131 
132 #include <Zeni/Undefine.h>
133 
134 #endif
A 3D Point represented with floats.
Definition: Coordinate.h:133
Plays Sound Data.
Definition: Sound_Source.h:147
Sound & get_Sound()
Get access to the singleton.
Definition: Sound.cpp:220
A Featureful 3-Space Vector Class.
Definition: Vector3f.h:58
Stores Sound Data.
Definition: Sound_Buffer.h:83
The Sound Singleton.
Definition: Sound.h:53