蓋莫音頻引擎1.2.8的上次發(fā)布版本為1.1.2版本
當前發(fā)布版本增加功能如下:
1.對音頻錄入的支持
2.對xm,mod,it,s3m的支持
3.修改了一些內(nèi)部實現(xiàn)
總的說來本引擎(API)功能如下:
1.支持ogg,mp3,wav,xm,it,s3m,mod格式
2.基于多線程流式播放音頻
3.真3d音效
4.支持低通,次級音效
本音頻引擎完全勝任游戲開發(fā),嵌入式設備等商業(yè)應用!
本音頻引擎使用于商業(yè)用途只需要付出少量的維護費即可(遠低于自主開發(fā)或者購買fmod音頻引擎的付出成本)
本版本依然依賴于OpenAL驅(qū)動
當前編譯版本為win32下的gcc版本
可使用codeblock,devc++
蓋莫音頻引擎(API)發(fā)展方向為:
/*!==========================================================================
* 蓋莫音頻引擎的發(fā)展方向:
* 1.提供pdf等說明,幫助文檔
* 2.支持多編譯環(huán)境和操作平臺
* 3.支持midi音樂格式
* 4.支持aiff,acc,ape,flac等音頻格式(基于插件)
* 5.支持音頻重采樣
* 6.支持頻譜獲取
* 7.解除對OpenAL驅(qū)動的依賴
* 8.提供強健,高效,真實的音頻特效
* 9.對內(nèi)存音頻的支持
* 10.實時音效
****************************************************************************/
下個預定版本1.4.2預計更新:
/*!==========================================================================
* 1.4.2版本預期修改說明
* 增加PDF說明文檔
* 對midi音頻文件的支持
* 修改音頻接口
* 解除使用音頻引擎需要安裝OpenAL驅(qū)動的問題
* 支持基于插件的音頻格式支持(aiff,au,flac,ape,acc...)(保持原有支持音頻不變!)
****************************************************************************/
當前蓋莫音頻引擎(API) sdk
配置簡表:
c++頭文件一個
a/lib文件一個 (可選擇使用a或者lib文件)
dll文件-audio.dll一個
OpenAL驅(qū)動一個
提供頭文件如下:
//! 蓋莫游戲3d音頻引擎是成都蓋莫軟件技術(shù)有限責任公司推出的一款專門
//! 面向游戲開發(fā)的音頻庫,該庫具有使用簡介,功能強大的功能
//! 本音頻庫使用于非商業(yè)產(chǎn)品不收取任何費用
//! 警告:本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格式
* 使用多線程流式播放
* 簡單易用的程序接口
* 使用本版本需要安裝OpenAL驅(qū)動
****************************************************************************/
/*!==========================================================================
* 2010.03.20 版本:1.1.0
* 提供功能:真3d音效,及幾個音效
* 使用本版本需要安裝OpenAL驅(qū)動
****************************************************************************/
/*!==========================================================================
* 2010.05.05 版本:1.2.8
* 增加功能:支持音頻錄入到文件(當前僅為wav格式)
* 增加了對:it,s3m,xm,mod4種音樂文件的支持
* 修改了幾個接口
* 使用本版本需要安裝OpenAL驅(qū)動
****************************************************************************/
/*!==========================================================================
* 1.4.0版本預期修改說明
* 增加PDF說明文檔
* 對midi音頻文件的支持
* 修改音頻接口
* 解除使用音頻引擎需要安裝OpenAL驅(qū)動的問題
* 支持基于插件的音頻格式支持(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 請使用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
{
////////////////////////////////////////////////////////////
/// 定義引擎引用計數(shù)類
////////////////////////////////////////////////////////////
class RefCount
{
public:
////////////////////////////////////////////////////////////
/// 引用計數(shù)構(gòu)造函數(shù)
////////////////////////////////////////////////////////////
RefCount(): refcnt(1),auto_del(true){}
////////////////////////////////////////////////////////////
/// 引用計數(shù)析構(gòu)函數(shù)
////////////////////////////////////////////////////////////
virtual ~RefCount(){}
////////////////////////////////////////////////////////////
/// 使用自刪除機制
////////////////////////////////////////////////////////////
void SetAutoDel(bool able = true){auto_del = able;}
////////////////////////////////////////////////////////////
/// 檢測是否為自刪除機制
////////////////////////////////////////////////////////////
const bool GetAutoDel()const{return auto_del;}
////////////////////////////////////////////////////////////
/// 增加對象引用計數(shù)
////////////////////////////////////////////////////////////
void Grab()const{++refcnt;};
////////////////////////////////////////////////////////////
/// 減少對象引用計數(shù)
////////////////////////////////////////////////////////////
bool Drop() const
{
//!ASSERT(refcnt>0 && "bad refcnt number!");
--refcnt;
if (refcnt == 0 && auto_del == true)
{
delete this;
return true;
}
return false;
}
////////////////////////////////////////////////////////////
/// 獲取引用計數(shù)
////////////////////////////////////////////////////////////
int GetRefCnt()const{return refcnt;};
private:
mutable int refcnt;
bool auto_del;
};
////////////////////////////////////////////////////////
/// 模板RefPtr用于基于計數(shù)的對象管理
/// 所有對象都必須要從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();
}
////////////////////////////////////////////////////////
/// 檢測指針是否為空
////////////////////////////////////////////////////////
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
};
//! 定義默認空間音速
const float AUDIO_SPACE_VELOCITY = 343.0f;
//! 定義默認多普勒因子
const float AUDIO_DOPPLER_FACTOR = 1.0f;
////////////////////////////////////////////////////////////
/// 定義音頻聽者基類
////////////////////////////////////////////////////////////
class AudioListener : public RefCount
{
public:
/////////////////////////////////////////////////////////
//! 構(gòu)造,析構(gòu)音頻聽者
/////////////////////////////////////////////////////////
AudioListener(){}
virtual ~AudioListener(){}
/////////////////////////////////////////////////////////
//! 設置,獲取音頻聽者當前新的位置
/////////////////////////////////////////////////////////
virtual void SetPosition(const Vector3f &pos) = 0;
virtual Vector3f GetPosition()const = 0;
/////////////////////////////////////////////////////////
//! 設置音頻聽者的方向
/////////////////////////////////////////////////////////
virtual void SetDirection(const Vector3f& dir) = 0;
virtual Vector3f GetDirection()const = 0;
/////////////////////////////////////////////////////////
//! 設置音頻聽者的向上位置(一般而言采取類似OpenGL的方向即0,1,0)
/////////////////////////////////////////////////////////
virtual void SetUpVector(const Vector3f &updir) = 0;
virtual Vector3f GetUpVector()const = 0;
/////////////////////////////////////////////////////////
//! 設置音頻聽者的速度
/////////////////////////////////////////////////////////
virtual void SetVelocity(const Vector3f &vel) = 0;
virtual Vector3f GetVelocity()const = 0;
/////////////////////////////////////////////////////////
//! 設置,獲取全局音量(0.0f,1.0f)
/////////////////////////////////////////////////////////
virtual void SetGlobalVolume(float volume) = 0;
virtual float GetGlobalVolume()const = 0;
/////////////////////////////////////////////////////////
//! 設置,獲取音效作用單位
/////////////////////////////////////////////////////////
virtual void SetMetersPerUnit(float meters) = 0;
virtual float GetMetersPerUnit(void) const = 0;
/////////////////////////////////////////////////////////
//! 移動聽者
/////////////////////////////////////////////////////////
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;
/////////////////////////////////////////////////////////
//! 檢測音源狀態(tài)函數(shù)
/////////////////////////////////////////////////////////
virtual bool IsPlay()const = 0;
virtual bool IsPause()const = 0;
virtual bool IsStop()const = 0;
/////////////////////////////////////////////////////////
//! 設置,獲取音頻增益[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;
/////////////////////////////////////////////////////////
/// 獲取,設置音源位置(x,y,z)
/////////////////////////////////////////////////////////
virtual Vector3f GetSourcePosition()const = 0;
virtual void SetSourcePosition(const Vector3f& position) = 0;
/////////////////////////////////////////////////////////
/// 獲取,設置音源方向(x,y,z)
/////////////////////////////////////////////////////////
virtual Vector3f GetSourceDirection()const = 0 ;
virtual void SetSourceDirection(const Vector3f& direction) = 0;
/////////////////////////////////////////////////////////
/// 獲取,設置音源速度
/////////////////////////////////////////////////////////
virtual Vector3f GetSourceVelocity()const = 0;
virtual void SetSourceVelocity(const Vector3f& vel) = 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;
/////////////////////////////////////////////////////////
/// 設置,獲取音頻扇出值[0.0,1.0]
/////////////////////////////////////////////////////////
virtual void SetRolloffFactor(float factor) = 0;
virtual float GetRolloffFactor()const=0;
/////////////////////////////////////////////////////////
/// 設置,獲取音頻音節(jié)值(pitch值每減少50%則音階降低1個八度音階)(0,+inf)
/////////////////////////////////////////////////////////
virtual void SetPitch(float pitch) = 0;
virtual float GetPitch()const = 0;
/////////////////////////////////////////////////////////
/// 同時改變音源位置和速度的便利函數(shù)
/////////////////////////////////////////////////////////
virtual void Move(const Vector3f &newpos) = 0;
/////////////////////////////////////////////////////////
/// 設置,獲取音源錐(內(nèi)錐,外錐,外增益)
/////////////////////////////////////////////////////////
virtual void SetAudioCone(float innerangle, float outerangle, float outergain) = 0;
virtual void GetAudioCone(float &innerangle, float &outerangle, float &outergain) = 0;
/////////////////////////////////////////////////////////
/// 設置,獲取多普勒速度強度
/////////////////////////////////////////////////////////
virtual void SetDopplerVelocity(const Vector3f& dvelocity) = 0;
virtual Vector3f GetDopplerVelocity()const = 0;
virtual void SetDopplerStrength(float strength) = 0;
virtual float GetDopplerStrength()const = 0;
/////////////////////////////////////////////////////////
/// 設置,獲取音源傳過空間的能力指數(shù)(0-+inf)
/////////////////////////////////////////////////////////
virtual void SetStrength(float strength) = 0;
virtual float GetStrength()const = 0;
/////////////////////////////////////////////////////////
/// 設置為環(huán)境音,檢測是否為環(huán)境音
/////////////////////////////////////////////////////////
virtual void SetAmbient(bool ambient) = 0;
virtual bool IsAmbient() = 0;
/////////////////////////////////////////////////////////
/// 設置音源位置是否相對于聽者,檢測是否相對于聽者
/////////////////////////////////////////////////////////
virtual void SetRelative(bool relative) = 0;
virtual bool IsRelative() = 0;
/////////////////////////////////////////////////////////
/// 設置Reverb值([0,1.0])
/////////////////////////////////////////////////////////
virtual bool SetReverbScale(float scale) = 0;
/////////////////////////////////////////////////////////
/// 設置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;
};
/////////////////////////////////////////////////////////
//! 定義音頻設備基類
/////////////////////////////////////////////////////////
class AudioDevice : public RefCount
{
public:
/////////////////////////////////////////////////////////
//! 構(gòu)造,析構(gòu)音頻設備
/////////////////////////////////////////////////////////
AudioDevice(){}
virtual ~AudioDevice(){}
/////////////////////////////////////////////////////////
//! 初始化,卸載音頻設備
/////////////////////////////////////////////////////////
virtual bool Init(const engine_string &devicename,
uint16 eax_effect_num,
uint16 output_freq) = 0;
virtual bool Deinit() = 0;
/////////////////////////////////////////////////////////
//! 獲取音頻引擎版本號
/////////////////////////////////////////////////////////
virtual engine_string GetVerson() const = 0;
/////////////////////////////////////////////////////////
//! 獲取音頻引擎作者
/////////////////////////////////////////////////////////
virtual engine_string GetMaker() const = 0;
/////////////////////////////////////////////////////////
//! 查詢音頻設備是否支持指定格式的音頻文件
/////////////////////////////////////////////////////////
virtual bool IsSupport(const AudioFileType& type)const = 0;
/////////////////////////////////////////////////////////
//! 抓取音頻音源指針(最大可獲取255個音源)
/////////////////////////////////////////////////////////
virtual RefPtr<AudioSource> GetAudioSource()const = 0;
/////////////////////////////////////////////////////////
//! 獲取聽者指針
/////////////////////////////////////////////////////////
virtual RefPtr<AudioListener> GetAudioListener()const = 0;
/////////////////////////////////////////////////////////
//! 獲取音頻捕獲設備指針(參數(shù)為音頻名字)(當前僅僅支持wav格式)(全局唯一)
/////////////////////////////////////////////////////////
virtual RefPtr<AudioCapture> GetAudioCapture(const engine_string& name = "capture")const = 0;
/////////////////////////////////////////////////////////
//! 獲取音頻設備列表個數(shù)
/////////////////////////////////////////////////////////
virtual uint16 GetAudioDeviceNumber() = 0;
virtual engine_string GetDeviceByIndex(uint8 index) = 0;
/////////////////////////////////////////////////////////
//! 獲取默認設備名
/////////////////////////////////////////////////////////
virtual engine_string GetDefaultDeviceName()const = 0;
};
/////////////////////////////////////////////////////////
//! 獲取蓋莫音頻設備指針
/////////////////////////////////////////////////////////
G_FUNC(RefPtr<AudioDevice>) GetAudioDevice();
}
#endif
//! maker:ccsdu2004
可以看出dll只到處了一個函數(shù)GetAudioDevice()
本音頻引擎(API)
當前提供的下載地址有3個:
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
三個站點只需要注冊即可下載!