Cpper
C/C++高级工程师 Android高级软件工程师 IT集成工程师 音频工程师 熟悉c,c++,java,c#,py,js,asp等多种语言 程序猿
盖莫音频引擎1.2.8的上次发布版本为1.1.2版本
当前发布版本增加功能如下:
1.对音频录入的支持
2.对xm,mod,it,s3m的支持
3.修改了一些内部实现

总的说来本引擎(API)功能如下:
1.支持ogg,mp3,wav,xm,it,s3m,mod格式
2.基于多线程流式播放音频
3.真3d音效
4.支持低通,次级音效

本音频引擎完全胜任游戏开发,嵌入式设备等商业应用!
本音频引擎使用于商业用途只需要付出少量的维护费即可(远低于自主开发或者购买fmod音频引擎的付出成本)

本版本依然依赖于OpenAL驱动

当前编译版本为win32下的gcc版本
可使用codeblock,devc++

盖莫音频引擎(API)发展方向为:
 /*!==========================================================================
 * 盖莫音频引擎的发展方向:
 *     1.提供pdf等说明,帮助文档
 *     2.支持多编译环境和操作平台
 *     3.支持midi音乐格式
 *     4.支持aiff,acc,ape,flac等音频格式(基于插件)
 *     5.支持音频重采样
 *     6.支持频谱获取
 *     7.解除对OpenAL驱动的依赖
 *     8.提供强健,高效,真实的音频特效
 *     9.对内存音频的支持
 *     10.实时音效
 ****************************************************************************/
下个预定版本1.4.2预计更新:
 /*!==========================================================================
 * 1.4.2版本预期修改说明
 *     增加PDF说明文档
 *     对midi音频文件的支持
 *     修改音频接口
 *     解除使用音频引擎需要安装OpenAL驱动的问题
 *     支持基于插件的音频格式支持(aiff,au,flac,ape,acc...)(保持原有支持音频不变!)
 ****************************************************************************/

当前盖莫音频引擎(API) sdk
配置简表:
c++头文件一个
a/lib文件一个 (可选择使用a或者lib文件)
dll文件-audio.dll一个
OpenAL驱动一个

提供头文件如下:
//! 盖莫游戏3d音频引擎是成都盖莫软件技术有限责任公司推出的一款专门
//! 面向游戏开发的音频库,该库具有使用简介,功能强大的功能
//! 本音频库使用于非商业产品不收取任何费用
//! 警告:本API不可使用于商业用途! 
//! 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驱动     
 ***************************************************************************
*/
/*!==========================================================================
 *  2010.03.20 版本:1.1.0
 *     提供功能:真3d音效,及几个音效 
 *     使用本版本需要安装OpenAL驱动     
 ***************************************************************************
*/
 
/*!==========================================================================
 *  2010.05.05 版本:1.2.8
 *     增加功能:支持音频录入到文件(当前仅为wav格式) 
 *     增加了对:it,s3m,xm,mod4种音乐文件的支持
 *     修改了几个接口
 *     使用本版本需要安装OpenAL驱动     
 ***************************************************************************
*/
 
/*!==========================================================================
 * 1.4.0版本预期修改说明 
 *     增加PDF说明文档
 *     对midi音频文件的支持
 *     修改音频接口
 *     解除使用音频引擎需要安装OpenAL驱动的问题
 *     支持基于插件的音频格式支持(aiff,au,flac,ape,acc)(保持原有支持音频不变!)
 ***************************************************************************
*/
#ifndef AUDIODEVICE_HPP
#define AUDIODEVICE_HPP

////////////////////////////////////////////////////////////
/// 头文件包含
////////////////////////////////////////////////////////////
#include <string>

#ifdef G_ENGINE
  
