zenilib: zenilib/jni/external/zenilib/zeni_audio/Zeni/Sound_Source.hxx Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Sound_Source.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_SOURCE_HXX
19 #define ZENI_SOUND_SOURCE_HXX
20
21 // HXXed below
22 #include <Zeni/Timer_HQ.h>
23
24 #include <Zeni/Sound_Source.h>
25
26 #include <cassert>
27 #include <cmath>
28
29 #ifndef DISABLE_AL
30 #ifndef AL_SEC_OFFSET
31 #define AL_SEC_OFFSET 0x1024
32 #endif
33 #endif
34
35 #include <Zeni/Define.h>
36
37 namespace Zeni {
38
39 void Sound_Source::set_priority(const int &priority) {m_priority = priority;}
40 void Sound_Source::set_buffer(const Sound_Buffer &buffer) {m_buffer = &buffer; if(m_hw) m_hw->set_buffer(buffer);}
41 void Sound_Source::set_pitch(const float &pitch) {m_pitch = pitch; if(m_hw) m_hw->set_pitch(pitch);}
42 void Sound_Source::set_gain(const float &gain) {m_gain = gain; if(m_hw) m_hw->set_gain(gain);}
43 void Sound_Source::set_position(const Point3f &position) {m_position = position; if(m_hw) m_hw->set_position(position);}
44 void Sound_Source::set_velocity(const Vector3f &velocity) {m_velocity = velocity; if(m_hw) m_hw->set_velocity(velocity);}
45 void Sound_Source::set_looping(const bool &looping) {m_looping = looping; if(m_hw) m_hw->set_looping(looping);}
46
47 void Sound_Source::set_time(const float &time) {
48 m_play_position = time;
49 if(m_playing)
50 m_play_time.update();
51
52 if(m_hw)
53 m_hw->set_time(time);
54 }
55
56 void Sound_Source::set_reference_distance(const float &reference_distance) {m_reference_distance = reference_distance; if(m_hw) m_hw->set_reference_distance(reference_distance);}
57 void Sound_Source::set_max_distance(const float &max_distance) {m_max_distance = max_distance; if(m_hw) m_hw->set_max_distance(max_distance);}
58 void Sound_Source::set_rolloff(const float &rolloff) {m_rolloff = rolloff; if(m_hw) m_hw->set_rolloff(rolloff);}
59
60 int Sound_Source::get_priority() const {return m_priority;}
61 Time_HQ Sound_Source::get_unstop_time() const {return m_unstop_time;}
62 const Sound_Buffer & Sound_Source::get_buffer() const {assert(m_buffer); return *m_buffer;}
63 float Sound_Source::get_duration() const {if(m_hw) m_duration = m_hw->get_duration(); return m_duration;}
64 float Sound_Source::get_pitch() const {return m_pitch;}
65 float Sound_Source::get_gain() const {return m_gain;}
66 Point3f Sound_Source::get_position() const {return m_position;}
67 Vector3f Sound_Source::get_velocity() const {return m_velocity;}
68 bool Sound_Source::is_looping() const {return m_looping;}
69 float Sound_Source::get_reference_distance() const {return m_reference_distance;}
70 float Sound_Source::get_max_distance() const {return m_max_distance;}
71 float Sound_Source::get_rolloff() const {return m_rolloff;}
72
73 void Sound_Source::play() {update_state(Sound_Source_HW::PLAYING); if(m_hw) m_hw->play(); m_unstop_time.update();}
74 void Sound_Source::pause() {update_state(Sound_Source_HW::PAUSED); if(m_hw) m_hw->pause(); m_unstop_time.update();}
75 void Sound_Source::stop() {update_state(Sound_Source_HW::STOPPED); if(m_hw) m_hw->stop();}
76
77 bool Sound_Source::is_playing() const {update_state(); return m_playing;}
78 bool Sound_Source::is_paused() const {update_state(); return m_paused;}
79 bool Sound_Source::is_stopped() const {update_state(); return m_stopped;}
80
81 bool Sound_Source::is_assigned() const {return m_hw != 0;}
82
83 }
84
85 #include <Zeni/Undefine.h>
86
87 #include <Zeni/Timer_HQ.hxx>
88
89 #endif
Zeni::Sound_Source_HW::get_duration
float get_duration() const
Get the duration of the Sound_Buffer in seconds.
Definition: Sound_Source.cpp:250
Zeni::Sound_Source::set_buffer
void set_buffer(const Sound_Buffer &buffer)
Set the Sound_Buffer to be played.
Definition: Sound_Source.hxx:40
Zeni::Sound_Source::get_rolloff
float get_rolloff() const
Definition: Sound_Source.hxx:71
Zeni::Sound_Source::stop
void stop()
Stop the Sound_Source. (Essentially the same as pause but resets the current time.)
Definition: Sound_Source.hxx:75
Zeni::Sound_Source::get_velocity
Vector3f get_velocity() const
Get the velocity of the Sound_Buffer.
Definition: Sound_Source.hxx:67
Zeni::Sound_Source::get_pitch
float get_pitch() const
Get the pitch.
Definition: Sound_Source.hxx:64
Zeni::Sound_Source::get_reference_distance
float get_reference_distance() const
Definition: Sound_Source.hxx:69
Zeni::Sound_Source_HW::set_buffer
void set_buffer(const Sound_Buffer &buffer)
Set the Sound_Buffer to be played.
Definition: Sound_Source.cpp:113
Timer_HQ.hxx
Zeni::Time_HQ
A Snapshot of the Timer_HQ.
Definition: Timer_HQ.h:79
Zeni::Sound_Source::get_gain
float get_gain() const
Get the gain.
Definition: Sound_Source.hxx:65
Sound_Source.h
Zeni::Sound_Source::is_paused
bool is_paused() const
Check to see if the Sound_Source is paused.
Definition: Sound_Source.hxx:78
Zeni::Sound_Source_HW::set_time
void set_time(const float &time)
Set the current position in the Sound_Buffer, offset in seconds.
Definition: Sound_Source.cpp:198
Zeni::Sound_Source::pause
void pause()
Pause the Sound_Source.
Definition: Sound_Source.hxx:74
Zeni::Time_HQ::update
void update()
Update to current Time.
Definition: Timer_HQ.hxx:47
Zeni::Sound_Source::get_priority
int get_priority() const
Get the Sound_Source&#39;s priority.
Definition: Sound_Source.hxx:60
Zeni::Sound_Source_HW::stop
void stop()
Stop the Sound_Source_HW. (Essentially the same as pause but resets the current time.)
Definition: Sound_Source.cpp:389
Zeni::Sound_Source::set_rolloff
void set_rolloff(const float &rolloff=ZENI_DEFAULT_ROLLOFF)
Definition: Sound_Source.hxx:58
Zeni::Sound_Source::get_unstop_time
Time_HQ get_unstop_time() const
Get the Time_HQ at which the Sound_Source was most recently played or unpaused.
Definition: Sound_Source.hxx:61
Zeni::Sound_Source_HW::play
void play()
Begin playing or unpause the Sound_Source_HW.
Definition: Sound_Source.cpp:362
Zeni::Sound_Source_HW::PAUSED
Definition: Sound_Source.h:87
Zeni::Sound_Source::get_max_distance
float get_max_distance() const
Definition: Sound_Source.hxx:70
assert
#define assert(x)
Definition: SDL_malloc.c:1234
Undefine.h
Zeni::Sound_Source_HW::set_gain
void set_gain(const float &gain=ZENI_DEFAULT_GAIN)
Set the gain.
Definition: Sound_Source.cpp:144
Zeni::Sound_Source_HW::set_reference_distance
void set_reference_distance(const float &reference_distance=ZENI_DEFAULT_REFERENCE_DISTANCE)
Definition: Sound_Source.cpp:215
Zeni::Sound_Source::play
void play()
Begin playing or unpause the Sound_Source.
Definition: Sound_Source.hxx:73
Zeni::Sound_Source_HW::set_looping
void set_looping(const bool &looping)
Set whether the Sound_Buffer should loop back to the start once it is done playing.
Definition: Sound_Source.cpp:181
Zeni::Sound_Source_HW::set_velocity
void set_velocity(const Vector3f &velocity)
Set the velocity of the Sound_Source_HW for the doppler effect.
Definition: Sound_Source.cpp:171
Zeni::Point3f
A 3D Point represented with floats.
Definition: Coordinate.h:133
Zeni::Sound_Source::get_position
Point3f get_position() const
Get the position of the Sound_Buffer.
Definition: Sound_Source.hxx:66
Zeni::Sound_Source_HW::set_max_distance
void set_max_distance(const float &max_distance=ZENI_DEFAULT_MAX_SOUND_DISTANCE)
Definition: Sound_Source.cpp:225
Zeni::Sound_Source::get_buffer
const Sound_Buffer & get_buffer() const
Get the Sound_Buffer&#39;s OpenAL id.
Definition: Sound_Source.hxx:62
buffer
EGLContext EGLenum EGLClientBuffer buffer
Definition: eglext.h:87
Zeni::Vector3f
A Featureful 3-Space Vector Class.
Definition: Vector3f.h:58
Zeni::Sound_Source_HW::set_rolloff
void set_rolloff(const float &rolloff=ZENI_DEFAULT_ROLLOFF)
Definition: Sound_Source.cpp:235
Define.h
Zeni::Sound_Source::set_time
void set_time(const float &time)
Set the current position in the Sound_Buffer, offset in seconds.
Definition: Sound_Source.hxx:47
Zeni::Sound_Source::set_max_distance
void set_max_distance(const float &max_distance=ZENI_DEFAULT_MAX_SOUND_DISTANCE)
Definition: Sound_Source.hxx:57
Zeni::Sound_Source::set_priority
void set_priority(const int &priority=ZENI_DEFAULT_SOUND_PRIORITY)
Set the priority that this Sound_Source should have. Higher numbers are more likely to be selected fo...
Definition: Sound_Source.hxx:39
Zeni::Sound_Buffer
Stores Sound Data.
Definition: Sound_Buffer.h:83
Zeni::Sound_Source::set_reference_distance
void set_reference_distance(const float &reference_distance=ZENI_DEFAULT_REFERENCE_DISTANCE)
Definition: Sound_Source.hxx:56
Zeni::Sound_Source::get_duration
float get_duration() const
Get the duration of the Sound_Buffer in seconds.
Definition: Sound_Source.hxx:63
Zeni::Sound_Source::set_looping
void set_looping(const bool &looping)
Set whether the Sound_Buffer should loop back to the start once it is done playing.
Definition: Sound_Source.hxx:45
Timer_HQ.h
Zeni::Sound_Source::set_gain
void set_gain(const float &gain=ZENI_DEFAULT_GAIN)
Set the gain.
Definition: Sound_Source.hxx:42
Zeni::Sound_Source_HW::STOPPED
Definition: Sound_Source.h:87
Zeni::Sound_Source_HW::PLAYING
Definition: Sound_Source.h:87
Zeni::Sound_Source::is_stopped
bool is_stopped() const
Check to see if the Sound_Source is stopped.
Definition: Sound_Source.hxx:79
Zeni::Sound_Source::is_playing
bool is_playing() const
Check to see if the Sound_Source is playing.
Definition: Sound_Source.hxx:77
Zeni::Sound_Source_HW::set_position
void set_position(const Point3f &position)
Set the position of the Sound_Source_HW.
Definition: Sound_Source.cpp:161
Zeni::Sound_Source::set_pitch
void set_pitch(const float &pitch=ZENI_DEFAULT_PITCH)
Set the pitch.
Definition: Sound_Source.hxx:41
Zeni::Sound_Source::set_velocity
void set_velocity(const Vector3f &velocity)
Set the velocity of the Sound_Source for the doppler effect.
Definition: Sound_Source.hxx:44
Zeni::Sound_Source::set_position
void set_position(const Point3f &position)
Set the position of the Sound_Source.
Definition: Sound_Source.hxx:43
Zeni::Sound_Source_HW::pause
void pause()
Pause the Sound_Source_HW.
Definition: Sound_Source.cpp:376
Zeni::Sound_Source::is_assigned
bool is_assigned() const
Check to see if the Sound_Source is assigned to actual hardware.
Definition: Sound_Source.hxx:81
Zeni::Sound_Source::is_looping
bool is_looping() const
Check to see if the Sound_Buffer is set to loop back to the start once it is done playing...
Definition: Sound_Source.hxx:68
Zeni::Sound_Source_HW::set_pitch
void set_pitch(const float &pitch=ZENI_DEFAULT_PITCH)
Set the pitch.
Definition: Sound_Source.cpp:134