##

OpenAL.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef _GAZEBO_UTIL_OPENAL_HH_
#define _GAZEBO_UTIL_OPENAL_HH_
#include <set>
#include <string>
#include <vector>
#include <sdf/sdf.hh>
#include <ignition/math/Vector3.hh>
#include <ignition/math/Pose3.hh>
#include "gazebo/common/SingletonT.hh"
#include "gazebo/util/UtilTypes.hh"
#include "gazebo/gazebo_config.h"
#include "gazebo/util/system.hh"
#ifdef HAVE_OPENAL
GZ_SINGLETON_DECLARE(GZ_UTIL_VISIBLE, gazebo, util, OpenAL)
namespace gazebo
{
namespace util
{
// Forward declare private openal data class
class OpenALPrivate;
// Forward declare private openal sourcedata class
class OpenALSourcePrivate;
class GZ_UTIL_VISIBLE OpenAL : public SingletonT<OpenAL>
{
private: OpenAL();
private: virtual ~OpenAL();
public: bool Load(sdf::ElementPtr _sdf = sdf::ElementPtr());
public: void Fini();
public: OpenALSourcePtr CreateSource(sdf::ElementPtr _sdf);
public: OpenALSinkPtr CreateSink(sdf::ElementPtr _sdf);
public: std::set<std::string> DeviceList() const;
private: std::unique_ptr<OpenALPrivate> dataPtr;
private: friend class SingletonT<OpenAL>;
};
class GZ_UTIL_VISIBLE OpenALSink
{
public: OpenALSink();
public: virtual ~OpenALSink();
public: bool SetPose(const ignition::math::Pose3d &_pose);
public: bool SetVelocity(const ignition::math::Vector3d &_vel);
};
class GZ_UTIL_VISIBLE OpenALSource
{
public: OpenALSource();
public: virtual ~OpenALSource();
public: bool Load(sdf::ElementPtr _sdf);
public: bool SetPose(const ignition::math::Pose3d &_pose);
public: bool SetVelocity(const ignition::math::Vector3d &_vel);
public: bool SetPitch(float _p);
public: bool SetGain(float _g);
public: bool SetLoop(bool _state);
public: bool OnContact() const;
public: std::vector<std::string> CollisionNames() const;
public: bool HasCollisionName(const std::string &_name) const;
public: void Play();
public: void Pause();
public: void Stop();
public: void Rewind();
public: bool IsPlaying();
public: bool FillBufferFromPCM(uint8_t *_pcmData, unsigned int _dataCount,
int _sampleRate);
public: void FillBufferFromFile(const std::string &_audioFile);
private: std::unique_ptr<OpenALSourcePrivate> dataPtr;
};
}
}
#endif
#endif
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo
gazebo
Definition: OpenAL.hh:37
gazebo::util::OpenAL
3D audio setup and playback.
Definition: OpenAL.hh:54
SingletonT
Singleton template class.
Definition: SingletonT.hh:33
gazebo::util::OpenALSourcePtr
std::shared_ptr< OpenALSource > OpenALSourcePtr
Definition: UtilTypes.hh:48
system.hh
util
util
Definition: OpenAL.hh:37
gazebo::util::OpenALSink
OpenAL Listener. This can be thought of as a microphone.
Definition: OpenAL.hh:94
UtilTypes.hh
gazebo::util::OpenALSinkPtr
std::shared_ptr< OpenALSink > OpenALSinkPtr
Definition: UtilTypes.hh:44
gazebo::util::OpenALSource
OpenAL Source. This can be thought of as a speaker.
Definition: OpenAL.hh:115
GZ_SINGLETON_DECLARE
#define GZ_SINGLETON_DECLARE(visibility, n1, n2, singletonType)
Helper to declare typed SingletonT.
Definition: SingletonT.hh:61
SingletonT.hh