11 Sound_Stream_AL::Sound_Stream_AL(
const String &
path,
const bool &looping_,
const float &time_)
15 if(!dynamic_cast<Sound_Renderer_AL *>(&
get_Sound().get_Renderer()))
22 vorbisInfo =
ov_info(&oggStream, -1);
35 ALfloat pos[3] = {0.0f, 0.0f, 0.0f};
59 if(dynamic_cast<Sound_Renderer_AL *>(&
get_Sound().get_Renderer()))
76 if(dynamic_cast<Sound_Renderer_AL *>(&
get_Sound().get_Renderer()))
93 return float(
ov_time_total(const_cast<OggVorbis_File *>(&oggStream), -1));
104 if(dynamic_cast<Sound_Renderer_AL *>(&
get_Sound().get_Renderer())) {
127 return float(
ov_time_tell(const_cast<OggVorbis_File *>(&oggStream)));
133 return reference_distance;
184 if(oggStream.
offset == oggStream.
end && !looping)
189 processed += NUM_BUFFERS - buffers_used;
193 if(buffers_used == NUM_BUFFERS)
196 buffer =
buffers[buffers_used++];
202 if(oggStream.
offset == oggStream.
end && !looping)
207 void Sound_Stream_AL::destroy() {
216 char data[BUFFER_SIZE];
221 while(size <
int(BUFFER_SIZE)) {
222 result =
ov_read(&oggStream, data + size, BUFFER_SIZE - size, 0, 2, 1, & section);
228 throw Sound_Stream_Ogg_Read_Failure();
237 throw Error(
"Failed to stream data from .ogg file.");
246 throw Sound_Stream_Update_Failure();
static alGetSourcefv_fcn alGetSourcefv()
static alSourceStop_fcn alSourceStop()
#define ZENI_DEFAULT_PITCH
static alDeleteSources_fcn alDeleteSources()
static alGetSourcei_fcn alGetSourcei()
void set_reference_distance(const float &reference_distance=ZENI_DEFAULT_REFERENCE_DISTANCE)
void set_max_distance(const float &max_distance=ZENI_DEFAULT_MAX_SOUND_DISTANCE)
double ov_time_total(OggVorbis_File *vf, int i)
Point3f get_position() const
Get the position of the Sound_Buffer.
static alSourcei_fcn alSourcei()
int ov_clear(OggVorbis_File *vf)
float get_gain() const
Get the gain.
static alGetSourcef_fcn alGetSourcef()
int ov_fopen(const char *path, OggVorbis_File *vf)
float get_reference_distance() const
GLsizei const GLchar *const * path
#define ZENI_DEFAULT_GAIN
static alSourcef_fcn alSourcef()
double ov_time_tell(OggVorbis_File *vf)
Vector3f get_velocity() const
Get the velocity of the Sound_Buffer.
A 3D Point represented with floats.
#define ZENI_DEFAULT_MAX_SOUND_DISTANCE
float get_duration() const
Get the duration of the Sound_Buffer in seconds.
void * this_pointer_is_silent_sound_two
void set_rolloff(const float &rolloff=ZENI_DEFAULT_ROLLOFF)
EGLContext EGLenum EGLClientBuffer buffer
int ov_raw_seek(OggVorbis_File *vf, ogg_int64_t pos)
Sound & get_Sound()
Get access to the singleton.
A Featureful 3-Space Vector Class.
static alSourceQueueBuffers_fcn alSourceQueueBuffers()
#define AL_ROLLOFF_FACTOR
float get_pitch() const
Get the pitch.
vorbis_info * ov_info(OggVorbis_File *vf, int link)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
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 set_gain(const float &gain=ZENI_DEFAULT_GAIN)
Set the gain.
static String errorString()
static alBufferData_fcn alBufferData()
float get_time() const
Get the current position in the Sound_Buffer, offset in seconds.
#define ZENI_DEFAULT_REFERENCE_DISTANCE
#define AL_BUFFERS_PROCESSED
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum format
void stop()
Stop the Sound_Source. (Essentially the same as pause but resets the current time.)
long ov_read(OggVorbis_File *vf, char *buffer, int length, int bigendianp, int word, int sgned, int *bitstream)
float get_rolloff() const
#define ZENI_DEFAULT_ROLLOFF
static alDeleteBuffers_fcn alDeleteBuffers()
#define AL_SOURCE_RELATIVE
static alSourcefv_fcn alSourcefv()
static alGetError_fcn alGetError()
static alSourcePlay_fcn alSourcePlay()
void play()
Begin playing or unpause the Sound_Source.
#define AL_REFERENCE_DISTANCE
vorbis_comment * ov_comment(OggVorbis_File *vf, int link)
#define AL_FORMAT_STEREO16
static alSourceUnqueueBuffers_fcn alSourceUnqueueBuffers()
bool is_playing() const
Check to see if the Sound_Source is playing.
static alSourcePause_fcn alSourcePause()
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.
int ov_time_seek(OggVorbis_File *vf, double pos)
static alGenSources_fcn alGenSources()
GLsizei GLsizei GLchar * source
void set_position(const Point3f &position)
Set the position of the Sound_Source_HW.
void set_pitch(const float &pitch=ZENI_DEFAULT_PITCH)
Set the pitch.
void set_velocity(const Vector3f &velocity)
Set the velocity of the Sound_Source_HW for the doppler effect.
static alGenBuffers_fcn alGenBuffers()
float get_max_distance() const