#error 盖莫游戏引擎内置盖莫音频引擎! 
#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 
{
          
////////////////////////////////////////////////////////////
/// 定义引擎引用计数类
////////////////////////////////////////////////////////////     
class RefCount
{
public:
    
////////////////////////////////////////////////////////////
    
/// 引用计数构造函数
    
////////////////////////////////////////////////////////////
    RefCount(): refcnt(1),auto_del(true){}

    
////////////////////////////////////////////////////////////
    
/// 引用计数析构函数
    
////////////////////////////////////////////////////////////
    virtual ~RefCount(){}
    
    
////////////////////////////////////////////////////////////
    
/// 使用自删除机制
    
////////////////////////////////////////////////////////////    
    void SetAutoDel(bool able = true){auto_del = able;}
    
    
////////////////////////////////////////////////////////////
    
/// 检测是否为自删除机制
    
////////////////////////////////////////////////////////////
    const bool GetAutoDel()const{return auto_del;}
    
    
////////////////////////////////////////////////////////////
    
/// 增加对象引用计数
    
////////////////////////////////////////////////////////////
    void Grab()const{++refcnt;}; 
 
    
////////////////////////////////////////////////////////////
    
/// 减少对象引用计数
    
////////////////////////////////////////////////////////////
    bool Drop() const
    {
        
//!ASSERT(refcnt>0 && "bad refcnt number!");

        
--refcnt;
        
if (refcnt == 0 && auto_del == true)
        {
            delete 
this;
            
return true;
        }

        
return false;
    }

    
////////////////////////////////////////////////////////////
    
/// 获取引用计数
    
////////////////////////////////////////////////////////////
    int GetRefCnt()const{return refcnt;}; 
 
private:
    mutable 
int  refcnt;
    
bool    auto_del; 
};

////////////////////////////////////////////////////////
/// 模板RefPtr用于基于计数的对象管理
/// 所有对象都必须要从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:
    
/////////////////////////////////////////////////////////
    //! 构造,析构音频听者
    /////////////////////////////////////////////////////////
    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(voidconst = 0;     
   
    
/////////////////////////////////////////////////////////
    //! 移动听者
    /////////////////////////////////////////////////////////       
    virtual void Move(const Vector3f& position) = 0;    
};

/////////////////////////////////////////////////////////
//! 定义盖莫音频引擎音源类
/////////////////////////////////////////////////////////
class AudioSource : public RefCount 
{
public:
    
/////////////////////////////////////////////////////////
    //! 构造,析构音频源
    /////////////////////////////////////////////////////////
    AudioSource(){}
    
virtual ~AudioSource(){}
    
    
/////////////////////////////////////////////////////////
    //! 播放指定音频文件,流 
    /////////////////////////////////////////////////////////
    virtual bool Play(const engine_string& audiofile, bool loop) = 0;

    
/////////////////////////////////////////////////////////
    //! 停止播放音频
    /////////////////////////////////////////////////////////
    virtual bool Stop() = 0;

    
/////////////////////////////////////////////////////////
    //! 暂停音频播放
    /////////////////////////////////////////////////////////
    virtual bool Pause() = 0;

    
/////////////////////////////////////////////////////////
    //! 检测音源状态函数 
    /////////////////////////////////////////////////////////
    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;

    
/////////////////////////////////////////////////////////
    
/// 设置,获取音频音节值(pitch值每减少50%则音阶降低1个八度音阶)(0,+inf)
    
/////////////////////////////////////////////////////////
    virtual void  SetPitch(float pitch) = 0;
    
virtual float GetPitch()const = 0;
    
    
/////////////////////////////////////////////////////////
    
/// 同时改变音源位置和速度的便利函数 
    
/////////////////////////////////////////////////////////    
    virtual void  Move(const Vector3f &newpos) = 0
    
    
/////////////////////////////////////////////////////////
    
/// 设置,获取音源锥(内锥,外锥,外增益) 
    
/////////////////////////////////////////////////////////
    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
   
    
/////////////////////////////////////////////////////////
    
/// 设置,获取音源传过空间的能力指数(0-+inf) 
    
/////////////////////////////////////////////////////////    
    virtual void SetStrength(float strength) = 0;            
    
virtual float GetStrength()const = 0
            
    
/////////////////////////////////////////////////////////
    
/// 设置为环境音,检测是否为环境音
    
/////////////////////////////////////////////////////////
    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.2ffloat gainhf = 0.6f= 0;    
    
    
/////////////////////////////////////////////////////////
    
/// 加载辅助音效 
    
/////////////////////////////////////////////////////////    
    virtual bool AttachAuxiliaryEffect() = 0;         
};

////////////////////////////////////////////////////////////
/// 定义音频录入类接口
//////////////////////////////////////////////////////////// 
class AudioCapture : public RefCount 
{
public:
    
/////////////////////////////////////////////////////////
    //! 构造,析构音频录入 
    /////////////////////////////////////////////////////////       
    AudioCapture(){}
    
virtual ~AudioCapture(){}
    
    
/////////////////////////////////////////////////////////
    //! 捕获,停止捕获音频数据 
    /////////////////////////////////////////////////////////     
    virtual void CaptureAudio() = 0;    
    
virtual void CaptureStop() = 0;    
};

/////////////////////////////////////////////////////////
//! 定义音频设备基类
/////////////////////////////////////////////////////////
class AudioDevice : public RefCount 
{
public:
    
/////////////////////////////////////////////////////////
    //! 构造,析构音频设备
    /////////////////////////////////////////////////////////
    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
    
    
/////////////////////////////////////////////////////////
    //! 获取音频捕获设备指针(参数为音频名字)(当前仅仅支持wav格式)(全局唯一) 
    /////////////////////////////////////////////////////////     
    virtual RefPtr<AudioCapture> GetAudioCapture(const engine_string& name = "capture")const = 0;     
    
    
/////////////////////////////////////////////////////////
    //! 获取音频设备列表个数 
    /////////////////////////////////////////////////////////
    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只到处了一个函数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
三个站点只需要注册即可下载!
posted on 2010-04-27 14:39 ccsdu2009 阅读(1356) 评论(0)  编辑 收藏 引用 所属分类: Game引擎

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理