X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fsound%2Fsample_openal.hxx;h=b5267bb10ca1963d8ddcf2e4bf8e759168f79326;hb=6250f675db9fdd6f2aef7be43207cd0ac0b6baeb;hp=56fc3d3aea366f76ee718b575dfe1cca0dbb46d2;hpb=1ac944b7c1e7236e6d3493a7c23ea2c099109261;p=simgear.git diff --git a/simgear/sound/sample_openal.hxx b/simgear/sound/sample_openal.hxx index 56fc3d3a..b5267bb1 100644 --- a/simgear/sound/sample_openal.hxx +++ b/simgear/sound/sample_openal.hxx @@ -35,6 +35,7 @@ #endif #include +#include #include #include @@ -42,7 +43,7 @@ #include #include -// #include +class SGPath; /** * manages everything we need to know for an individual audio sample @@ -59,11 +60,10 @@ public: /** * Constructor - * @param path Path name to sound * @param file File name of sound Buffer data is freed by the sample group */ - SGSoundSample( const char *path, const char *file ); + SGSoundSample(const char *file, const SGPath& currentDir); /** * Constructor. @@ -90,6 +90,8 @@ public: */ inline bool is_file() const { return _is_file; } + SGPath file_path() const; + /** * Test if this audio sample configuration has changed since the last call. * Calling this function will reset the flag so calling it a second @@ -115,8 +117,8 @@ public: * at the next call op SoundGroup::update() * @param _loop Define whether this sound should be played in a loop. */ - void play( bool loop ) { - _playing = true; _loop = loop; _changed = true; + void play( bool loop = false ) { + _playing = true; _loop = loop; _changed = true; _static_changed = true; } /** @@ -128,7 +130,7 @@ public: /** * Schedule this audio sample to stop playing. */ - void stop() { + virtual void stop() { _playing = false; _changed = true; } @@ -158,7 +160,7 @@ public: inline void set_data( const unsigned char **data ) { _data = (unsigned char*)*data; *data = NULL; } - inline void set_data( void **data ) { + inline void set_data( const void **data ) { _data = (unsigned char*)*data; *data = NULL; } @@ -172,14 +174,14 @@ public: * Free the data associated with this audio sample */ void free_data() { - if ( _data ) free( _data ); _data = NULL; + if ( _data != NULL ) free( _data ); _data = NULL; } /** * Set the source id of this source * @param sid OpenAL source-id */ - void set_source(unsigned int sid) { + virtual inline void set_source(unsigned int sid) { _source = sid; _valid_source = true; _changed = true; } @@ -187,24 +189,24 @@ public: * Get the OpenAL source id of this source * @return OpenAL source-id */ - inline unsigned int get_source() { return _source; } + virtual inline unsigned int get_source() { return _source; } /** * Test if the source-id of this audio sample may be passed to OpenAL. * @return true if the source-id is valid */ - inline bool is_valid_source() const { return _valid_source; } + virtual inline bool is_valid_source() const { return _valid_source; } /** * Set the source-id of this audio sample to invalid. */ - inline void no_valid_source() { _valid_source = false; } + virtual inline void no_valid_source() { _valid_source = false; } /** * Set the OpenAL buffer-id of this source * @param bid OpenAL buffer-id */ - void set_buffer(unsigned int bid) { + inline void set_buffer(unsigned int bid) { _buffer = bid; _valid_buffer = true; _changed = true; } @@ -285,7 +287,7 @@ public: * Set the frequency (in Herz) of this audio sample. * @param freq Frequency */ - inline void set_frequency( int freq ) { _freq = freq; _changed = true; } + inline void set_frequency( int freq ) { _freq = freq; } /** * Returns the frequency (in Herz) of this audio sample. @@ -322,14 +324,6 @@ public: _base_pos = pos; _changed = true; } - /** - * Set the base position offset in Cartesian coordinates - * @param offs offset in Cartesian coordinates - */ - inline void set_position_offset( const SGVec3d& offs ) { - _base_offs = offs; _changed = true; - } - /** * Get the absolute position of this sound. * This is in the same coordinate system as OpenGL; y=up, z=back, x=right. @@ -345,12 +339,8 @@ public: _orientation = ori; _changed = true; } - /** - * Set the rotation quatgernion of this sound. - * @param rotation Quaternion containing the rotation information - */ - inline void set_rotation( const SGQuatd& rotation ) { - _rotation = rotation; _changed = true; + inline void set_rotation( const SGQuatd& ec2body ) { + _rotation = ec2body; _changed = true; } /** @@ -359,20 +349,18 @@ public: * @param dir Sound emission direction */ inline void set_direction( const SGVec3f& dir ) { - _direction = toVec3d(dir); _changed = true; + _direction = toVec3d(dir); _static_changed = true; } /** * Define the audio cone parameters for directional audio. - * Note: setting it to 1 degree will result in 0.5 degrees to both sides. + * Note: setting it to 2 degree will result in 1 degree to both sides. * @param inner Inner cone angle (0 - 360 degrees) * @param outer Outer cone angle (0 - 360 degrees) * @param gain Remaining gain at the edge of the outer cone (0.0 - 1.0) */ void set_audio_cone( float inner, float outer, float gain ) { - _inner_angle = inner; - _outer_angle = outer; - _outer_gain = gain; + _inner_angle = inner; _outer_angle = outer; _outer_gain = gain; _static_changed = true; } @@ -457,6 +445,8 @@ public: */ inline std::string get_sample_name() const { return _refname; } + inline virtual bool is_queue() const { return false; } + void update_pos_and_orientation(); private: @@ -469,10 +459,10 @@ private: // The position and orientation of this sound SGQuatd _orientation; // base orientation - SGQuatd _rotation; // rotation vector for relative offsets SGVec3f _orivec; // orientation vector for OpenAL SGVec3d _base_pos; // base position - SGVec3d _base_offs; // base offset position + + SGQuatd _rotation; std::string _refname; // name or file path unsigned char* _data;