|
|
[em14] [em14]
/*!==========================================================================
* GaiMo Audio SDK1.6.0(GAudio1.6.0)
* personal edition free.
* enterprise edition 288$(USD)
* emai:gaimosoft@yahoo.com
* website:www.gaimosoft.com
* please ensure openal is installed.
*****************************************************************************
/*!==========================================================================
* GaiMo Audio SDK is a Cplusplus Library designed for game engine used(GaimoEngine.).
* The following audio type is supported:
* ogg,mp3,wav,it,mod,xm,s3m,flac,au,aiff
* And it support 3D playing mode and support.
* There are 2 versions here:
* personal edition free
* and enterprise edition 388$
* Emai:gaimosoft@yahoo.com
* libsndfile.dll is additive.
* PLEASE ENSURE OPENAL IS INSTALLED.
*****************************************************************************
//! websize:www.sooftmoon.com
//! email:ccsdu2004@yahoo.com.cn
//! telephone:+86-028-67607663,
//! fax: +86-028-67607665
//! update list.
/*!==========================================================================
* 2010.01.22 version:1.0.0
* support:wav,ogg,mp3 format
* use thread for aduio stream playing.
* easy to use.
* this version needed OpenAL device.
****************************************************************************/
/*!==========================================================================
* 2010.03.20 version:1.1.0
* support 3D Audfio effect
* this version needed OpenAL device.
****************************************************************************/
/*!==========================================================================
* 2010.05.05 version:1.2.8
* support audio cature to wav file
* support it,s3m,xm and mod4 aduio file
* modified interface
* this version needed OpenAL device.
****************************************************************************/
/*!==========================================================================
* 2010.05.18 version:1.4.2
* 1.os support:xp,vista,win7
* 2.compile support:vc6,vc7,vc9,codeblock,devc++
* 4.support aiff,flac auduo format
* 5.use thread for audio capture
****************************************************************************/
/*!==========================================================================
* 2010.06.20 version 1.5.5
* 1.support flac,au by sndfile plugin
* 2.add audio effect plugin folder.
* 3.add interface for audio playing time and current playing time
* 4.support reverb and reverb
* 5.support lowpass filter.
* 6.configurable audio effect para(by xml)
* 7.add log output
****************************************************************************/
/*!==========================================================================
* 2010.10.25 version 1.6.0
* 1.changed interface.
* 2.remove effect config file setting.
****************************************************************************/
/*!==========================================================================
* GAudio's target:
* 1.support macrosoft window,linux,mac and xbox
* 2.support lang:c#,Dephi,Python and so on
* 3.use own audio algorithm for new audio effect
* 4.support other audio format(voc,aac,acc,ape,wma,midi and so forth)(plugin or embodied)
* 5.support audio spectrum
* 6.support audio format conversion
****************************************************************************/
/*!==========================================================================
* Next Version planning(GAudio SDK1.8.0):
* 1.support Dephi and C#
* 2.support ape and wma audio format
* 3.support linux os(32 bits)
* 4.use dsound in macrosoft window(maybe)
* 5.support capture audio as mp3 and ogg format
* 6.support ring effect
* 7.support playing audio stream
* 8.support audio spectrum
****************************************************************************/
/*!==========================================================================
* message:GAudio library include:
* 1.cplusplus file-audiodevce.hpp,
* 2.library GAudio_vc.lib for msvc complier.
* 3.library libGAudio_mingw.a for mingw32 complier
* 3.dynamic link library libsndfile.dll is for flac and au audio format
****************************************************************************/
/*!==========================================================================
* Licensing
* GAudio is available under following 2 license schemes
* 1.non-commercial license,which allows software not intended to for commercial distribution to use GAudio for free(ony for study,one PC)
* 2.commercial license,licensed on a per-platform basis.intended for commercial software and games(288 USD for one software!)
****************************************************************************/
#ifndef GAIMO_AUDIODEVICE_HPP
#define GAIMO_AUDIODEVICE_HPP
////////////////////////////////////////////////////////////
/// header file include
////////////////////////////////////////////////////////////
#include <string>
#if defined(_WIN32) || (defined(__WIN32__)) || defined(WIN32)
#ifndef G_WIN32
#define G_WIN32
#endif
#endif
#ifndef __cplusplus
#error please use cplusplus compiler.
#endif
#ifndef G_CALL
# ifdef G_WIN32
# define G_CALL __stdcall
# else
# define G_CALL __stdcall
# endif
#endif
#if !defined(G_DLL_API) && defined(G_WIN32)
#if defined(BUILDING_DLL)
#define G_DLL_API __declspec(dllexport)
#else
#define G_DLL_API __declspec(dllimport)
#endif
#endif
#define G_FUNC(ret) extern "C" G_DLL_API ret
#ifndef NULL
#define NULL 0
#endif
typedef unsigned char uchar8;
typedef unsigned int uint;
typedef unsigned char uint8;
typedef signed short int16;
typedef unsigned short uint16;
typedef signed int int32;
typedef std::string engine_string;
//! version
#ifndef GAUDIO_VERSION_PERSON
#define GAUDIO_VERSION_PERSON
#endif
namespace core
{
/////////////////////////////////////////////////////////
//! audio file type.
/////////////////////////////////////////////////////////
enum AUDIO_FILE_TYPE
{
//! wav
AUDIO_FILE_TYPE_WAV = 0, //! support!
//! ogg
AUDIO_FILE_TYPE_OGG, //! support!
//! mp3
AUDIO_FILE_TYPE_MP3, //! support!
//! XM,IT,MOD,S3M
AUDIO_FILE_TYPE_XM, //! support!
AUDIO_FILE_TYPE_IT, //! support!
AUDIO_FILE_TYPE_MOD, //! support!
AUDIO_FILE_TYPE_S3M, //! support!
//! AU
AUDIO_FILE_TYPE_AU, //! support!
//! AIFF
AUDIO_FILE_TYPE_AIFF, //! support!
AUDIO_FILE_TYPE_AAC,
AUDIO_FILE_TYPE_ACC,
AUDIO_FILE_TYPE_MP1,
AUDIO_FILE_TYPE_MP2,
AUDIO_FILE_TYPE_VOC,
//! WMA
AUDIO_FILE_TYPE_WMA,
//! APE
AUDIO_FILE_TYPE_APE,
//! MIDI
AUDIO_FILE_TYPE_MIDI,
//! FLAC
AUDIO_FILE_TYPE_FLAC, //! support!
//! NULL
AUDIO_FILE_TYPE_NULL
};
////////////////////////////////////////////////////////////
/// audio distance mode.
////////////////////////////////////////////////////////////
enum AUDIO_DISTANCE_MODE
{
AUDIO_DISTANCE_MODEL = 0,
AUDIO_INVERSE_DISTANCE,
AUDIO_INVERSE_DISTANCE_CLAMPED,
AUDIO_LINEAR_DISTANCE,
AUDIO_LINEAR_DISTANCE_CLAMPED,
AUDIO_EXPONENT_DISTANCE,
AUDIO_EXPONENT_DISTANCE_CLAMPED,
AUDIO_DISTANCE_MODE_NULL
};
/////////////////////////////////////////////////////////
//! audio effect type.
/////////////////////////////////////////////////////////
enum AUDIO_EFFECT_TYPE
{
AUDIO_EFFECT_TYPE_REVERB = 0,
AUDIO_EFFECT_TYPE_EFXREVERB,
AUDIO_EFFECT_TYPE_CHORUS,
AUDIO_EFFECT_TYPE_DISTORTION,
AUDIO_EFFECT_TYPE_ECHO,
AUDIO_EFFECT_TYPE_FLANGER,
AUDIO_EFFECT_TYPE_FREQUENCY_SHIFTER,
AUDIO_EFFECT_TYPE_VOCAL_MORPHER,
AUDIO_EFFECT_TYPE_PITCH_SHIFTER,
AUDIO_EFFECT_TYPE_RING_MODULATOR,
AUDIO_EFFECT_TYPE_AUTOWAH,
AUDIO_EFFECT_TYPE_COMPRESSOR,
AUDIO_EFFECT_TYPE_EQUALIZER,
AUDIO_EFFECT_TYPE_NULL
};
/////////////////////////////////////////////////////////
//! audio filter type.
/////////////////////////////////////////////////////////
enum AUDIO_FILTER_TYPE
{
AUDIO_FILTER_TYPE_LOWPASS,
AUDIO_FILTER_TYPE_HIGHPASS,
AUDIO_FILTER_TYPE_BANDPASS,
AUDIO_FILTER_TYPE_NULL
};
//! audio vel.
const float AUDIO_SPACE_VELOCITY = 343.0f;
//! doppler factor.
const float AUDIO_DOPPLER_FACTOR = 1.0f;
/////////////////////////////////////////////////////////
/// audio object.
/////////////////////////////////////////////////////////
class AudioObject
{
public:
virtual ~AudioObject(){}
public:
/////////////////////////////////////////////////////
//! set,get audio object pos.
/////////////////////////////////////////////////////
virtual void SetPosition(float x,float y,float z) = 0;
virtual void GetPosition(float &x,float &y,float &z) = 0;
/////////////////////////////////////////////////////
//! set,get audio object direction.
/////////////////////////////////////////////////////
virtual void SetDirection(float dirx,float diry,float dirz) = 0;
virtual void GetDirection(float &dirx,float &diry,float &dirz) = 0;
/////////////////////////////////////////////////////
//! set,get audio object vel.
/////////////////////////////////////////////////////
virtual void SetVelocity(float velx,float vely,float velz) = 0;
virtual void GetVelocity(float &velx,float &vely,float &velz) = 0;
////////////////////////////////////////////////////
//! move audio object(by offset.)
////////////////////////////////////////////////////
virtual void Move(float offsetx,float offsety,float offsetz) = 0;
};
//////////////////////////////////////////////////////
/// audio capture interface.
//////////////////////////////////////////////////////
class AudioCapture
{
public:
virtual ~AudioCapture(){}
public:
//////////////////////////////////////////////////
//! capture audio and stop it.
//////////////////////////////////////////////////
virtual void CaptureAudio() = 0;
virtual void CaptureStop() = 0;
};
/////////////////////////////////////////////////////////
/// object listener.
/////////////////////////////////////////////////////////
class AudioListener : public AudioObject
{
public:
/////////////////////////////////////////////////////
//! set,get global volume(0.0f,1.0f)
/////////////////////////////////////////////////////
virtual void SetGlobalVolume(float volume) = 0;
virtual float GetGlobalVolume()const = 0;
};
////////////////////////////////////////////////////////
//! audio source object
////////////////////////////////////////////////////////
class AudioSource : public AudioObject
{
public:
////////////////////////////////////////////////////
//! play audio(2d mode.)
////////////////////////////////////////////////////
virtual bool Play(const engine_string& audiofile,bool loop = false) = 0;
////////////////////////////////////////////////////
//! play audio(3d mode.)
////////////////////////////////////////////////////
virtual bool Play(const engine_string& audiofile,bool loop,float mindist,float maxdist) = 0;
////////////////////////////////////////////////////
//! stop,pause audio.
////////////////////////////////////////////////////
virtual bool Stop() = 0;
virtual bool Pause() = 0;
///////////////////////////////////////////////////
//! check status.
///////////////////////////////////////////////////
virtual bool IsPlay()const = 0;
virtual bool IsPause()const = 0;
virtual bool IsStop()const = 0;
///////////////////////////////////////////////////
//! set,get volume[0.0f,1.0f]
///////////////////////////////////////////////////
virtual void SetVolume(float gain) = 0;
virtual float GetVolume()const = 0;
virtual void SetMaxVolume(float gain) = 0;
virtual float GetMinVolume()const = 0;
virtual void SetMinVolume(float gain) = 0;
virtual float GetMaxVolume()const = 0;
virtual void SetMaxDistance(float distance) = 0;
virtual void GetMaxDistance(float &distance)= 0;
virtual void SetMinDistance(float distance) = 0;
virtual void GetMinDistance(float &distance)= 0;
virtual void SetAudioCone(float innerangle,float outerangle,float outergain) = 0;
virtual void GetAudioCone(float &innerangle,float &outerangle,float &outergain) = 0;
////////////////////////////////////////////////////
//! get playing time.
////////////////////////////////////////////////////
virtual float GetTotalTime()const = 0;
virtual float GetCurTime()const = 0;
////////////////////////////////////////////////////
//! able,disable effectr
////////////////////////////////////////////////////
virtual bool EnableEffect(AUDIO_EFFECT_TYPE type) = 0;
virtual void DisableEffect() = 0;
virtual bool IsEffectActive() = 0;
////////////////////////////////////////////////////
//! able,disable filter.
////////////////////////////////////////////////////
virtual bool AttachFiler(AUDIO_FILTER_TYPE type) = 0;
};
//////////////////////////////////////////////////////
//! audio device.
//////////////////////////////////////////////////////
class AudioDevice
{
public:
/////////////////////////////////////////////////
//! get audio device version.
/////////////////////////////////////////////////
virtual engine_string GetVerson() const = 0;
/////////////////////////////////////////////////
//! get audio maker.
/////////////////////////////////////////////////
virtual engine_string GetMaker() const = 0;
/////////////////////////////////////////////////
//! check given audio type is supported or not.
/////////////////////////////////////////////////
virtual bool IsSupport(const AUDIO_FILE_TYPE& type)const = 0;
/////////////////////////////////////////////////
//! get audio source(trial version for 5 sources.)
/////////////////////////////////////////////////
virtual AudioSource* GetAudioSource() = 0;
/////////////////////////////////////////////////
//! get listener pointer(only 1)
/////////////////////////////////////////////////
virtual AudioListener* GetAudioListener(float x,float y,float z) = 0;
/////////////////////////////////////////////////
//! get audio capture pointer((trial version for 1 capture.)
/////////////////////////////////////////////////
virtual AudioCapture* GetAudioCapture(const engine_string& name) = 0;
virtual void SetMetersPerUnit(float meters) = 0;
virtual float GetMetersPerUnit(void) const = 0;
virtual int GetMaxEffectMuber()const = 0;
/////////////////////////////////////////////////
//! set doppler factor(1.0f,343.3)
/////////////////////////////////////////////////
virtual void SetDoppler(float factor,float vel) = 0;
/////////////////////////////////////////////////
//! set audio wolrd sistance model.
/////////////////////////////////////////////////
virtual void SetDistanceModel(const AUDIO_DISTANCE_MODE &model) = 0;
/////////////////////////////////////////////////
//! check given effect
/////////////////////////////////////////////////
virtual bool IsSupportAudioEffect(AUDIO_EFFECT_TYPE type) = 0;
};
/////////////////////////////////////////////////////
//! init audio device(return NULL for failed.)
/////////////////////////////////////////////////////
G_FUNC(AudioDevice*) InitAudioDevice();
/////////////////////////////////////////////////////
//! deinit audio device.
/////////////////////////////////////////////////////
G_FUNC(void) TerminateAudioDevice();
}
#endif
//! maker:ccsdu2004
|
|