zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Sound_Stream_AL.h
Go to the documentation of this file.
1 #ifndef ZENI_SOUND_STREAM_AL_H
2 #define ZENI_SOUND_STREAM_AL_H
3 
5 
6 #ifndef DISABLE_AL
7 
8 #include <Zeni/Define.h>
9 
10 namespace Zeni {
11 
12  class ZENI_AUDIO_DLL Sound_Stream_AL {
14  Sound_Stream_AL & operator=(const Sound_Stream_AL &);
15 
16  // stereo 44kHz = 2 * 88000 bytes per second
17  static const size_t NUM_BUFFERS = 60;
18  static const size_t BUFFER_SIZE = 4096;
19 
20  public:
21  Sound_Stream_AL(const String &path, const bool &looping_ = false, const float &time_ = 0.0f);
22  ~Sound_Stream_AL();
23 
24  void set_pitch(const float &pitch = ZENI_DEFAULT_PITCH);
25  void set_gain(const float &gain = ZENI_DEFAULT_GAIN);
26  void set_position(const Point3f &position);
27  void set_velocity(const Vector3f &velocity);
28  void set_looping(const bool &looping);
29  void set_time(const float &time);
30  void set_reference_distance(const float &reference_distance = ZENI_DEFAULT_REFERENCE_DISTANCE); // Set the near clamping distance
31  void set_max_distance(const float &max_distance = ZENI_DEFAULT_MAX_SOUND_DISTANCE); // Set the far clamping distance
32  void set_rolloff(const float &rolloff = ZENI_DEFAULT_ROLLOFF); // Set the maximum reduction in volume due to distance
33 
34  float get_duration() const;
35  float get_pitch() const;
36  float get_gain() const;
37  Point3f get_position() const;
38  Vector3f get_velocity() const;
39  bool is_looping() const;
40  float get_time() const;
41  float get_reference_distance() const; // Get the near clamping distance
42  float get_max_distance() const; // Get the far clamping distance
43  float get_rolloff() const; // Get the maximum reduction in volume due to distance
44 
45  void play();
46  void pause();
47  void stop();
48 
49  bool is_playing() const;
50  bool is_paused() const;
51  bool is_stopped() const;
52 
53  void update();
54 
55  private:
56  void destroy();
57  void stream(ALuint buffer); // reloads a buffer
58 
59  OggVorbis_File oggStream; // stream handle
60  vorbis_info* vorbisInfo; // some formatting data
61  vorbis_comment* vorbisComment; // user comments
62 
63  ALuint buffers[NUM_BUFFERS]; // front and back buffers
64  ALuint buffers_used; // number of buffers in the queue
65  ALuint source; // audio source
66  ALenum format; // internal format
67 
68  bool looping;
69  };
70 
71  struct ZENI_AUDIO_DLL Sound_Stream_Init_Failure : public Error {
72  Sound_Stream_Init_Failure() : Error("Zeni Sound Stream Failed to Initialize Correctly") {}
73  };
74 
75  struct ZENI_AUDIO_DLL Sound_Stream_Update_Failure : public Error {
76  Sound_Stream_Update_Failure() : Error("Zeni Sound Stream Failed to Update Correctly") {}
77  };
78 
79  struct ZENI_AUDIO_DLL Sound_Stream_Ogg_Read_Failure : public Error {
80  Sound_Stream_Ogg_Read_Failure() : Error("Zeni Sound Stream Failed to Read .ogg File Correctly") {}
81  };
82 
83 }
84 
85 #include <Zeni/Undefine.h>
86 
87 #endif
88 
89 #endif
#define NUM_BUFFERS
Definition: alstream.c:48
GLclampf f
Definition: glew.h:3390
#define ZENI_DEFAULT_PITCH
Definition: Define.h:54
GLuint GLuint stream
Definition: glew.h:6573
#define BUFFER_SIZE
Definition: alstream.c:49
GLsizei const GLchar *const * path
Definition: glew.h:5828
#define ZENI_DEFAULT_GAIN
Definition: Define.h:55
A 3D Point represented with floats.
Definition: Coordinate.h:133
static long get_time(void)
Definition: test_bbox.c:16
#define ZENI_DEFAULT_MAX_SOUND_DISTANCE
Definition: Define.h:57
const GLuint * buffers
Definition: glew.h:1669
EGLContext EGLenum EGLClientBuffer buffer
Definition: eglext.h:87
A Featureful 3-Space Vector Class.
Definition: Vector3f.h:58
#define ZENI_DEFAULT_REFERENCE_DISTANCE
Definition: Define.h:56
int ALenum
Definition: al.h:65
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl2ext.h:845
unsigned int ALuint
Definition: al.h:59
local int destroy(gz_stream *s)
Definition: gzio.c:355
#define ZENI_DEFAULT_ROLLOFF
Definition: Define.h:58
The Error Class.
Definition: Error.h:52
GLsizei GLsizei GLchar * source
Definition: gl2ext.h:994