2007-05-27 12:01:53 -04:00
|
|
|
//
|
|
|
|
// SuperTuxKart - a fun racing game with go-kart
|
|
|
|
// Copyright (C) 2006 Patrick Ammann <pammann@aro.ch>
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
2008-06-12 20:53:52 -04:00
|
|
|
// as published by the Free Software Foundation; either version 3
|
2007-05-27 12:01:53 -04:00
|
|
|
// of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
2008-09-17 23:24:19 -04:00
|
|
|
#ifndef HEADER_SFX_OPENAL_HPP
|
|
|
|
#define HEADER_SFX_OPENAL_HPP
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2011-11-26 20:14:16 -05:00
|
|
|
#if HAVE_OGGVORBIS
|
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
#include <assert.h>
|
|
|
|
#ifdef __APPLE__
|
|
|
|
# include <OpenAL/al.h>
|
|
|
|
#else
|
|
|
|
# include <AL/al.h>
|
|
|
|
#endif
|
2008-09-17 23:24:19 -04:00
|
|
|
#include "audio/sfx_base.hpp"
|
|
|
|
#include "audio/sfx_manager.hpp"
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2010-04-23 16:36:13 -04:00
|
|
|
/**
|
|
|
|
* \brief OpenAL implementation of the abstract SFXBase interface
|
|
|
|
* \ingroup audio
|
|
|
|
*/
|
2008-09-17 23:24:19 -04:00
|
|
|
class SFXOpenAL : public SFXBase
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2008-09-17 23:24:19 -04:00
|
|
|
private:
|
2010-10-11 16:26:31 -04:00
|
|
|
SFXBuffer* m_soundBuffer; //!< Buffers hold sound data.
|
|
|
|
ALuint m_soundSource; //!< Sources are points emitting sound.
|
2008-09-20 10:23:20 -04:00
|
|
|
bool m_ok;
|
2008-11-06 02:17:11 -05:00
|
|
|
bool m_positional;
|
2009-04-12 07:20:13 -04:00
|
|
|
float m_defaultGain;
|
2010-10-11 16:26:31 -04:00
|
|
|
|
|
|
|
/** The OpenAL source contains this info, but if audio is disabled initially then
|
|
|
|
the sound source won't be created and we'll be left with no clue when enabling
|
|
|
|
sounds later */
|
|
|
|
bool m_loop;
|
|
|
|
|
|
|
|
/** Contains a volume if set through the "volume" method, or a negative number if
|
|
|
|
this method was not called.
|
|
|
|
The OpenAL source contains this info, but if audio is disabled initially then
|
|
|
|
the sound source won't be created and we'll be left with no clue when enabling
|
|
|
|
sounds later. */
|
|
|
|
float m_gain;
|
|
|
|
|
2012-12-09 18:30:26 -05:00
|
|
|
bool m_owns_buffer;
|
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
public:
|
2012-12-09 18:30:26 -05:00
|
|
|
SFXOpenAL(SFXBuffer* buffer, bool positional, float gain,
|
|
|
|
bool owns_buffer = false);
|
2008-09-20 10:23:20 -04:00
|
|
|
virtual ~SFXOpenAL();
|
2010-10-10 22:00:36 -04:00
|
|
|
|
|
|
|
/** Late creation, if SFX was initially disabled */
|
|
|
|
virtual bool init();
|
|
|
|
|
2008-09-20 10:23:20 -04:00
|
|
|
virtual void play();
|
2010-06-24 19:10:25 -04:00
|
|
|
virtual void setLoop(bool status);
|
2008-09-20 10:23:20 -04:00
|
|
|
virtual void stop();
|
|
|
|
virtual void pause();
|
|
|
|
virtual void resume();
|
|
|
|
virtual void speed(float factor);
|
2008-10-09 18:24:19 -04:00
|
|
|
virtual void position(const Vec3 &position);
|
2009-04-12 07:20:13 -04:00
|
|
|
virtual void volume(float gain);
|
2008-09-20 10:23:20 -04:00
|
|
|
virtual SFXManager::SFXStatus getStatus();
|
2010-10-11 18:35:58 -04:00
|
|
|
virtual void onSoundEnabledBack();
|
2011-08-06 16:37:54 -04:00
|
|
|
virtual void setRolloff(float rolloff);
|
|
|
|
|
|
|
|
virtual const SFXBuffer* getBuffer() const { return m_soundBuffer; }
|
2010-12-08 17:18:55 -05:00
|
|
|
|
2008-09-17 23:24:19 -04:00
|
|
|
}; // SFXOpenAL
|
|
|
|
|
2011-11-26 20:14:16 -05:00
|
|
|
#endif
|
2008-09-17 23:24:19 -04:00
|
|
|
#endif // HEADER_SFX_OPENAL_HPP
|
2007-05-27 12:01:53 -04:00
|
|
|
|