蓋莫音頻引擎1.2.8的上次發(fā)布版本為1.1.2版本
當(dāng)前發(fā)布版本增加功能如下:
1.對(duì)音頻錄入的支持
2.對(duì)xm,mod,it,s3m的支持
3.修改了一些內(nèi)部實(shí)現(xiàn)
總的說來本引擎(API)功能如下:
1.支持ogg,mp3,wav,xm,it,s3m,mod格式
2.基于多線程流式播放音頻
3.真3d音效
4.支持低通,次級(jí)音效
本音頻引擎完全勝任游戲開發(fā),嵌入式設(shè)備等商業(yè)應(yīng)用!
本音頻引擎使用于商業(yè)用途只需要付出少量的維護(hù)費(fèi)即可(遠(yuǎn)低于自主開發(fā)或者購(gòu)買fmod音頻引擎的付出成本)
本版本依然依賴于OpenAL驅(qū)動(dòng)
當(dāng)前編譯版本為win32下的gcc版本
可使用codeblock,devc++
蓋莫音頻引擎(API)發(fā)展方向?yàn)?
/*!==========================================================================
* 蓋莫音頻引擎的發(fā)展方向:
* 1.提供pdf等說明,幫助文檔
* 2.支持多編譯環(huán)境和操作平臺(tái)
* 3.支持midi音樂格式
* 4.支持aiff,acc,ape,flac等音頻格式(基于插件)
* 5.支持音頻重采樣
* 6.支持頻譜獲取
* 7.解除對(duì)OpenAL驅(qū)動(dòng)的依賴
* 8.提供強(qiáng)健,高效,真實(shí)的音頻特效
* 9.對(duì)內(nèi)存音頻的支持
* 10.實(shí)時(shí)音效
****************************************************************************/
下個(gè)預(yù)定版本1.4.2預(yù)計(jì)更新:
/*!==========================================================================
* 1.4.2版本預(yù)期修改說明
* 增加PDF說明文檔
* 對(duì)midi音頻文件的支持
* 修改音頻接口
* 解除使用音頻引擎需要安裝OpenAL驅(qū)動(dòng)的問題
* 支持基于插件的音頻格式支持(aiff,au,flac,ape,acc...)(保持原有支持音頻不變!)
****************************************************************************/
當(dāng)前蓋莫音頻引擎(API) sdk
配置簡(jiǎn)表:
c++頭文件一個(gè)
a/lib文件一個(gè) (可選擇使用a或者lib文件)
dll文件-audio.dll一個(gè)
OpenAL驅(qū)動(dòng)一個(gè)
提供頭文件如下:
//! 蓋莫游戲3d音頻引擎是成都蓋莫軟件技術(shù)有限責(zé)任公司推出的一款專門
//! 面向游戲開發(fā)的音頻庫(kù),該庫(kù)具有使用簡(jiǎn)介,功能強(qiáng)大的功能
//! 本音頻庫(kù)使用于非商業(yè)產(chǎn)品不收取任何費(fèi)用
//! 警告:本API不可使用于商業(yè)用途!
//! websize:www.gaimo.net
//! email:ccsdu2009@sohu.com
//! telephone:+86-028-67607663,
//! +86-028-67607665
//! 版本更新list.
/*!==========================================================================
* 2010.01.22 版本:1.0.0
* 提供功能:支持wav,ogg,mp3格式
* 使用多線程流式播放
* 簡(jiǎn)單易用的程序接口
* 使用本版本需要安裝OpenAL驅(qū)動(dòng)
****************************************************************************/
/*!==========================================================================
* 2010.03.20 版本:1.1.0
* 提供功能:真3d音效,及幾個(gè)音效
* 使用本版本需要安裝OpenAL驅(qū)動(dòng)
****************************************************************************/
/*!==========================================================================
* 2010.05.05 版本:1.2.8
* 增加功能:支持音頻錄入到文件(當(dāng)前僅為wav格式)
* 增加了對(duì):it,s3m,xm,mod4種音樂文件的支持
* 修改了幾個(gè)接口
* 使用本版本需要安裝OpenAL驅(qū)動(dòng)
****************************************************************************/
/*!==========================================================================
* 1.4.0版本預(yù)期修改說明
* 增加PDF說明文檔
* 對(duì)midi音頻文件的支持
* 修改音頻接口
* 解除使用音頻引擎需要安裝OpenAL驅(qū)動(dòng)的問題
* 支持基于插件的音頻格式支持(aiff,au,flac,ape,acc
)(保持原有支持音頻不變!)
****************************************************************************/
#ifndef AUDIODEVICE_HPP
#define AUDIODEVICE_HPP
////////////////////////////////////////////////////////////
/// 頭文件包含
////////////////////////////////////////////////////////////
#include <string>
#ifdef G_ENGINE
#error 蓋莫游戲引擎內(nèi)置蓋莫音頻引擎!
#endif
#if defined(_WIN32) || (defined(__WIN32__)) || defined(WIN32)
#define G_WIN32
#endif
#ifndef __cplusplus
# error 請(qǐng)使用c++編譯器
#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;
namespace core
{
////////////////////////////////////////////////////////////
/// 定義引擎引用計(jì)數(shù)類
////////////////////////////////////////////////////////////
class RefCount
{
public:
////////////////////////////////////////////////////////////
/// 引用計(jì)數(shù)構(gòu)造函數(shù)
////////////////////////////////////////////////////////////
RefCount(): refcnt(1),auto_del(true){}
////////////////////////////////////////////////////////////
/// 引用計(jì)數(shù)析構(gòu)函數(shù)
////////////////////////////////////////////////////////////
virtual ~RefCount(){}
////////////////////////////////////////////////////////////
/// 使用自刪除機(jī)制
////////////////////////////////////////////////////////////
void SetAutoDel(bool able = true){auto_del = able;}
////////////////////////////////////////////////////////////
/// 檢測(cè)是否為自刪除機(jī)制
////////////////////////////////////////////////////////////
const bool GetAutoDel()const{return auto_del;}
////////////////////////////////////////////////////////////
/// 增加對(duì)象引用計(jì)數(shù)
////////////////////////////////////////////////////////////
void Grab()const{++refcnt;};
////////////////////////////////////////////////////////////
/// 減少對(duì)象引用計(jì)數(shù)
////////////////////////////////////////////////////////////
bool Drop() const
{
//!ASSERT(refcnt>0 && "bad refcnt number!");
--refcnt;
if (refcnt == 0 && auto_del == true)
{
delete this;
return true;
}
return false;
}
////////////////////////////////////////////////////////////
/// 獲取引用計(jì)數(shù)
////////////////////////////////////////////////////////////
int GetRefCnt()const{return refcnt;};
private:
mutable int refcnt;
bool auto_del;
};
////////////////////////////////////////////////////////
/// 模板RefPtr用于基于計(jì)數(shù)的對(duì)象管理
/// 所有對(duì)象都必須要從RefCount繼承之
////////////////////////////////////////////////////////
template<class T>
class RefPtr
{
public:
RefPtr(T* object = NULL)
{
this->object = object;
if(this->object)
object->Grab();
}
RefPtr(const RefPtr<T>& other)
{
object = NULL;
*this = other;
}
~RefPtr()
{
if(object)
object->Drop();
object = NULL;
}
RefPtr<T>& operator=(const RefPtr<T>& other)
{
if (other)
other->Grab();
if (object)
object->Drop();
object = other.get();
return *this;
}
RefPtr& operator=(T* other)
{
if (other)
other->Grab();
if (object)
object->Drop();
object = other;
return *this;
}
void swap(RefPtr<T>& other)
{
T* tmp = other.get();
other = object;
object = tmp;
}
void reset(T* other){*this = other;}
T* get() const {return object;}
T* operator->() const
{
//!ASSERT(object && "bad object ptr");
return object;
}
T& operator*() const
{
//!ASSERT(object && "bad object ptr");
return *object;
}
bool operator<(const RefPtr<T>& other) const
{
return object < other.get();
}
////////////////////////////////////////////////////////
/// 檢測(cè)指針是否為空
////////////////////////////////////////////////////////
operator bool() const {return object != NULL;}
protected:
T* object;
};
namespace math
{
template<class T>
struct Vector3
{
T x,y,z;
Vector3():x(0),y(0),z(0){}
};
}
typedef math::Vector3<float> Vector3f;
/////////////////////////////////////////////////////////
//! 枚舉音頻文件格式
/////////////////////////////////////////////////////////
enum AudioFileType
{
AUDIOFILE_TYPE_WAV = 0,
AUDIOFILE_TYPE_OGG,
AUDIOFILE_TYPE_MP3,
AUDIOFILE_TYPE_XM,
AUDIOFILE_TYPE_IT,
AUDIOFILE_TYPE_MOD,
AUDIOFILE_TYPE_S3M,
AUDIOFILE_TYPE_AU,
AUDIOFILE_TYPE_AIFF,
AUDIOFILE_TYPE_WMA,
AUDIOFILE_TYPE_AAC,
AUDIOFILE_TYPE_APE,
AUDIOFILE_TYPE_MIDI
};
/////////////////////////////////////////////////////////
//! 枚舉引擎支持音頻格式類型
/////////////////////////////////////////////////////////
enum AudioFormat
{
AUDIO_8BIT_MONO = 0,
AUDIO_8BIT_STEREO,
ADUIO_16BIT_MONO,
AUDIO_16BIT_STEREO
};
//! 定義默認(rèn)空間音速
const float AUDIO_SPACE_VELOCITY = 343.0f;
//! 定義默認(rèn)多普勒因子
const float AUDIO_DOPPLER_FACTOR = 1.0f;
////////////////////////////////////////////////////////////
/// 定義音頻聽者基類
////////////////////////////////////////////////////////////
class AudioListener : public RefCount
{
public:
/////////////////////////////////////////////////////////
//! 構(gòu)造,析構(gòu)音頻聽者
/////////////////////////////////////////////////////////
AudioListener(){}
virtual ~AudioListener(){}
/////////////////////////////////////////////////////////
//! 設(shè)置,獲取音頻聽者當(dāng)前新的位置
/////////////////////////////////////////////////////////
virtual void SetPosition(const Vector3f &pos) = 0;
virtual Vector3f GetPosition()const = 0;
/////////////////////////////////////////////////////////
//! 設(shè)置音頻聽者的方向
/////////////////////////////////////////////////////////
virtual void SetDirection(const Vector3f& dir) = 0;
virtual Vector3f GetDirection()const = 0;
/////////////////////////////////////////////////////////
//! 設(shè)置音頻聽者的向上位置(一般而言采取類似OpenGL的方向即0,1,0)
/////////////////////////////////////////////////////////
virtual void SetUpVector(const Vector3f &updir) = 0;
virtual Vector3f GetUpVector()const = 0;
/////////////////////////////////////////////////////////
//! 設(shè)置音頻聽者的速度
/////////////////////////////////////////////////////////
virtual void SetVelocity(const Vector3f &vel) = 0;
virtual Vector3f GetVelocity()const = 0;
/////////////////////////////////////////////////////////
//! 設(shè)置,獲取全局音量(0.0f,1.0f)
/////////////////////////////////////////////////////////
virtual void SetGlobalVolume(float volume) = 0;
virtual float GetGlobalVolume()const = 0;
/////////////////////////////////////////////////////////
//! 設(shè)置,獲取音效作用單位
/////////////////////////////////////////////////////////
virtual void SetMetersPerUnit(float meters) = 0;
virtual float GetMetersPerUnit(void) const = 0;
/////////////////////////////////////////////////////////
//! 移動(dòng)聽者
/////////////////////////////////////////////////////////
virtual void Move(const Vector3f& position) = 0;
};
/////////////////////////////////////////////////////////
//! 定義蓋莫音頻引擎音源類
/////////////////////////////////////////////////////////
class AudioSource : public RefCount
{
public:
/////////////////////////////////////////////////////////
//! 構(gòu)造,析構(gòu)音頻源
/////////////////////////////////////////////////////////
AudioSource(){}
virtual ~AudioSource(){}
/////////////////////////////////////////////////////////
//! 播放指定音頻文件,流
/////////////////////////////////////////////////////////
virtual bool Play(const engine_string& audiofile, bool loop) = 0;
/////////////////////////////////////////////////////////
//! 停止播放音頻
/////////////////////////////////////////////////////////
virtual bool Stop() = 0;
/////////////////////////////////////////////////////////
//! 暫停音頻播放
/////////////////////////////////////////////////////////
virtual bool Pause() = 0;
/////////////////////////////////////////////////////////
//! 檢測(cè)音源狀態(tài)函數(shù)
/////////////////////////////////////////////////////////
virtual bool IsPlay()const = 0;
virtual bool IsPause()const = 0;
virtual bool IsStop()const = 0;
/////////////////////////////////////////////////////////
//! 設(shè)置,獲取音頻增益[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;
/////////////////////////////////////////////////////////
/// 獲取,設(shè)置音源位置(x,y,z)
/////////////////////////////////////////////////////////
virtual Vector3f GetSourcePosition()const = 0;
virtual void SetSourcePosition(const Vector3f& position) = 0;
/////////////////////////////////////////////////////////
/// 獲取,設(shè)置音源方向(x,y,z)
/////////////////////////////////////////////////////////
virtual Vector3f GetSourceDirection()const = 0 ;
virtual void SetSourceDirection(const Vector3f& direction) = 0;
/////////////////////////////////////////////////////////
/// 獲取,設(shè)置音源速度
/////////////////////////////////////////////////////////
virtual Vector3f GetSourceVelocity()const = 0;
virtual void SetSourceVelocity(const Vector3f& vel) = 0;
/////////////////////////////////////////////////////////
/// 設(shè)置,獲取音源最大,最小傳播距離
/////////////////////////////////////////////////////////
virtual void SetMaxDistance(float distance) = 0;
virtual void GetMaxDistance(float &distance)= 0;
virtual void SetMinDistance(float distance) = 0;
virtual void GetMinDistance(float &distance)= 0;
/////////////////////////////////////////////////////////
/// 設(shè)置,獲取音頻扇出值[0.0,1.0]
/////////////////////////////////////////////////////////
virtual void SetRolloffFactor(float factor) = 0;
virtual float GetRolloffFactor()const=0;
/////////////////////////////////////////////////////////
/// 設(shè)置,獲取音頻音節(jié)值(pitch值每減少50%則音階降低1個(gè)八度音階)(0,+inf)
/////////////////////////////////////////////////////////
virtual void SetPitch(float pitch) = 0;
virtual float GetPitch()const = 0;
/////////////////////////////////////////////////////////
/// 同時(shí)改變音源位置和速度的便利函數(shù)
/////////////////////////////////////////////////////////
virtual void Move(const Vector3f &newpos) = 0;
/////////////////////////////////////////////////////////
/// 設(shè)置,獲取音源錐(內(nèi)錐,外錐,外增益)
/////////////////////////////////////////////////////////
virtual void SetAudioCone(float innerangle, float outerangle, float outergain) = 0;
virtual void GetAudioCone(float &innerangle, float &outerangle, float &outergain) = 0;
/////////////////////////////////////////////////////////
/// 設(shè)置,獲取多普勒速度強(qiáng)度
/////////////////////////////////////////////////////////
virtual void SetDopplerVelocity(const Vector3f& dvelocity) = 0;
virtual Vector3f GetDopplerVelocity()const = 0;
virtual void SetDopplerStrength(float strength) = 0;
virtual float GetDopplerStrength()const = 0;
/////////////////////////////////////////////////////////
/// 設(shè)置,獲取音源傳過空間的能力指數(shù)(0-+inf)
/////////////////////////////////////////////////////////
virtual void SetStrength(float strength) = 0;
virtual float GetStrength()const = 0;
/////////////////////////////////////////////////////////
/// 設(shè)置為環(huán)境音,檢測(cè)是否為環(huán)境音
/////////////////////////////////////////////////////////
virtual void SetAmbient(bool ambient) = 0;
virtual bool IsAmbient() = 0;
/////////////////////////////////////////////////////////
/// 設(shè)置音源位置是否相對(duì)于聽者,檢測(cè)是否相對(duì)于聽者
/////////////////////////////////////////////////////////
virtual void SetRelative(bool relative) = 0;
virtual bool IsRelative() = 0;
/////////////////////////////////////////////////////////
/// 設(shè)置Reverb值([0,1.0])
/////////////////////////////////////////////////////////
virtual bool SetReverbScale(float scale) = 0;
/////////////////////////////////////////////////////////
/// 設(shè)置Reverb值([0,1.0])
/////////////////////////////////////////////////////////
virtual bool SetReverbDelay(float delay) = 0;
public:
/////////////////////////////////////////////////////////
/// 加載低通濾波效果器
/////////////////////////////////////////////////////////
virtual bool AttachLowPassFiler(float gain = 1.2f, float gainhf = 0.6f) = 0;
/////////////////////////////////////////////////////////
/// 加載輔助音效
/////////////////////////////////////////////////////////
virtual bool AttachAuxiliaryEffect() = 0;
};
////////////////////////////////////////////////////////////
/// 定義音頻錄入類接口
////////////////////////////////////////////////////////////
class AudioCapture : public RefCount
{
public:
/////////////////////////////////////////////////////////
//! 構(gòu)造,析構(gòu)音頻錄入
/////////////////////////////////////////////////////////
AudioCapture(){}
virtual ~AudioCapture(){}
/////////////////////////////////////////////////////////
//! 捕獲,停止捕獲音頻數(shù)據(jù)
/////////////////////////////////////////////////////////
virtual void CaptureAudio() = 0;
virtual void CaptureStop() = 0;
};
/////////////////////////////////////////////////////////
//! 定義音頻設(shè)備基類
/////////////////////////////////////////////////////////
class AudioDevice : public RefCount
{
public:
/////////////////////////////////////////////////////////
//! 構(gòu)造,析構(gòu)音頻設(shè)備
/////////////////////////////////////////////////////////
AudioDevice(){}
virtual ~AudioDevice(){}
/////////////////////////////////////////////////////////
//! 初始化,卸載音頻設(shè)備
/////////////////////////////////////////////////////////
virtual bool Init(const engine_string &devicename,
uint16 eax_effect_num,
uint16 output_freq) = 0;
virtual bool Deinit() = 0;
/////////////////////////////////////////////////////////
//! 獲取音頻引擎版本號(hào)
/////////////////////////////////////////////////////////
virtual engine_string GetVerson() const = 0;
/////////////////////////////////////////////////////////
//! 獲取音頻引擎作者
/////////////////////////////////////////////////////////
virtual engine_string GetMaker() const = 0;
/////////////////////////////////////////////////////////
//! 查詢音頻設(shè)備是否支持指定格式的音頻文件
/////////////////////////////////////////////////////////
virtual bool IsSupport(const AudioFileType& type)const = 0;
/////////////////////////////////////////////////////////
//! 抓取音頻音源指針(最大可獲取255個(gè)音源)
/////////////////////////////////////////////////////////
virtual RefPtr<AudioSource> GetAudioSource()const = 0;
/////////////////////////////////////////////////////////
//! 獲取聽者指針
/////////////////////////////////////////////////////////
virtual RefPtr<AudioListener> GetAudioListener()const = 0;
/////////////////////////////////////////////////////////
//! 獲取音頻捕獲設(shè)備指針(參數(shù)為音頻名字)(當(dāng)前僅僅支持wav格式)(全局唯一)
/////////////////////////////////////////////////////////
virtual RefPtr<AudioCapture> GetAudioCapture(const engine_string& name = "capture")const = 0;
/////////////////////////////////////////////////////////
//! 獲取音頻設(shè)備列表個(gè)數(shù)
/////////////////////////////////////////////////////////
virtual uint16 GetAudioDeviceNumber() = 0;
virtual engine_string GetDeviceByIndex(uint8 index) = 0;
/////////////////////////////////////////////////////////
//! 獲取默認(rèn)設(shè)備名
/////////////////////////////////////////////////////////
virtual engine_string GetDefaultDeviceName()const = 0;
};
/////////////////////////////////////////////////////////
//! 獲取蓋莫音頻設(shè)備指針
/////////////////////////////////////////////////////////
G_FUNC(RefPtr<AudioDevice>) GetAudioDevice();
}
#endif
//! maker:ccsdu2004
可以看出dll只到處了一個(gè)函數(shù)GetAudioDevice()
本音頻引擎(API)
當(dāng)前提供的下載地址有3個(gè):
1.http://www.libcode.cn/show.php?sid=85
2.http://www.pudn.com/downloads246/sourcecode/windows/multimedia/detail1145892.html
3.http://download.csdn.net/source/2290755
三個(gè)站點(diǎn)只需要注冊(cè)即可下載!