Patched cAudio using nalins patch for unicode support.

This commit is contained in:
Raynaldo Rivera 2011-05-19 04:36:14 +00:00
parent 68df33ca10
commit ec9c8485a5
68 changed files with 6135 additions and 6032 deletions

View File

@ -1,5 +1,5 @@
//**************************************************************** //****************************************************************
//cAudio 2.1.0 Tutorial 1 //cAudio 2.2.0 Tutorial 1
//Basic 2d Audio //Basic 2d Audio
//**************************************************************** //****************************************************************
@ -14,7 +14,7 @@ using namespace std;
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
//Some fancy text //Some fancy text
cout << "cAudio 2.1.0 Tutorial 1: Basic 2D Audio. \n \n"; cout << "cAudio 2.2.0 Tutorial 1: Basic 2D Audio. \n \n";
//Create an uninitialized Audio Manager //Create an uninitialized Audio Manager
cAudio::IAudioManager* manager = cAudio::createAudioManager(false); cAudio::IAudioManager* manager = cAudio::createAudioManager(false);

View File

@ -1,5 +1,5 @@
//**************************************************************** //****************************************************************
//cAudio 2.1.0 Tutorial 2 //cAudio 2.2.0 Tutorial 2
//Basic 3d Audio. Moving Audio source. Must be mono sound source //Basic 3d Audio. Moving Audio source. Must be mono sound source
//**************************************************************** //****************************************************************
@ -16,7 +16,7 @@ using namespace std;
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
//Some fancy text //Some fancy text
cout << "cAudio 2.1.0 Tutorial 2: Basic 3D Audio. \n \n"; cout << "cAudio 2.2.0 Tutorial 2: Basic 3D Audio. \n \n";
//Hold audio source x position //Hold audio source x position
float rot = 0; float rot = 0;

View File

@ -1,5 +1,5 @@
//**************************************************************** //****************************************************************
//cAudio 2.1.0 Tutorial 3 //cAudio 2.2.0 Tutorial 3
//Basic Memory Playback *Virtual file systems* //Basic Memory Playback *Virtual file systems*
//bling.h created with bin2h http://deadnode.org/sw/bin2h/ //bling.h created with bin2h http://deadnode.org/sw/bin2h/
//**************************************************************** //****************************************************************

View File

@ -1,5 +1,5 @@
//**************************************************************** //****************************************************************
//cAudio 2.1.0 Tutorial 4 //cAudio 2.2.0 Tutorial 4
//Audio Capture and playback //Audio Capture and playback
//**************************************************************** //****************************************************************

View File

@ -1,5 +1,5 @@
//**************************************************************** //****************************************************************
//cAudio 2.1.0 Tutorial 5 //cAudio 2.2.0 Tutorial 5
//Audio effects //Audio effects
//**************************************************************** //****************************************************************

View File

@ -1,5 +1,5 @@
//**************************************************************** //****************************************************************
//cAudio 2.0.0 Tutorial 6 //cAudio 2.2.0 Tutorial 6
//Custom event handler //Custom event handler
//**************************************************************** //****************************************************************

View File

@ -1,5 +1,5 @@
//**************************************************************** //****************************************************************
//cAudio 2.1.0 Tutorial 6 //cAudio 2.2.0 Tutorial 6
//Custom Event Handler //Custom Event Handler
//**************************************************************** //****************************************************************

View File

@ -1,5 +1,5 @@
//**************************************************************** //****************************************************************
//cAudio 2.0.0 Tutorial 7 //cAudio 2.2.0 Tutorial 7
//Custom log receiver //Custom log receiver
//**************************************************************** //****************************************************************

View File

@ -1,5 +1,5 @@
//**************************************************************** //****************************************************************
//cAudio 2.1.0 Tutorial 7 //cAudio 2.2.0 Tutorial 7
//Custom log receiver //Custom log receiver
//**************************************************************** //****************************************************************

View File

@ -1,102 +1,98 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef CAUDIOCAPTURE_H #ifndef CAUDIOCAPTURE_H
#define CAUDIOCAPTURE_H #define CAUDIOCAPTURE_H
#include "../include/IAudioCapture.h" #include "../include/IAudioCapture.h"
#if defined(CAUDIO_PLATFORM_IPHONE) || defined(CAUDIO_PLATFORM_MAC) #include <AL/al.h>
#include <al.h> #include <AL/alc.h>
#include <alc.h> #include "../Headers/cMutex.h"
#else #include "../Headers/cMemoryOverride.h"
#include <AL/al.h> #include "../include/cSTLAllocator.h"
#include <AL/alc.h> #include "../include/cAudioString.h"
#endif
#include "../Headers/cMutex.h" namespace cAudio
#include "../Headers/cMemoryOverride.h" {
#include "../Headers/cSTLAllocator.h" class cAudioCapture : public IAudioCapture, public cMemoryOverride
{
namespace cAudio public:
{
class cAudioCapture : public IAudioCapture, public cMemoryOverride enum Events{
{ ON_INIT,
public: ON_UPDATE,
ON_RELEASE,
enum Events{ ON_BEGINCAPTURE,
ON_INIT, ON_ENDCAPTURE,
ON_UPDATE, ON_USERREQUESTEDBUFFER,
ON_RELEASE, };
ON_BEGINCAPTURE,
ON_ENDCAPTURE, cAudioCapture();
ON_USERREQUESTEDBUFFER, ~cAudioCapture();
};
//! Checks to see if capturing audio is supported by OpenAL
cAudioCapture(); bool checkCaptureExtension();
~cAudioCapture();
virtual bool initialize(const char* deviceName = 0x0, unsigned int frequency = 22050, AudioFormats format = EAF_16BIT_MONO, unsigned int internalBufferSize = 8192);
//! Checks to see if capturing audio is supported by OpenAL virtual bool isSupported() { return Supported; }
bool checkCaptureExtension(); virtual bool isReady() { return Ready; }
virtual void updateCaptureBuffer(bool force = false);
virtual bool initialize(const char* deviceName = 0x0, unsigned int frequency = 22050, AudioFormats format = EAF_16BIT_MONO, unsigned int internalBufferSize = 8192); virtual void shutdown();
virtual bool isSupported() { return Supported; }
virtual bool isReady() { return Ready; } virtual const char* getAvailableDeviceName(unsigned int index);
virtual void updateCaptureBuffer(bool force = false); virtual unsigned int getAvailableDeviceCount();
virtual void shutdown(); virtual const char* getDefaultDeviceName();
virtual const char* getAvailableDeviceName(unsigned int index); virtual const char* getDeviceName() { return toUTF8(DeviceName); }
virtual unsigned int getAvailableDeviceCount(); virtual unsigned int getFrequency() { return Frequency; }
virtual const char* getDefaultDeviceName(); virtual AudioFormats getFormat() { return Format; }
virtual unsigned int getInternalBufferSize() { return InternalBufferSize; }
virtual const char* getDeviceName() { return DeviceName.c_str(); } virtual unsigned int getSampleSize() { return SampleSize; }
virtual unsigned int getFrequency() { return Frequency; }
virtual AudioFormats getFormat() { return Format; } virtual bool setDevice(const char* deviceName);
virtual unsigned int getInternalBufferSize() { return InternalBufferSize; } virtual bool setFrequency(unsigned int frequency);
virtual unsigned int getSampleSize() { return SampleSize; } virtual bool setFormat(AudioFormats format);
virtual bool setInternalBufferSize(unsigned int internalBufferSize);
virtual bool setDevice(const char* deviceName);
virtual bool setFrequency(unsigned int frequency); virtual bool beginCapture();
virtual bool setFormat(AudioFormats format); virtual void stopCapture();
virtual bool setInternalBufferSize(unsigned int internalBufferSize); virtual unsigned int getCapturedAudio(void* outputBuffer, unsigned int outputBufferSize);
virtual bool beginCapture(); virtual unsigned int getCurrentCapturedAudioSize();
virtual void stopCapture(); void getAvailableDevices();
virtual unsigned int getCapturedAudio(void* outputBuffer, unsigned int outputBufferSize);
virtual void registerEventHandler(ICaptureEventHandler* handler);
virtual unsigned int getCurrentCapturedAudioSize(); virtual void unRegisterEventHandler(ICaptureEventHandler* handler);
void getAvailableDevices(); virtual void unRegisterAllEventHandlers();
virtual void registerEventHandler(ICaptureEventHandler* handler); protected:
virtual void unRegisterEventHandler(ICaptureEventHandler* handler); cAudioMutex Mutex;
virtual void unRegisterAllEventHandlers();
bool initOpenALDevice();
protected: void shutdownOpenALDevice();
cAudioMutex Mutex;
unsigned int Frequency;
bool initOpenALDevice(); AudioFormats Format;
void shutdownOpenALDevice(); unsigned int InternalBufferSize;
int SampleSize;
unsigned int Frequency;
AudioFormats Format; cAudioVector<char>::Type CaptureBuffer;
unsigned int InternalBufferSize; cAudioVector<cAudioString>::Type AvailableDevices;
int SampleSize; cAudioString DefaultDevice;
cAudioList<ICaptureEventHandler*>::Type eventHandlerList;
cAudioVector<char>::Type CaptureBuffer;
cAudioVector<cAudioString>::Type AvailableDevices; bool Supported;
cAudioString DefaultDevice; bool Ready;
cAudioList<ICaptureEventHandler*>::Type eventHandlerList; bool Capturing;
bool Supported; cAudioString DeviceName;
bool Ready; ALCdevice* CaptureDevice;
bool Capturing;
bool checkError();
cAudioString DeviceName; ALenum convertAudioFormatEnum(AudioFormats format);
ALCdevice* CaptureDevice; void signalEvent(Events sevent);
};
bool checkError(); };
ALenum convertAudioFormatEnum(AudioFormats format);
void signalEvent(Events sevent);
};
};
#endif //! CAUDIOCAPTURE_H #endif //! CAUDIOCAPTURE_H

View File

@ -1,90 +1,90 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef CAUDIOEFFECTS_H #ifndef CAUDIOEFFECTS_H
#define CAUDIOEFFECTS_H #define CAUDIOEFFECTS_H
#include "../include/IAudioEffects.h" #include "../include/IAudioEffects.h"
#include "../Headers/cMutex.h" #include "../include/cSTLAllocator.h"
#include "../Headers/cEFXFunctions.h" #include "../Headers/cMutex.h"
#include "../Headers/cSTLAllocator.h" #include "../Headers/cEFXFunctions.h"
#ifdef CAUDIO_EFX_ENABLED #ifdef CAUDIO_EFX_ENABLED
namespace cAudio namespace cAudio
{ {
class cAudioEffects : public IAudioEffects class cAudioEffects : public IAudioEffects
{ {
public: public:
cAudioEffects(); cAudioEffects();
virtual ~cAudioEffects(); virtual ~cAudioEffects();
virtual IEffect* createEffect(); virtual IEffect* createEffect();
virtual IFilter* createFilter(); virtual IFilter* createFilter();
virtual unsigned int getMaxEffectsSupported() const; virtual unsigned int getMaxEffectsSupported() const;
virtual bool isEffectSupported(const EffectTypes& type) const; virtual bool isEffectSupported(const EffectTypes& type) const;
virtual bool isFilterSupported(const FilterTypes& type) const; virtual bool isFilterSupported(const FilterTypes& type) const;
virtual bool addEAXReverbEffectPreset(const char* name, const sEAXReverbParameters& setting); virtual bool addEAXReverbEffectPreset(const char* name, const sEAXReverbParameters& setting);
virtual bool addReverbEffectPreset(const char* name, const sReverbParameters& setting); virtual bool addReverbEffectPreset(const char* name, const sReverbParameters& setting);
virtual bool addChorusEffectPreset(const char* name, const sChorusParameters& setting); virtual bool addChorusEffectPreset(const char* name, const sChorusParameters& setting);
virtual bool addDistortionEffectPreset(const char* name, const sDistortionParameters& setting); virtual bool addDistortionEffectPreset(const char* name, const sDistortionParameters& setting);
virtual bool addEchoEffectPreset(const char* name, const sEchoParameters& setting); virtual bool addEchoEffectPreset(const char* name, const sEchoParameters& setting);
virtual bool addFlangerEffectPreset(const char* name, const sFlangerParameters& setting); virtual bool addFlangerEffectPreset(const char* name, const sFlangerParameters& setting);
virtual bool addFrequencyShiftEffectPreset(const char* name, const sFrequencyShiftParameters& setting); virtual bool addFrequencyShiftEffectPreset(const char* name, const sFrequencyShiftParameters& setting);
virtual bool addVocalMorpherEffectPreset(const char* name, const sVocalMorpherParameters& setting); virtual bool addVocalMorpherEffectPreset(const char* name, const sVocalMorpherParameters& setting);
virtual bool addPitchShifterEffectPreset(const char* name, const sPitchShifterParameters& setting); virtual bool addPitchShifterEffectPreset(const char* name, const sPitchShifterParameters& setting);
virtual bool addRingModulatorEffectPreset(const char* name, const sRingModulatorParameters& setting); virtual bool addRingModulatorEffectPreset(const char* name, const sRingModulatorParameters& setting);
virtual bool addAutowahEffectPreset(const char* name, const sAutowahParameters& setting); virtual bool addAutowahEffectPreset(const char* name, const sAutowahParameters& setting);
virtual bool addCompressorEffectPreset(const char* name, const sCompressorParameters& setting); virtual bool addCompressorEffectPreset(const char* name, const sCompressorParameters& setting);
virtual bool addEqualizerEffectPreset(const char* name, const sEqualizerParameters& setting); virtual bool addEqualizerEffectPreset(const char* name, const sEqualizerParameters& setting);
virtual sEAXReverbParameters getEAXReverbEffectPreset(const char* name); virtual sEAXReverbParameters getEAXReverbEffectPreset(const char* name);
virtual sReverbParameters getReverbEffectPreset(const char* name); virtual sReverbParameters getReverbEffectPreset(const char* name);
virtual sChorusParameters getChorusEffectPreset(const char* name); virtual sChorusParameters getChorusEffectPreset(const char* name);
virtual sDistortionParameters getDistortionEffectPreset(const char* name); virtual sDistortionParameters getDistortionEffectPreset(const char* name);
virtual sEchoParameters getEchoEffectPreset(const char* name); virtual sEchoParameters getEchoEffectPreset(const char* name);
virtual sFlangerParameters getFlangerEffectPreset(const char* name); virtual sFlangerParameters getFlangerEffectPreset(const char* name);
virtual sFrequencyShiftParameters getFrequencyShiftEffectPreset(const char* name); virtual sFrequencyShiftParameters getFrequencyShiftEffectPreset(const char* name);
virtual sVocalMorpherParameters getVocalMorpherEffectPreset(const char* name); virtual sVocalMorpherParameters getVocalMorpherEffectPreset(const char* name);
virtual sPitchShifterParameters getPitchShifterEffectPreset(const char* name); virtual sPitchShifterParameters getPitchShifterEffectPreset(const char* name);
virtual sRingModulatorParameters getRingModulatorEffectPreset(const char* name); virtual sRingModulatorParameters getRingModulatorEffectPreset(const char* name);
virtual sAutowahParameters getAutowahEffectPreset(const char* name); virtual sAutowahParameters getAutowahEffectPreset(const char* name);
virtual sCompressorParameters getCompressorEffectPreset(const char* name); virtual sCompressorParameters getCompressorEffectPreset(const char* name);
virtual sEqualizerParameters getEqualizerEffectPreset(const char* name); virtual sEqualizerParameters getEqualizerEffectPreset(const char* name);
virtual void removeEffectPreset(const EffectTypes& type, const char* name); virtual void removeEffectPreset(const EffectTypes& type, const char* name);
virtual bool isEffectPresetRegistered(const EffectTypes& type, const char* name); virtual bool isEffectPresetRegistered(const EffectTypes& type, const char* name);
virtual void removeAllEffectPresets(const EffectTypes& type); virtual void removeAllEffectPresets(const EffectTypes& type);
cEFXFunctions* getEFXInterface(); cEFXFunctions* getEFXInterface();
void checkEFXSupportDetails(); void checkEFXSupportDetails();
private: private:
cAudioMutex Mutex; cAudioMutex Mutex;
cEFXFunctions EFXInterface; cEFXFunctions EFXInterface;
unsigned int MaxEffectsSupported; unsigned int MaxEffectsSupported;
bool SupportedEffects[EET_COUNT]; bool SupportedEffects[EET_COUNT];
bool SupportedFilters[EFT_COUNT]; bool SupportedFilters[EFT_COUNT];
cAudioMap<cAudioString, sEAXReverbParameters>::Type EAXReverbPresets; cAudioMap<cAudioString, sEAXReverbParameters>::Type EAXReverbPresets;
cAudioMap<cAudioString, sReverbParameters>::Type ReverbPresets; cAudioMap<cAudioString, sReverbParameters>::Type ReverbPresets;
cAudioMap<cAudioString, sChorusParameters>::Type ChorusPresets; cAudioMap<cAudioString, sChorusParameters>::Type ChorusPresets;
cAudioMap<cAudioString, sDistortionParameters>::Type DistortionPresets; cAudioMap<cAudioString, sDistortionParameters>::Type DistortionPresets;
cAudioMap<cAudioString, sEchoParameters>::Type EchoPresets; cAudioMap<cAudioString, sEchoParameters>::Type EchoPresets;
cAudioMap<cAudioString, sFlangerParameters>::Type FlangerPresets; cAudioMap<cAudioString, sFlangerParameters>::Type FlangerPresets;
cAudioMap<cAudioString, sFrequencyShiftParameters>::Type FrequencyShiftPresets; cAudioMap<cAudioString, sFrequencyShiftParameters>::Type FrequencyShiftPresets;
cAudioMap<cAudioString, sVocalMorpherParameters>::Type VocalMorpherPresets; cAudioMap<cAudioString, sVocalMorpherParameters>::Type VocalMorpherPresets;
cAudioMap<cAudioString, sPitchShifterParameters>::Type PitchShifterPresets; cAudioMap<cAudioString, sPitchShifterParameters>::Type PitchShifterPresets;
cAudioMap<cAudioString, sRingModulatorParameters>::Type RingModulatorPresets; cAudioMap<cAudioString, sRingModulatorParameters>::Type RingModulatorPresets;
cAudioMap<cAudioString, sAutowahParameters>::Type AutowahPresets; cAudioMap<cAudioString, sAutowahParameters>::Type AutowahPresets;
cAudioMap<cAudioString, sCompressorParameters>::Type CompressorPresets; cAudioMap<cAudioString, sCompressorParameters>::Type CompressorPresets;
cAudioMap<cAudioString, sEqualizerParameters>::Type EqualizerPresets; cAudioMap<cAudioString, sEqualizerParameters>::Type EqualizerPresets;
}; };
}; };
#endif #endif
#endif //! CAUDIOEFFECTS_H #endif //! CAUDIOEFFECTS_H

View File

@ -12,16 +12,11 @@
#include "../Headers/cMutex.h" #include "../Headers/cMutex.h"
#include "../Headers/cAudioEffects.h" #include "../Headers/cAudioEffects.h"
#include "../Headers/cMemoryOverride.h" #include "../Headers/cMemoryOverride.h"
#include "../Headers/cSTLAllocator.h" #include "../include/cSTLAllocator.h"
#include "../include/cAudioString.h"
#include "cAudioPlatform.h"
#if defined(CAUDIO_PLATFORM_IPHONE) || defined(CAUDIO_PLATFORM_MAC)
#include <al.h>
#include <alc.h>
#else
#include <AL/al.h> #include <AL/al.h>
#include <AL/alc.h> #include <AL/alc.h>
#endif
#ifdef CAUDIO_PLATFORM_LINUX #ifdef CAUDIO_PLATFORM_LINUX
#include <AL/alext.h> #include <AL/alext.h>
@ -31,9 +26,9 @@ namespace cAudio
{ {
class IAudioSource; class IAudioSource;
class cAudioManager : public IAudioManager, public cMemoryOverride class cAudioManager : public IAudioManager, public cMemoryOverride
{ {
public: public:
enum Events{ enum Events{
ON_INIT, ON_INIT,
ON_UPDATE, ON_UPDATE,
@ -60,7 +55,7 @@ namespace cAudio
virtual IAudioSource* create(const char* name, const char* filename, bool stream = false); virtual IAudioSource* create(const char* name, const char* filename, bool stream = false);
virtual IAudioSource* createFromMemory(const char* name, const char* data, size_t length, const char* extension); virtual IAudioSource* createFromMemory(const char* name, const char* data, size_t length, const char* extension);
virtual IAudioSource* createFromRaw(const char* name, const char* data, size_t length, unsigned int frequency, AudioFormats format); virtual IAudioSource* createFromRaw(const char* name, const char* data, size_t length, unsigned int frequency, AudioFormats format);
virtual bool registerAudioDecoder(IAudioDecoderFactory* factory, const char* extension); virtual bool registerAudioDecoder(IAudioDecoderFactory* factory, const char* extension);
virtual void unRegisterAudioDecoder(const char* extension); virtual void unRegisterAudioDecoder(const char* extension);
virtual bool isAudioDecoderRegistered(const char* extension); virtual bool isAudioDecoderRegistered(const char* extension);
@ -131,7 +126,7 @@ namespace cAudio
//! List of all attached event handlers //! List of all attached event handlers
cAudioList<IManagerEventHandler*>::Type eventHandlerList; cAudioList<IManagerEventHandler*>::Type eventHandlerList;
}; };
} }
#endif //! CAUDIOMANAGER_H_INCLUDED #endif //! CAUDIOMANAGER_H_INCLUDED

View File

@ -1,190 +1,184 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef CAUDIOSOURCE_H_INCLUDED #ifndef CAUDIOSOURCE_H_INCLUDED
#define CAUDIOSOURCE_H_INCLUDED #define CAUDIOSOURCE_H_INCLUDED
#include <list> #include <list>
#include <string> #include <string>
#include <vector> #include <vector>
#include "cAudioPlatform.h" #include <AL/al.h>
#if defined(CAUDIO_PLATFORM_IPHONE) || defined(CAUDIO_PLATFORM_MAC) #include <AL/alc.h>
#include <al.h>
#include <alc.h> #include "../include/IAudioSource.h"
#else #include "../include/cVector3.h"
#include <AL/al.h> #include "../Headers/cMutex.h"
#include <AL/alc.h> #include "../include/ILogger.h"
#endif #include "../Headers/cEFXFunctions.h"
#include "../Headers/cMemoryOverride.h"
#include "../include/IAudioSource.h" #include "../include/cSTLAllocator.h"
#include "../include/cVector3.h"
#include "../Headers/cMutex.h" namespace cAudio
#include "../include/ILogger.h" {
#include "../Headers/cEFXFunctions.h"
#include "../Headers/cMemoryOverride.h" class cAudioSource : public IAudioSource, public cMemoryOverride
#include "../Headers/cSTLAllocator.h" {
public:
namespace cAudio
{ enum Events{
ON_UPDATE,
class cAudioSource : public IAudioSource, public cMemoryOverride ON_RELEASE,
{ ON_PLAY,
public: ON_PAUSE,
ON_STOP,
enum Events{ };
ON_UPDATE,
ON_RELEASE, #ifdef CAUDIO_EFX_ENABLED
ON_PLAY, cAudioSource(IAudioDecoder* decoder, ALCcontext* context, cEFXFunctions* oALFunctions);
ON_PAUSE, #else
ON_STOP, cAudioSource(IAudioDecoder* decoder, ALCcontext* context);
}; #endif
~cAudioSource();
#ifdef CAUDIO_EFX_ENABLED
cAudioSource(IAudioDecoder* decoder, ALCcontext* context, cEFXFunctions* oALFunctions); virtual bool play();
#else virtual bool play2d(const bool& toLoop = false);
cAudioSource(IAudioDecoder* decoder, ALCcontext* context); virtual bool play3d(const cVector3& position, const float& soundstr = 1.0 , const bool& toLoop = false);
#endif
~cAudioSource(); virtual void pause();
virtual void stop();
virtual bool play(); virtual void loop(const bool& toLoop);
virtual bool play2d(const bool& toLoop = false); virtual bool seek(const float& seconds, bool relative = false);
virtual bool play3d(const cVector3& position, const float& soundstr = 1.0 , const bool& toLoop = false);
virtual float getTotalAudioTime();
virtual void pause(); virtual int getTotalAudioSize();
virtual void stop(); virtual int getCompressedAudioSize();
virtual void loop(const bool& toLoop);
virtual bool seek(const float& seconds, bool relative = false); virtual float getCurrentAudioTime();
virtual int getCurrentAudioPosition();
virtual float getTotalAudioTime(); virtual int getCurrentCompressedAudioPosition();
virtual int getTotalAudioSize();
virtual int getCompressedAudioSize(); virtual bool update();
virtual void release();
virtual float getCurrentAudioTime();
virtual int getCurrentAudioPosition(); virtual const bool isValid() const;
virtual int getCurrentCompressedAudioPosition(); virtual const bool isPlaying() const;
virtual const bool isPaused() const;
virtual bool update(); virtual const bool isStopped() const;
virtual void release(); virtual const bool isLooping() const;
virtual const bool isValid() const; virtual void setPosition(const cVector3& position);
virtual const bool isPlaying() const; virtual void setVelocity(const cVector3& velocity);
virtual const bool isPaused() const; virtual void setDirection(const cVector3& direction);
virtual const bool isStopped() const;
virtual const bool isLooping() const; virtual void setRolloffFactor(const float& rolloff);
virtual void setStrength(const float& soundstrength);
virtual void setPosition(const cVector3& position); virtual void setMinDistance(const float& minDistance);
virtual void setVelocity(const cVector3& velocity); virtual void setMaxDistance(const float& maxDistance);
virtual void setDirection(const cVector3& direction);
virtual void setPitch(const float& pitch);
virtual void setRolloffFactor(const float& rolloff); virtual void setVolume(const float& volume);
virtual void setStrength(const float& soundstrength); virtual void setMinVolume(const float& minVolume);
virtual void setMinDistance(const float& minDistance); virtual void setMaxVolume(const float& maxVolume);
virtual void setMaxDistance(const float& maxDistance);
virtual void setInnerConeAngle(const float& innerAngle);
virtual void setPitch(const float& pitch); virtual void setOuterConeAngle(const float& outerAngle);
virtual void setVolume(const float& volume); virtual void setOuterConeVolume(const float& outerVolume);
virtual void setMinVolume(const float& minVolume);
virtual void setMaxVolume(const float& maxVolume); virtual void setDopplerStrength(const float& dstrength);
virtual void setDopplerVelocity(const cVector3& dvelocity);
virtual void setInnerConeAngle(const float& innerAngle);
virtual void setOuterConeAngle(const float& outerAngle); virtual void move(const cVector3& position);
virtual void setOuterConeVolume(const float& outerVolume);
virtual const cVector3 getPosition() const;
virtual void setDopplerStrength(const float& dstrength); virtual const cVector3 getVelocity() const;
virtual void setDopplerVelocity(const cVector3& dvelocity); virtual const cVector3 getDirection() const;
virtual void move(const cVector3& position); virtual const float getRolloffFactor() const;
virtual const float getStrength() const;
virtual const cVector3 getPosition() const; virtual const float getMinDistance() const;
virtual const cVector3 getVelocity() const; virtual const float getMaxDistance() const;
virtual const cVector3 getDirection() const;
virtual const float getPitch() const;
virtual const float getRolloffFactor() const; virtual const float getVolume() const;
virtual const float getStrength() const; virtual const float getMinVolume() const;
virtual const float getMinDistance() const; virtual const float getMaxVolume() const;
virtual const float getMaxDistance() const;
virtual const float getInnerConeAngle() const;
virtual const float getPitch() const; virtual const float getOuterConeAngle() const;
virtual const float getVolume() const; virtual const float getOuterConeVolume() const;
virtual const float getMinVolume() const;
virtual const float getMaxVolume() const; virtual const float getDopplerStrength() const;
virtual const cVector3 getDopplerVelocity() const;
virtual const float getInnerConeAngle() const;
virtual const float getOuterConeAngle() const; virtual void registerEventHandler(ISourceEventHandler* handler);
virtual const float getOuterConeVolume() const; virtual void unRegisterEventHandler(ISourceEventHandler* handler);
virtual void unRegisterAllEventHandlers();
virtual const float getDopplerStrength() const;
virtual const cVector3 getDopplerVelocity() const; #ifdef CAUDIO_EFX_ENABLED
virtual unsigned int getNumEffectSlotsAvailable() const;
virtual void registerEventHandler(ISourceEventHandler* handler); virtual bool attachEffect(unsigned int slot, IEffect* effect);
virtual void unRegisterEventHandler(ISourceEventHandler* handler); virtual void removeEffect(unsigned int slot);
virtual void unRegisterAllEventHandlers();
virtual bool attachFilter(IFilter* filter);
#ifdef CAUDIO_EFX_ENABLED virtual void removeFilter();
virtual unsigned int getNumEffectSlotsAvailable() const; #endif
virtual bool attachEffect(unsigned int slot, IEffect* effect);
virtual void removeEffect(unsigned int slot); protected:
private:
virtual bool attachFilter(IFilter* filter); //! Mutex for thread syncronization
virtual void removeFilter(); cAudioMutex Mutex;
#endif //! Empties the current working buffer queue
void empty();
protected: //! Checks for OpenAL errors and reports them
private: bool checkError();
//! Mutex for thread syncronization //! Streams audio data from the decoder into a buffer
cAudioMutex Mutex; bool stream(ALuint buffer);
//! Empties the current working buffer queue //! Signals a event to all event handlers
void empty(); void signalEvent(Events sevent);
//! Checks for OpenAL errors and reports them //! Converts our audio format enum to OpenAL's
bool checkError() const; ALenum convertAudioFormatEnum(AudioFormats format);
//! Streams audio data from the decoder into a buffer
bool stream(ALuint buffer); //! The context that owns this source
//! Signals a event to all event handlers ALCcontext* Context;
void signalEvent(Events sevent);
//! Converts our audio format enum to OpenAL's //! Internal audio buffers
ALenum convertAudioFormatEnum(AudioFormats format); ALuint Buffers[CAUDIO_SOURCE_NUM_BUFFERS];
//! OpenAL source
//! The context that owns this source ALuint Source;
ALCcontext* Context;
ALenum oldState;
//! Internal audio buffers //! cAudio decoder being used to stream data
ALuint Buffers[CAUDIO_SOURCE_NUM_BUFFERS]; IAudioDecoder* Decoder;
//! OpenAL source
ALuint Source; //! Stores whether the source is to loop the audio stream
bool Loop;
ALenum oldState; //! Stores whether the source is ready to be used
//! cAudio decoder being used to stream data bool Valid;
IAudioDecoder* Decoder;
//! List of registered event handlers
//! Stores whether the source is to loop the audio stream cAudioList<ISourceEventHandler*>::Type eventHandlerList;
bool Loop;
//! Stores whether the source is ready to be used #ifdef CAUDIO_EFX_ENABLED
bool Valid; //! Holds pointers to all the EFX related functions
cEFXFunctions* EFX;
//! List of registered event handlers //! Updates the attached filter
cAudioList<ISourceEventHandler*>::Type eventHandlerList; void updateFilter(bool remove = false);
//! Updates the effect attached to a specific slot
#ifdef CAUDIO_EFX_ENABLED void updateEffect(unsigned int slot, bool remove = false);
//! Holds pointers to all the EFX related functions
cEFXFunctions* EFX; //! Stores the effects attached to this source
//! Updates the attached filter IEffect* Effects[CAUDIO_SOURCE_MAX_EFFECT_SLOTS];
void updateFilter(bool remove = false); //! Stores the last updated time stamps for the attached effects
//! Updates the effect attached to a specific slot unsigned int LastEffectTimeStamp[CAUDIO_SOURCE_MAX_EFFECT_SLOTS];
void updateEffect(unsigned int slot, bool remove = false);
//! Stores the attached direct feed filter
//! Stores the effects attached to this source IFilter* Filter;
IEffect* Effects[CAUDIO_SOURCE_MAX_EFFECT_SLOTS]; //! Stores the last updated time stamp for the attached filter
//! Stores the last updated time stamps for the attached effects unsigned int LastFilterTimeStamp;
unsigned int LastEffectTimeStamp[CAUDIO_SOURCE_MAX_EFFECT_SLOTS];
//! Number of effects supported by the OpenAL Context
//! Stores the attached direct feed filter unsigned int EffectSlotsAvailable;
IFilter* Filter; #endif
//! Stores the last updated time stamp for the attached filter };
unsigned int LastFilterTimeStamp; };
#endif //! CAUDIOSOURCE_H_INCLUDED
//! Number of effects supported by the OpenAL Context
unsigned int EffectSlotsAvailable;
#endif
};
};
#endif //! CAUDIOSOURCE_H_INCLUDED

View File

@ -1,25 +1,25 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef CCONSOLELOGRECEIVER_H_INCLUDED #ifndef CCONSOLELOGRECEIVER_H_INCLUDED
#define CCONSOLELOGRECEIVER_H_INCLUDED #define CCONSOLELOGRECEIVER_H_INCLUDED
#include "../include/ILogReceiver.h" #include "../include/ILogReceiver.h"
#include "../include/cAudioDefines.h" #include "../include/cAudioDefines.h"
#ifdef CAUDIO_COMPILE_WITH_CONSOLE_LOG_RECEIVER #ifdef CAUDIO_COMPILE_WITH_CONSOLE_LOG_RECEIVER
namespace cAudio namespace cAudio
{ {
class cConsoleLogReceiver : public ILogReceiver class cConsoleLogReceiver : public ILogReceiver
{ {
public: public:
virtual bool OnLogMessage(const char* sender, const char* message, LogLevel level, float time); virtual bool OnLogMessage(const char* sender, const char* message, LogLevel level, float time);
}; };
}; };
#endif #endif
#endif //! CCONSOLELOGRECEIVER_H_INCLUDED #endif //! CCONSOLELOGRECEIVER_H_INCLUDED

View File

@ -1,193 +1,193 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef CEFXFUNCTIONS_H #ifndef CEFXFUNCTIONS_H
#define CEFXFUNCTIONS_H #define CEFXFUNCTIONS_H
#include "../include/cAudioDefines.h" #include "../include/cAudioDefines.h"
#ifdef CAUDIO_EFX_ENABLED #ifdef CAUDIO_EFX_ENABLED
#include <AL/al.h> #include <AL/al.h>
#include <AL/alc.h> #include <AL/alc.h>
#include <efx.h> #include <AL/efx.h>
#include <efx-creative.h> #include <AL/efx-creative.h>
#include "../Headers/cMutex.h" #include "../Headers/cMutex.h"
//To use EFX in linux. //To use EFX in linux.
#ifndef ALC_EXT_EFX #ifndef ALC_EXT_EFX
#define AL_FILTER_TYPE 0x8001 #define AL_FILTER_TYPE 0x8001
#define AL_EFFECT_TYPE 0x8001 #define AL_EFFECT_TYPE 0x8001
#define AL_FILTER_NULL 0x0000 #define AL_FILTER_NULL 0x0000
#define AL_FILTER_LOWPASS 0x0001 #define AL_FILTER_LOWPASS 0x0001
#define AL_FILTER_HIGHPASS 0x0002 #define AL_FILTER_HIGHPASS 0x0002
#define AL_FILTER_BANDPASS 0x0003 #define AL_FILTER_BANDPASS 0x0003
#define AL_EFFECT_NULL 0x0000 #define AL_EFFECT_NULL 0x0000
#define AL_EFFECT_EAXREVERB 0x8000 #define AL_EFFECT_EAXREVERB 0x8000
#define AL_EFFECT_REVERB 0x0001 #define AL_EFFECT_REVERB 0x0001
#define AL_EFFECT_CHORUS 0x0002 #define AL_EFFECT_CHORUS 0x0002
#define AL_EFFECT_DISTORTION 0x0003 #define AL_EFFECT_DISTORTION 0x0003
#define AL_EFFECT_ECHO 0x0004 #define AL_EFFECT_ECHO 0x0004
#define AL_EFFECT_FLANGER 0x0005 #define AL_EFFECT_FLANGER 0x0005
#define AL_EFFECT_FREQUENCY_SHIFTER 0x0006 #define AL_EFFECT_FREQUENCY_SHIFTER 0x0006
#define AL_EFFECT_VOCAL_MORPHER 0x0007 #define AL_EFFECT_VOCAL_MORPHER 0x0007
#define AL_EFFECT_PITCH_SHIFTER 0x0008 #define AL_EFFECT_PITCH_SHIFTER 0x0008
#define AL_EFFECT_RING_MODULATOR 0x0009 #define AL_EFFECT_RING_MODULATOR 0x0009
#define AL_EFFECT_AUTOWAH 0x000A #define AL_EFFECT_AUTOWAH 0x000A
#define AL_EFFECT_COMPRESSOR 0x000B #define AL_EFFECT_COMPRESSOR 0x000B
#define AL_EFFECT_EQUALIZER 0x000C #define AL_EFFECT_EQUALIZER 0x000C
#define ALC_EFX_MAJOR_VERSION 0x20001 #define ALC_EFX_MAJOR_VERSION 0x20001
#define ALC_EFX_MINOR_VERSION 0x20002 #define ALC_EFX_MINOR_VERSION 0x20002
#define ALC_MAX_AUXILIARY_SENDS 0x20003 #define ALC_MAX_AUXILIARY_SENDS 0x20003
#endif #endif
namespace cAudio namespace cAudio
{ {
//! EFX Extension function pointers and setup //! EFX Extension function pointers and setup
struct cEFXFunctions struct cEFXFunctions
{ {
cEFXFunctions::cEFXFunctions() cEFXFunctions::cEFXFunctions()
{ {
alGenEffects = NULL; alGenEffects = NULL;
alDeleteEffects = NULL; alDeleteEffects = NULL;
alIsEffect = NULL; alIsEffect = NULL;
alEffecti = NULL; alEffecti = NULL;
alEffectiv = NULL; alEffectiv = NULL;
alEffectf = NULL; alEffectf = NULL;
alEffectfv = NULL; alEffectfv = NULL;
alGetEffecti = NULL; alGetEffecti = NULL;
alGetEffectiv = NULL; alGetEffectiv = NULL;
alGetEffectf = NULL; alGetEffectf = NULL;
alGetEffectfv = NULL; alGetEffectfv = NULL;
alGenFilters = NULL; alGenFilters = NULL;
alDeleteFilters = NULL; alDeleteFilters = NULL;
alIsFilter = NULL; alIsFilter = NULL;
alFilteri = NULL; alFilteri = NULL;
alFilteriv = NULL; alFilteriv = NULL;
alFilterf = NULL; alFilterf = NULL;
alFilterfv = NULL; alFilterfv = NULL;
alGetFilteri = NULL; alGetFilteri = NULL;
alGetFilteriv = NULL; alGetFilteriv = NULL;
alGetFilterf = NULL; alGetFilterf = NULL;
alGetFilterfv = NULL; alGetFilterfv = NULL;
alGenAuxiliaryEffectSlots = NULL; alGenAuxiliaryEffectSlots = NULL;
alDeleteAuxiliaryEffectSlots = NULL; alDeleteAuxiliaryEffectSlots = NULL;
alIsAuxiliaryEffectSlot = NULL; alIsAuxiliaryEffectSlot = NULL;
alAuxiliaryEffectSloti = NULL; alAuxiliaryEffectSloti = NULL;
alAuxiliaryEffectSlotiv = NULL; alAuxiliaryEffectSlotiv = NULL;
alAuxiliaryEffectSlotf = NULL; alAuxiliaryEffectSlotf = NULL;
alAuxiliaryEffectSlotfv = NULL; alAuxiliaryEffectSlotfv = NULL;
alGetAuxiliaryEffectSloti = NULL; alGetAuxiliaryEffectSloti = NULL;
alGetAuxiliaryEffectSlotiv = NULL; alGetAuxiliaryEffectSlotiv = NULL;
alGetAuxiliaryEffectSlotf = NULL; alGetAuxiliaryEffectSlotf = NULL;
alGetAuxiliaryEffectSlotfv = NULL; alGetAuxiliaryEffectSlotfv = NULL;
Supported = false; Supported = false;
} }
// Effect objects // Effect objects
LPALGENEFFECTS alGenEffects; LPALGENEFFECTS alGenEffects;
LPALDELETEEFFECTS alDeleteEffects; LPALDELETEEFFECTS alDeleteEffects;
LPALISEFFECT alIsEffect; LPALISEFFECT alIsEffect;
LPALEFFECTI alEffecti; LPALEFFECTI alEffecti;
LPALEFFECTIV alEffectiv; LPALEFFECTIV alEffectiv;
LPALEFFECTF alEffectf; LPALEFFECTF alEffectf;
LPALEFFECTFV alEffectfv; LPALEFFECTFV alEffectfv;
LPALGETEFFECTI alGetEffecti; LPALGETEFFECTI alGetEffecti;
LPALGETEFFECTIV alGetEffectiv; LPALGETEFFECTIV alGetEffectiv;
LPALGETEFFECTF alGetEffectf; LPALGETEFFECTF alGetEffectf;
LPALGETEFFECTFV alGetEffectfv; LPALGETEFFECTFV alGetEffectfv;
// Filter objects // Filter objects
LPALGENFILTERS alGenFilters; LPALGENFILTERS alGenFilters;
LPALDELETEFILTERS alDeleteFilters; LPALDELETEFILTERS alDeleteFilters;
LPALISFILTER alIsFilter; LPALISFILTER alIsFilter;
LPALFILTERI alFilteri; LPALFILTERI alFilteri;
LPALFILTERIV alFilteriv; LPALFILTERIV alFilteriv;
LPALFILTERF alFilterf; LPALFILTERF alFilterf;
LPALFILTERFV alFilterfv; LPALFILTERFV alFilterfv;
LPALGETFILTERI alGetFilteri; LPALGETFILTERI alGetFilteri;
LPALGETFILTERIV alGetFilteriv; LPALGETFILTERIV alGetFilteriv;
LPALGETFILTERF alGetFilterf; LPALGETFILTERF alGetFilterf;
LPALGETFILTERFV alGetFilterfv; LPALGETFILTERFV alGetFilterfv;
// Auxiliary slot object // Auxiliary slot object
LPALGENAUXILIARYEFFECTSLOTS alGenAuxiliaryEffectSlots; LPALGENAUXILIARYEFFECTSLOTS alGenAuxiliaryEffectSlots;
LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots; LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots;
LPALISAUXILIARYEFFECTSLOT alIsAuxiliaryEffectSlot; LPALISAUXILIARYEFFECTSLOT alIsAuxiliaryEffectSlot;
LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti; LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti;
LPALAUXILIARYEFFECTSLOTIV alAuxiliaryEffectSlotiv; LPALAUXILIARYEFFECTSLOTIV alAuxiliaryEffectSlotiv;
LPALAUXILIARYEFFECTSLOTF alAuxiliaryEffectSlotf; LPALAUXILIARYEFFECTSLOTF alAuxiliaryEffectSlotf;
LPALAUXILIARYEFFECTSLOTFV alAuxiliaryEffectSlotfv; LPALAUXILIARYEFFECTSLOTFV alAuxiliaryEffectSlotfv;
LPALGETAUXILIARYEFFECTSLOTI alGetAuxiliaryEffectSloti; LPALGETAUXILIARYEFFECTSLOTI alGetAuxiliaryEffectSloti;
LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv; LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv;
LPALGETAUXILIARYEFFECTSLOTF alGetAuxiliaryEffectSlotf; LPALGETAUXILIARYEFFECTSLOTF alGetAuxiliaryEffectSlotf;
LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv; LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv;
cAudioMutex Mutex; cAudioMutex Mutex;
bool Supported; bool Supported;
bool CheckEFXSupport(ALCdevice* device) bool CheckEFXSupport(ALCdevice* device)
{ {
Supported = false; Supported = false;
if (alcIsExtensionPresent(device, "ALC_EXT_EFX")) if (alcIsExtensionPresent(device, "ALC_EXT_EFX"))
{ {
// Get function pointers // Get function pointers
alGenEffects = (LPALGENEFFECTS)alGetProcAddress("alGenEffects"); alGenEffects = (LPALGENEFFECTS)alGetProcAddress("alGenEffects");
alDeleteEffects = (LPALDELETEEFFECTS )alGetProcAddress("alDeleteEffects"); alDeleteEffects = (LPALDELETEEFFECTS )alGetProcAddress("alDeleteEffects");
alIsEffect = (LPALISEFFECT )alGetProcAddress("alIsEffect"); alIsEffect = (LPALISEFFECT )alGetProcAddress("alIsEffect");
alEffecti = (LPALEFFECTI)alGetProcAddress("alEffecti"); alEffecti = (LPALEFFECTI)alGetProcAddress("alEffecti");
alEffectiv = (LPALEFFECTIV)alGetProcAddress("alEffectiv"); alEffectiv = (LPALEFFECTIV)alGetProcAddress("alEffectiv");
alEffectf = (LPALEFFECTF)alGetProcAddress("alEffectf"); alEffectf = (LPALEFFECTF)alGetProcAddress("alEffectf");
alEffectfv = (LPALEFFECTFV)alGetProcAddress("alEffectfv"); alEffectfv = (LPALEFFECTFV)alGetProcAddress("alEffectfv");
alGetEffecti = (LPALGETEFFECTI)alGetProcAddress("alGetEffecti"); alGetEffecti = (LPALGETEFFECTI)alGetProcAddress("alGetEffecti");
alGetEffectiv = (LPALGETEFFECTIV)alGetProcAddress("alGetEffectiv"); alGetEffectiv = (LPALGETEFFECTIV)alGetProcAddress("alGetEffectiv");
alGetEffectf = (LPALGETEFFECTF)alGetProcAddress("alGetEffectf"); alGetEffectf = (LPALGETEFFECTF)alGetProcAddress("alGetEffectf");
alGetEffectfv = (LPALGETEFFECTFV)alGetProcAddress("alGetEffectfv"); alGetEffectfv = (LPALGETEFFECTFV)alGetProcAddress("alGetEffectfv");
alGenFilters = (LPALGENFILTERS)alGetProcAddress("alGenFilters"); alGenFilters = (LPALGENFILTERS)alGetProcAddress("alGenFilters");
alDeleteFilters = (LPALDELETEFILTERS)alGetProcAddress("alDeleteFilters"); alDeleteFilters = (LPALDELETEFILTERS)alGetProcAddress("alDeleteFilters");
alIsFilter = (LPALISFILTER)alGetProcAddress("alIsFilter"); alIsFilter = (LPALISFILTER)alGetProcAddress("alIsFilter");
alFilteri = (LPALFILTERI)alGetProcAddress("alFilteri"); alFilteri = (LPALFILTERI)alGetProcAddress("alFilteri");
alFilteriv = (LPALFILTERIV)alGetProcAddress("alFilteriv"); alFilteriv = (LPALFILTERIV)alGetProcAddress("alFilteriv");
alFilterf = (LPALFILTERF)alGetProcAddress("alFilterf"); alFilterf = (LPALFILTERF)alGetProcAddress("alFilterf");
alFilterfv = (LPALFILTERFV)alGetProcAddress("alFilterfv"); alFilterfv = (LPALFILTERFV)alGetProcAddress("alFilterfv");
alGetFilteri = (LPALGETFILTERI )alGetProcAddress("alGetFilteri"); alGetFilteri = (LPALGETFILTERI )alGetProcAddress("alGetFilteri");
alGetFilteriv= (LPALGETFILTERIV )alGetProcAddress("alGetFilteriv"); alGetFilteriv= (LPALGETFILTERIV )alGetProcAddress("alGetFilteriv");
alGetFilterf = (LPALGETFILTERF )alGetProcAddress("alGetFilterf"); alGetFilterf = (LPALGETFILTERF )alGetProcAddress("alGetFilterf");
alGetFilterfv= (LPALGETFILTERFV )alGetProcAddress("alGetFilterfv"); alGetFilterfv= (LPALGETFILTERFV )alGetProcAddress("alGetFilterfv");
alGenAuxiliaryEffectSlots = (LPALGENAUXILIARYEFFECTSLOTS)alGetProcAddress("alGenAuxiliaryEffectSlots"); alGenAuxiliaryEffectSlots = (LPALGENAUXILIARYEFFECTSLOTS)alGetProcAddress("alGenAuxiliaryEffectSlots");
alDeleteAuxiliaryEffectSlots = (LPALDELETEAUXILIARYEFFECTSLOTS)alGetProcAddress("alDeleteAuxiliaryEffectSlots"); alDeleteAuxiliaryEffectSlots = (LPALDELETEAUXILIARYEFFECTSLOTS)alGetProcAddress("alDeleteAuxiliaryEffectSlots");
alIsAuxiliaryEffectSlot = (LPALISAUXILIARYEFFECTSLOT)alGetProcAddress("alIsAuxiliaryEffectSlot"); alIsAuxiliaryEffectSlot = (LPALISAUXILIARYEFFECTSLOT)alGetProcAddress("alIsAuxiliaryEffectSlot");
alAuxiliaryEffectSloti = (LPALAUXILIARYEFFECTSLOTI)alGetProcAddress("alAuxiliaryEffectSloti"); alAuxiliaryEffectSloti = (LPALAUXILIARYEFFECTSLOTI)alGetProcAddress("alAuxiliaryEffectSloti");
alAuxiliaryEffectSlotiv = (LPALAUXILIARYEFFECTSLOTIV)alGetProcAddress("alAuxiliaryEffectSlotiv"); alAuxiliaryEffectSlotiv = (LPALAUXILIARYEFFECTSLOTIV)alGetProcAddress("alAuxiliaryEffectSlotiv");
alAuxiliaryEffectSlotf = (LPALAUXILIARYEFFECTSLOTF)alGetProcAddress("alAuxiliaryEffectSlotf"); alAuxiliaryEffectSlotf = (LPALAUXILIARYEFFECTSLOTF)alGetProcAddress("alAuxiliaryEffectSlotf");
alAuxiliaryEffectSlotfv = (LPALAUXILIARYEFFECTSLOTFV)alGetProcAddress("alAuxiliaryEffectSlotfv"); alAuxiliaryEffectSlotfv = (LPALAUXILIARYEFFECTSLOTFV)alGetProcAddress("alAuxiliaryEffectSlotfv");
alGetAuxiliaryEffectSloti = (LPALGETAUXILIARYEFFECTSLOTI)alGetProcAddress("alGetAuxiliaryEffectSloti"); alGetAuxiliaryEffectSloti = (LPALGETAUXILIARYEFFECTSLOTI)alGetProcAddress("alGetAuxiliaryEffectSloti");
alGetAuxiliaryEffectSlotiv = (LPALGETAUXILIARYEFFECTSLOTIV)alGetProcAddress("alGetAuxiliaryEffectSlotiv"); alGetAuxiliaryEffectSlotiv = (LPALGETAUXILIARYEFFECTSLOTIV)alGetProcAddress("alGetAuxiliaryEffectSlotiv");
alGetAuxiliaryEffectSlotf = (LPALGETAUXILIARYEFFECTSLOTF)alGetProcAddress("alGetAuxiliaryEffectSlotf"); alGetAuxiliaryEffectSlotf = (LPALGETAUXILIARYEFFECTSLOTF)alGetProcAddress("alGetAuxiliaryEffectSlotf");
alGetAuxiliaryEffectSlotfv = (LPALGETAUXILIARYEFFECTSLOTFV)alGetProcAddress("alGetAuxiliaryEffectSlotfv"); alGetAuxiliaryEffectSlotfv = (LPALGETAUXILIARYEFFECTSLOTFV)alGetProcAddress("alGetAuxiliaryEffectSlotfv");
if (alGenEffects && alDeleteEffects && alIsEffect && alEffecti && alEffectiv && alEffectf && if (alGenEffects && alDeleteEffects && alIsEffect && alEffecti && alEffectiv && alEffectf &&
alEffectfv && alGetEffecti && alGetEffectiv && alGetEffectf && alGetEffectfv && alGenFilters && alEffectfv && alGetEffecti && alGetEffectiv && alGetEffectf && alGetEffectfv && alGenFilters &&
alDeleteFilters && alIsFilter && alFilteri && alFilteriv && alFilterf && alFilterfv && alDeleteFilters && alIsFilter && alFilteri && alFilteriv && alFilterf && alFilterfv &&
alGetFilteri && alGetFilteriv && alGetFilterf && alGetFilterfv && alGenAuxiliaryEffectSlots && alGetFilteri && alGetFilteriv && alGetFilterf && alGetFilterfv && alGenAuxiliaryEffectSlots &&
alDeleteAuxiliaryEffectSlots && alIsAuxiliaryEffectSlot && alAuxiliaryEffectSloti && alDeleteAuxiliaryEffectSlots && alIsAuxiliaryEffectSlot && alAuxiliaryEffectSloti &&
alAuxiliaryEffectSlotiv && alAuxiliaryEffectSlotf && alAuxiliaryEffectSlotfv && alAuxiliaryEffectSlotiv && alAuxiliaryEffectSlotf && alAuxiliaryEffectSlotfv &&
alGetAuxiliaryEffectSloti && alGetAuxiliaryEffectSlotiv && alGetAuxiliaryEffectSlotf && alGetAuxiliaryEffectSloti && alGetAuxiliaryEffectSlotiv && alGetAuxiliaryEffectSlotf &&
alGetAuxiliaryEffectSlotfv) alGetAuxiliaryEffectSlotfv)
Supported = true; Supported = true;
} }
return Supported; return Supported;
} }
}; };
}; };
#endif #endif
#endif //! CEFXFUNCTIONS_H #endif //! CEFXFUNCTIONS_H

View File

@ -1,127 +1,127 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef CEFFECT_H #ifndef CEFFECT_H
#define CEFFECT_H #define CEFFECT_H
#include "../include/IEffect.h" #include "../include/IEffect.h"
#include "../Headers/cMutex.h" #include "../Headers/cMutex.h"
#include "../Headers/cEFXFunctions.h" #include "../Headers/cEFXFunctions.h"
#include "../Headers/cMemoryOverride.h" #include "../Headers/cMemoryOverride.h"
#ifdef CAUDIO_EFX_ENABLED #ifdef CAUDIO_EFX_ENABLED
#include <AL/al.h> #include <AL/al.h>
#include <AL/alc.h> #include <AL/alc.h>
namespace cAudio namespace cAudio
{ {
class cEffect : public IEffect, public cMemoryOverride class cEffect : public IEffect, public cMemoryOverride
{ {
public: public:
cEffect(cEFXFunctions* oALFunctions); cEffect(cEFXFunctions* oALFunctions);
virtual ~cEffect(); virtual ~cEffect();
virtual const EffectTypes& getType() const; virtual const EffectTypes& getType() const;
virtual void setType(const EffectTypes& type); virtual void setType(const EffectTypes& type);
virtual const sEAXReverbParameters& getEAXReverbParameters() const; virtual const sEAXReverbParameters& getEAXReverbParameters() const;
virtual void setEAXReverbParameters(const sEAXReverbParameters& param); virtual void setEAXReverbParameters(const sEAXReverbParameters& param);
virtual const sReverbParameters& getReverbParameters() const; virtual const sReverbParameters& getReverbParameters() const;
virtual void setReverbParameters(const sReverbParameters& param); virtual void setReverbParameters(const sReverbParameters& param);
virtual const sChorusParameters& getChorusParameters() const; virtual const sChorusParameters& getChorusParameters() const;
virtual void setChorusParameters(const sChorusParameters& param); virtual void setChorusParameters(const sChorusParameters& param);
virtual const sDistortionParameters& getDistortionParameters() const; virtual const sDistortionParameters& getDistortionParameters() const;
virtual void setDistortionParameters(const sDistortionParameters& param); virtual void setDistortionParameters(const sDistortionParameters& param);
virtual const sEchoParameters& getEchoParameters() const; virtual const sEchoParameters& getEchoParameters() const;
virtual void setEchoParameters(const sEchoParameters& param); virtual void setEchoParameters(const sEchoParameters& param);
virtual const sFlangerParameters& getFlangerParameters() const; virtual const sFlangerParameters& getFlangerParameters() const;
virtual void setFlangerParameters(const sFlangerParameters& param); virtual void setFlangerParameters(const sFlangerParameters& param);
virtual const sFrequencyShiftParameters& getFrequencyShiftParameters() const; virtual const sFrequencyShiftParameters& getFrequencyShiftParameters() const;
virtual void setFrequencyShiftParameters(const sFrequencyShiftParameters& param); virtual void setFrequencyShiftParameters(const sFrequencyShiftParameters& param);
virtual const sVocalMorpherParameters& getVocalMorpherParameters() const; virtual const sVocalMorpherParameters& getVocalMorpherParameters() const;
virtual void setVocalMorpherParameters(const sVocalMorpherParameters& param); virtual void setVocalMorpherParameters(const sVocalMorpherParameters& param);
virtual const sPitchShifterParameters& getPitchShifterParameters() const; virtual const sPitchShifterParameters& getPitchShifterParameters() const;
virtual void setPitchShifterParameters(const sPitchShifterParameters& param); virtual void setPitchShifterParameters(const sPitchShifterParameters& param);
virtual const sRingModulatorParameters& getRingModulatorParameters() const; virtual const sRingModulatorParameters& getRingModulatorParameters() const;
virtual void setRingModulatorParameters(const sRingModulatorParameters& param); virtual void setRingModulatorParameters(const sRingModulatorParameters& param);
virtual const sAutowahParameters& getAutowahParameters() const; virtual const sAutowahParameters& getAutowahParameters() const;
virtual void setAutowahParameters(const sAutowahParameters& param); virtual void setAutowahParameters(const sAutowahParameters& param);
virtual const sCompressorParameters& getCompressorParameters() const; virtual const sCompressorParameters& getCompressorParameters() const;
virtual void setCompressorParameters(const sCompressorParameters& param); virtual void setCompressorParameters(const sCompressorParameters& param);
virtual const sEqualizerParameters& getEqualizerParameters() const; virtual const sEqualizerParameters& getEqualizerParameters() const;
virtual void setEqualizerParameters(const sEqualizerParameters& param); virtual void setEqualizerParameters(const sEqualizerParameters& param);
virtual float getMasterVolume() const; virtual float getMasterVolume() const;
virtual void setMasterVolume(const float& volume); virtual void setMasterVolume(const float& volume);
virtual bool isIgnoringAttenuation() const; virtual bool isIgnoringAttenuation() const;
virtual void ignoreAttenuation(const bool& ignore); virtual void ignoreAttenuation(const bool& ignore);
virtual IFilter* getFilter() const; virtual IFilter* getFilter() const;
virtual void attachFilter(IFilter* filter); virtual void attachFilter(IFilter* filter);
virtual void removeFilter(); virtual void removeFilter();
virtual unsigned int getLastUpdated() const; virtual unsigned int getLastUpdated() const;
virtual bool isValid() const; virtual bool isValid() const;
ALuint getOpenALEffect() const; ALuint getOpenALEffect() const;
ALuint getOpenALEffectSlot() const; ALuint getOpenALEffectSlot() const;
private: private:
cEFXFunctions* EFX; cEFXFunctions* EFX;
//Mutex for thread syncronization //Mutex for thread syncronization
cAudioMutex Mutex; cAudioMutex Mutex;
EffectTypes Type; EffectTypes Type;
float Volume; float Volume;
bool IgnoreAttenuation; bool IgnoreAttenuation;
unsigned int LastUpdated; unsigned int LastUpdated;
bool Valid; bool Valid;
IFilter* Filter; IFilter* Filter;
ALuint Effect; ALuint Effect;
ALuint EffectSlot; ALuint EffectSlot;
bool UpdateEffect(); bool UpdateEffect();
bool CheckError(); bool CheckError();
ALenum ConvertEffectEnum(EffectTypes type); ALenum ConvertEffectEnum(EffectTypes type);
ALenum ConvertFrequencyShiftEnum(sFrequencyShiftParameters::ShiftDirection shift); ALenum ConvertFrequencyShiftEnum(sFrequencyShiftParameters::ShiftDirection shift);
ALenum ConvertVocalMorphPhonemeEnum(sVocalMorpherParameters::MorpherPhoneme phoneme); ALenum ConvertVocalMorphPhonemeEnum(sVocalMorpherParameters::MorpherPhoneme phoneme);
//Storage for all the possible settings for effects //Storage for all the possible settings for effects
sEAXReverbParameters EAXReverbParam; sEAXReverbParameters EAXReverbParam;
sReverbParameters ReverbParam; sReverbParameters ReverbParam;
sChorusParameters ChorusParam; sChorusParameters ChorusParam;
sDistortionParameters DistortionParam; sDistortionParameters DistortionParam;
sEchoParameters EchoParam; sEchoParameters EchoParam;
sFlangerParameters FlangerParam; sFlangerParameters FlangerParam;
sFrequencyShiftParameters FrequencyShiftParam; sFrequencyShiftParameters FrequencyShiftParam;
sVocalMorpherParameters VocalMorpherParam; sVocalMorpherParameters VocalMorpherParam;
sPitchShifterParameters PitchShifterParam; sPitchShifterParameters PitchShifterParam;
sRingModulatorParameters RingModulatorParam; sRingModulatorParameters RingModulatorParam;
sAutowahParameters AutowahParam; sAutowahParameters AutowahParam;
sCompressorParameters CompressorParam; sCompressorParameters CompressorParam;
sEqualizerParameters EqualizerParam; sEqualizerParameters EqualizerParam;
}; };
}; };
#endif #endif
#endif //! CEFFECT_H #endif //! CEFFECT_H

View File

@ -1,31 +1,31 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef CFILELOGRECEIVER_H_INCLUDED #ifndef CFILELOGRECEIVER_H_INCLUDED
#define CFILELOGERCEIVER_H_INCLUDED #define CFILELOGERCEIVER_H_INCLUDED
#include "../include/ILogReceiver.h" #include "../include/ILogReceiver.h"
#include "../include/cAudioDefines.h" #include "../include/cAudioDefines.h"
#ifdef CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER #ifdef CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER
namespace cAudio namespace cAudio
{ {
class cFileLogReceiver : public ILogReceiver class cFileLogReceiver : public ILogReceiver
{ {
public: public:
cFileLogReceiver(); cFileLogReceiver();
~cFileLogReceiver(); ~cFileLogReceiver();
bool OnLogMessage(const char* sender, const char* message, LogLevel level, float time); bool OnLogMessage(const char* sender, const char* message, LogLevel level, float time);
private: private:
bool firsttime; bool firsttime;
}; };
}; };
#endif #endif
#endif //!CFILELOGRECEIVER_H_INCLUDED #endif //!CFILELOGRECEIVER_H_INCLUDED

View File

@ -1,45 +1,45 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef CFILESOURCE_H #ifndef CFILESOURCE_H
#define CFILESOURCE_H #define CFILESOURCE_H
#include "../include/IDataSource.h" #include "../include/IDataSource.h"
#include "../include/cAudioDefines.h" #include "../include/cAudioDefines.h"
#include "../Headers/cMemoryOverride.h" #include "../Headers/cMemoryOverride.h"
#ifdef CAUDIO_COMPILE_WITH_FILE_SOURCE #ifdef CAUDIO_COMPILE_WITH_FILE_SOURCE
#include <fstream> #include <fstream>
namespace cAudio namespace cAudio
{ {
class cFileSource : public IDataSource, public cMemoryOverride class cFileSource : public IDataSource, public cMemoryOverride
{ {
public: public:
cFileSource(const char* filename); cFileSource(const char* filename);
~cFileSource(); ~cFileSource();
virtual bool isValid(); virtual bool isValid();
virtual int getCurrentPos(); virtual int getCurrentPos();
virtual int getSize(); virtual int getSize();
virtual int read(void* output, int size); virtual int read(void* output, int size);
virtual bool seek(int amount, bool relative); virtual bool seek(int amount, bool relative);
protected: protected:
//! Holds if valid //! Holds if valid
bool Valid; bool Valid;
//! Holds file size //! Holds file size
int Filesize; int Filesize;
//! File stream //! File stream
FILE* pFile; FILE* pFile;
private: private:
}; };
}; };
#endif #endif
#endif //! CFILESOURCE_H #endif //! CFILESOURCE_H

View File

@ -1,60 +1,60 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef CFILESOURCEFACTORY_H #ifndef CFILESOURCEFACTORY_H
#define CFILESOURCEFACTORY_H #define CFILESOURCEFACTORY_H
#include "../include/IDataSourceFactory.h" #include "../include/IDataSourceFactory.h"
#ifdef CAUDIO_COMPILE_WITH_FILE_SOURCE #ifdef CAUDIO_COMPILE_WITH_FILE_SOURCE
#include "../Headers/cFileSource.h" #include "../Headers/cFileSource.h"
#include "../Headers/cMemorySource.h" #include "../Headers/cMemorySource.h"
#include "../Headers/cMutex.h" #include "../Headers/cMutex.h"
namespace cAudio namespace cAudio
{ {
class cFileSourceFactory : public IDataSourceFactory class cFileSourceFactory : public IDataSourceFactory
{ {
public: public:
cFileSourceFactory() { } cFileSourceFactory() { }
virtual ~cFileSourceFactory() { } virtual ~cFileSourceFactory() { }
virtual IDataSource* CreateDataSource(const char* filename, bool streamingRequested) virtual IDataSource* CreateDataSource(const char* filename, bool streamingRequested)
{ {
cAudioMutexBasicLock lock(Mutex); cAudioMutexBasicLock lock(Mutex);
IDataSource* source = CAUDIO_NEW cFileSource(filename); IDataSource* source = CAUDIO_NEW cFileSource(filename);
if(!streamingRequested && source && source->isValid()) if(!streamingRequested && source && source->isValid())
{ {
//A bit hackish, but if the user doesn't want streaming, make this a memory source //A bit hackish, but if the user doesn't want streaming, make this a memory source
int length = source->getSize(); int length = source->getSize();
char* tempbuf = (char*)CAUDIO_MALLOC(length); char* tempbuf = (char*)CAUDIO_MALLOC(length);
if(tempbuf) if(tempbuf)
{ {
source->read(tempbuf, length); source->read(tempbuf, length);
IDataSource* memSource = CAUDIO_NEW cMemorySource(tempbuf, length, true); IDataSource* memSource = CAUDIO_NEW cMemorySource(tempbuf, length, true);
CAUDIO_FREE(tempbuf); CAUDIO_FREE(tempbuf);
if(memSource && memSource->isValid()) if(memSource && memSource->isValid())
{ {
source->drop(); source->drop();
return memSource; return memSource;
} }
if(memSource) if(memSource)
memSource->drop(); memSource->drop();
} }
} }
return source; return source;
} }
protected: protected:
cAudioMutex Mutex; cAudioMutex Mutex;
private: private:
}; };
}; };
#endif #endif
#endif //! CFILESOURCEFACTORY_H #endif //! CFILESOURCEFACTORY_H

View File

@ -1,67 +1,67 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef CFILTER_H #ifndef CFILTER_H
#define CFILTER_H #define CFILTER_H
#include "../include/IFilter.h" #include "../include/IFilter.h"
#include "../Headers/cMutex.h" #include "../Headers/cMutex.h"
#include "../Headers/cEFXFunctions.h" #include "../Headers/cEFXFunctions.h"
#include "../Headers/cMemoryOverride.h" #include "../Headers/cMemoryOverride.h"
#ifdef CAUDIO_EFX_ENABLED #ifdef CAUDIO_EFX_ENABLED
#include <AL/al.h> #include <AL/al.h>
#include <AL/alc.h> #include <AL/alc.h>
namespace cAudio namespace cAudio
{ {
class cFilter : public IFilter, public cMemoryOverride class cFilter : public IFilter, public cMemoryOverride
{ {
public: public:
cFilter(cEFXFunctions* oALFunctions); cFilter(cEFXFunctions* oALFunctions);
~cFilter(); ~cFilter();
virtual const FilterTypes& getType() const; virtual const FilterTypes& getType() const;
virtual void setType(const FilterTypes& type); virtual void setType(const FilterTypes& type);
virtual float getVolume() const; virtual float getVolume() const;
virtual void setVolume(const float& volume); virtual void setVolume(const float& volume);
virtual float getLowFrequencyVolume() const; virtual float getLowFrequencyVolume() const;
virtual void setLowFrequencyVolume(const float& volumeLF); virtual void setLowFrequencyVolume(const float& volumeLF);
virtual float getHighFrequencyVolume() const; virtual float getHighFrequencyVolume() const;
virtual void setHighFrequencyVolume(const float& volumeHF); virtual void setHighFrequencyVolume(const float& volumeHF);
virtual unsigned int getLastUpdated() const; virtual unsigned int getLastUpdated() const;
virtual bool isValid() const; virtual bool isValid() const;
ALuint getOpenALFilter() const; ALuint getOpenALFilter() const;
protected: protected:
cEFXFunctions* EFX; cEFXFunctions* EFX;
//Mutex for thread syncronization //Mutex for thread syncronization
cAudioMutex Mutex; cAudioMutex Mutex;
FilterTypes Type; FilterTypes Type;
float Volume; float Volume;
float LowFreqVolume; float LowFreqVolume;
float HighFreqVolume; float HighFreqVolume;
unsigned int LastUpdated; unsigned int LastUpdated;
bool Valid; bool Valid;
ALuint Filter; ALuint Filter;
bool UpdateFilter(); bool UpdateFilter();
bool CheckError(); bool CheckError();
ALenum ConvertFilterEnum(FilterTypes type); ALenum ConvertFilterEnum(FilterTypes type);
}; };
}; };
#endif #endif
#endif //! CFILTER_H #endif //! CFILTER_H

View File

@ -1,50 +1,50 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef CLISTENER_H_INCLUDED #ifndef CLISTENER_H_INCLUDED
#define CLISTENER_H_INCLUDED #define CLISTENER_H_INCLUDED
#include "../include/IListener.h" #include "../include/IListener.h"
#include "../Headers/cMutex.h" #include "../Headers/cMutex.h"
namespace cAudio namespace cAudio
{ {
class cListener : public IListener class cListener : public IListener
{ {
public: public:
cListener() : Direction(cVector3(0.f, 0.f, -1.f)), cListener() : Direction(cVector3(0.f, 0.f, -1.f)),
UpVector(cVector3(0.f, 1.f, 0.f)), UpVector(cVector3(0.f, 1.f, 0.f)),
MasterGain(1.f) {} MasterGain(1.f) {}
virtual ~cListener() {} virtual ~cListener() {}
virtual void setPosition(const cVector3& pos); virtual void setPosition(const cVector3& pos);
virtual void setDirection(const cVector3& dir); virtual void setDirection(const cVector3& dir);
virtual void setUpVector(const cVector3& up); virtual void setUpVector(const cVector3& up);
virtual void setVelocity(const cVector3& vel); virtual void setVelocity(const cVector3& vel);
virtual void setMasterVolume(const float& volume); virtual void setMasterVolume(const float& volume);
virtual void move(const cVector3& pos); virtual void move(const cVector3& pos);
virtual cVector3 getPosition(void) const { return Position; } virtual cVector3 getPosition(void) const { return Position; }
virtual cVector3 getDirection(void) const { return Direction; } virtual cVector3 getDirection(void) const { return Direction; }
virtual cVector3 getUpVector(void) const { return UpVector; } virtual cVector3 getUpVector(void) const { return UpVector; }
virtual cVector3 getVelocity(void) const { return Velocity; } virtual cVector3 getVelocity(void) const { return Velocity; }
virtual float getMasterVolume(void) const { return MasterGain; } virtual float getMasterVolume(void) const { return MasterGain; }
#ifdef CAUDIO_EFX_ENABLED #ifdef CAUDIO_EFX_ENABLED
virtual void setMetersPerUnit(const float& meters); virtual void setMetersPerUnit(const float& meters);
virtual float getMetersPerUnit(void) const; virtual float getMetersPerUnit(void) const;
#endif #endif
protected: protected:
cAudioMutex Mutex; cAudioMutex Mutex;
cVector3 Position; cVector3 Position;
cVector3 Direction; cVector3 Direction;
cVector3 UpVector; cVector3 UpVector;
cVector3 Velocity; cVector3 Velocity;
float MasterGain; float MasterGain;
private: private:
}; };
} }
#endif //! CLISTENER_H_INCLUDED #endif //! CLISTENER_H_INCLUDED

View File

@ -1,48 +1,49 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef CLOGGER_H_INCLUDED #ifndef CLOGGER_H_INCLUDED
#define CLOGGER_H_INCLUDED #define CLOGGER_H_INCLUDED
#include <stdarg.h> #include <stdarg.h>
#include "../include/ILogger.h" #include "../include/ILogger.h"
#include "../Headers/cMutex.h" #include "../Headers/cMutex.h"
#include "../Headers/cSTLAllocator.h" #include "../include/cSTLAllocator.h"
#include "../include/cAudioString.h"
namespace cAudio
{ namespace cAudio
class cLogger : public ILogger {
{ class cLogger : public ILogger
public: {
cLogger(); public:
virtual ~cLogger() { } cLogger();
virtual ~cLogger() { }
virtual void logCritical( const char* sender, const char *msg, ... );
virtual void logError( const char* sender, const char *msg, ... ); virtual void logCritical( const char* sender, const char *msg, ... );
virtual void logWarning( const char* sender, const char *msg, ... ); virtual void logError( const char* sender, const char *msg, ... );
virtual void logInfo( const char* sender, const char *msg, ... ); virtual void logWarning( const char* sender, const char *msg, ... );
virtual void logDebug( const char* sender, const char *msg, ... ); virtual void logInfo( const char* sender, const char *msg, ... );
virtual void logDebug( const char* sender, const char *msg, ... );
virtual const LogLevel& getLogLevel() const { return MinLogLevel; }
virtual void setLogLevel( const LogLevel& logLevel ); virtual const LogLevel& getLogLevel() const { return MinLogLevel; }
virtual void setLogLevel( const LogLevel& logLevel );
virtual bool registerLogReceiver(ILogReceiver* receiver, const char* name);
virtual void unRegisterLogReceiver(const char* name); virtual bool registerLogReceiver(ILogReceiver* receiver, const char* name);
virtual bool isLogReceiverRegistered(const char* name); virtual void unRegisterLogReceiver(const char* name);
virtual ILogReceiver* getLogReceiver(const char* name); virtual bool isLogReceiverRegistered(const char* name);
virtual ILogReceiver* getLogReceiver(const char* name);
protected:
void broadcastMessage( LogLevel level, const char* sender, const char* msg, va_list args ); protected:
void broadcastMessage( LogLevel level, const char* sender, const char* msg, va_list args );
cAudioMutex Mutex;
unsigned long StartTime; cAudioMutex Mutex;
char TempTextBuf[2048]; unsigned long StartTime;
LogLevel MinLogLevel; char TempTextBuf[2048];
cAudioMap<cAudioString, ILogReceiver*>::Type Receivers; LogLevel MinLogLevel;
typedef cAudioMap<cAudioString, ILogReceiver*>::Type::iterator ReceiversIterator; cAudioMap<cAudioString, ILogReceiver*>::Type Receivers;
private: typedef cAudioMap<cAudioString, ILogReceiver*>::Type::iterator ReceiversIterator;
}; private:
}; };
#endif //! CLOGGER_H_INCLUDED };
#endif //! CLOGGER_H_INCLUDED

View File

@ -1,66 +1,66 @@
#ifndef CMEMORYOVERRIDE_H_INCLUDED #ifndef CMEMORYOVERRIDE_H_INCLUDED
#define CMEMORYOVERRIDE_H_INCLUDED #define CMEMORYOVERRIDE_H_INCLUDED
#include <new> #include <new>
#include "../include/cAudioMemory.h" #include "../include/cAudioMemory.h"
namespace cAudio namespace cAudio
{ {
//! Overrides the memory allocations for classes derived from it and makes them use the cAudio memory system //! Overrides the memory allocations for classes derived from it and makes them use the cAudio memory system
class cMemoryOverride class cMemoryOverride
{ {
public: public:
void* operator new(size_t size, const char* file, int line, const char* function) void* operator new(size_t size, const char* file, int line, const char* function)
{ {
return cAudio::getMemoryProvider()->Allocate(size, file, line, function); return cAudio::getMemoryProvider()->Allocate(size, file, line, function);
} }
void* operator new(size_t size) void* operator new(size_t size)
{ {
return cAudio::getMemoryProvider()->Allocate(size, NULL, -1, NULL); return cAudio::getMemoryProvider()->Allocate(size, NULL, -1, NULL);
} }
void* operator new(size_t size, void* pointer) void* operator new(size_t size, void* pointer)
{ {
(void) size; (void) size;
return pointer; return pointer;
} }
void* operator new[] ( size_t size, const char* file, int line, const char* function ) void* operator new[] ( size_t size, const char* file, int line, const char* function )
{ {
return cAudio::getMemoryProvider()->Allocate(size, file, line, function); return cAudio::getMemoryProvider()->Allocate(size, file, line, function);
} }
void* operator new[] ( size_t size ) void* operator new[] ( size_t size )
{ {
return cAudio::getMemoryProvider()->Allocate(size, NULL, -1, NULL); return cAudio::getMemoryProvider()->Allocate(size, NULL, -1, NULL);
} }
void operator delete( void* pointer ) void operator delete( void* pointer )
{ {
cAudio::getMemoryProvider()->Free(pointer); cAudio::getMemoryProvider()->Free(pointer);
} }
void operator delete( void* pointer, void* ) void operator delete( void* pointer, void* )
{ {
cAudio::getMemoryProvider()->Free(pointer); cAudio::getMemoryProvider()->Free(pointer);
} }
void operator delete( void* pointer, const char* , int , const char* ) void operator delete( void* pointer, const char* , int , const char* )
{ {
cAudio::getMemoryProvider()->Free(pointer); cAudio::getMemoryProvider()->Free(pointer);
} }
void operator delete[] ( void* pointer ) void operator delete[] ( void* pointer )
{ {
cAudio::getMemoryProvider()->Free(pointer); cAudio::getMemoryProvider()->Free(pointer);
} }
void operator delete[] ( void* pointer, const char* , int , const char* ) void operator delete[] ( void* pointer, const char* , int , const char* )
{ {
cAudio::getMemoryProvider()->Free(pointer); cAudio::getMemoryProvider()->Free(pointer);
} }
}; };
}; };
#endif //! CMEMORYOVERRIDE_H_INCLUDED #endif //! CMEMORYOVERRIDE_H_INCLUDED

View File

@ -1,41 +1,41 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef CMEMORYSOURCE_H #ifndef CMEMORYSOURCE_H
#define CMEMORYSOURCE_H #define CMEMORYSOURCE_H
#include "../include/IDataSource.h" #include "../include/IDataSource.h"
#include "../Headers/cMemoryOverride.h" #include "../Headers/cMemoryOverride.h"
namespace cAudio namespace cAudio
{ {
//!Class used to read from a memory buffer. //!Class used to read from a memory buffer.
class cMemorySource : public IDataSource, public cMemoryOverride class cMemorySource : public IDataSource, public cMemoryOverride
{ {
public: public:
/** Default Constructor /** Default Constructor
\param data: Pointer to a data buffer to use. \param data: Pointer to a data buffer to use.
\param size: Size of the target buffer. \param size: Size of the target buffer.
\param copy: Whether to copy the buffer or use the provided pointer. On destruct, that pointer will be deleted unless copy is true. \param copy: Whether to copy the buffer or use the provided pointer. On destruct, that pointer will be deleted unless copy is true.
*/ */
cMemorySource(const void* data, int size, bool copy); cMemorySource(const void* data, int size, bool copy);
~cMemorySource(); ~cMemorySource();
virtual bool isValid(); virtual bool isValid();
virtual int getCurrentPos(); virtual int getCurrentPos();
virtual int getSize(); virtual int getSize();
virtual int read(void* output, int size); virtual int read(void* output, int size);
virtual bool seek(int amount, bool relative); virtual bool seek(int amount, bool relative);
protected: protected:
char* Data; char* Data;
int Size; int Size;
bool Valid; bool Valid;
int Pos; int Pos;
private: private:
}; };
}; };
#endif //! CMEMORYSOURCE_H #endif //! CMEMORYSOURCE_H

View File

@ -1,74 +1,74 @@
#ifndef CMEMORYTRACKER_H_INCLUDED #ifndef CMEMORYTRACKER_H_INCLUDED
#define CMEMORYTRACKER_H_INCLUDED #define CMEMORYTRACKER_H_INCLUDED
#include "../include/cAudioDefines.h" #include "../include/cAudioDefines.h"
#ifdef CAUDIO_USE_MEMORYTRACKER #ifdef CAUDIO_USE_MEMORYTRACKER
#include <map> #include <map>
#include "../Headers/cMutex.h" #include "../Headers/cMutex.h"
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
namespace cAudio namespace cAudio
{ {
//! Tracks all allocations that go through cAudio's memory system and keeps statistics on it //! Tracks all allocations that go through cAudio's memory system and keeps statistics on it
class cMemoryTracker class cMemoryTracker
{ {
public: public:
cMemoryTracker(); cMemoryTracker();
~cMemoryTracker(); ~cMemoryTracker();
static cMemoryTracker* Instance() static cMemoryTracker* Instance()
{ {
static cMemoryTracker Singleton; static cMemoryTracker Singleton;
return &Singleton; return &Singleton;
} }
//! Adds an allocation to be tracked //! Adds an allocation to be tracked
void AddAllocation(void* pointer, size_t size, const char* filename, int line, const char* function); void AddAllocation(void* pointer, size_t size, const char* filename, int line, const char* function);
//! Removes a previously tracked allocation (for when it has been deallocated) //! Removes a previously tracked allocation (for when it has been deallocated)
void RemoveAllocation(void* pointer); void RemoveAllocation(void* pointer);
private: private:
cAudioMutex Mutex; cAudioMutex Mutex;
struct cTrackedMemoryBlock struct cTrackedMemoryBlock
{ {
size_t size; size_t size;
const char* filename; const char* filename;
int line; int line;
const char* function; const char* function;
}; };
std::map<void*, cTrackedMemoryBlock> TrackedBlocks; std::map<void*, cTrackedMemoryBlock> TrackedBlocks;
#ifdef CAUDIO_MEMORYTRACKER_GENERATE_STATISTICS #ifdef CAUDIO_MEMORYTRACKER_GENERATE_STATISTICS
struct Statistics struct Statistics
{ {
Statistics() : AllocationHighWaterMark(0), CurrentAllocationBytes(0), Statistics() : AllocationHighWaterMark(0), CurrentAllocationBytes(0),
TotalAllocationBytes(0), MaxNumAllocations(0), TotalAllocationBytes(0), MaxNumAllocations(0),
CurrentNumAllocations(0), TotalNumAllocations(0) CurrentNumAllocations(0), TotalNumAllocations(0)
{ } { }
size_t AllocationHighWaterMark; size_t AllocationHighWaterMark;
size_t CurrentAllocationBytes; size_t CurrentAllocationBytes;
size_t TotalAllocationBytes; size_t TotalAllocationBytes;
size_t MaxNumAllocations; size_t MaxNumAllocations;
size_t CurrentNumAllocations; size_t CurrentNumAllocations;
size_t TotalNumAllocations; size_t TotalNumAllocations;
} MemStats; } MemStats;
#endif #endif
void DumpLeaks(); void DumpLeaks();
#ifdef CAUDIO_MEMORYTRACKER_LOG_ALL_ALLOCATIONS #ifdef CAUDIO_MEMORYTRACKER_LOG_ALL_ALLOCATIONS
std::ofstream outMemLog; std::ofstream outMemLog;
#endif #endif
}; };
}; };
#endif #endif
#endif //! CMEMORYTRACKER_H_INCLUDED #endif //! CMEMORYTRACKER_H_INCLUDED

View File

@ -1,71 +1,71 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef CAUDIOMUTEX_H #ifndef CAUDIOMUTEX_H
#define CAUDIOMUTEX_H #define CAUDIOMUTEX_H
#include "../include/cAudioDefines.h" #include "../include/cAudioDefines.h"
#ifdef CAUDIO_MAKE_THREAD_SAFE #ifdef CAUDIO_MAKE_THREAD_SAFE
#ifdef CAUDIO_PLATFORM_WIN #ifdef CAUDIO_PLATFORM_WIN
#include <windows.h> //Basic windows include #include <windows.h> //Basic windows include
#else #else
#include <pthread.h> //Assumed linux system #include <pthread.h> //Assumed linux system
#endif #endif
#endif #endif
namespace cAudio namespace cAudio
{ {
#ifdef CAUDIO_MAKE_THREAD_SAFE #ifdef CAUDIO_MAKE_THREAD_SAFE
//! Basic mutex class used for internal thread locking //! Basic mutex class used for internal thread locking
class cAudioMutex class cAudioMutex
{ {
public: public:
cAudioMutex(); cAudioMutex();
~cAudioMutex(); ~cAudioMutex();
void lock(); void lock();
void unlock(); void unlock();
private: private:
void initialize(); void initialize();
#ifdef CAUDIO_PLATFORM_WIN #ifdef CAUDIO_PLATFORM_WIN
CRITICAL_SECTION criticalSection; CRITICAL_SECTION criticalSection;
#else #else
pthread_mutex_t Mutex; pthread_mutex_t Mutex;
#endif #endif
bool Initialized; bool Initialized;
}; };
#else #else
//Dud class to disable the mutex //Dud class to disable the mutex
class cAudioMutex class cAudioMutex
{ {
public: public:
cAudioMutex(); cAudioMutex();
~cAudioMutex(); ~cAudioMutex();
void lock(); void lock();
void unlock(); void unlock();
private: private:
void initialize(); void initialize();
bool Initialized; bool Initialized;
}; };
#endif #endif
class cAudioMutexBasicLock class cAudioMutexBasicLock
{ {
public: public:
cAudioMutexBasicLock(cAudioMutex& mutex) : Mutex(&mutex) cAudioMutexBasicLock(cAudioMutex& mutex) : Mutex(&mutex)
{ {
Mutex->lock(); Mutex->lock();
} }
~cAudioMutexBasicLock() ~cAudioMutexBasicLock()
{ {
Mutex->unlock(); Mutex->unlock();
} }
protected: protected:
cAudioMutex* Mutex; cAudioMutex* Mutex;
}; };
}; };
#endif //! CAUDIOMUTEX_H #endif //! CAUDIOMUTEX_H

View File

@ -1,40 +1,40 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef COGGAUDIODECODERFACTORY_H #ifndef COGGAUDIODECODERFACTORY_H
#define COGGAUDIODECODERFACTORY_H #define COGGAUDIODECODERFACTORY_H
#include "../include/IAudioDecoderFactory.h" #include "../include/IAudioDecoderFactory.h"
#include "cOggDecoder.h" #include "cOggDecoder.h"
#include "../Headers/cMutex.h" #include "../Headers/cMutex.h"
#ifdef CAUDIO_COMPILE_WITH_OGG_DECODER #ifdef CAUDIO_COMPILE_WITH_OGG_DECODER
namespace cAudio namespace cAudio
{ {
class cOggAudioDecoderFactory : public IAudioDecoderFactory class cOggAudioDecoderFactory : public IAudioDecoderFactory
{ {
public: public:
cOggAudioDecoderFactory() {} cOggAudioDecoderFactory() {}
~cOggAudioDecoderFactory() {} ~cOggAudioDecoderFactory() {}
IAudioDecoder* CreateAudioDecoder(IDataSource* stream) IAudioDecoder* CreateAudioDecoder(IDataSource* stream)
{ {
Mutex.lock(); Mutex.lock();
IAudioDecoder* decoder = CAUDIO_NEW cOggDecoder(stream); IAudioDecoder* decoder = CAUDIO_NEW cOggDecoder(stream);
Mutex.unlock(); Mutex.unlock();
return decoder; return decoder;
} }
protected: protected:
cAudioMutex Mutex; cAudioMutex Mutex;
private: private:
}; };
}; };
#endif #endif
#endif //! COGGAUDIODECODERFACTORY_H #endif //! COGGAUDIODECODERFACTORY_H

View File

@ -1,58 +1,58 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef COGGDECODER_H_INCLUDED #ifndef COGGDECODER_H_INCLUDED
#define COGGDECODER_H_INCLUDED #define COGGDECODER_H_INCLUDED
#include "../include/cAudioDefines.h" #include "../include/cAudioDefines.h"
#ifdef CAUDIO_COMPILE_WITH_OGG_DECODER #ifdef CAUDIO_COMPILE_WITH_OGG_DECODER
#include "../include/IAudioDecoder.h" #include "../include/IAudioDecoder.h"
#include <ogg/ogg.h> #include <ogg/ogg.h>
#include <vorbis/codec.h> #include <vorbis/codec.h>
#include <vorbis/vorbisfile.h> #include <vorbis/vorbisfile.h>
#include "../Headers/cMemoryOverride.h" #include "../Headers/cMemoryOverride.h"
namespace cAudio namespace cAudio
{ {
class cOggDecoder : public IAudioDecoder, public cMemoryOverride class cOggDecoder : public IAudioDecoder, public cMemoryOverride
{ {
public: public:
cOggDecoder(IDataSource* stream); cOggDecoder(IDataSource* stream);
~cOggDecoder(); ~cOggDecoder();
virtual AudioFormats getFormat(); virtual AudioFormats getFormat();
virtual int getFrequency(); virtual int getFrequency();
virtual bool isSeekingSupported(); virtual bool isSeekingSupported();
virtual bool isValid(); virtual bool isValid();
virtual int readAudioData(void* output, int amount); virtual int readAudioData(void* output, int amount);
virtual bool setPosition(int position, bool relative); virtual bool setPosition(int position, bool relative);
virtual bool seek(float seconds,bool relative); virtual bool seek(float seconds,bool relative);
virtual float getTotalTime(); virtual float getTotalTime();
virtual int getTotalSize(); virtual int getTotalSize();
virtual int getCompressedSize(); virtual int getCompressedSize();
virtual float getCurrentTime(); virtual float getCurrentTime();
virtual int getCurrentPosition(); virtual int getCurrentPosition();
virtual int getCurrentCompressedPosition(); virtual int getCurrentCompressedPosition();
protected: protected:
//! Callbacks used for read memory //! Callbacks used for read memory
ov_callbacks vorbisCallbacks; ov_callbacks vorbisCallbacks;
//! Format information //! Format information
vorbis_info* vorbisInfo; vorbis_info* vorbisInfo;
//! User Comments //! User Comments
vorbis_comment* vorbisComment; vorbis_comment* vorbisComment;
//! Stream handle //! Stream handle
OggVorbis_File oggStream; OggVorbis_File oggStream;
bool Valid; bool Valid;
}; };
} }
#endif #endif
#endif //! COGGDECODER_H_INCLUDED #endif //! COGGDECODER_H_INCLUDED

View File

@ -1,84 +1,85 @@
#ifndef CPLUGINMANAGER_H_INCLUDED #ifndef CPLUGINMANAGER_H_INCLUDED
#define CPLUGINMANAGER_H_INCLUDED #define CPLUGINMANAGER_H_INCLUDED
#include "../include/IPluginManager.h" #include "../include/IPluginManager.h"
#include "../include/IAudioPlugin.h" #include "../include/IAudioPlugin.h"
#include "../Headers/cMutex.h" #include "../Headers/cMutex.h"
#include "../Headers/cSTLAllocator.h" #include "../include/cSTLAllocator.h"
#include "../include/cAudioString.h"
#ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
#ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
#ifdef CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT
#ifdef CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT
#ifdef CAUDIO_PLATFORM_WIN
# define WIN32_LEAN_AND_MEAN #ifdef CAUDIO_PLATFORM_WIN
# include <windows.h> # define WIN32_LEAN_AND_MEAN
# include <windows.h>
struct HINSTANCE__;
typedef struct HINSTANCE__* hInstance; struct HINSTANCE__;
typedef struct HINSTANCE__* hInstance;
# define DYNLIB_HANDLE hInstance
# define DYNLIB_LOAD( a ) LoadLibraryEx( a, NULL, LOAD_WITH_ALTERED_SEARCH_PATH ) # define DYNLIB_HANDLE hInstance
# define DYNLIB_GETSYM( a, b ) GetProcAddress( a, b ) # define DYNLIB_LOAD( a ) LoadLibraryEx( a, NULL, LOAD_WITH_ALTERED_SEARCH_PATH )
# define DYNLIB_UNLOAD( a ) !FreeLibrary( a ) # define DYNLIB_GETSYM( a, b ) GetProcAddress( a, b )
#endif # define DYNLIB_UNLOAD( a ) !FreeLibrary( a )
#endif
#ifdef CAUDIO_PLATFORM_MAC
# include <dlfcn.h> #ifdef CAUDIO_PLATFORM_MAC
# define DYNLIB_HANDLE void* # include <dlfcn.h>
# define DYNLIB_LOAD( a ) dlopen( a, RTLD_LAZY | RTLD_GLOBAL) # define DYNLIB_HANDLE void*
# define DYNLIB_GETSYM( a, b ) dlsym( a, b ) # define DYNLIB_LOAD( a ) dlopen( a, RTLD_LAZY | RTLD_GLOBAL)
# define DYNLIB_UNLOAD( a ) dlclose( a ) # define DYNLIB_GETSYM( a, b ) dlsym( a, b )
#endif # define DYNLIB_UNLOAD( a ) dlclose( a )
#endif
#ifdef CAUDIO_PLATFORM_LINUX
# include <dlfcn.h> #ifdef CAUDIO_PLATFORM_LINUX
# define DYNLIB_HANDLE void* # include <dlfcn.h>
# define DYNLIB_LOAD( a ) dlopen( a, RTLD_LAZY | RTLD_GLOBAL) # define DYNLIB_HANDLE void*
# define DYNLIB_GETSYM( a, b ) dlsym( a, b ) # define DYNLIB_LOAD( a ) dlopen( a, RTLD_LAZY | RTLD_GLOBAL)
# define DYNLIB_UNLOAD( a ) dlclose( a ) # define DYNLIB_GETSYM( a, b ) dlsym( a, b )
#endif # define DYNLIB_UNLOAD( a ) dlclose( a )
#endif
#endif //! CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT
#endif //! CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT
namespace cAudio
{ namespace cAudio
class cPluginManager : public IPluginManager {
{ class cPluginManager : public IPluginManager
public: {
cPluginManager(); public:
~cPluginManager(); cPluginManager();
~cPluginManager();
static cPluginManager* Instance()
{ static cPluginManager* Instance()
static cPluginManager theInstance; {
return &theInstance; static cPluginManager theInstance;
} return &theInstance;
}
virtual bool installPlugin(IAudioPlugin* plugin, const char* name);
virtual bool installPlugin(const char* filename, const char* name); virtual bool installPlugin(IAudioPlugin* plugin, const char* name);
virtual bool installPlugin(const char* filename, const char* name);
virtual bool checkForPlugin(const char* name);
virtual IAudioPlugin* getPlugin(const char* name); virtual bool checkForPlugin(const char* name);
virtual unsigned int getPluginCount(); virtual IAudioPlugin* getPlugin(const char* name);
cAudioVector<IAudioPlugin*>::Type getPluginList(); virtual unsigned int getPluginCount();
cAudioVector<IAudioPlugin*>::Type getPluginList();
virtual void uninstallPlugin(IAudioPlugin* plugin);
virtual void uninstallPlugin(const char* name); virtual void uninstallPlugin(IAudioPlugin* plugin);
virtual void uninstallPlugin(const char* name);
#ifdef CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT
void autoLoadPlugins(); #ifdef CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT
#endif void autoLoadPlugins();
protected: #endif
cAudioMap<cAudioString, IAudioPlugin*>::Type RegisteredPlugins; protected:
typedef cAudioMap<cAudioString, IAudioPlugin*>::Type::iterator RegisteredPluginsIterator; cAudioMap<cAudioString, IAudioPlugin*>::Type RegisteredPlugins;
#ifdef CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT typedef cAudioMap<cAudioString, IAudioPlugin*>::Type::iterator RegisteredPluginsIterator;
cAudioMap<IAudioPlugin*, DYNLIB_HANDLE>::Type DynamicallyLoadedPlugins; #ifdef CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT
typedef cAudioMap<IAudioPlugin*, DYNLIB_HANDLE>::Type::iterator DynamicallyLoadedPluginsIterator; cAudioMap<IAudioPlugin*, DYNLIB_HANDLE>::Type DynamicallyLoadedPlugins;
#endif typedef cAudioMap<IAudioPlugin*, DYNLIB_HANDLE>::Type::iterator DynamicallyLoadedPluginsIterator;
}; #endif
}; };
};
#endif //! CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
#endif //! CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
#endif //! CPLUGINMANAGER_H_INCLUDED #endif //! CPLUGINMANAGER_H_INCLUDED

View File

@ -1,43 +1,43 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef CRAWAUDIODECODERFACOTRY_H_INCLUDED #ifndef CRAWAUDIODECODERFACOTRY_H_INCLUDED
#define CRAWAUDIODECODERFACOTRY_H_INCLUDED #define CRAWAUDIODECODERFACOTRY_H_INCLUDED
#include "../include/IAudioDecoderFactory.h" #include "../include/IAudioDecoderFactory.h"
#include "cRawDecoder.h" #include "cRawDecoder.h"
#include "../Headers/cMutex.h" #include "../Headers/cMutex.h"
namespace cAudio namespace cAudio
{ {
class cRawAudioDecoderFactory : public IAudioDecoderFactory class cRawAudioDecoderFactory : public IAudioDecoderFactory
{ {
public: public:
cRawAudioDecoderFactory() {} cRawAudioDecoderFactory() {}
~cRawAudioDecoderFactory() {} ~cRawAudioDecoderFactory() {}
IAudioDecoder* CreateAudioDecoder(IDataSource* stream) IAudioDecoder* CreateAudioDecoder(IDataSource* stream)
{ {
Mutex.lock(); Mutex.lock();
IAudioDecoder* decoder = CAUDIO_NEW cRawDecoder(stream, 22050, EAF_16BIT_MONO); IAudioDecoder* decoder = CAUDIO_NEW cRawDecoder(stream, 22050, EAF_16BIT_MONO);
Mutex.unlock(); Mutex.unlock();
return decoder; return decoder;
} }
IAudioDecoder* CreateAudioDecoder(IDataSource* stream, unsigned int frequency = 22050, AudioFormats format = EAF_16BIT_MONO) IAudioDecoder* CreateAudioDecoder(IDataSource* stream, unsigned int frequency = 22050, AudioFormats format = EAF_16BIT_MONO)
{ {
Mutex.lock(); Mutex.lock();
IAudioDecoder* decoder = CAUDIO_NEW cRawDecoder(stream, frequency, format); IAudioDecoder* decoder = CAUDIO_NEW cRawDecoder(stream, frequency, format);
Mutex.unlock(); Mutex.unlock();
return decoder; return decoder;
} }
protected: protected:
cAudioMutex Mutex; cAudioMutex Mutex;
private: private:
}; };
}; };
#endif //! CRAWAUDIODECODERFACOTRY_H_INCLUDED #endif //! CRAWAUDIODECODERFACOTRY_H_INCLUDED

View File

@ -1,40 +1,40 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef CRAWDECODER_H_INCLUDED #ifndef CRAWDECODER_H_INCLUDED
#define CRAWDECODER_H_INCLUDED #define CRAWDECODER_H_INCLUDED
#include "../include/IAudioDecoder.h" #include "../include/IAudioDecoder.h"
#include "../Headers/cMemoryOverride.h" #include "../Headers/cMemoryOverride.h"
namespace cAudio namespace cAudio
{ {
class cRawDecoder : public IAudioDecoder, public cMemoryOverride class cRawDecoder : public IAudioDecoder, public cMemoryOverride
{ {
public: public:
cRawDecoder(IDataSource* stream, unsigned int frequency, AudioFormats format); cRawDecoder(IDataSource* stream, unsigned int frequency, AudioFormats format);
~cRawDecoder(); ~cRawDecoder();
virtual AudioFormats getFormat(); virtual AudioFormats getFormat();
virtual int getFrequency(); virtual int getFrequency();
virtual bool isSeekingSupported(); virtual bool isSeekingSupported();
virtual bool isValid(); virtual bool isValid();
virtual int readAudioData(void* output, int amount); virtual int readAudioData(void* output, int amount);
virtual bool setPosition(int position, bool relative); virtual bool setPosition(int position, bool relative);
virtual bool seek(float seconds,bool relative); virtual bool seek(float seconds,bool relative);
virtual float getTotalTime(); virtual float getTotalTime();
virtual int getTotalSize(); virtual int getTotalSize();
virtual int getCompressedSize(); virtual int getCompressedSize();
virtual float getCurrentTime(); virtual float getCurrentTime();
virtual int getCurrentPosition(); virtual int getCurrentPosition();
virtual int getCurrentCompressedPosition(); virtual int getCurrentCompressedPosition();
private: private:
unsigned int Frequency; unsigned int Frequency;
AudioFormats Format; AudioFormats Format;
}; };
}; };
#endif //! CRAWDECODER_H_INCLUDED #endif //! CRAWDECODER_H_INCLUDED

View File

@ -1,18 +1,18 @@
#ifndef CSTANDARDMEMORYPROVIDER_H_INCLUDED #ifndef CSTANDARDMEMORYPROVIDER_H_INCLUDED
#define CSTANDARDMEMORYPROVIDER_H_INCLUDED #define CSTANDARDMEMORYPROVIDER_H_INCLUDED
#include "../include/IMemoryProvider.h" #include "../include/IMemoryProvider.h"
#include <cstring> #include <cstring>
namespace cAudio namespace cAudio
{ {
//! Memory provider that wraps the standard memalloc and free //! Memory provider that wraps the standard memalloc and free
class cStandardMemoryProvider : public IMemoryProvider class cStandardMemoryProvider : public IMemoryProvider
{ {
public: public:
virtual void* Allocate(size_t size, const char* filename, int line, const char* function); virtual void* Allocate(size_t size, const char* filename, int line, const char* function);
virtual void Free(void* pointer); virtual void Free(void* pointer);
virtual size_t getMaxAllocationSize(); virtual size_t getMaxAllocationSize();
}; };
}; };
#endif //! CSTANDARDMEMORYPROVIDER_H_INCLUDED #endif //! CSTANDARDMEMORYPROVIDER_H_INCLUDED

View File

@ -1,34 +1,34 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef CAUDIOTHREAD_H #ifndef CAUDIOTHREAD_H
#define CAUDIOTHREAD_H #define CAUDIOTHREAD_H
#include "../include/cAudioDefines.h" #include "../include/cAudioDefines.h"
//Helper defines in order to make sure the function is declared right for use as a thread //Helper defines in order to make sure the function is declared right for use as a thread
#ifdef CAUDIO_PLATFORM_WIN #ifdef CAUDIO_PLATFORM_WIN
#define CAUDIO_DECLARE_THREAD_FUNCTION(functionName) unsigned __stdcall functionName( void* arguments ) #define CAUDIO_DECLARE_THREAD_FUNCTION(functionName) unsigned __stdcall functionName( void* arguments )
#else #else
#define CAUDIO_DECLARE_THREAD_FUNCTION(functionName) void* functionName( void* arguments ) #define CAUDIO_DECLARE_THREAD_FUNCTION(functionName) void* functionName( void* arguments )
#endif #endif
namespace cAudio namespace cAudio
{ {
class cAudioThread class cAudioThread
{ {
public: public:
// Really basic function to spawn a single detached thread // Really basic function to spawn a single detached thread
/** \param start_address The function you want to call /** \param start_address The function you want to call
// \param arg Any arguments to pass to the function // \param arg Any arguments to pass to the function
// \return 0 if successful, otherwise an error */ // \return 0 if successful, otherwise an error */
#ifdef CAUDIO_PLATFORM_WIN #ifdef CAUDIO_PLATFORM_WIN
static int SpawnThread( unsigned __stdcall start_address( void* ), void *arg); static int SpawnThread( unsigned __stdcall start_address( void* ), void *arg);
#else #else
static int SpawnThread( void* start_address( void* ), void *arg); static int SpawnThread( void* start_address( void* ), void *arg);
#endif #endif
}; };
}; };
#endif //! CAUDIOTHREAD_H #endif //! CAUDIOTHREAD_H

View File

@ -1,83 +1,86 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef CUTILS_H_INCLUDED #ifndef CUTILS_H_INCLUDED
#define CUTILS_H_INCLUDED #define CUTILS_H_INCLUDED
#include "../include/cAudioPlatform.h" #include "../include/cAudioPlatform.h"
#include "../Headers/cSTLAllocator.h" #include "../include/cSTLAllocator.h"
#include "../include/cAudioString.h"
#ifdef CAUDIO_PLATFORM_WIN
# define WIN32_LEAN_AND_MEAN #ifdef CAUDIO_PLATFORM_WIN
# include <windows.h> # define WIN32_LEAN_AND_MEAN
# include <direct.h> # include <windows.h>
# include <io.h> # include <direct.h>
#endif # include <io.h>
#endif
#ifdef CAUDIO_PLATFORM_LINUX
# include <dirent.h> #ifdef CAUDIO_PLATFORM_LINUX
# include <stdio.h> # include <dirent.h>
# include <cstring> # include <stdio.h>
#endif # include <cstring>
#endif
namespace cAudio
{ namespace cAudio
{
//! Grabs the current extention of a given string.
static cAudioString getExt(const cAudioString& filename) //! Grabs the current extention of a given string.
{ static cAudioString getExt(const cAudioString& filename)
if(filename.find_last_of(".") == cAudioString::npos) return filename; {
return filename.substr(filename.find_last_of(".") + 1, filename.length()-filename.find_last_of(".")-1); if(filename.find_last_of(_CTEXT(".")) == cAudioString::npos) return filename;
} return filename.substr(filename.find_last_of(_CTEXT(".")) + 1, filename.length()-filename.find_last_of(_CTEXT("."))-1);
}
//! Prevents a bug with NULL passed into cAudioString.
static cAudioString safeCStr(const char* str) //! Prevents a bug with NULL passed into cAudioString.
{
if( str != NULL ) return cAudioString(str); static cAudioString safeCStr(const char* str)
else return cAudioString(""); {
} if( str != NULL ) return cAudioString(str);
else return cAudioString("");
//! Returns a list of files/directories in the supplied directory. Used internally for auto-installation of plugins. }
static cAudioVector<cAudioString>::Type getFilesInDirectory(cAudioString path)
{
cAudioVector<cAudioString>::Type FileList; //! Returns a list of files/directories in the supplied directory. Used internally for auto-installation of plugins.
#ifdef CAUDIO_PLATFORM_WIN static cAudioVector<cAudioString>::Type getFilesInDirectory(cAudioString path)
cAudioString search = path + "\\" + cAudioString("*.*"); {
WIN32_FIND_DATA info; cAudioVector<cAudioString>::Type FileList;
HANDLE h = FindFirstFile(search.c_str(), &info); #ifdef CAUDIO_PLATFORM_WIN
if (h != INVALID_HANDLE_VALUE) cAudioString search = path + _CTEXT("\\") + cAudioString(_CTEXT("*.*"));
{ WIN32_FIND_DATA info;
do HANDLE h = FindFirstFile(search.c_str(), &info);
{ if (h != INVALID_HANDLE_VALUE)
if (!(strcmp(info.cFileName, ".") == 0 || strcmp(info.cFileName, "..") == 0)) {
{ do
FileList.push_back(info.cFileName); {
} if (!(cstrcmp(info.cFileName, _CTEXT(".")) == 0 || cstrcmp(info.cFileName, _CTEXT("..")) == 0))
} while (FindNextFile(h, &info)); {
FindClose(h); FileList.push_back(info.cFileName);
} }
#endif } while (FindNextFile(h, &info));
FindClose(h);
#ifdef CAUDIO_PLATFORM_LINUX }
DIR *d; #endif
struct dirent *dir;
d = opendir(path.c_str()); #ifdef CAUDIO_PLATFORM_LINUX
if (d) DIR *d;
{ struct dirent *dir;
while ((dir = readdir(d)) != NULL) d = opendir(path.c_str());
{ if (d)
if( strcmp( dir->d_name, "." ) == 0 || strcmp( dir->d_name, ".." ) == 0 ) { continue; } {
if( dir->d_type == DT_DIR ) continue; while ((dir = readdir(d)) != NULL)
FileList.push_back(dir->d_name); {
} if( strcmp( dir->d_name, "." ) == 0 || strcmp( dir->d_name, ".." ) == 0 ) { continue; }
if( dir->d_type == DT_DIR ) continue;
closedir(d); FileList.push_back(dir->d_name);
} }
#endif
closedir(d);
return FileList; }
} #endif
}; return FileList;
}
#endif //! CUTILS_H_INCLUDED
};
#endif //! CUTILS_H_INCLUDED

View File

@ -1,39 +1,39 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef CWAVAUDIODECODERFACOTRY_H_INCLUDED #ifndef CWAVAUDIODECODERFACOTRY_H_INCLUDED
#define CWAVAUDIODECODERFACOTRY_H_INCLUDED #define CWAVAUDIODECODERFACOTRY_H_INCLUDED
#include "../include/IAudioDecoderFactory.h" #include "../include/IAudioDecoderFactory.h"
#include "cWavDecoder.h" #include "cWavDecoder.h"
#include "../Headers/cMutex.h" #include "../Headers/cMutex.h"
#ifdef CAUDIO_COMPILE_WITH_WAV_DECODER #ifdef CAUDIO_COMPILE_WITH_WAV_DECODER
namespace cAudio namespace cAudio
{ {
class cWavAudioDecoderFactory : public IAudioDecoderFactory class cWavAudioDecoderFactory : public IAudioDecoderFactory
{ {
public: public:
cWavAudioDecoderFactory() {} cWavAudioDecoderFactory() {}
~cWavAudioDecoderFactory() {} ~cWavAudioDecoderFactory() {}
IAudioDecoder* CreateAudioDecoder(IDataSource* stream) IAudioDecoder* CreateAudioDecoder(IDataSource* stream)
{ {
Mutex.lock(); Mutex.lock();
IAudioDecoder* decoder = CAUDIO_NEW cWavDecoder(stream); IAudioDecoder* decoder = CAUDIO_NEW cWavDecoder(stream);
Mutex.unlock(); Mutex.unlock();
return decoder; return decoder;
} }
protected: protected:
cAudioMutex Mutex; cAudioMutex Mutex;
private: private:
}; };
}; };
#endif #endif
#endif //! CWAVAUDIODECODERFACOTRY_H_INCLUDED #endif //! CWAVAUDIODECODERFACOTRY_H_INCLUDED

View File

@ -1,53 +1,53 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef CWAVDECODER_H_INCLUDED #ifndef CWAVDECODER_H_INCLUDED
#define CWAVDECODER_H_INCLUDED #define CWAVDECODER_H_INCLUDED
#include "../include/IAudioDecoder.h" #include "../include/IAudioDecoder.h"
#include "../include/cAudioDefines.h" #include "../include/cAudioDefines.h"
#include "../Headers/cMemoryOverride.h" #include "../Headers/cMemoryOverride.h"
#ifdef CAUDIO_COMPILE_WITH_WAV_DECODER #ifdef CAUDIO_COMPILE_WITH_WAV_DECODER
namespace cAudio namespace cAudio
{ {
class cWavDecoder : public IAudioDecoder, public cMemoryOverride class cWavDecoder : public IAudioDecoder, public cMemoryOverride
{ {
public: public:
cWavDecoder(IDataSource* stream); cWavDecoder(IDataSource* stream);
~cWavDecoder(); ~cWavDecoder();
virtual AudioFormats getFormat(); virtual AudioFormats getFormat();
virtual int getFrequency(); virtual int getFrequency();
virtual bool isSeekingSupported(); virtual bool isSeekingSupported();
virtual bool isValid(); virtual bool isValid();
virtual int readAudioData(void* output, int amount); virtual int readAudioData(void* output, int amount);
virtual bool setPosition(int position, bool relative); virtual bool setPosition(int position, bool relative);
virtual bool seek(float seconds,bool relative); virtual bool seek(float seconds,bool relative);
virtual float getTotalTime(); virtual float getTotalTime();
virtual int getTotalSize(); virtual int getTotalSize();
virtual int getCompressedSize(); virtual int getCompressedSize();
virtual float getCurrentTime(); virtual float getCurrentTime();
virtual int getCurrentPosition(); virtual int getCurrentPosition();
virtual int getCurrentCompressedPosition(); virtual int getCurrentCompressedPosition();
private: private:
short Channels; short Channels;
int SampleRate; int SampleRate;
int ByteRate; int ByteRate;
short BlockAlign; short BlockAlign;
short BitsPerSample; short BitsPerSample;
int DataSize; int DataSize;
int DataOffset; int DataOffset;
bool Valid; bool Valid;
}; };
}; };
#endif #endif
#endif //! CFLACDECODER_H_INCLUDED #endif //! CFLACDECODER_H_INCLUDED

View File

@ -22,7 +22,6 @@ set (file_root_header_files
Headers/cRawAudioDecoderFactory.h Headers/cRawAudioDecoderFactory.h
Headers/cRawDecoder.h Headers/cRawDecoder.h
Headers/cStandardMemoryProvider.h Headers/cStandardMemoryProvider.h
Headers/cSTLAllocator.h
Headers/cThread.h Headers/cThread.h
Headers/cWavAudioDecoderFactory.h Headers/cWavAudioDecoderFactory.h
Headers/cWavDecoder.h Headers/cWavDecoder.h
@ -33,6 +32,8 @@ set (file_root_include
include/cAudioMemory.h include/cAudioMemory.h
include/cAudioPlatform.h include/cAudioPlatform.h
include/cAudioSleep.h include/cAudioSleep.h
include/cAudioString.h
include/cSTLAllocator.h
include/EAudioFormats.h include/EAudioFormats.h
include/IAudioCapture.h include/IAudioCapture.h
include/IAudioDecoder.h include/IAudioDecoder.h

View File

@ -1,20 +1,20 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef EAUDIOFORMATS_H #ifndef EAUDIOFORMATS_H
#define EAUDIOFORMATS_H #define EAUDIOFORMATS_H
namespace cAudio namespace cAudio
{ {
//! Enumeration of audio formats supported by the engine. //! Enumeration of audio formats supported by the engine.
enum AudioFormats enum AudioFormats
{ {
EAF_8BIT_MONO, EAF_8BIT_MONO,
EAF_8BIT_STEREO, EAF_8BIT_STEREO,
EAF_16BIT_MONO, EAF_16BIT_MONO,
EAF_16BIT_STEREO EAF_16BIT_STEREO
}; };
}; };
#endif //! EAUDIOFORMATS_H #endif //! EAUDIOFORMATS_H

View File

@ -1,135 +1,135 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef IAUDIOCAPTURE_H #ifndef IAUDIOCAPTURE_H
#define IAUDIOCAPTURE_H #define IAUDIOCAPTURE_H
#include "EAudioFormats.h" #include "EAudioFormats.h"
#include "cAudioDefines.h" #include "cAudioDefines.h"
#include "ICaptureEventHandler.h" #include "ICaptureEventHandler.h"
namespace cAudio namespace cAudio
{ {
//! Interface for capturing operations in the cAudio Engine. //! Interface for capturing operations in the cAudio Engine.
class IAudioCapture class IAudioCapture
{ {
public: public:
IAudioCapture() { } IAudioCapture() { }
virtual ~IAudioCapture() { } virtual ~IAudioCapture() { }
//! Initializes the capture device to the selected settings. //! Initializes the capture device to the selected settings.
/** Note that calling this will cause the capture device to be reinitialized. Calling while in use will clear the internal audio buffer. /** Note that calling this will cause the capture device to be reinitialized. Calling while in use will clear the internal audio buffer.
\param deviceName: Name of the audio device to capture audio from, pass NULL to specify the default one. \param deviceName: Name of the audio device to capture audio from, pass NULL to specify the default one.
\param frequency: Frequency that the captured audio will be captured at in hertz. \param frequency: Frequency that the captured audio will be captured at in hertz.
\param format: Format of the captured audio. \param format: Format of the captured audio.
\param internalBufferSize: Size of the internal OpenAL buffer used to store the captured audio between calls to getCapturedAudio() in bytes. \param internalBufferSize: Size of the internal OpenAL buffer used to store the captured audio between calls to getCapturedAudio() in bytes.
\return True on success, False if the capture device failed to initialize. \return True on success, False if the capture device failed to initialize.
*/ */
virtual bool initialize(const char* deviceName = 0x0, unsigned int frequency = 22050, AudioFormats format = EAF_16BIT_MONO, unsigned int internalBufferSize = 8192) = 0; virtual bool initialize(const char* deviceName = 0x0, unsigned int frequency = 22050, AudioFormats format = EAF_16BIT_MONO, unsigned int internalBufferSize = 8192) = 0;
//! Returns true if the current OpenAL implementation supports capturing audio. //! Returns true if the current OpenAL implementation supports capturing audio.
virtual bool isSupported() = 0; virtual bool isSupported() = 0;
//! Returns true if the capture device is ready to be used. False may indicate an error with the current settings. //! Returns true if the capture device is ready to be used. False may indicate an error with the current settings.
virtual bool isReady() = 0; virtual bool isReady() = 0;
//! Grabs samples from the OpenAL buffer into the capture buffer if the OpenAL buffer has reached half full. Should be run once every audio frame, unless threading is enabled. //! Grabs samples from the OpenAL buffer into the capture buffer if the OpenAL buffer has reached half full. Should be run once every audio frame, unless threading is enabled.
/** \param force: Force capturing data from the buffer, even if the buffer is not half full. */ /** \param force: Force capturing data from the buffer, even if the buffer is not half full. */
virtual void updateCaptureBuffer(bool force = false) = 0; virtual void updateCaptureBuffer(bool force = false) = 0;
//! Shuts down the capture device, clearing the internal buffer and setting the audio capture into an uninitialized state. You must call initialize() again in order to reuse this object. //! Shuts down the capture device, clearing the internal buffer and setting the audio capture into an uninitialized state. You must call initialize() again in order to reuse this object.
virtual void shutdown() = 0; virtual void shutdown() = 0;
//! Returns the name of an available capture device. //! Returns the name of an available capture device.
/** \param index: Specify which name to retrieve ( Range: 0 to getAvailableDeviceCount()-1 ). /** \param index: Specify which name to retrieve ( Range: 0 to getAvailableDeviceCount()-1 ).
\return Name of the selected device. */ \return Name of the selected device. */
virtual const char* getAvailableDeviceName(unsigned int index) = 0; virtual const char* getAvailableDeviceName(unsigned int index) = 0;
//! Returns the number of capture devices available for use. //! Returns the number of capture devices available for use.
/** \return Number of capture devices available. */ /** \return Number of capture devices available. */
virtual unsigned int getAvailableDeviceCount() = 0; virtual unsigned int getAvailableDeviceCount() = 0;
//! Returns the name of the default system playback device. //! Returns the name of the default system playback device.
/** \return Name of the default capture device. */ /** \return Name of the default capture device. */
virtual const char* getDefaultDeviceName() = 0; virtual const char* getDefaultDeviceName() = 0;
//! Returns the name of the audio device being used to capture audio. //! Returns the name of the audio device being used to capture audio.
virtual const char* getDeviceName() = 0; virtual const char* getDeviceName() = 0;
//! Returns the frequency that the captured audio will be at. //! Returns the frequency that the captured audio will be at.
virtual unsigned int getFrequency() = 0; virtual unsigned int getFrequency() = 0;
//! Returns the format of the captured audio. //! Returns the format of the captured audio.
virtual AudioFormats getFormat() = 0; virtual AudioFormats getFormat() = 0;
//! Returns the internal OpenAL buffer size in bytes. //! Returns the internal OpenAL buffer size in bytes.
/** \return Size of the buffer in bytes. */ /** \return Size of the buffer in bytes. */
virtual unsigned int getInternalBufferSize() = 0; virtual unsigned int getInternalBufferSize() = 0;
//! Returns the size of a "sample" of audio data. Useful for making sure you grab audio data at sample boundaries. //! Returns the size of a "sample" of audio data. Useful for making sure you grab audio data at sample boundaries.
/** \return Size of a sample in bytes. */ /** \return Size of a sample in bytes. */
virtual unsigned int getSampleSize() = 0; virtual unsigned int getSampleSize() = 0;
//! Sets the audio device . Will cause the capture device to be reinitialized. Calling while in use will clear the internal audio buffer. //! Sets the audio device . Will cause the capture device to be reinitialized. Calling while in use will clear the internal audio buffer.
/** /**
\param deviceName: Name of the audio device to capture audio from, pass NULL to specify the default one. \param deviceName: Name of the audio device to capture audio from, pass NULL to specify the default one.
\return True on success, False if the capture device failed to initialize. */ \return True on success, False if the capture device failed to initialize. */
virtual bool setDevice(const char* deviceName) = 0; virtual bool setDevice(const char* deviceName) = 0;
//! Sets the frequency that the captured audio will be at. Will cause the capture device to be reinitialized. Calling while in use will clear the internal audio buffer. //! Sets the frequency that the captured audio will be at. Will cause the capture device to be reinitialized. Calling while in use will clear the internal audio buffer.
/** /**
\param frequency: Frequency that the captured audio will be captured at in hertz. \param frequency: Frequency that the captured audio will be captured at in hertz.
\return True on success, False if the capture device failed to initialize. */ \return True on success, False if the capture device failed to initialize. */
virtual bool setFrequency(unsigned int frequency) = 0; virtual bool setFrequency(unsigned int frequency) = 0;
//! Sets the format that the captured audio will be at. Will cause the capture device to be reinitialized. Calling while in use will clear the internal audio buffer. //! Sets the format that the captured audio will be at. Will cause the capture device to be reinitialized. Calling while in use will clear the internal audio buffer.
/** /**
\param format: Format of the captured audio. \param format: Format of the captured audio.
\return True on success, False if the capture device failed to initialize. */ \return True on success, False if the capture device failed to initialize. */
virtual bool setFormat(AudioFormats format) = 0; virtual bool setFormat(AudioFormats format) = 0;
//! Sets the internal buffer size that OpenAL will use to store captured audio between calls to getCapturedAudio() in bytes. Will cause the capture device to be reinitialized. Calling while in use will clear the internal audio buffer. //! Sets the internal buffer size that OpenAL will use to store captured audio between calls to getCapturedAudio() in bytes. Will cause the capture device to be reinitialized. Calling while in use will clear the internal audio buffer.
/** /**
\param internalBufferSize: Size of the internal OpenAL buffer in bytes. \param internalBufferSize: Size of the internal OpenAL buffer in bytes.
\return True on success, False if the capture device failed to initialize. */ \return True on success, False if the capture device failed to initialize. */
virtual bool setInternalBufferSize(unsigned int internalBufferSize) = 0; virtual bool setInternalBufferSize(unsigned int internalBufferSize) = 0;
//! Starts capturing audio data to an internal buffer. Will clear any old data in the buffer. //! Starts capturing audio data to an internal buffer. Will clear any old data in the buffer.
/** \return True if capture was successfully started. */ /** \return True if capture was successfully started. */
virtual bool beginCapture() = 0; virtual bool beginCapture() = 0;
//! Stops capturing audio data to an internal buffer. //! Stops capturing audio data to an internal buffer.
virtual void stopCapture() = 0; virtual void stopCapture() = 0;
//! Allows access to the audio data in the internal capture buffer. //! Allows access to the audio data in the internal capture buffer.
/** Can be called at any time to retrieve recorded audio. It is recommended that you call it every so often with long recordings to prevent the internal buffer from growing too large. /** Can be called at any time to retrieve recorded audio. It is recommended that you call it every so often with long recordings to prevent the internal buffer from growing too large.
Once successfully retrieved, the captured audio will be deleted from the internal buffer. Once successfully retrieved, the captured audio will be deleted from the internal buffer.
\param outputBuffer: Pointer to an output array to copy audio data to. \param outputBuffer: Pointer to an output array to copy audio data to.
\param outputBufferSize: Size of the output array in bytes. \param outputBufferSize: Size of the output array in bytes.
\return Size in bytes of the data actually copied to the output buffer. \return Size in bytes of the data actually copied to the output buffer.
*/ */
virtual unsigned int getCapturedAudio(void* outputBuffer, unsigned int outputBufferSize) = 0; virtual unsigned int getCapturedAudio(void* outputBuffer, unsigned int outputBufferSize) = 0;
//! Returns the current size of the internal audio buffer in bytes. //! Returns the current size of the internal audio buffer in bytes.
virtual unsigned int getCurrentCapturedAudioSize() = 0; virtual unsigned int getCurrentCapturedAudioSize() = 0;
//!Registers a new event handler to this manager. //!Registers a new event handler to this manager.
/** \param handler: Pointer to an event handler to attach. */ /** \param handler: Pointer to an event handler to attach. */
virtual void registerEventHandler(ICaptureEventHandler* handler) = 0; virtual void registerEventHandler(ICaptureEventHandler* handler) = 0;
//!Removes the specified event handler from this manager. //!Removes the specified event handler from this manager.
/** \param handler: Pointer to an event handler to remove. */ /** \param handler: Pointer to an event handler to remove. */
virtual void unRegisterEventHandler(ICaptureEventHandler* handler) = 0; virtual void unRegisterEventHandler(ICaptureEventHandler* handler) = 0;
//!Removes all event handlers attached to this manager. //!Removes all event handlers attached to this manager.
virtual void unRegisterAllEventHandlers() = 0; virtual void unRegisterAllEventHandlers() = 0;
}; };
//! Creates an interface to an Audio Capture Object. //! Creates an interface to an Audio Capture Object.
/** Note: This is the only way to get access to the audio capture capabilities of cAudio. /** Note: This is the only way to get access to the audio capture capabilities of cAudio.
You must delete this interface using destroyAudioCapture() once you are done with it. You must delete this interface using destroyAudioCapture() once you are done with it.
\param initializeDefault: Whether to return an object initialized with the default settings. If set to false, you must make a call to initialize before audio can be captured. \param initializeDefault: Whether to return an object initialized with the default settings. If set to false, you must make a call to initialize before audio can be captured.
\return A pointer to the created object, NULL if the object could not be allocated. \return A pointer to the created object, NULL if the object could not be allocated.
*/ */
CAUDIO_API IAudioCapture* createAudioCapture(bool initializeDefault = true); CAUDIO_API IAudioCapture* createAudioCapture(bool initializeDefault = true);
//! Destroys an interface to a previously created Audio Capture Object and frees the memory allocated for it. //! Destroys an interface to a previously created Audio Capture Object and frees the memory allocated for it.
/** /**
\param capture: The object to destroy \param capture: The object to destroy
*/ */
CAUDIO_API void destroyAudioCapture(IAudioCapture* capture); CAUDIO_API void destroyAudioCapture(IAudioCapture* capture);
//! Returns if the thread used to update all Audio Capture Objects is running. //! Returns if the thread used to update all Audio Capture Objects is running.
/** Note: Will always return false if threading is disabled. /** Note: Will always return false if threading is disabled.
The library automatically shuts down the thread if no Audio Capture objects exist and will restart the thread on creation of a new object. The library automatically shuts down the thread if no Audio Capture objects exist and will restart the thread on creation of a new object.
\return True if the thread is currently running, false otherwise. \return True if the thread is currently running, false otherwise.
*/ */
CAUDIO_API bool isAudioCaptureThreadRunning(); CAUDIO_API bool isAudioCaptureThreadRunning();
}; };
#endif //! IAUDIOCAPTURE_H #endif //! IAUDIOCAPTURE_H

View File

@ -1,79 +1,79 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef IAUDIODECODER_H #ifndef IAUDIODECODER_H
#define IAUDIODECODER_H #define IAUDIODECODER_H
#include "IRefCounted.h" #include "IRefCounted.h"
#include "IDataSource.h" #include "IDataSource.h"
#include "EAudioFormats.h" #include "EAudioFormats.h"
namespace cAudio namespace cAudio
{ {
//! Interface for all Audio Decoders in cAudio //! Interface for all Audio Decoders in cAudio
class IAudioDecoder : public IRefCounted class IAudioDecoder : public IRefCounted
{ {
public: public:
//! Default Constructor //! Default Constructor
/** \param stream: Data Source to attach to this decoder. */ /** \param stream: Data Source to attach to this decoder. */
IAudioDecoder(IDataSource* stream) : Stream(stream) { if(Stream) Stream->grab(); } IAudioDecoder(IDataSource* stream) : Stream(stream) { if(Stream) Stream->grab(); }
virtual ~IAudioDecoder() { if(Stream) Stream->drop(); } virtual ~IAudioDecoder() { if(Stream) Stream->drop(); }
//! Returns the format of the audio data //! Returns the format of the audio data
virtual AudioFormats getFormat() = 0; virtual AudioFormats getFormat() = 0;
//! Returns the frequency (sample rate) of the audio data //! Returns the frequency (sample rate) of the audio data
virtual int getFrequency() = 0; virtual int getFrequency() = 0;
//! Returns whether seeking is supported //! Returns whether seeking is supported
virtual bool isSeekingSupported() = 0; virtual bool isSeekingSupported() = 0;
//! Returns whether the stream is valid for this codec //! Returns whether the stream is valid for this codec
virtual bool isValid() = 0; virtual bool isValid() = 0;
//! Reads a section of data out of the audio stream //! Reads a section of data out of the audio stream
/** /**
\param output: Pointer to the buffer to put the decoded audio. \param output: Pointer to the buffer to put the decoded audio.
\param amount: Amount of data in bytes to ask the decoder to output. \param amount: Amount of data in bytes to ask the decoder to output.
\return Number of bytes of audio data actually output. */ \return Number of bytes of audio data actually output. */
virtual int readAudioData(void* output, int amount) = 0; virtual int readAudioData(void* output, int amount) = 0;
//! Sets the position in the stream to read from //! Sets the position in the stream to read from
/** /**
\param position: Position to seek to. \param position: Position to seek to.
\param relative: Whether the number in position is relative to the current position. \param relative: Whether the number in position is relative to the current position.
\return True on success, False on failure. */ \return True on success, False on failure. */
virtual bool setPosition(int position, bool relative) = 0; virtual bool setPosition(int position, bool relative) = 0;
//! If seeking is supported, will seek the stream to seconds //! If seeking is supported, will seek the stream to seconds
/** /**
\param seconds: Time in seconds to seek. \param seconds: Time in seconds to seek.
\param relative: Whether the number in position is relative to the current position. \param relative: Whether the number in position is relative to the current position.
\return True on success, False on failure. */ \return True on success, False on failure. */
virtual bool seek(float seconds, bool relative) = 0; virtual bool seek(float seconds, bool relative) = 0;
//! If seeking is supported, will return the length of the audio steam in seconds. Returns a negative number if the total time cannot be determined. //! If seeking is supported, will return the length of the audio steam in seconds. Returns a negative number if the total time cannot be determined.
virtual float getTotalTime() = 0; virtual float getTotalTime() = 0;
//! If available, returns the total decoded size of the audio stream. Returns a negative number if this cannot be determined. //! If available, returns the total decoded size of the audio stream. Returns a negative number if this cannot be determined.
virtual int getTotalSize() = 0; virtual int getTotalSize() = 0;
//! Returns the compressed (original) size of the audio stream, before decoding. //! Returns the compressed (original) size of the audio stream, before decoding.
virtual int getCompressedSize() = 0; virtual int getCompressedSize() = 0;
//! If seeking is supported, will return the current position in the stream in seconds. Returns a negative number if the current time cannot be determined. //! If seeking is supported, will return the current position in the stream in seconds. Returns a negative number if the current time cannot be determined.
virtual float getCurrentTime() = 0; virtual float getCurrentTime() = 0;
//! If available, returns the current position in the decoded audio stream in bytes. Returns a negative number if this cannot be determined. //! If available, returns the current position in the decoded audio stream in bytes. Returns a negative number if this cannot be determined.
virtual int getCurrentPosition() = 0; virtual int getCurrentPosition() = 0;
//! Returns the position in the compressed (original) audio stream before decoding. //! Returns the position in the compressed (original) audio stream before decoding.
virtual int getCurrentCompressedPosition() = 0; virtual int getCurrentCompressedPosition() = 0;
protected: protected:
//! Pointer to the data source to take audio data from. //! Pointer to the data source to take audio data from.
IDataSource* Stream; IDataSource* Stream;
}; };
}; };
#endif //! IAUDIODECODER_H #endif //! IAUDIODECODER_H

View File

@ -1,29 +1,29 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef IAUDIODECODERFACTORY_H #ifndef IAUDIODECODERFACTORY_H
#define IAUDIODECODERFACTORY_H #define IAUDIODECODERFACTORY_H
#include "IAudioDecoder.h" #include "IAudioDecoder.h"
namespace cAudio namespace cAudio
{ {
//! Interface for factories that create Audio Decoders for cAudio //! Interface for factories that create Audio Decoders for cAudio
class IAudioDecoderFactory class IAudioDecoderFactory
{ {
public: public:
IAudioDecoderFactory() {} IAudioDecoderFactory() {}
virtual ~IAudioDecoderFactory() {} virtual ~IAudioDecoderFactory() {}
//! Returns an audio decoder. //! Returns an audio decoder.
/** /**
\param stream: Data Source to attach to this decoder. \param stream: Data Source to attach to this decoder.
\return A pointer to a decoder instance, or NULL on failure to allocate. */ \return A pointer to a decoder instance, or NULL on failure to allocate. */
virtual IAudioDecoder* CreateAudioDecoder(IDataSource* stream) = 0; virtual IAudioDecoder* CreateAudioDecoder(IDataSource* stream) = 0;
protected: protected:
private: private:
}; };
}; };
#endif //! IAUDIODECODERFACTORY_H #endif //! IAUDIODECODERFACTORY_H

View File

@ -1,240 +1,240 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef IAUDIOEFFECTS_H #ifndef IAUDIOEFFECTS_H
#define IAUDIOEFFECTS_H #define IAUDIOEFFECTS_H
#include "IEffect.h" #include "IEffect.h"
#include "IFilter.h" #include "IFilter.h"
#include "cAudioDefines.h" #include "cAudioDefines.h"
#ifdef CAUDIO_EFX_ENABLED #ifdef CAUDIO_EFX_ENABLED
namespace cAudio namespace cAudio
{ {
//! Interface for Audio Effects in cAudio. //! Interface for Audio Effects in cAudio.
class IAudioEffects class IAudioEffects
{ {
public: public:
IAudioEffects() {} IAudioEffects() {}
virtual ~IAudioEffects() {} virtual ~IAudioEffects() {}
//! Creates an Audio Effect for use with audio sources. //! Creates an Audio Effect for use with audio sources.
/** \return Pointer to the created Effect instance. */ /** \return Pointer to the created Effect instance. */
virtual IEffect* createEffect() = 0; virtual IEffect* createEffect() = 0;
//! Creates an Audio Filter for use with audio sources. //! Creates an Audio Filter for use with audio sources.
/** \return Pointer to the created Filter instance. */ /** \return Pointer to the created Filter instance. */
virtual IFilter* createFilter() = 0; virtual IFilter* createFilter() = 0;
//! Returns the max number of effects supported. //! Returns the max number of effects supported.
virtual unsigned int getMaxEffectsSupported() const = 0; virtual unsigned int getMaxEffectsSupported() const = 0;
//! Checks to see if the given effect type is supported. //! Checks to see if the given effect type is supported.
/** /**
\param type: the effect type to be checked. \param type: the effect type to be checked.
\return True if the effect is supported, False if the effect isn't supported. */ \return True if the effect is supported, False if the effect isn't supported. */
virtual bool isEffectSupported(const EffectTypes& type) const = 0; virtual bool isEffectSupported(const EffectTypes& type) const = 0;
//! Checks to see if the given filter type is supported. //! Checks to see if the given filter type is supported.
/** /**
\param type: the filter type to be checked. \param type: the filter type to be checked.
\return True if the filter is supported, False if the filter isn't supported. */ \return True if the filter is supported, False if the filter isn't supported. */
virtual bool isFilterSupported(const FilterTypes& type) const = 0; virtual bool isFilterSupported(const FilterTypes& type) const = 0;
//! Adds a preset for the EAX Reverb Audio Effect type. //! Adds a preset for the EAX Reverb Audio Effect type.
/** /**
\param name: Name of the preset. \param name: Name of the preset.
\param setting: Instance of the Effect parameter struct for this type of effect. \param setting: Instance of the Effect parameter struct for this type of effect.
\return True on success, False on failure. */ \return True on success, False on failure. */
virtual bool addEAXReverbEffectPreset(const char* name, const sEAXReverbParameters& setting) = 0; virtual bool addEAXReverbEffectPreset(const char* name, const sEAXReverbParameters& setting) = 0;
//! Adds a preset for the Reverb Audio Effect type. //! Adds a preset for the Reverb Audio Effect type.
/** /**
\param name: Name of the preset. \param name: Name of the preset.
\param setting: Instance of the Effect parameter struct for this type of effect. \param setting: Instance of the Effect parameter struct for this type of effect.
\return True on success, False on failure. */ \return True on success, False on failure. */
virtual bool addReverbEffectPreset(const char* name, const sReverbParameters& setting) = 0; virtual bool addReverbEffectPreset(const char* name, const sReverbParameters& setting) = 0;
//! Adds a preset for the Chorus Audio Effect type. //! Adds a preset for the Chorus Audio Effect type.
/** /**
\param name: Name of the preset. \param name: Name of the preset.
\param setting: Instance of the Effect parameter struct for this type of effect. \param setting: Instance of the Effect parameter struct for this type of effect.
\return True on success, False on failure. */ \return True on success, False on failure. */
virtual bool addChorusEffectPreset(const char* name, const sChorusParameters& setting) = 0; virtual bool addChorusEffectPreset(const char* name, const sChorusParameters& setting) = 0;
//! Adds a preset for the Distortion Audio Effect type. //! Adds a preset for the Distortion Audio Effect type.
/** /**
\param name: Name of the preset. \param name: Name of the preset.
\param setting: Instance of the Effect parameter struct for this type of effect. \param setting: Instance of the Effect parameter struct for this type of effect.
\return True on success, False on failure. */ \return True on success, False on failure. */
virtual bool addDistortionEffectPreset(const char* name, const sDistortionParameters& setting) = 0; virtual bool addDistortionEffectPreset(const char* name, const sDistortionParameters& setting) = 0;
//! Adds a preset for the Echo Audio Effect type. //! Adds a preset for the Echo Audio Effect type.
/** /**
\param name: Name of the preset. \param name: Name of the preset.
\param setting: Instance of the Effect parameter struct for this type of effect. \param setting: Instance of the Effect parameter struct for this type of effect.
\return True on success, False on failure. */ \return True on success, False on failure. */
virtual bool addEchoEffectPreset(const char* name, const sEchoParameters& setting) = 0; virtual bool addEchoEffectPreset(const char* name, const sEchoParameters& setting) = 0;
//! Adds a preset for the Flanger Audio Effect type. //! Adds a preset for the Flanger Audio Effect type.
/** /**
\param name: Name of the preset. \param name: Name of the preset.
\param setting: Instance of the Effect parameter struct for this type of effect. \param setting: Instance of the Effect parameter struct for this type of effect.
\return True on success, False on failure. */ \return True on success, False on failure. */
virtual bool addFlangerEffectPreset(const char* name, const sFlangerParameters& setting) = 0; virtual bool addFlangerEffectPreset(const char* name, const sFlangerParameters& setting) = 0;
//! Adds a preset for the Frequency Shift Audio Effect type. //! Adds a preset for the Frequency Shift Audio Effect type.
/** /**
\param name: Name of the preset. \param name: Name of the preset.
\param setting: Instance of the Effect parameter struct for this type of effect. \param setting: Instance of the Effect parameter struct for this type of effect.
\return True on success, False on failure. */ \return True on success, False on failure. */
virtual bool addFrequencyShiftEffectPreset(const char* name, const sFrequencyShiftParameters& setting) = 0; virtual bool addFrequencyShiftEffectPreset(const char* name, const sFrequencyShiftParameters& setting) = 0;
//! Adds a preset for the Vocal Morpher Audio Effect type. //! Adds a preset for the Vocal Morpher Audio Effect type.
/** /**
\param name: Name of the preset. \param name: Name of the preset.
\param setting: Instance of the Effect parameter struct for this type of effect. \param setting: Instance of the Effect parameter struct for this type of effect.
\return True on success, False on failure. */ \return True on success, False on failure. */
virtual bool addVocalMorpherEffectPreset(const char* name, const sVocalMorpherParameters& setting) = 0; virtual bool addVocalMorpherEffectPreset(const char* name, const sVocalMorpherParameters& setting) = 0;
//! Adds a preset for the Pitch Shifter Audio Effect type. //! Adds a preset for the Pitch Shifter Audio Effect type.
/** /**
\param name: Name of the preset. \param name: Name of the preset.
\param setting: Instance of the Effect parameter struct for this type of effect. \param setting: Instance of the Effect parameter struct for this type of effect.
\return True on success, False on failure. */ \return True on success, False on failure. */
virtual bool addPitchShifterEffectPreset(const char* name, const sPitchShifterParameters& setting) = 0; virtual bool addPitchShifterEffectPreset(const char* name, const sPitchShifterParameters& setting) = 0;
//! Adds a preset for the Ring Modulator Audio Effect type. //! Adds a preset for the Ring Modulator Audio Effect type.
/** /**
\param name: Name of the preset. \param name: Name of the preset.
\param setting: Instance of the Effect parameter struct for this type of effect. \param setting: Instance of the Effect parameter struct for this type of effect.
\return True on success, False on failure. */ \return True on success, False on failure. */
virtual bool addRingModulatorEffectPreset(const char* name, const sRingModulatorParameters& setting) = 0; virtual bool addRingModulatorEffectPreset(const char* name, const sRingModulatorParameters& setting) = 0;
//! Adds a preset for the Autowah Audio Effect type. //! Adds a preset for the Autowah Audio Effect type.
/** /**
\param name: Name of the preset. \param name: Name of the preset.
\param setting: Instance of the Effect parameter struct for this type of effect. \param setting: Instance of the Effect parameter struct for this type of effect.
\return True on success, False on failure. */ \return True on success, False on failure. */
virtual bool addAutowahEffectPreset(const char* name, const sAutowahParameters& setting) = 0; virtual bool addAutowahEffectPreset(const char* name, const sAutowahParameters& setting) = 0;
//! Adds a preset for the Compressor Audio Effect type. //! Adds a preset for the Compressor Audio Effect type.
/** /**
\param name: Name of the preset. \param name: Name of the preset.
\param setting: Instance of the Effect parameter struct for this type of effect. \param setting: Instance of the Effect parameter struct for this type of effect.
\return True on success, False on failure. */ \return True on success, False on failure. */
virtual bool addCompressorEffectPreset(const char* name, const sCompressorParameters& setting) = 0; virtual bool addCompressorEffectPreset(const char* name, const sCompressorParameters& setting) = 0;
//! Adds a preset for the Equalizer Audio Effect type. //! Adds a preset for the Equalizer Audio Effect type.
/** /**
\param name: Name of the preset. \param name: Name of the preset.
\param setting: Instance of the Effect parameter struct for this type of effect. \param setting: Instance of the Effect parameter struct for this type of effect.
\return True on success, False on failure. */ \return True on success, False on failure. */
virtual bool addEqualizerEffectPreset(const char* name, const sEqualizerParameters& setting) = 0; virtual bool addEqualizerEffectPreset(const char* name, const sEqualizerParameters& setting) = 0;
//! Returns a previously registered preset for the EAX Reverb Effect. //! Returns a previously registered preset for the EAX Reverb Effect.
/** /**
\param name: Name of the preset to retrieve. \param name: Name of the preset to retrieve.
\return The preset or the default parameters if the preset could not be found. */ \return The preset or the default parameters if the preset could not be found. */
virtual sEAXReverbParameters getEAXReverbEffectPreset(const char* name) = 0; virtual sEAXReverbParameters getEAXReverbEffectPreset(const char* name) = 0;
//! Returns a previously registered preset for the Reverb Effect. //! Returns a previously registered preset for the Reverb Effect.
/** /**
\param name: Name of the preset to retrieve. \param name: Name of the preset to retrieve.
\return The preset or the default parameters if the preset could not be found. */ \return The preset or the default parameters if the preset could not be found. */
virtual sReverbParameters getReverbEffectPreset(const char* name) = 0; virtual sReverbParameters getReverbEffectPreset(const char* name) = 0;
//! Returns a previously registered preset for the Chorus Effect. //! Returns a previously registered preset for the Chorus Effect.
/** /**
\param name: Name of the preset to retrieve. \param name: Name of the preset to retrieve.
\return The preset or the default parameters if the preset could not be found. */ \return The preset or the default parameters if the preset could not be found. */
virtual sChorusParameters getChorusEffectPreset(const char* name) = 0; virtual sChorusParameters getChorusEffectPreset(const char* name) = 0;
//! Returns a previously registered preset for the Distortion Effect. //! Returns a previously registered preset for the Distortion Effect.
/** /**
\param name: Name of the preset to retrieve. \param name: Name of the preset to retrieve.
\return The preset or the default parameters if the preset could not be found. */ \return The preset or the default parameters if the preset could not be found. */
virtual sDistortionParameters getDistortionEffectPreset(const char* name) = 0; virtual sDistortionParameters getDistortionEffectPreset(const char* name) = 0;
//! Returns a previously registered preset for the Echo Effect. //! Returns a previously registered preset for the Echo Effect.
/** /**
\param name: Name of the preset to retrieve. \param name: Name of the preset to retrieve.
\return The preset or the default parameters if the preset could not be found. */ \return The preset or the default parameters if the preset could not be found. */
virtual sEchoParameters getEchoEffectPreset(const char* name) = 0; virtual sEchoParameters getEchoEffectPreset(const char* name) = 0;
//! Returns a previously registered preset for the Flanger Effect. //! Returns a previously registered preset for the Flanger Effect.
/** /**
\param name: Name of the preset to retrieve. \param name: Name of the preset to retrieve.
\return The preset or the default parameters if the preset could not be found. */ \return The preset or the default parameters if the preset could not be found. */
virtual sFlangerParameters getFlangerEffectPreset(const char* name) = 0; virtual sFlangerParameters getFlangerEffectPreset(const char* name) = 0;
//! Returns a previously registered preset for the Frequency Shift Effect. //! Returns a previously registered preset for the Frequency Shift Effect.
/** /**
\param name: Name of the preset to retrieve. \param name: Name of the preset to retrieve.
\return The preset or the default parameters if the preset could not be found. */ \return The preset or the default parameters if the preset could not be found. */
virtual sFrequencyShiftParameters getFrequencyShiftEffectPreset(const char* name) = 0; virtual sFrequencyShiftParameters getFrequencyShiftEffectPreset(const char* name) = 0;
//! Returns a previously registered preset for the Vocal Morpher Effect. //! Returns a previously registered preset for the Vocal Morpher Effect.
/** /**
\param name: Name of the preset to retrieve. \param name: Name of the preset to retrieve.
\return The preset or the default parameters if the preset could not be found. */ \return The preset or the default parameters if the preset could not be found. */
virtual sVocalMorpherParameters getVocalMorpherEffectPreset(const char* name) = 0; virtual sVocalMorpherParameters getVocalMorpherEffectPreset(const char* name) = 0;
//! Returns a previously registered preset for the Pitch Shifter Effect. //! Returns a previously registered preset for the Pitch Shifter Effect.
/** /**
\param name: Name of the preset to retrieve. \param name: Name of the preset to retrieve.
\return The preset or the default parameters if the preset could not be found. */ \return The preset or the default parameters if the preset could not be found. */
virtual sPitchShifterParameters getPitchShifterEffectPreset(const char* name) = 0; virtual sPitchShifterParameters getPitchShifterEffectPreset(const char* name) = 0;
//! Returns a previously registered preset for the Ring Modulator Effect. //! Returns a previously registered preset for the Ring Modulator Effect.
/** /**
\param name: Name of the preset to retrieve. \param name: Name of the preset to retrieve.
\return The preset or the default parameters if the preset could not be found. */ \return The preset or the default parameters if the preset could not be found. */
virtual sRingModulatorParameters getRingModulatorEffectPreset(const char* name) = 0; virtual sRingModulatorParameters getRingModulatorEffectPreset(const char* name) = 0;
//! Returns a previously registered preset for the Autowah Effect. //! Returns a previously registered preset for the Autowah Effect.
/** /**
\param name: Name of the preset to retrieve. \param name: Name of the preset to retrieve.
\return The preset or the default parameters if the preset could not be found. */ \return The preset or the default parameters if the preset could not be found. */
virtual sAutowahParameters getAutowahEffectPreset(const char* name) = 0; virtual sAutowahParameters getAutowahEffectPreset(const char* name) = 0;
//! Returns a previously registered preset for the Compressor Effect. //! Returns a previously registered preset for the Compressor Effect.
/** /**
\param name: Name of the preset to retrieve. \param name: Name of the preset to retrieve.
\return The preset or the default parameters if the preset could not be found. */ \return The preset or the default parameters if the preset could not be found. */
virtual sCompressorParameters getCompressorEffectPreset(const char* name) = 0; virtual sCompressorParameters getCompressorEffectPreset(const char* name) = 0;
//! Returns a previously registered preset for the Equalizer Effect. //! Returns a previously registered preset for the Equalizer Effect.
/** /**
\param name: Name of the preset to retrieve. \param name: Name of the preset to retrieve.
\return The preset or the default parameters if the preset could not be found. */ \return The preset or the default parameters if the preset could not be found. */
virtual sEqualizerParameters getEqualizerEffectPreset(const char* name) = 0; virtual sEqualizerParameters getEqualizerEffectPreset(const char* name) = 0;
//! Removes a previously registered effect preset. //! Removes a previously registered effect preset.
/** /**
\param type: Type of effect to remove a preset for. \param type: Type of effect to remove a preset for.
\param name: Name of the preset to remove. */ \param name: Name of the preset to remove. */
virtual void removeEffectPreset(const EffectTypes& type, const char* name) = 0; virtual void removeEffectPreset(const EffectTypes& type, const char* name) = 0;
//! Returns if a effect preset of a certain name is registered. //! Returns if a effect preset of a certain name is registered.
/** /**
\param type: Type of the effect. \param type: Type of the effect.
\param name: Name of the preset. \param name: Name of the preset.
\return True if it exists, false if not. */ \return True if it exists, false if not. */
virtual bool isEffectPresetRegistered(const EffectTypes& type, const char* name) = 0; virtual bool isEffectPresetRegistered(const EffectTypes& type, const char* name) = 0;
//! Removes all effect presets for a specific effect type. //! Removes all effect presets for a specific effect type.
/** /**
\param type: Type of effect to remove presets for, or EET_NULL to remove all of them. */ \param type: Type of effect to remove presets for, or EET_NULL to remove all of them. */
virtual void removeAllEffectPresets(const EffectTypes& type) = 0; virtual void removeAllEffectPresets(const EffectTypes& type) = 0;
protected: protected:
private: private:
}; };
}; };
#endif #endif
#endif //! IAUDIOEFFECTS_H #endif //! IAUDIOEFFECTS_H

View File

@ -1,202 +1,202 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef IAUDIOMANAGER_H #ifndef IAUDIOMANAGER_H
#define IAUDIOMANAGER_H #define IAUDIOMANAGER_H
#include "IListener.h" #include "IListener.h"
#include "cAudioDefines.h" #include "cAudioDefines.h"
#include "EAudioFormats.h" #include "EAudioFormats.h"
#include "IAudioEffects.h" #include "IAudioEffects.h"
#include "IDataSourceFactory.h" #include "IDataSourceFactory.h"
#include "IManagerEventHandler.h" #include "IManagerEventHandler.h"
#include <string> #include <string>
namespace cAudio namespace cAudio
{ {
class IAudioSource; class IAudioSource;
class IAudioDecoderFactory; class IAudioDecoderFactory;
//! Interface for the playback capabilities of cAudio. //! Interface for the playback capabilities of cAudio.
class IAudioManager class IAudioManager
{ {
public: public:
IAudioManager() { } IAudioManager() { }
virtual ~IAudioManager() { } virtual ~IAudioManager() { }
//! Initializes the manager. //! Initializes the manager.
/** /**
\param deviceName: Name of the device to create this manager for. \param deviceName: Name of the device to create this manager for.
\param outputFrequency: Frequency of the output audio or -1 for the device default. \param outputFrequency: Frequency of the output audio or -1 for the device default.
\param eaxEffectSlots: Number of EFX effect slots to request. Has no effect if EFX is not supported or compiled out. \param eaxEffectSlots: Number of EFX effect slots to request. Has no effect if EFX is not supported or compiled out.
\return True on success, False if initialization of OpenAL failed. */ \return True on success, False if initialization of OpenAL failed. */
virtual bool initialize(const char* deviceName = 0x0, int outputFrequency = -1, int eaxEffectSlots = 4) = 0; virtual bool initialize(const char* deviceName = 0x0, int outputFrequency = -1, int eaxEffectSlots = 4) = 0;
//! Shuts the manager down, cleaning up audio sources in the process. Does not clean up decoders, data sources, or event handlers. //! Shuts the manager down, cleaning up audio sources in the process. Does not clean up decoders, data sources, or event handlers.
virtual void shutDown() = 0; virtual void shutDown() = 0;
//! If threading is disabled, you must call this function every frame to update the playback buffers of audio sources. Otherwise it should not be called. //! If threading is disabled, you must call this function every frame to update the playback buffers of audio sources. Otherwise it should not be called.
virtual void update() = 0; virtual void update() = 0;
//! Returns an Audio Source by its "name" and NULL if the name is not found //! Returns an Audio Source by its "name" and NULL if the name is not found
/** /**
\param name: Name of the audio source to retrieve. \param name: Name of the audio source to retrieve.
\return Pointer to the audio source object or NULL if it could not be found.*/ \return Pointer to the audio source object or NULL if it could not be found.*/
virtual IAudioSource* getSoundByName(const char* name) = 0; virtual IAudioSource* getSoundByName(const char* name) = 0;
//! Releases ALL Audio Sources (but does not shutdown the manager) //! Releases ALL Audio Sources (but does not shutdown the manager)
virtual void releaseAllSources() = 0; virtual void releaseAllSources() = 0;
//! Releases a single Audio Source, removing it from the manager. //! Releases a single Audio Source, removing it from the manager.
/** \param source: Pointer to the source to release. */ /** \param source: Pointer to the source to release. */
virtual void release(IAudioSource* source) = 0; virtual void release(IAudioSource* source) = 0;
//! Returns the name of an available playback device. //! Returns the name of an available playback device.
/** \param index: Specify which name to retrieve ( Range: 0 to getAvailableDeviceCount()-1 ) /** \param index: Specify which name to retrieve ( Range: 0 to getAvailableDeviceCount()-1 )
\return Name of the selected device. */ \return Name of the selected device. */
virtual const char* getAvailableDeviceName(unsigned int index) = 0; virtual const char* getAvailableDeviceName(unsigned int index) = 0;
//! Returns the number of playback devices available for use. //! Returns the number of playback devices available for use.
/** \return Number of playback devices available. */ /** \return Number of playback devices available. */
virtual unsigned int getAvailableDeviceCount() = 0; virtual unsigned int getAvailableDeviceCount() = 0;
//! Returns the name of the default system playback device. //! Returns the name of the default system playback device.
/** \return Name of the default playback device. */ /** \return Name of the default playback device. */
virtual const char* getDefaultDeviceName() = 0; virtual const char* getDefaultDeviceName() = 0;
//! Creates an Audio Source object using the highest priority data source that has the referenced filename //! Creates an Audio Source object using the highest priority data source that has the referenced filename
/** /**
\param name: Name of the audio source. \param name: Name of the audio source.
\param filename: Path to the file to load audio data from. \param filename: Path to the file to load audio data from.
\param stream: Whether to stream the audio data or load it all into a memory buffer at the start. You should consider using streaming for really large sound files. \param stream: Whether to stream the audio data or load it all into a memory buffer at the start. You should consider using streaming for really large sound files.
\return A pointer to an Audio Source or NULL if creation failed. \return A pointer to an Audio Source or NULL if creation failed.
*/ */
virtual IAudioSource* create(const char* name, const char* filename, bool stream = false) = 0; virtual IAudioSource* create(const char* name, const char* filename, bool stream = false) = 0;
//! Creates an Audio Source from a memory buffer using a specific audio codec. //! Creates an Audio Source from a memory buffer using a specific audio codec.
/** /**
\param name: Name of the audio source. \param name: Name of the audio source.
\param data: Pointer to a buffer in memory to load the data from. \param data: Pointer to a buffer in memory to load the data from.
\param length: Length of the data buffer. \param length: Length of the data buffer.
\param extension: Extension for the audio codec of the data in the memory buffer. \param extension: Extension for the audio codec of the data in the memory buffer.
\return A pointer to an Audio Source or NULL if creation failed. \return A pointer to an Audio Source or NULL if creation failed.
*/ */
virtual IAudioSource* createFromMemory(const char* name, const char* data, size_t length, const char* extension) = 0; virtual IAudioSource* createFromMemory(const char* name, const char* data, size_t length, const char* extension) = 0;
//! Creates an Audio Source from raw audio data in a memory buffer. //! Creates an Audio Source from raw audio data in a memory buffer.
/** /**
\param name: Name of the audio source. \param name: Name of the audio source.
\param data: Pointer to a buffer in memory to load the data from. \param data: Pointer to a buffer in memory to load the data from.
\param length: Length of the data buffer. \param length: Length of the data buffer.
\param frequency: Frequency (or sample rate) of the audio data. \param frequency: Frequency (or sample rate) of the audio data.
\param format: Format of the audio data. \param format: Format of the audio data.
\return A pointer to an Audio Source or NULL if creation failed. \return A pointer to an Audio Source or NULL if creation failed.
*/ */
virtual IAudioSource* createFromRaw(const char* name, const char* data, size_t length, unsigned int frequency, AudioFormats format) = 0; virtual IAudioSource* createFromRaw(const char* name, const char* data, size_t length, unsigned int frequency, AudioFormats format) = 0;
//! Register an Audio Decoder. //! Register an Audio Decoder.
/** /**
\param factory: Pointer to the factory instance to use. \param factory: Pointer to the factory instance to use.
\param extension: Extension of the audio codec to register this decoder under. For example, .wav for a RIFF/wav decoder. \param extension: Extension of the audio codec to register this decoder under. For example, .wav for a RIFF/wav decoder.
\return True on seccess, False if registration failed. */ \return True on seccess, False if registration failed. */
virtual bool registerAudioDecoder(IAudioDecoderFactory* factory, const char* extension) = 0; virtual bool registerAudioDecoder(IAudioDecoderFactory* factory, const char* extension) = 0;
//! Unregister a previously registered Audio Decoder. //! Unregister a previously registered Audio Decoder.
/** Note that all current sound sources will still continue to use any currently allocated decoders. Will NOT delete any user added factory instance, you must do that yourself. /** Note that all current sound sources will still continue to use any currently allocated decoders. Will NOT delete any user added factory instance, you must do that yourself.
\param extension: Extension for the audio decoder to remove. */ \param extension: Extension for the audio decoder to remove. */
virtual void unRegisterAudioDecoder(const char* extension) = 0; virtual void unRegisterAudioDecoder(const char* extension) = 0;
//! Returns whether an audio decoder is currently registered for this file type //! Returns whether an audio decoder is currently registered for this file type
/** /**
\param extension: Extension for the audio decoder to check for. \param extension: Extension for the audio decoder to check for.
\return True if the specified decoder is registered or False if not. */ \return True if the specified decoder is registered or False if not. */
virtual bool isAudioDecoderRegistered(const char* extension) = 0; virtual bool isAudioDecoderRegistered(const char* extension) = 0;
//! Returns a registered audio decoder factory. //! Returns a registered audio decoder factory.
/** /**
\param extension: Extension for the audio decoder to return. \param extension: Extension for the audio decoder to return.
\return A pointer to the found factory or NULL if it could not be found. */ \return A pointer to the found factory or NULL if it could not be found. */
virtual IAudioDecoderFactory* getAudioDecoderFactory(const char* extension) = 0; virtual IAudioDecoderFactory* getAudioDecoderFactory(const char* extension) = 0;
//! Unregisters all attached Audio Decoders. //! Unregisters all attached Audio Decoders.
/** Note that all current sound sources will still continue to use any currently allocated decoders. Will NOT delete any user added factory instance, you must do that yourself. */ /** Note that all current sound sources will still continue to use any currently allocated decoders. Will NOT delete any user added factory instance, you must do that yourself. */
virtual void unRegisterAllAudioDecoders() = 0; virtual void unRegisterAllAudioDecoders() = 0;
//! Registers a data source with this manager //! Registers a data source with this manager
/** Use this function to provide access to a custom resource manager, zip archive, vfs, or any other place you'd like to get audio files from. /** Use this function to provide access to a custom resource manager, zip archive, vfs, or any other place you'd like to get audio files from.
\param factory: Pointer to the data source factory to register. \param factory: Pointer to the data source factory to register.
\param name: Name for the data source (ie. Zip Archive or FileSystem) \param name: Name for the data source (ie. Zip Archive or FileSystem)
\param priority: Determines what order data sources are asked for a file. The higher the priority, the sooner they are asked. cAudio stops looking for a file as soon as any data source returns it. \param priority: Determines what order data sources are asked for a file. The higher the priority, the sooner they are asked. cAudio stops looking for a file as soon as any data source returns it.
\return True on success, False on failure to register. */ \return True on success, False on failure to register. */
virtual bool registerDataSource(IDataSourceFactory* factory, const char* name, int priority) = 0; virtual bool registerDataSource(IDataSourceFactory* factory, const char* name, int priority) = 0;
//! Removes a previously registered data source. //! Removes a previously registered data source.
/** Note that sound sources will still continue to use any currently allocated sources, so you may not be able to close an open zip/archive file handle until they are done. Will NOT delete any user added factory instance, you must do that yourself. /** Note that sound sources will still continue to use any currently allocated sources, so you may not be able to close an open zip/archive file handle until they are done. Will NOT delete any user added factory instance, you must do that yourself.
\param name: Name of the data source to unregister. */ \param name: Name of the data source to unregister. */
virtual void unRegisterDataSource(const char* name) = 0; virtual void unRegisterDataSource(const char* name) = 0;
//! Returns whether a data source is currently registered under a certain name. //! Returns whether a data source is currently registered under a certain name.
/** /**
\param name: Name of the data source to check for. \param name: Name of the data source to check for.
\return True if the specified data source is registered or False if not. */ \return True if the specified data source is registered or False if not. */
virtual bool isDataSourceRegistered(const char* name) = 0; virtual bool isDataSourceRegistered(const char* name) = 0;
//! Returns a previously registered data source factory. //! Returns a previously registered data source factory.
/** /**
\param name: Name of the data source to return. \param name: Name of the data source to return.
\return A pointer to the found factory or NULL if it could not be found. */ \return A pointer to the found factory or NULL if it could not be found. */
virtual IDataSourceFactory* getDataSourceFactory(const char* name) = 0; virtual IDataSourceFactory* getDataSourceFactory(const char* name) = 0;
//! Removes all previously registered data sources. //! Removes all previously registered data sources.
/** Note that sound sources will still continue to use any currently allocated sources, so you may not be able to close an open zip/archive file handle until they are done. Will NOT delete any user added factory instance, you must do that yourself. */ /** Note that sound sources will still continue to use any currently allocated sources, so you may not be able to close an open zip/archive file handle until they are done. Will NOT delete any user added factory instance, you must do that yourself. */
virtual void unRegisterAllDataSources() = 0; virtual void unRegisterAllDataSources() = 0;
//! Registers a new event handler with the manager. //! Registers a new event handler with the manager.
/** /**
\param handler: Pointer to an event handler instance to register. */ \param handler: Pointer to an event handler instance to register. */
virtual void registerEventHandler(IManagerEventHandler* handler) = 0; virtual void registerEventHandler(IManagerEventHandler* handler) = 0;
//! Unregisters a previously registered event handler from the manager. //! Unregisters a previously registered event handler from the manager.
/** Note: Will not delete your event handler, you must take care of that yourself. /** Note: Will not delete your event handler, you must take care of that yourself.
\param handler: Pointer to the event handler to remove. */ \param handler: Pointer to the event handler to remove. */
virtual void unRegisterEventHandler(IManagerEventHandler* handler) = 0; virtual void unRegisterEventHandler(IManagerEventHandler* handler) = 0;
//! Unregisters all previously registered event handlers from the manager. //! Unregisters all previously registered event handlers from the manager.
/** Note: Will not delete your event handler, you must take care of that yourself. */ /** Note: Will not delete your event handler, you must take care of that yourself. */
virtual void unRegisterAllEventHandlers() = 0; virtual void unRegisterAllEventHandlers() = 0;
//! Returns the interface for the listener. //! Returns the interface for the listener.
virtual IListener* getListener() = 0; virtual IListener* getListener() = 0;
#ifdef CAUDIO_EFX_ENABLED #ifdef CAUDIO_EFX_ENABLED
//! Returns the interface for audio effects. //! Returns the interface for audio effects.
virtual IAudioEffects* getEffects() = 0; virtual IAudioEffects* getEffects() = 0;
#endif #endif
protected: protected:
private: private:
}; };
//! Creates an interface to an Audio Manager. //! Creates an interface to an Audio Manager.
/** Note: This is the only way to get access to the audio playback capabilities of cAudio. /** Note: This is the only way to get access to the audio playback capabilities of cAudio.
You must delete this interface using destroyAudioManager() once you are done with it. You must delete this interface using destroyAudioManager() once you are done with it.
\param initializeDefault: Whether to return an object initialized with the default settings. If set to false, you must make a call to initialize before you can create audio sources. \param initializeDefault: Whether to return an object initialized with the default settings. If set to false, you must make a call to initialize before you can create audio sources.
\return A pointer to the created object, NULL if the object could not be allocated. \return A pointer to the created object, NULL if the object could not be allocated.
*/ */
CAUDIO_API IAudioManager* createAudioManager(bool initializeDefault = true); CAUDIO_API IAudioManager* createAudioManager(bool initializeDefault = true);
//! Destroys an interface to a previously created Audio Manager and frees the memory allocated for it. //! Destroys an interface to a previously created Audio Manager and frees the memory allocated for it.
/** /**
\param capture: The object to destroy. \param capture: The object to destroy.
*/ */
CAUDIO_API void destroyAudioManager(IAudioManager* manager); CAUDIO_API void destroyAudioManager(IAudioManager* manager);
//! Returns if the thread used to update all Audio Managers is running. //! Returns if the thread used to update all Audio Managers is running.
/** Note: Will always return false if threading is disabled. /** Note: Will always return false if threading is disabled.
The library automatically shuts down the thread if no Audio Managers exist and will restart the thread on creation of a new manager. The library automatically shuts down the thread if no Audio Managers exist and will restart the thread on creation of a new manager.
\return True if the thread is currently running, false otherwise. \return True if the thread is currently running, false otherwise.
*/ */
CAUDIO_API bool isAudioManagerThreadRunning(); CAUDIO_API bool isAudioManagerThreadRunning();
} }
#endif //! IAUDIOMANAGER_H #endif //! IAUDIOMANAGER_H

View File

@ -1,54 +1,54 @@
#ifndef IAUDIOPLUGIN_H_INCLUDED #ifndef IAUDIOPLUGIN_H_INCLUDED
#define IAUDIOPLUGIN_H_INCLUDED #define IAUDIOPLUGIN_H_INCLUDED
#include "IRefCounted.h" #include "IRefCounted.h"
#include "IAudioManager.h" #include "IAudioManager.h"
#include "IAudioCapture.h" #include "IAudioCapture.h"
#include "ILogger.h" #include "ILogger.h"
namespace cAudio namespace cAudio
{ {
//! Interface for all plugins in cAudio. //! Interface for all plugins in cAudio.
class IAudioPlugin : public IRefCounted class IAudioPlugin : public IRefCounted
{ {
public: public:
IAudioPlugin() { } IAudioPlugin() { }
~IAudioPlugin() { } ~IAudioPlugin() { }
//! Called to initialize the plugin. Use this for any initial setup that needs to be done. //! Called to initialize the plugin. Use this for any initial setup that needs to be done.
/** /**
\param logger: Pointer to the logger singleton. \param logger: Pointer to the logger singleton.
\return True if plugin initialization was successful, false if there was an error. */ \return True if plugin initialization was successful, false if there was an error. */
virtual bool installPlugin(ILogger* logger) = 0; virtual bool installPlugin(ILogger* logger) = 0;
//! Called to retrieve a name to register this plugin under if the user didn't specify one (or the plugin was auto-loaded). //! Called to retrieve a name to register this plugin under if the user didn't specify one (or the plugin was auto-loaded).
/** /**
\return Name of the plugin. */ \return Name of the plugin. */
virtual const char* getPluginName() = 0; virtual const char* getPluginName() = 0;
//! Called to shutdown the plugin and do any final cleanup. This is the last function call cAudio will give you before your plugin is completely removed. //! Called to shutdown the plugin and do any final cleanup. This is the last function call cAudio will give you before your plugin is completely removed.
virtual void uninstallPlugin() = 0; virtual void uninstallPlugin() = 0;
//! Called on creation of an Audio Playback Manager. //! Called on creation of an Audio Playback Manager.
/** Use this to register any decoders or event handlers that you'd like to add to the engine. /** Use this to register any decoders or event handlers that you'd like to add to the engine.
\param manager: Pointer to the newly created manager. */ \param manager: Pointer to the newly created manager. */
virtual void onCreateAudioManager(IAudioManager* manager) { } virtual void onCreateAudioManager(IAudioManager* manager) { }
//! Called on creation of an Audio Capture Manager. //! Called on creation of an Audio Capture Manager.
/** Use this to register any event handlers that you'd like to add to the engine. /** Use this to register any event handlers that you'd like to add to the engine.
\param capture: Pointer to the newly created capture interface. */ \param capture: Pointer to the newly created capture interface. */
virtual void onCreateAudioCapture(IAudioCapture* capture) { } virtual void onCreateAudioCapture(IAudioCapture* capture) { }
//! Called on destruction of an Audio Playback Manager. //! Called on destruction of an Audio Playback Manager.
/** Use this to remove anything you added to the playback manger earlier. /** Use this to remove anything you added to the playback manger earlier.
\param manager: Pointer to the soon to be destroyed playback interface. */ \param manager: Pointer to the soon to be destroyed playback interface. */
virtual void onDestroyAudioManager(IAudioManager* manager) { } virtual void onDestroyAudioManager(IAudioManager* manager) { }
//! Called on destruction of an Audio Capture Manager. //! Called on destruction of an Audio Capture Manager.
/** Use this to remove anything you added to a capture manger earlier. /** Use this to remove anything you added to a capture manger earlier.
\param capture: Pointer to the soon to be destroyed capture interface. */ \param capture: Pointer to the soon to be destroyed capture interface. */
virtual void onDestoryAudioCapture(IAudioCapture* capture) { } virtual void onDestoryAudioCapture(IAudioCapture* capture) { }
}; };
}; };
#endif //! IAUDIOPLUGIN_H_INCLUDED #endif //! IAUDIOPLUGIN_H_INCLUDED

View File

@ -1,280 +1,280 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef IAUDIOSOURCE_H #ifndef IAUDIOSOURCE_H
#define IAUDIOSOURCE_H #define IAUDIOSOURCE_H
#include "cAudioDefines.h" #include "cAudioDefines.h"
#include "IRefCounted.h" #include "IRefCounted.h"
#include "IAudioDecoder.h" #include "IAudioDecoder.h"
#include "cVector3.h" #include "cVector3.h"
#include "IEffect.h" #include "IEffect.h"
#include "IFilter.h" #include "IFilter.h"
#include "ISourceEventHandler.h" #include "ISourceEventHandler.h"
namespace cAudio namespace cAudio
{ {
//! Interface for a single audio source, which allow you to manipulate sound sources (speakers) in 2D or 3D space. //! Interface for a single audio source, which allow you to manipulate sound sources (speakers) in 2D or 3D space.
class IAudioSource : public IRefCounted class IAudioSource : public IRefCounted
{ {
public: public:
IAudioSource() {} IAudioSource() {}
virtual ~IAudioSource() {} virtual ~IAudioSource() {}
//! Plays the source with the last set parameters. //! Plays the source with the last set parameters.
/** /**
\return True if the source is playing, false if not. */ \return True if the source is playing, false if not. */
virtual bool play() = 0; virtual bool play() = 0;
//! Plays the source in 2D mode. //! Plays the source in 2D mode.
/** No automatic attenuation or panning will take place in this mode, but using setPosition will allow you to manually pan mono audio streams. /** No automatic attenuation or panning will take place in this mode, but using setPosition will allow you to manually pan mono audio streams.
\param toLoop: Whether to loop (restart) the audio when the end is reached. \param toLoop: Whether to loop (restart) the audio when the end is reached.
\return True if the source is playing, false if not. */ \return True if the source is playing, false if not. */
virtual bool play2d(const bool& toLoop = false) = 0; virtual bool play2d(const bool& toLoop = false) = 0;
//! Plays the source in 3D mode. //! Plays the source in 3D mode.
/** /**
\param position: Position to start the sound off at. \param position: Position to start the sound off at.
\param soundstr: Affects how the source attenuates due to distance. Higher values cause the source to stand out more over distance. \param soundstr: Affects how the source attenuates due to distance. Higher values cause the source to stand out more over distance.
\param toLoop: Whether to loop (restart) the audio when the end is reached. \param toLoop: Whether to loop (restart) the audio when the end is reached.
\return True if the source is playing, false if not. */ \return True if the source is playing, false if not. */
virtual bool play3d(const cVector3& position, const float& soundstr = 1.0 , const bool& toLoop = false) = 0; virtual bool play3d(const cVector3& position, const float& soundstr = 1.0 , const bool& toLoop = false) = 0;
//! Pauses playback of the sound source. //! Pauses playback of the sound source.
virtual void pause() = 0; virtual void pause() = 0;
//! Stops playback of the sound source. //! Stops playback of the sound source.
virtual void stop() = 0; virtual void stop() = 0;
//! Controls whether the source should loop or not. //! Controls whether the source should loop or not.
/** \param toLoop: Whether to loop (restart) the audio when the end is reached. */ /** \param toLoop: Whether to loop (restart) the audio when the end is reached. */
virtual void loop(const bool& toLoop) = 0; virtual void loop(const bool& toLoop) = 0;
//! Seeks through the audio stream to a specific spot. //! Seeks through the audio stream to a specific spot.
/** Note: May not be supported by all codecs. /** Note: May not be supported by all codecs.
\param seconds: Number of seconds to seek. \param seconds: Number of seconds to seek.
\param relative: Whether to seek from the current position or the start of the stream. \param relative: Whether to seek from the current position or the start of the stream.
\return True on success, False if the codec does not support seeking. */ \return True on success, False if the codec does not support seeking. */
virtual bool seek(const float& seconds, bool relative = false) = 0; virtual bool seek(const float& seconds, bool relative = false) = 0;
//! Returns the total amount of time in the audio stream. See IAudioDecoder for details. //! Returns the total amount of time in the audio stream. See IAudioDecoder for details.
virtual float getTotalAudioTime() = 0; virtual float getTotalAudioTime() = 0;
//! Returns the total decoded size of the audio stream. See IAudioDecoder for details. //! Returns the total decoded size of the audio stream. See IAudioDecoder for details.
virtual int getTotalAudioSize() = 0; virtual int getTotalAudioSize() = 0;
//! Returns the original size of the audio stream. See IAudioDecoder for details. //! Returns the original size of the audio stream. See IAudioDecoder for details.
virtual int getCompressedAudioSize() = 0; virtual int getCompressedAudioSize() = 0;
//! Returns the current position in the audio stream in seconds. See IAudioDecoder for details. //! Returns the current position in the audio stream in seconds. See IAudioDecoder for details.
virtual float getCurrentAudioTime() = 0; virtual float getCurrentAudioTime() = 0;
//! Returns the current position in the decoded audio stream in bytes. See IAudioDecoder for details. //! Returns the current position in the decoded audio stream in bytes. See IAudioDecoder for details.
virtual int getCurrentAudioPosition() = 0; virtual int getCurrentAudioPosition() = 0;
//! Returns the current position in the original audio stream in bytes. See IAudioDecoder for details. //! Returns the current position in the original audio stream in bytes. See IAudioDecoder for details.
virtual int getCurrentCompressedAudioPosition() = 0; virtual int getCurrentCompressedAudioPosition() = 0;
//! Normally called every frame by the audio manager to update the internal buffers. Note: For internal use only. //! Normally called every frame by the audio manager to update the internal buffers. Note: For internal use only.
virtual bool update() = 0; virtual bool update() = 0;
//! Releases all resources used by the audio source, normally used to clean up before deletion. Note: For internal use only. //! Releases all resources used by the audio source, normally used to clean up before deletion. Note: For internal use only.
virtual void release() = 0; virtual void release() = 0;
//! Returns if the source is ready to be used. //! Returns if the source is ready to be used.
virtual const bool isValid() const = 0; virtual const bool isValid() const = 0;
//! Returns if the source is playing. //! Returns if the source is playing.
virtual const bool isPlaying() const = 0; virtual const bool isPlaying() const = 0;
//! Returns if the source is paused. //! Returns if the source is paused.
virtual const bool isPaused() const = 0; virtual const bool isPaused() const = 0;
//! Returns if the source is stopped. //! Returns if the source is stopped.
virtual const bool isStopped() const = 0; virtual const bool isStopped() const = 0;
//! Returns if the source is looping. //! Returns if the source is looping.
virtual const bool isLooping() const = 0; virtual const bool isLooping() const = 0;
//! Sets the position of the source in 3D space. //! Sets the position of the source in 3D space.
/** /**
\param position: A 3D vector giving the new location to put this source. */ \param position: A 3D vector giving the new location to put this source. */
virtual void setPosition(const cVector3& position) = 0; virtual void setPosition(const cVector3& position) = 0;
//! Sets the current velocity of the source for doppler effects. //! Sets the current velocity of the source for doppler effects.
/** /**
\param velocity: A 3D vector giving the speed and direction that the source is moving. */ \param velocity: A 3D vector giving the speed and direction that the source is moving. */
virtual void setVelocity(const cVector3& velocity) = 0; virtual void setVelocity(const cVector3& velocity) = 0;
//! Sets the direction the source is facing. //! Sets the direction the source is facing.
/** /**
\param direction: A 3D vector giving the direction that the source is aiming. */ \param direction: A 3D vector giving the direction that the source is aiming. */
virtual void setDirection(const cVector3& direction) = 0; virtual void setDirection(const cVector3& direction) = 0;
//! Sets the factor used in attenuating the source over distance. //! Sets the factor used in attenuating the source over distance.
/** Larger values make it attenuate faster, smaller values make the source carry better. /** Larger values make it attenuate faster, smaller values make the source carry better.
Range: 0.0f to +inf (Default: 1.0f). Range: 0.0f to +inf (Default: 1.0f).
\param rolloff: The rolloff factor to apply to the attenuation calculation. */ \param rolloff: The rolloff factor to apply to the attenuation calculation. */
virtual void setRolloffFactor(const float& rolloff) = 0; virtual void setRolloffFactor(const float& rolloff) = 0;
//! Sets how well the source carries over distance. //! Sets how well the source carries over distance.
/** Same as setRolloffFactor(1.0f/soundstrength). /** Same as setRolloffFactor(1.0f/soundstrength).
Range: 0.0f to +inf (Default: 1.0f). Range: 0.0f to +inf (Default: 1.0f).
\param soundstrength: How well the sound carries over distance. */ \param soundstrength: How well the sound carries over distance. */
virtual void setStrength(const float& soundstrength) = 0; virtual void setStrength(const float& soundstrength) = 0;
//! Sets the distance from the source where attenuation will begin. //! Sets the distance from the source where attenuation will begin.
/** Range: 0.0f to +inf /** Range: 0.0f to +inf
\param minDistance: Distance from the source where attenuation begins. */ \param minDistance: Distance from the source where attenuation begins. */
virtual void setMinDistance(const float& minDistance) = 0; virtual void setMinDistance(const float& minDistance) = 0;
//! Sets the distance from the source where attenuation will stop. //! Sets the distance from the source where attenuation will stop.
/** Range: 0.0f to +inf /** Range: 0.0f to +inf
\param maxDistance: Distance where attenuation will cease. Normally the farthest range you can hear the source. */ \param maxDistance: Distance where attenuation will cease. Normally the farthest range you can hear the source. */
virtual void setMaxDistance(const float& maxDistance) = 0; virtual void setMaxDistance(const float& maxDistance) = 0;
//! Sets the pitch of the source. //! Sets the pitch of the source.
/** Range: 0.0f to +inf (Default: 1.0f) /** Range: 0.0f to +inf (Default: 1.0f)
\param pitch: New pitch level. Note that higher values will speed up the playback of the sound. */ \param pitch: New pitch level. Note that higher values will speed up the playback of the sound. */
virtual void setPitch(const float& pitch) = 0; virtual void setPitch(const float& pitch) = 0;
//! Sets the source volume before attenuation and other effects. //! Sets the source volume before attenuation and other effects.
/** Range: 0.0f to +inf (Default: 1.0f). /** Range: 0.0f to +inf (Default: 1.0f).
\param volume: New volume of the source. */ \param volume: New volume of the source. */
virtual void setVolume(const float& volume) = 0; virtual void setVolume(const float& volume) = 0;
//! Sets the minimum volume that the source can be attenuated to. //! Sets the minimum volume that the source can be attenuated to.
/** Range: 0.0f to +inf (Default: 0.0f). /** Range: 0.0f to +inf (Default: 0.0f).
\param minVolume: New minimum volume of the source. */ \param minVolume: New minimum volume of the source. */
virtual void setMinVolume(const float& minVolume) = 0; virtual void setMinVolume(const float& minVolume) = 0;
//! Sets the maximum volume that the source can achieve. //! Sets the maximum volume that the source can achieve.
/** Range: 0.0f to +inf (Default: 1.0f). /** Range: 0.0f to +inf (Default: 1.0f).
\param maxVolume: New maximum volume of the source. */ \param maxVolume: New maximum volume of the source. */
virtual void setMaxVolume(const float& maxVolume) = 0; virtual void setMaxVolume(const float& maxVolume) = 0;
//! Sets the angle of the inner sound cone of the source. The cone opens up in the direction of the source as set by setDirection(). //! Sets the angle of the inner sound cone of the source. The cone opens up in the direction of the source as set by setDirection().
/** Note: This causes the sound to be loudest only if the listener is inside this cone. /** Note: This causes the sound to be loudest only if the listener is inside this cone.
Range: 0.0f to 360.0f (Default: 360.0f). Range: 0.0f to 360.0f (Default: 360.0f).
\param innerAngle: Inside angle of the cone. */ \param innerAngle: Inside angle of the cone. */
virtual void setInnerConeAngle(const float& innerAngle) = 0; virtual void setInnerConeAngle(const float& innerAngle) = 0;
//! Sets the angle of the outer sound cone of the source. The cone opens up in the direction of the source as set by setDirection(). //! Sets the angle of the outer sound cone of the source. The cone opens up in the direction of the source as set by setDirection().
/** Note: If the listener is outside of this cone, the sound cannot be heard. Between the inner cone angle and this angle, the sound volume will fall off. /** Note: If the listener is outside of this cone, the sound cannot be heard. Between the inner cone angle and this angle, the sound volume will fall off.
Range: 0.0f to 360.0f (Default: 360.0f). Range: 0.0f to 360.0f (Default: 360.0f).
\param outerAngle: Outside angle of the cone. */ \param outerAngle: Outside angle of the cone. */
virtual void setOuterConeAngle(const float& outerAngle) = 0; virtual void setOuterConeAngle(const float& outerAngle) = 0;
//! Sets how much the volume of the source is scaled in the outer cone. //! Sets how much the volume of the source is scaled in the outer cone.
/** Range: 0.0f to +inf (Default: 0.0f). /** Range: 0.0f to +inf (Default: 0.0f).
\param outerVolume: Volume of the source in the outside cone. */ \param outerVolume: Volume of the source in the outside cone. */
virtual void setOuterConeVolume(const float& outerVolume) = 0; virtual void setOuterConeVolume(const float& outerVolume) = 0;
//! Sets the doppler strength, which enhances or diminishes the doppler effect. Can be used to exaggerate the doppler for a special effect. //! Sets the doppler strength, which enhances or diminishes the doppler effect. Can be used to exaggerate the doppler for a special effect.
/** Range: 0.0f to +inf (Default: 1.0f). /** Range: 0.0f to +inf (Default: 1.0f).
\param dstrength: New strength for the doppler effect. */ \param dstrength: New strength for the doppler effect. */
virtual void setDopplerStrength(const float& dstrength) = 0; virtual void setDopplerStrength(const float& dstrength) = 0;
//! Overrides the doppler velocity vector. It is usually better to let the engine take care of it automatically. //! Overrides the doppler velocity vector. It is usually better to let the engine take care of it automatically.
/** Note: must be set every time you set the position, velocity, or direction. /** Note: must be set every time you set the position, velocity, or direction.
\param dvelocity: New doppler vector for the source. */ \param dvelocity: New doppler vector for the source. */
virtual void setDopplerVelocity(const cVector3& dvelocity) = 0; virtual void setDopplerVelocity(const cVector3& dvelocity) = 0;
//! Convenience function to automatically set the velocity and position for you in a single call. //! Convenience function to automatically set the velocity and position for you in a single call.
/** Velocity will be set to new position - last position. /** Velocity will be set to new position - last position.
\param position: Position to move the source to. */ \param position: Position to move the source to. */
virtual void move(const cVector3& position) = 0; virtual void move(const cVector3& position) = 0;
//! Returns the audio objects position //! Returns the audio objects position
virtual const cVector3 getPosition() const = 0; virtual const cVector3 getPosition() const = 0;
//! Returns the audio objects velocity //! Returns the audio objects velocity
virtual const cVector3 getVelocity() const = 0; virtual const cVector3 getVelocity() const = 0;
//! Returns the audio objects direction //! Returns the audio objects direction
virtual const cVector3 getDirection() const = 0; virtual const cVector3 getDirection() const = 0;
//! Returns the factor used in attenuating the source over distance //! Returns the factor used in attenuating the source over distance
virtual const float getRolloffFactor() const = 0; virtual const float getRolloffFactor() const = 0;
//! Returns the strength of the source //! Returns the strength of the source
virtual const float getStrength() const = 0; virtual const float getStrength() const = 0;
//! Returns the distance from the source where attenuation will begin //! Returns the distance from the source where attenuation will begin
virtual const float getMinDistance() const = 0; virtual const float getMinDistance() const = 0;
//! Returns the distance from the source where attenuation will stop //! Returns the distance from the source where attenuation will stop
virtual const float getMaxDistance() const = 0; virtual const float getMaxDistance() const = 0;
//! Returns the pitch of the source //! Returns the pitch of the source
virtual const float getPitch() const = 0; virtual const float getPitch() const = 0;
//! Returns the source volume before attenuation and other effects //! Returns the source volume before attenuation and other effects
virtual const float getVolume() const = 0; virtual const float getVolume() const = 0;
//! Returns the minimum volume that the source can be attenuated to //! Returns the minimum volume that the source can be attenuated to
virtual const float getMinVolume() const = 0; virtual const float getMinVolume() const = 0;
//! Returns the maximum volume that the source can achieve //! Returns the maximum volume that the source can achieve
virtual const float getMaxVolume() const = 0; virtual const float getMaxVolume() const = 0;
//! Returns the angle of the inner sound cone of the source //! Returns the angle of the inner sound cone of the source
virtual const float getInnerConeAngle() const = 0; virtual const float getInnerConeAngle() const = 0;
//! Returns the angle of the outer sound cone of the source //! Returns the angle of the outer sound cone of the source
virtual const float getOuterConeAngle() const = 0; virtual const float getOuterConeAngle() const = 0;
//! Returns how much the volume of the source is scaled in the outer cone //! Returns how much the volume of the source is scaled in the outer cone
virtual const float getOuterConeVolume() const = 0; virtual const float getOuterConeVolume() const = 0;
//! Returns the doppler strength, which enhances or diminishes the doppler effect //! Returns the doppler strength, which enhances or diminishes the doppler effect
virtual const float getDopplerStrength() const = 0; virtual const float getDopplerStrength() const = 0;
//! Returns the override for the doppler velocity vector //! Returns the override for the doppler velocity vector
virtual const cVector3 getDopplerVelocity() const = 0; virtual const cVector3 getDopplerVelocity() const = 0;
//! Registers a new event handler to this source //! Registers a new event handler to this source
/** /**
\param handler: Pointer to the event handler to register. */ \param handler: Pointer to the event handler to register. */
virtual void registerEventHandler(ISourceEventHandler* handler) = 0; virtual void registerEventHandler(ISourceEventHandler* handler) = 0;
//! Removes a specified event handler from this source //! Removes a specified event handler from this source
/** /**
\param handler: Pointer to the event handler to remove. */ \param handler: Pointer to the event handler to remove. */
virtual void unRegisterEventHandler(ISourceEventHandler* handler) = 0; virtual void unRegisterEventHandler(ISourceEventHandler* handler) = 0;
//! Removes all event handlers attached to this source //! Removes all event handlers attached to this source
virtual void unRegisterAllEventHandlers() = 0; virtual void unRegisterAllEventHandlers() = 0;
#ifdef CAUDIO_EFX_ENABLED #ifdef CAUDIO_EFX_ENABLED
//! Returns the number of effects at one time this source can support. //! Returns the number of effects at one time this source can support.
virtual unsigned int getNumEffectSlotsAvailable() const = 0; virtual unsigned int getNumEffectSlotsAvailable() const = 0;
//! Attaches an EFX audio effect to this sound source to a specific slot. //! Attaches an EFX audio effect to this sound source to a specific slot.
/** /**
\param slot: Slot to attach this effect to. Range: 0 to getNumEffectSlotsAvailable(). \param slot: Slot to attach this effect to. Range: 0 to getNumEffectSlotsAvailable().
\param effect: Pointer to an effect object to attach. \param effect: Pointer to an effect object to attach.
\return Whether the effect was successfully attached. */ \return Whether the effect was successfully attached. */
virtual bool attachEffect(unsigned int slot, IEffect* effect) = 0; virtual bool attachEffect(unsigned int slot, IEffect* effect) = 0;
//! Removes an EFX audio effect from this sound source. //! Removes an EFX audio effect from this sound source.
/** /**
\param slot: Slot of the effect to remove. Range: 0 to getNumEffectSlotsAvailable().*/ \param slot: Slot of the effect to remove. Range: 0 to getNumEffectSlotsAvailable().*/
virtual void removeEffect(unsigned int slot) = 0; virtual void removeEffect(unsigned int slot) = 0;
//! Attaches an audio filter to this sound source that will operate on the direct feed, separate from any effects. //! Attaches an audio filter to this sound source that will operate on the direct feed, separate from any effects.
/** /**
\param filter: Pointer to the filter to attach. Any previous filter will be dropped. \param filter: Pointer to the filter to attach. Any previous filter will be dropped.
\return Whether the filter was successfully attached. */ \return Whether the filter was successfully attached. */
virtual bool attachFilter(IFilter* filter) = 0; virtual bool attachFilter(IFilter* filter) = 0;
//! Removes a previously attached filter. //! Removes a previously attached filter.
virtual void removeFilter() = 0; virtual void removeFilter() = 0;
#endif #endif
protected: protected:
private: private:
}; };
}; };
#endif //! IAUDIO_H #endif //! IAUDIO_H

View File

@ -1,36 +1,36 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef ICAPTUREEVENTHANDLER_H #ifndef ICAPTUREEVENTHANDLER_H
#define ICAPTUREEVENTHANDLER_H #define ICAPTUREEVENTHANDLER_H
namespace cAudio namespace cAudio
{ {
//! Interface for recieving Capture Manager Events //! Interface for recieving Capture Manager Events
class ICaptureEventHandler class ICaptureEventHandler
{ {
public: public:
//! This function is called on capture device intialize. //! This function is called on capture device intialize.
virtual void onInit() = 0; virtual void onInit() = 0;
//! This function is called when the capture manager update's its internal buffers. //! This function is called when the capture manager update's its internal buffers.
virtual void onUpdate() = 0; virtual void onUpdate() = 0;
//! This function is called on capture device shutdown. //! This function is called on capture device shutdown.
virtual void onRelease() = 0; virtual void onRelease() = 0;
//! This function is called when the user begins capturing audio. //! This function is called when the user begins capturing audio.
virtual void onBeginCapture() = 0; virtual void onBeginCapture() = 0;
//! This function is called when the user ends a capture operation. //! This function is called when the user ends a capture operation.
virtual void onEndCapture() = 0; virtual void onEndCapture() = 0;
//! This function is called whe user requests data from the capture buffer. //! This function is called whe user requests data from the capture buffer.
virtual void onUserRequestBuffer() = 0; virtual void onUserRequestBuffer() = 0;
}; };
}; };
#endif //! ICAPTUREEVENTHANDLER_H #endif //! ICAPTUREEVENTHANDLER_H

View File

@ -1,46 +1,46 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef IDATASOURCE_H #ifndef IDATASOURCE_H
#define IDATASOURCE_H #define IDATASOURCE_H
#include "IRefCounted.h" #include "IRefCounted.h"
namespace cAudio namespace cAudio
{ {
//! Interface for data providers in cAudio. //! Interface for data providers in cAudio.
class IDataSource : public IRefCounted class IDataSource : public IRefCounted
{ {
public: public:
IDataSource() { } IDataSource() { }
virtual ~IDataSource() { } virtual ~IDataSource() { }
//! Returns whether the source is valid. //! Returns whether the source is valid.
/** /**
\return Returns false in case of an error, like the file couldn't be found. */ \return Returns false in case of an error, like the file couldn't be found. */
virtual bool isValid() = 0; virtual bool isValid() = 0;
//! Returns the current location in the data stream. //! Returns the current location in the data stream.
virtual int getCurrentPos() = 0; virtual int getCurrentPos() = 0;
//! Returns the total size of the data stream. //! Returns the total size of the data stream.
virtual int getSize() = 0; virtual int getSize() = 0;
//! Reads out a section of the data stream. //! Reads out a section of the data stream.
/** /**
\param output: Pointer to a location to put the read data. \param output: Pointer to a location to put the read data.
\param size: Size in bytes of the data to read. \param size: Size in bytes of the data to read.
\return Number of bytes actually read. 0 bytes may indicate end of file or stream. */ \return Number of bytes actually read. 0 bytes may indicate end of file or stream. */
virtual int read(void* output, int size) = 0; virtual int read(void* output, int size) = 0;
//! Seek to a position in the data stream. //! Seek to a position in the data stream.
/** /**
\param amount: Amount in bytes to seek to. \param amount: Amount in bytes to seek to.
\param relative: If true the number of bytes in amount is relative to the current position in the stream. \param relative: If true the number of bytes in amount is relative to the current position in the stream.
\return True if seek was successful, false if not. */ \return True if seek was successful, false if not. */
virtual bool seek(int amount, bool relative) = 0; virtual bool seek(int amount, bool relative) = 0;
}; };
}; };
#endif //! IDATASOURCE_H #endif //! IDATASOURCE_H

View File

@ -1,30 +1,30 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef IDATASOURCEFACTORY_H #ifndef IDATASOURCEFACTORY_H
#define IDATASOURCEFACTORY_H #define IDATASOURCEFACTORY_H
#include "IDataSource.h" #include "IDataSource.h"
namespace cAudio namespace cAudio
{ {
//! Interface for creating data sources for use with the engine. //! Interface for creating data sources for use with the engine.
class IDataSourceFactory class IDataSourceFactory
{ {
public: public:
IDataSourceFactory() { } IDataSourceFactory() { }
virtual ~IDataSourceFactory() { } virtual ~IDataSourceFactory() { }
//! Creates a data source instance for use with the engine. //! Creates a data source instance for use with the engine.
/** /**
\param filename: Filename of the file to get a stream for. \param filename: Filename of the file to get a stream for.
\param streamingRequested: True if the user requested streaming capabilities from the data source. \param streamingRequested: True if the user requested streaming capabilities from the data source.
\return A pointer to a data source instance or NULL on failure to allocate. */ \return A pointer to a data source instance or NULL on failure to allocate. */
virtual IDataSource* CreateDataSource(const char* filename, bool streamingRequested) = 0; virtual IDataSource* CreateDataSource(const char* filename, bool streamingRequested) = 0;
protected: protected:
private: private:
}; };
}; };
#endif //! IDATASOURCEFACTORY_H #endif //! IDATASOURCEFACTORY_H

View File

@ -1,195 +1,195 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef IEFFECT_H #ifndef IEFFECT_H
#define IEFFECT_H #define IEFFECT_H
#include "IRefCounted.h" #include "IRefCounted.h"
#include "IFilter.h" #include "IFilter.h"
#include "IEffectParameters.h" #include "IEffectParameters.h"
#include "cAudioDefines.h" #include "cAudioDefines.h"
#ifdef CAUDIO_EFX_ENABLED #ifdef CAUDIO_EFX_ENABLED
namespace cAudio namespace cAudio
{ {
//! Enum of all available effect types in cAudio. //! Enum of all available effect types in cAudio.
enum EffectTypes enum EffectTypes
{ {
EET_NULL, EET_NULL,
EET_EAX_REVERB, EET_EAX_REVERB,
EET_REVERB, EET_REVERB,
EET_CHORUS, EET_CHORUS,
EET_DISTORTION, EET_DISTORTION,
EET_ECHO, EET_ECHO,
EET_FLANGER, EET_FLANGER,
EET_FREQUENCY_SHIFTER, EET_FREQUENCY_SHIFTER,
EET_VOCAL_MORPHER, EET_VOCAL_MORPHER,
EET_PITCH_SHIFTER, EET_PITCH_SHIFTER,
EET_RING_MODULATOR, EET_RING_MODULATOR,
EET_AUTOWAH, EET_AUTOWAH,
EET_COMPRESSOR, EET_COMPRESSOR,
EET_EQUALIZER, EET_EQUALIZER,
EET_COUNT EET_COUNT
}; };
//! Interface for a single effect in cAudio. //! Interface for a single effect in cAudio.
class IEffect : public IRefCounted class IEffect : public IRefCounted
{ {
public: public:
IEffect() { } IEffect() { }
virtual ~IEffect() { } virtual ~IEffect() { }
//! Returns the current type this effect object is set to. //! Returns the current type this effect object is set to.
virtual const EffectTypes& getType() const = 0; virtual const EffectTypes& getType() const = 0;
//! Sets the type of this effect object. //! Sets the type of this effect object.
/** /**
\param type: Type of effect to switch to. */ \param type: Type of effect to switch to. */
virtual void setType(const EffectTypes& type) = 0; virtual void setType(const EffectTypes& type) = 0;
//! Returns the current parameters for the EAX Reverb Effect. //! Returns the current parameters for the EAX Reverb Effect.
virtual const sEAXReverbParameters& getEAXReverbParameters() const = 0; virtual const sEAXReverbParameters& getEAXReverbParameters() const = 0;
//! Sets the parameters for the EAX Reverb Effect. //! Sets the parameters for the EAX Reverb Effect.
/** /**
\param param: Parameter struct to set this effect to.*/ \param param: Parameter struct to set this effect to.*/
virtual void setEAXReverbParameters(const sEAXReverbParameters& param) = 0; virtual void setEAXReverbParameters(const sEAXReverbParameters& param) = 0;
//! Returns the current parameters for the Reverb Effect. //! Returns the current parameters for the Reverb Effect.
virtual const sReverbParameters& getReverbParameters() const = 0; virtual const sReverbParameters& getReverbParameters() const = 0;
//! Sets the parameters for the Reverb Effect. //! Sets the parameters for the Reverb Effect.
/** /**
\param param: Parameter struct to set this effect to.*/ \param param: Parameter struct to set this effect to.*/
virtual void setReverbParameters(const sReverbParameters& param) = 0; virtual void setReverbParameters(const sReverbParameters& param) = 0;
//! Returns the current parameters for the Chorus Effect. //! Returns the current parameters for the Chorus Effect.
virtual const sChorusParameters& getChorusParameters() const = 0; virtual const sChorusParameters& getChorusParameters() const = 0;
//! Sets the parameters for the Chorus Effect. //! Sets the parameters for the Chorus Effect.
/** /**
\param param: Parameter struct to set this effect to.*/ \param param: Parameter struct to set this effect to.*/
virtual void setChorusParameters(const sChorusParameters& param) = 0; virtual void setChorusParameters(const sChorusParameters& param) = 0;
//! Returns the current parameters for the Distortion Effect. //! Returns the current parameters for the Distortion Effect.
virtual const sDistortionParameters& getDistortionParameters() const = 0; virtual const sDistortionParameters& getDistortionParameters() const = 0;
//! Sets the parameters for the Distortion Effect. //! Sets the parameters for the Distortion Effect.
/** /**
\param param: Parameter struct to set this effect to.*/ \param param: Parameter struct to set this effect to.*/
virtual void setDistortionParameters(const sDistortionParameters& param) = 0; virtual void setDistortionParameters(const sDistortionParameters& param) = 0;
//! Returns the current parameters for the Echo Effect. //! Returns the current parameters for the Echo Effect.
virtual const sEchoParameters& getEchoParameters() const = 0; virtual const sEchoParameters& getEchoParameters() const = 0;
//! Sets the parameters for the Echo Effect. //! Sets the parameters for the Echo Effect.
/** /**
\param param: Parameter struct to set this effect to.*/ \param param: Parameter struct to set this effect to.*/
virtual void setEchoParameters(const sEchoParameters& param) = 0; virtual void setEchoParameters(const sEchoParameters& param) = 0;
//! Returns the current parameters for the Flanger Effect. //! Returns the current parameters for the Flanger Effect.
virtual const sFlangerParameters& getFlangerParameters() const = 0; virtual const sFlangerParameters& getFlangerParameters() const = 0;
//! Sets the parameters for the Flanger Effect. //! Sets the parameters for the Flanger Effect.
/** /**
\param param: Parameter struct to set this effect to.*/ \param param: Parameter struct to set this effect to.*/
virtual void setFlangerParameters(const sFlangerParameters& param) = 0; virtual void setFlangerParameters(const sFlangerParameters& param) = 0;
//! Returns the current parameters for the Frequency Shift Effect. //! Returns the current parameters for the Frequency Shift Effect.
virtual const sFrequencyShiftParameters& getFrequencyShiftParameters() const = 0; virtual const sFrequencyShiftParameters& getFrequencyShiftParameters() const = 0;
//! Sets the parameters for the Frequency Shift Effect. //! Sets the parameters for the Frequency Shift Effect.
/** /**
\param param: Parameter struct to set this effect to.*/ \param param: Parameter struct to set this effect to.*/
virtual void setFrequencyShiftParameters(const sFrequencyShiftParameters& param) = 0; virtual void setFrequencyShiftParameters(const sFrequencyShiftParameters& param) = 0;
//! Returns the current parameters for the Vocal Morpher Effect. //! Returns the current parameters for the Vocal Morpher Effect.
virtual const sVocalMorpherParameters& getVocalMorpherParameters() const = 0; virtual const sVocalMorpherParameters& getVocalMorpherParameters() const = 0;
//! Sets the parameters for the Vocal Morpher Effect. //! Sets the parameters for the Vocal Morpher Effect.
/** /**
\param param: Parameter struct to set this effect to.*/ \param param: Parameter struct to set this effect to.*/
virtual void setVocalMorpherParameters(const sVocalMorpherParameters& param) = 0; virtual void setVocalMorpherParameters(const sVocalMorpherParameters& param) = 0;
//! Returns the current parameters for the Pitch Shifter Effect. //! Returns the current parameters for the Pitch Shifter Effect.
virtual const sPitchShifterParameters& getPitchShifterParameters() const = 0; virtual const sPitchShifterParameters& getPitchShifterParameters() const = 0;
//! Sets the parameters for the Pitch Shifter Effect. //! Sets the parameters for the Pitch Shifter Effect.
/** /**
\param param: Parameter struct to set this effect to.*/ \param param: Parameter struct to set this effect to.*/
virtual void setPitchShifterParameters(const sPitchShifterParameters& param) = 0; virtual void setPitchShifterParameters(const sPitchShifterParameters& param) = 0;
//! Returns the current parameters for the Ring Modulator Effect. //! Returns the current parameters for the Ring Modulator Effect.
virtual const sRingModulatorParameters& getRingModulatorParameters() const = 0; virtual const sRingModulatorParameters& getRingModulatorParameters() const = 0;
//! Sets the parameters for the Ring Modulator Effect. //! Sets the parameters for the Ring Modulator Effect.
/** /**
\param param: Parameter struct to set this effect to.*/ \param param: Parameter struct to set this effect to.*/
virtual void setRingModulatorParameters(const sRingModulatorParameters& param) = 0; virtual void setRingModulatorParameters(const sRingModulatorParameters& param) = 0;
//! Returns the current parameters for the Autowah Effect. //! Returns the current parameters for the Autowah Effect.
virtual const sAutowahParameters& getAutowahParameters() const = 0; virtual const sAutowahParameters& getAutowahParameters() const = 0;
//! Sets the parameters for the Autowah Effect. //! Sets the parameters for the Autowah Effect.
/** /**
\param param: Parameter struct to set this effect to.*/ \param param: Parameter struct to set this effect to.*/
virtual void setAutowahParameters(const sAutowahParameters& param) = 0; virtual void setAutowahParameters(const sAutowahParameters& param) = 0;
//! Returns the current parameters for the Compressor Effect. //! Returns the current parameters for the Compressor Effect.
virtual const sCompressorParameters& getCompressorParameters() const = 0; virtual const sCompressorParameters& getCompressorParameters() const = 0;
//! Sets the parameters for the Compressor Effect. //! Sets the parameters for the Compressor Effect.
/** /**
\param param: Parameter struct to set this effect to.*/ \param param: Parameter struct to set this effect to.*/
virtual void setCompressorParameters(const sCompressorParameters& param) = 0; virtual void setCompressorParameters(const sCompressorParameters& param) = 0;
//! Returns the current parameters for the Equalizer Effect. //! Returns the current parameters for the Equalizer Effect.
virtual const sEqualizerParameters& getEqualizerParameters() const = 0; virtual const sEqualizerParameters& getEqualizerParameters() const = 0;
//! Sets the parameters for the Equalizer Effect. //! Sets the parameters for the Equalizer Effect.
/** /**
\param param: Parameter struct to set this effect to.*/ \param param: Parameter struct to set this effect to.*/
virtual void setEqualizerParameters(const sEqualizerParameters& param) = 0; virtual void setEqualizerParameters(const sEqualizerParameters& param) = 0;
//! Returns the master volume for this effect. //! Returns the master volume for this effect.
/** This volume scales the amount of effect audible from all attached sources. /** This volume scales the amount of effect audible from all attached sources.
\return Currently set volume. */ \return Currently set volume. */
virtual float getMasterVolume() const = 0; virtual float getMasterVolume() const = 0;
//! Sets the master volume for this effect. //! Sets the master volume for this effect.
/** This volume scales the amount of effect audible from all attached sources. /** This volume scales the amount of effect audible from all attached sources.
\param volume: Volume to set the master volume to. 1.0f equal no volume change. Range: 0.0f to 1.0.*/ \param volume: Volume to set the master volume to. 1.0f equal no volume change. Range: 0.0f to 1.0.*/
virtual void setMasterVolume(const float& volume) = 0; virtual void setMasterVolume(const float& volume) = 0;
//! Returns if the effect for each attached source is attenuated by distance. //! Returns if the effect for each attached source is attenuated by distance.
virtual bool isIgnoringAttenuation() const = 0; virtual bool isIgnoringAttenuation() const = 0;
//! Sets whether the effect for each attached source is attenuated by distance. //! Sets whether the effect for each attached source is attenuated by distance.
/** If set to true, can cause some interesting and non-realistic effects, so be careful with it. /** If set to true, can cause some interesting and non-realistic effects, so be careful with it.
\param ignore: Whether to ignore attenuation. */ \param ignore: Whether to ignore attenuation. */
virtual void ignoreAttenuation(const bool& ignore) = 0; virtual void ignoreAttenuation(const bool& ignore) = 0;
//! Returns the attached filter to this audio effect. //! Returns the attached filter to this audio effect.
virtual IFilter* getFilter() const = 0; virtual IFilter* getFilter() const = 0;
//! Attaches a filter to this effect. //! Attaches a filter to this effect.
/** /**
\param filter: A Pointer to the filter to attach. */ \param filter: A Pointer to the filter to attach. */
virtual void attachFilter(IFilter* filter) = 0; virtual void attachFilter(IFilter* filter) = 0;
//! Removes the currently attached filter. //! Removes the currently attached filter.
virtual void removeFilter() = 0; virtual void removeFilter() = 0;
//! Returns a timestamp indicating the last time settings on this effect were changed. Used internally by the engine to update attached sources. //! Returns a timestamp indicating the last time settings on this effect were changed. Used internally by the engine to update attached sources.
virtual unsigned int getLastUpdated() const = 0; virtual unsigned int getLastUpdated() const = 0;
//! Returns if this effect is ready to be used or if it has encountered a fatal error. //! Returns if this effect is ready to be used or if it has encountered a fatal error.
virtual bool isValid() const = 0; virtual bool isValid() const = 0;
}; };
}; };
#endif #endif
#endif //! IEFFECT_H #endif //! IEFFECT_H

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +1,74 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef IFILTER_H #ifndef IFILTER_H
#define IFILTER_H #define IFILTER_H
#include "IRefCounted.h" #include "IRefCounted.h"
#include "cAudioDefines.h" #include "cAudioDefines.h"
#ifdef CAUDIO_EFX_ENABLED #ifdef CAUDIO_EFX_ENABLED
namespace cAudio namespace cAudio
{ {
//! Enum of all available filter types in cAudio. //! Enum of all available filter types in cAudio.
enum FilterTypes enum FilterTypes
{ {
EFT_NULL, EFT_NULL,
EFT_LOWPASS, EFT_LOWPASS,
EFT_HIGHPASS, EFT_HIGHPASS,
EFT_BANDPASS, EFT_BANDPASS,
EFT_COUNT EFT_COUNT
}; };
//! Interface for a filter in cAudio. //! Interface for a filter in cAudio.
class IFilter : public IRefCounted class IFilter : public IRefCounted
{ {
public: public:
IFilter() { } IFilter() { }
virtual ~IFilter() { } virtual ~IFilter() { }
//! Returns the type of the filter. //! Returns the type of the filter.
virtual const FilterTypes& getType() const = 0; virtual const FilterTypes& getType() const = 0;
//! Sets the type of this filter. //! Sets the type of this filter.
/** /**
\param type: Type of filter to set this filter up as. */ \param type: Type of filter to set this filter up as. */
virtual void setType(const FilterTypes& type) = 0; virtual void setType(const FilterTypes& type) = 0;
//! Returns the master volume of this filter. //! Returns the master volume of this filter.
virtual float getVolume() const = 0; virtual float getVolume() const = 0;
//! Sets the master volume of this filter. //! Sets the master volume of this filter.
/** This volume scales all audio that goes through it by this amount. /** This volume scales all audio that goes through it by this amount.
\param volume: New volume amount. Range: 0.0f to 1.0. */ \param volume: New volume amount. Range: 0.0f to 1.0. */
virtual void setVolume(const float& volume) = 0; virtual void setVolume(const float& volume) = 0;
//! Returns the volume for low frequencies. //! Returns the volume for low frequencies.
virtual float getLowFrequencyVolume() const = 0; virtual float getLowFrequencyVolume() const = 0;
//! Sets the volume for low frequencies. //! Sets the volume for low frequencies.
/** This volume scales lower frequency audio that goes through it by this amount. /** This volume scales lower frequency audio that goes through it by this amount.
\param volume: New volume amount. Range: 0.0f to 1.0. */ \param volume: New volume amount. Range: 0.0f to 1.0. */
virtual void setLowFrequencyVolume(const float& volumeLF) = 0; virtual void setLowFrequencyVolume(const float& volumeLF) = 0;
//! Returns the volume for high frequencies. //! Returns the volume for high frequencies.
virtual float getHighFrequencyVolume() const = 0; virtual float getHighFrequencyVolume() const = 0;
//! Sets the volume for high frequencies. //! Sets the volume for high frequencies.
/** This volume scales higher frequency audio that goes through it by this amount. /** This volume scales higher frequency audio that goes through it by this amount.
\param volume: New volume amount. Range: 0.0f to 1.0. */ \param volume: New volume amount. Range: 0.0f to 1.0. */
virtual void setHighFrequencyVolume(const float& volumeHF) = 0; virtual void setHighFrequencyVolume(const float& volumeHF) = 0;
//! Returns a timestamp indicating the last time settings on this filter were changed. Used internally by the engine to update attached sources or effects. //! Returns a timestamp indicating the last time settings on this filter were changed. Used internally by the engine to update attached sources or effects.
virtual unsigned int getLastUpdated() const = 0; virtual unsigned int getLastUpdated() const = 0;
//! Returns if this filter is ready to be used or if it has encountered a fatal error. //! Returns if this filter is ready to be used or if it has encountered a fatal error.
virtual bool isValid() const = 0; virtual bool isValid() const = 0;
}; };
}; };
#endif #endif
#endif //! IFILTER_H #endif //! IFILTER_H

View File

@ -1,81 +1,81 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef ILISTENER_H #ifndef ILISTENER_H
#define ILISTENER_H #define ILISTENER_H
#include "cVector3.h" #include "cVector3.h"
#include "cAudioDefines.h" #include "cAudioDefines.h"
namespace cAudio namespace cAudio
{ {
//! Interface for the listener in cAudio. This class provides abilities to move and orient where your camera or user is in the audio world. //! Interface for the listener in cAudio. This class provides abilities to move and orient where your camera or user is in the audio world.
class IListener class IListener
{ {
public: public:
IListener() {} IListener() {}
virtual ~IListener() {} virtual ~IListener() {}
//! Sets the position of the listener. //! Sets the position of the listener.
/** Note that you will still have to set velocity after this call for proper doppler effects. /** Note that you will still have to set velocity after this call for proper doppler effects.
Use move() if you'd like to have cAudio automatically handle velocity for you. */ Use move() if you'd like to have cAudio automatically handle velocity for you. */
/** /**
\param pos: New position for the listener. */ \param pos: New position for the listener. */
virtual void setPosition(const cVector3& pos) = 0; virtual void setPosition(const cVector3& pos) = 0;
//! Sets the direction the listener is facing //! Sets the direction the listener is facing
/** /**
\param dir: New direction vector for the listener. */ \param dir: New direction vector for the listener. */
virtual void setDirection(const cVector3& dir) = 0; virtual void setDirection(const cVector3& dir) = 0;
//! Sets the up vector to use for the listener //! Sets the up vector to use for the listener
/** Default up vector is Y+, same as OpenGL. /** Default up vector is Y+, same as OpenGL.
\param up: New up vector for the listener. */ \param up: New up vector for the listener. */
virtual void setUpVector(const cVector3& up) = 0; virtual void setUpVector(const cVector3& up) = 0;
//! Sets the current velocity of the listener for doppler effects //! Sets the current velocity of the listener for doppler effects
/** /**
\param vel: New velocity for the listener. */ \param vel: New velocity for the listener. */
virtual void setVelocity(const cVector3& vel) = 0; virtual void setVelocity(const cVector3& vel) = 0;
//! Sets the global volume modifier (will effect all sources) //! Sets the global volume modifier (will effect all sources)
/** /**
\param volume: Volume to scale all sources by. Range: 0.0 to +inf. */ \param volume: Volume to scale all sources by. Range: 0.0 to +inf. */
virtual void setMasterVolume(const float& volume) = 0; virtual void setMasterVolume(const float& volume) = 0;
//! Convenience function to automatically set the velocity and position for you in a single call //! Convenience function to automatically set the velocity and position for you in a single call
/** Velocity will be set to new position - last position /** Velocity will be set to new position - last position
\param pos: New position to move the listener to. */ \param pos: New position to move the listener to. */
virtual void move(const cVector3& pos) = 0; virtual void move(const cVector3& pos) = 0;
//! Returns the current position of the listener //! Returns the current position of the listener
virtual cVector3 getPosition(void) const = 0; virtual cVector3 getPosition(void) const = 0;
//! Returns the current direction of the listener //! Returns the current direction of the listener
virtual cVector3 getDirection(void) const = 0; virtual cVector3 getDirection(void) const = 0;
//! Returns the current up vector of the listener //! Returns the current up vector of the listener
virtual cVector3 getUpVector(void) const = 0; virtual cVector3 getUpVector(void) const = 0;
//! Returns the current velocity of the listener //! Returns the current velocity of the listener
virtual cVector3 getVelocity(void) const = 0; virtual cVector3 getVelocity(void) const = 0;
//! Returns the global volume modifier for all sources //! Returns the global volume modifier for all sources
virtual float getMasterVolume(void) const = 0; virtual float getMasterVolume(void) const = 0;
#ifdef CAUDIO_EFX_ENABLED #ifdef CAUDIO_EFX_ENABLED
//! Sets the meters per user world unit for use with sound effects //! Sets the meters per user world unit for use with sound effects
/** /**
\param meters: Number of meters per world unit in your simulation. */ \param meters: Number of meters per world unit in your simulation. */
virtual void setMetersPerUnit(const float& meters) = 0; virtual void setMetersPerUnit(const float& meters) = 0;
//! Returns the meters per user world unit for use with sound effects //! Returns the meters per user world unit for use with sound effects
virtual float getMetersPerUnit(void) const = 0; virtual float getMetersPerUnit(void) const = 0;
#endif #endif
protected: protected:
private: private:
}; };
} }
#endif //! ILISTENER_H #endif //! ILISTENER_H

View File

@ -1,48 +1,48 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef ILOGRECEIVER_H_INCLUDED #ifndef ILOGRECEIVER_H_INCLUDED
#define ILOGRECEIVER_H_INCLUDED #define ILOGRECEIVER_H_INCLUDED
namespace cAudio namespace cAudio
{ {
//! Enum of all supported log levels in cAudio. //! Enum of all supported log levels in cAudio.
enum LogLevel enum LogLevel
{ {
ELL_DEBUG, ELL_DEBUG,
ELL_INFO, ELL_INFO,
ELL_WARNING, ELL_WARNING,
ELL_ERROR, ELL_ERROR,
ELL_CRITICAL, ELL_CRITICAL,
ELL_COUNT ELL_COUNT
}; };
//! Contains strings for each log level to make them easier to print to a stream. //! Contains strings for each log level to make them easier to print to a stream.
const char* const LogLevelStrings[] = const char* const LogLevelStrings[] =
{ {
"Debug", "Debug",
"Information", "Information",
"Warning", "Warning",
"Error", "Error",
"Critical", "Critical",
0 0
}; };
//! Interface for receiving log messages and relaying them to some kind of output device or stream. //! Interface for receiving log messages and relaying them to some kind of output device or stream.
class ILogReceiver class ILogReceiver
{ {
public: public:
ILogReceiver() { } ILogReceiver() { }
~ILogReceiver() { } ~ILogReceiver() { }
//! Called on every logged message that is greater than or equal to the minimum log level. //! Called on every logged message that is greater than or equal to the minimum log level.
/** /**
\param sender: The class/component sending the message. \param sender: The class/component sending the message.
\param message: The log message itself. \param message: The log message itself.
\param level: Log level of the message. \param level: Log level of the message.
\param time: Time in seconds that the message was sent. This time has millisecond accuracy. */ \param time: Time in seconds that the message was sent. This time has millisecond accuracy. */
virtual bool OnLogMessage(const char* sender, const char* message, LogLevel level, float time) = 0; virtual bool OnLogMessage(const char* sender, const char* message, LogLevel level, float time) = 0;
}; };
}; };
#endif //! ILOGRECEIVER_H_INCLUDED #endif //! ILOGRECEIVER_H_INCLUDED

View File

@ -1,92 +1,92 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef ILOGGER_H_INCLUDED #ifndef ILOGGER_H_INCLUDED
#define ILOGGER_H_INCLUDED #define ILOGGER_H_INCLUDED
#include "ILogReceiver.h" #include "ILogReceiver.h"
#include "cAudioDefines.h" #include "cAudioDefines.h"
namespace cAudio namespace cAudio
{ {
//! Interface for all logging operations in cAudio. //! Interface for all logging operations in cAudio.
class ILogger class ILogger
{ {
public: public:
ILogger() { } ILogger() { }
virtual ~ILogger() { } virtual ~ILogger() { }
//! Used to log a critical error message to the logging system. //! Used to log a critical error message to the logging system.
/** /**
\param sender: Name of the class/component sending the message. \param sender: Name of the class/component sending the message.
\param msg: The message to send. */ \param msg: The message to send. */
virtual void logCritical( const char* sender, const char *msg, ... ) = 0; virtual void logCritical( const char* sender, const char *msg, ... ) = 0;
//! Used to log an error message to the logging system. //! Used to log an error message to the logging system.
/** /**
\param sender: Name of the class/component sending the message. \param sender: Name of the class/component sending the message.
\param msg: The message to send. */ \param msg: The message to send. */
virtual void logError( const char* sender, const char *msg, ... ) = 0; virtual void logError( const char* sender, const char *msg, ... ) = 0;
//! Used to log a warning to the logging system. //! Used to log a warning to the logging system.
/** /**
\param sender: Name of the class/component sending the message. \param sender: Name of the class/component sending the message.
\param msg: The message to send. */ \param msg: The message to send. */
virtual void logWarning( const char* sender, const char *msg, ... ) = 0; virtual void logWarning( const char* sender, const char *msg, ... ) = 0;
//! Used to log an informational message to the logging system. //! Used to log an informational message to the logging system.
/** /**
\param sender: Name of the class/component sending the message. \param sender: Name of the class/component sending the message.
\param msg: The message to send. */ \param msg: The message to send. */
virtual void logInfo( const char* sender, const char *msg, ... ) = 0; virtual void logInfo( const char* sender, const char *msg, ... ) = 0;
//! Used to log a debug message to the logging system. //! Used to log a debug message to the logging system.
/** /**
\param sender: Name of the class/component sending the message. \param sender: Name of the class/component sending the message.
\param msg: The message to send. */ \param msg: The message to send. */
virtual void logDebug( const char* sender, const char *msg, ... ) = 0; virtual void logDebug( const char* sender, const char *msg, ... ) = 0;
//! Returns the minimum log level that will be sent to the log receivers. //! Returns the minimum log level that will be sent to the log receivers.
virtual const LogLevel& getLogLevel() const = 0; virtual const LogLevel& getLogLevel() const = 0;
//! Sets the minimum log level that the engine will send to log receivers. //! Sets the minimum log level that the engine will send to log receivers.
/** Primarily used to prevent too much verbose information from being sent to disk/console. /** Primarily used to prevent too much verbose information from being sent to disk/console.
\param logLevel: LogLevel to set as the new minimum. Anything equal to or greater than this level will be logged. */ \param logLevel: LogLevel to set as the new minimum. Anything equal to or greater than this level will be logged. */
virtual void setLogLevel( const LogLevel& logLevel ) = 0; virtual void setLogLevel( const LogLevel& logLevel ) = 0;
//! Register Log Receiver. //! Register Log Receiver.
/** Note: Any class registered will become owned by the internal thread. /** Note: Any class registered will become owned by the internal thread.
If threading is enabled, you MUST make the receiver threadsafe if you plan to access it in your application while it is registered. If threading is enabled, you MUST make the receiver threadsafe if you plan to access it in your application while it is registered.
\param receiver: Pointer to your implementation of ILogReceiver. \param receiver: Pointer to your implementation of ILogReceiver.
\param name: Name of the log receiver. \param name: Name of the log receiver.
\return True on success, False on failure. */ \return True on success, False on failure. */
virtual bool registerLogReceiver(ILogReceiver* receiver, const char* name) = 0; virtual bool registerLogReceiver(ILogReceiver* receiver, const char* name) = 0;
//! Unregister a Log Receiver. //! Unregister a Log Receiver.
/** Will NOT delete any user added receiver, you must do that yourself. /** Will NOT delete any user added receiver, you must do that yourself.
\param name: Name of the log receiver to remove. */ \param name: Name of the log receiver to remove. */
virtual void unRegisterLogReceiver(const char* name) = 0; virtual void unRegisterLogReceiver(const char* name) = 0;
//! Returns whether an log receiver is currently registered. //! Returns whether an log receiver is currently registered.
/** /**
\param name: Name of the log receiver to check for. */ \param name: Name of the log receiver to check for. */
virtual bool isLogReceiverRegistered(const char* name) = 0; virtual bool isLogReceiverRegistered(const char* name) = 0;
//! Returns a registered log receiver. //! Returns a registered log receiver.
/** /**
\param name: Name of the log receiver to return. \param name: Name of the log receiver to return.
\return Pointer to the found log receiver or NULL if it could not be found. */ \return Pointer to the found log receiver or NULL if it could not be found. */
virtual ILogReceiver* getLogReceiver(const char* name) = 0; virtual ILogReceiver* getLogReceiver(const char* name) = 0;
protected: protected:
private: private:
}; };
//! Gets the interface to the logger. //! Gets the interface to the logger.
/** Note: This is the only way to get access to the logging capabilities of cAudio. /** Note: This is the only way to get access to the logging capabilities of cAudio.
\return A pointer to the logger interface. \return A pointer to the logger interface.
*/ */
CAUDIO_API ILogger* getLogger(); CAUDIO_API ILogger* getLogger();
}; };
#endif //! ILOGGER_H_INCLUDED #endif //! ILOGGER_H_INCLUDED

View File

@ -1,34 +1,34 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef IMANAGEREVENTHANDLER_H #ifndef IMANAGEREVENTHANDLER_H
#define IMANAGEREVENTHANDLER_H #define IMANAGEREVENTHANDLER_H
namespace cAudio namespace cAudio
{ {
//! Interface for event handlers for playback manager events. //! Interface for event handlers for playback manager events.
class IManagerEventHandler class IManagerEventHandler
{ {
public: public:
//! This function is called on manager initialization. //! This function is called on manager initialization.
virtual void onInit() = 0; virtual void onInit() = 0;
//! This function is called on every manager update. //! This function is called on every manager update.
virtual void onUpdate() = 0; virtual void onUpdate() = 0;
//! This function is called on manager shutdown. //! This function is called on manager shutdown.
virtual void onRelease() = 0; virtual void onRelease() = 0;
//! This function is called on when an audio source is created. //! This function is called on when an audio source is created.
virtual void onSourceCreate() = 0; virtual void onSourceCreate() = 0;
//! This function is called when an audio decoder is registered. //! This function is called when an audio decoder is registered.
virtual void onDecoderRegister() = 0; virtual void onDecoderRegister() = 0;
//! This function is called when a data source is registered. //! This function is called when a data source is registered.
virtual void onDataSourceRegister() = 0; virtual void onDataSourceRegister() = 0;
}; };
}; };
#endif //! IMANAGEREVENTHANDLER_H #endif //! IMANAGEREVENTHANDLER_H

View File

@ -1,31 +1,31 @@
#ifndef IMEMORYPROVIDER_H_INCLUDED #ifndef IMEMORYPROVIDER_H_INCLUDED
#define IMEMORYPROVIDER_H_INCLUDED #define IMEMORYPROVIDER_H_INCLUDED
#include "cAudioDefines.h" #include "cAudioDefines.h"
#include <cstring> #include <cstring>
namespace cAudio namespace cAudio
{ {
//! Interface for a class that allocates and frees memory used by cAudio. //! Interface for a class that allocates and frees memory used by cAudio.
class IMemoryProvider class IMemoryProvider
{ {
public: public:
//! Allocates memory and returns a pointer to it. //! Allocates memory and returns a pointer to it.
/** /**
\param size: Size of the memory chunk to allocate in bytes. \param size: Size of the memory chunk to allocate in bytes.
\param filename: Filename of the source file that this allocation took place in (in Debug) or NULL otherwise. \param filename: Filename of the source file that this allocation took place in (in Debug) or NULL otherwise.
\param line: Line of the source file where this allocation took place (in Debug) or -1 otherwise. \param line: Line of the source file where this allocation took place (in Debug) or -1 otherwise.
\param function: Function that this allocation took place in (in Debug) or NULL otherwise. \param function: Function that this allocation took place in (in Debug) or NULL otherwise.
\return Pointer to the allocated memory or NULL if allocation failed. */ \return Pointer to the allocated memory or NULL if allocation failed. */
virtual void* Allocate(size_t size, const char* filename, int line, const char* function) = 0; virtual void* Allocate(size_t size, const char* filename, int line, const char* function) = 0;
//! Frees memory previously allocated. //! Frees memory previously allocated.
/** /**
\param pointer: Pointer to the memory location to free. */ \param pointer: Pointer to the memory location to free. */
virtual void Free(void* pointer) = 0; virtual void Free(void* pointer) = 0;
//! Returns the largest possible single allocation that can be made. //! Returns the largest possible single allocation that can be made.
virtual size_t getMaxAllocationSize() = 0; virtual size_t getMaxAllocationSize() = 0;
}; };
}; };
#endif //! IMEMORYPROVIDER_H_INCLUDED #endif //! IMEMORYPROVIDER_H_INCLUDED

View File

@ -1,65 +1,65 @@
#ifndef IPLUGINMANAGER_H_INCLUDED #ifndef IPLUGINMANAGER_H_INCLUDED
#define IPLUGINMANAGER_H_INCLUDED #define IPLUGINMANAGER_H_INCLUDED
#include "IAudioPlugin.h" #include "IAudioPlugin.h"
#include "cAudioDefines.h" #include "cAudioDefines.h"
#ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT #ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
namespace cAudio namespace cAudio
{ {
//! Interface for the plugin capabilities of cAudio. //! Interface for the plugin capabilities of cAudio.
class IPluginManager class IPluginManager
{ {
public: public:
IPluginManager() { } IPluginManager() { }
~IPluginManager() { } ~IPluginManager() { }
//! Installs a plugin using a statically linked plugin implementation. //! Installs a plugin using a statically linked plugin implementation.
/** /**
\param plugin: Pointer to a plugin implementation to install. \param plugin: Pointer to a plugin implementation to install.
\param name: Optional name for the plugin. Pass NULL to have the plugin use its default name. \param name: Optional name for the plugin. Pass NULL to have the plugin use its default name.
\return True if plugin was installed successfully. */ \return True if plugin was installed successfully. */
virtual bool installPlugin(IAudioPlugin* plugin, const char* name = NULL) = 0; virtual bool installPlugin(IAudioPlugin* plugin, const char* name = NULL) = 0;
//! Installs a plugin from a dynamically linked library on your hard drive. //! Installs a plugin from a dynamically linked library on your hard drive.
/** /**
\param filename: Path to the dll/so/dynlib on your hard drive. \param filename: Path to the dll/so/dynlib on your hard drive.
\param name: Optional name for the plugin. Pass NULL to have the plugin use its default name. \param name: Optional name for the plugin. Pass NULL to have the plugin use its default name.
\return True if plugin was installed successfully. */ \return True if plugin was installed successfully. */
virtual bool installPlugin(const char* filename, const char* name = NULL) = 0; virtual bool installPlugin(const char* filename, const char* name = NULL) = 0;
//! Checks for the existance of a plugin with the supplied name. //! Checks for the existance of a plugin with the supplied name.
/** /**
\param name: Name of the plugin to check for. */ \param name: Name of the plugin to check for. */
virtual bool checkForPlugin(const char* name) = 0; virtual bool checkForPlugin(const char* name) = 0;
//! Returns a plugin interface for a plugin with the supplied name. //! Returns a plugin interface for a plugin with the supplied name.
/** /**
\param name: Name of the plugin to check return. \param name: Name of the plugin to check return.
\return A pointer to the plugin interface or NULL if it could not be found. */ \return A pointer to the plugin interface or NULL if it could not be found. */
virtual IAudioPlugin* getPlugin(const char* name) = 0; virtual IAudioPlugin* getPlugin(const char* name) = 0;
//! Returns the total number of installed plugins. //! Returns the total number of installed plugins.
virtual unsigned int getPluginCount() = 0; virtual unsigned int getPluginCount() = 0;
//! Removes a plugin installed via statically linked reference. //! Removes a plugin installed via statically linked reference.
/** /**
\param plugin: Pointer to the plugin implementation to uninstall. */ \param plugin: Pointer to the plugin implementation to uninstall. */
virtual void uninstallPlugin(IAudioPlugin* plugin) = 0; virtual void uninstallPlugin(IAudioPlugin* plugin) = 0;
//! Removes a plugin with the specified name. //! Removes a plugin with the specified name.
/** /**
\param name: Name of the plugin to uninstall. */ \param name: Name of the plugin to uninstall. */
virtual void uninstallPlugin(const char* name) = 0; virtual void uninstallPlugin(const char* name) = 0;
}; };
//! Gets the interface to the plugin manager. //! Gets the interface to the plugin manager.
/** Note: This is the only way to get access to the plugin capabilities of cAudio. /** Note: This is the only way to get access to the plugin capabilities of cAudio.
\return A pointer to the manager. \return A pointer to the manager.
*/ */
CAUDIO_API IPluginManager* getPluginManager(); CAUDIO_API IPluginManager* getPluginManager();
}; };
#endif //! CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT #endif //! CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
#endif //! IPLUGINMANAGER_H_INCLUDED #endif //! IPLUGINMANAGER_H_INCLUDED

View File

@ -1,47 +1,47 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef IREFCOUNTED_H #ifndef IREFCOUNTED_H
#define IREFCOUNTED_H #define IREFCOUNTED_H
#include "cAudioMemory.h" #include "cAudioMemory.h"
namespace cAudio namespace cAudio
{ {
//! Applies reference counting to certain cAudio objects. //! Applies reference counting to certain cAudio objects.
class IRefCounted class IRefCounted
{ {
public: public:
IRefCounted() : RefCount(1) { } IRefCounted() : RefCount(1) { }
virtual ~IRefCounted() { } virtual ~IRefCounted() { }
//! Increments the reference count by one. //! Increments the reference count by one.
void grab() void grab()
{ {
++RefCount; ++RefCount;
} }
//! Decrements the reference count by one. If it hits zero, this object is deleted. //! Decrements the reference count by one. If it hits zero, this object is deleted.
bool drop() bool drop()
{ {
--RefCount; --RefCount;
if (RefCount < 1) if (RefCount < 1)
{ {
CAUDIO_DELETE this; CAUDIO_DELETE this;
return true; return true;
} }
return false; return false;
} }
//! Returns the current reference count of this object. //! Returns the current reference count of this object.
int getReferenceCount() const int getReferenceCount() const
{ {
return RefCount; return RefCount;
} }
private: private:
int RefCount; int RefCount;
}; };
} }
#endif //! IREFCOUNTED_H #endif //! IREFCOUNTED_H

View File

@ -1,31 +1,31 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef ISOURCEEVENTHANDLER_H #ifndef ISOURCEEVENTHANDLER_H
#define ISOURCEEVENTHANDLER_H #define ISOURCEEVENTHANDLER_H
namespace cAudio namespace cAudio
{ {
//! Interface for event handlers on Audio Sources. //! Interface for event handlers on Audio Sources.
class ISourceEventHandler class ISourceEventHandler
{ {
public: public:
//! This function is called when a source updates its buffers. //! This function is called when a source updates its buffers.
virtual void onUpdate() = 0; virtual void onUpdate() = 0;
//! This function is called when a source is released and soon to be deleted. //! This function is called when a source is released and soon to be deleted.
virtual void onRelease() = 0; virtual void onRelease() = 0;
//! This function is called when a source starts playing. //! This function is called when a source starts playing.
virtual void onPlay() = 0; virtual void onPlay() = 0;
//! This function is called when a source stopped playback. //! This function is called when a source stopped playback.
virtual void onStop() = 0; virtual void onStop() = 0;
//! This function is called when a source is paused. //! This function is called when a source is paused.
virtual void onPause() = 0; virtual void onPause() = 0;
}; };
}; };
#endif //! ISOURCEEVENTHANDLER_H #endif //! ISOURCEEVENTHANDLER_H

View File

@ -1,111 +1,111 @@
/* cAudio.h -- interface of the 'cAudio Engine' /* cAudio.h -- interface of the 'cAudio Engine'
Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#ifndef CAUDIO_H #ifndef CAUDIO_H
#define CAUDIO_H #define CAUDIO_H
#include "cAudioDefines.h" #include "cAudioDefines.h"
#include "cAudioPlatform.h" #include "cAudioPlatform.h"
#include "cAudioSleep.h" #include "cAudioSleep.h"
#include "EAudioFormats.h" #include "EAudioFormats.h"
#include "IAudioSource.h" #include "IAudioSource.h"
#include "IAudioCapture.h" #include "IAudioCapture.h"
#include "IAudioDecoder.h" #include "IAudioDecoder.h"
#include "IAudioDecoderFactory.h" #include "IAudioDecoderFactory.h"
#include "IAudioEffects.h" #include "IAudioEffects.h"
#include "IAudioManager.h" #include "IAudioManager.h"
#include "IDataSource.h" #include "IDataSource.h"
#include "IEffect.h" #include "IEffect.h"
#include "IEffectParameters.h" #include "IEffectParameters.h"
#include "IFilter.h" #include "IFilter.h"
#include "IListener.h" #include "IListener.h"
#include "ILogger.h" #include "ILogger.h"
#include "ILogReceiver.h" #include "ILogReceiver.h"
#include "IPluginManager.h" #include "IPluginManager.h"
#include "IRefCounted.h" #include "IRefCounted.h"
/*! \mainpage cAudio 2.1.0 API documentation /*! \mainpage cAudio 2.1.0 API documentation
* *
* <img src="../cAudioLogo.jpg"></img> * <img src="../cAudioLogo.jpg"></img>
* *
* \section intro Introduction * \section intro Introduction
* *
* Welcome to the Main API Documentation for cAudio 2.1.0. cAudio is an advanced C++ wrapper around OpenAL, a professional and powerful * Welcome to the Main API Documentation for cAudio 2.1.0. cAudio is an advanced C++ wrapper around OpenAL, a professional and powerful
* audio library. Thus cAudio provides you with a number of classes to allow you to easily manipulate your audio world and * audio library. Thus cAudio provides you with a number of classes to allow you to easily manipulate your audio world and
* intergrate audio effects like reverberation, doppler, attenuation, ect. cAudio also has a plugin system, allowing developers to extend * intergrate audio effects like reverberation, doppler, attenuation, ect. cAudio also has a plugin system, allowing developers to extend
* the functionality of the library. Furthermore, cAudio is released under the zlib license, meaning it is free for you to use in your projects, * the functionality of the library. Furthermore, cAudio is released under the zlib license, meaning it is free for you to use in your projects,
* even if they are commercial. Of course, we suggest you read the full text of the license by looking at the local license.txt file or cAudio.h. * even if they are commercial. Of course, we suggest you read the full text of the license by looking at the local license.txt file or cAudio.h.
* *
* Included with the SDK is a number of tutorials. We suggest you begin with them as they will guide you through the basics of cAudio usage * Included with the SDK is a number of tutorials. We suggest you begin with them as they will guide you through the basics of cAudio usage
* and work up to more advanced topics. If you find you need more help, found a bug, or just want to talk about cAudio, please visit our forums * and work up to more advanced topics. If you find you need more help, found a bug, or just want to talk about cAudio, please visit our forums
* at <A HREF="http://www.deathtouchstudios.com/phpBB3/index.php" >http://www.deathtouchstudios.com/phpBB3/index.php</A>. * at <A HREF="http://www.deathtouchstudios.com/phpBB3/index.php" >http://www.deathtouchstudios.com/phpBB3/index.php</A>.
* *
* \section links Links * \section links Links
* *
* <A HREF="namespacec_audio.html">Namespaces</A>: Central namespace for the entire engine. A good place to begin looking.<BR> * <A HREF="namespacec_audio.html">Namespaces</A>: Central namespace for the entire engine. A good place to begin looking.<BR>
* <A HREF="annotated.html">Class list</A>: List of all classes in the engine with descriptions.<BR> * <A HREF="annotated.html">Class list</A>: List of all classes in the engine with descriptions.<BR>
* <A HREF="functions.html">Class members</A>: List of all methods.<BR> * <A HREF="functions.html">Class members</A>: List of all methods.<BR>
* *
* \section example Short example * \section example Short example
* *
* Below is a simple "Hello World" example of how to use the engine. Of course this is only the "tip of the iceburg" * Below is a simple "Hello World" example of how to use the engine. Of course this is only the "tip of the iceburg"
* when it comes to what cAudio is capable of. * when it comes to what cAudio is capable of.
* *
* \code * \code
* #include <cAudio.h> * #include <cAudio.h>
* *
* int main() * int main()
* { * {
* //Create an Audio Manager * //Create an Audio Manager
* cAudio::IAudioManager* manager = cAudio::createAudioManager(true); * cAudio::IAudioManager* manager = cAudio::createAudioManager(true);
* *
* //Create an audio source and load a sound from a file * //Create an audio source and load a sound from a file
* cAudio::IAudioSource* mysound = manager->create("music","../../media/cAudioTheme1.ogg",true); * cAudio::IAudioSource* mysound = manager->create("music","../../media/cAudioTheme1.ogg",true);
* *
* if(mysound) * if(mysound)
* { * {
* //Play our source in 2D once. * //Play our source in 2D once.
* mysound->play2d(false); * mysound->play2d(false);
* *
* //Wait for the sound to finish playing * //Wait for the sound to finish playing
* while(mysound->isPlaying()) * while(mysound->isPlaying())
* cAudio::cAudioSleep(10); * cAudio::cAudioSleep(10);
* } * }
* *
* //Shutdown cAudio * //Shutdown cAudio
* manager->shutDown(); * manager->shutDown();
* cAudio::destroyAudioManager(manager); * cAudio::destroyAudioManager(manager);
* *
* return 0; * return 0;
* } * }
* \endcode * \endcode
*/ */
//! Main namespace for the entire cAudio library //! Main namespace for the entire cAudio library
namespace cAudio namespace cAudio
{ {
}; };
#endif #endif

View File

@ -1,251 +1,251 @@
#ifndef CAUDIODEFINES_H #ifndef CAUDIODEFINES_H
#define CAUDIODEFINES_H #define CAUDIODEFINES_H
#include "cAudioPlatform.h" #include "cAudioPlatform.h"
//! Global define for the version of cAudio. //! Global define for the version of cAudio.
//! This is used primarily by plugins to make sure they are linking to the right library. //! This is used primarily by plugins to make sure they are linking to the right library.
#define CAUDIO_VERSION "2.1.0" #define CAUDIO_VERSION "2.2.0"
#if !defined( CAUDIO_DEBUG ) #if !defined( CAUDIO_DEBUG )
#if defined( DEBUG ) || defined( _DEBUG ) #if defined( DEBUG ) || defined( _DEBUG )
#define CAUDIO_DEBUG #define CAUDIO_DEBUG
#endif #endif
#endif #endif
////////////////////// //////////////////////
// Windows Settings // // Windows Settings //
////////////////////// //////////////////////
#ifdef CAUDIO_PLATFORM_WIN #ifdef CAUDIO_PLATFORM_WIN
#ifndef CAUDIO_STATIC_LIB #ifndef CAUDIO_STATIC_LIB
#define CAUDIO_API __declspec(dllexport) #define CAUDIO_API __declspec(dllexport)
#else #else
#define CAUDIO_API extern "C" #define CAUDIO_API extern "C"
#endif // CAUDIO_STATIC_LIB #endif // CAUDIO_STATIC_LIB
//!Define for making the entire library Thread Safe, comment out to disable. Will also disable internal threading by the library. //!Define for making the entire library Thread Safe, comment out to disable. Will also disable internal threading by the library.
#define CAUDIO_MAKE_THREAD_SAFE #define CAUDIO_MAKE_THREAD_SAFE
#ifdef CAUDIO_MAKE_THREAD_SAFE #ifdef CAUDIO_MAKE_THREAD_SAFE
//! Define enables threading for the main update loop. Disable to run the internal update loop yourself. NOTE: Internal threading should NOT be used if the library is not thread safe! //! Define enables threading for the main update loop. Disable to run the internal update loop yourself. NOTE: Internal threading should NOT be used if the library is not thread safe!
#define CAUDIO_USE_INTERNAL_THREAD #define CAUDIO_USE_INTERNAL_THREAD
#endif //CAUDIO_MAKE_THREAD_SAFE #endif //CAUDIO_MAKE_THREAD_SAFE
//! This define controls whether the Ogg/Vorbis decoder is compiled into the library. //! This define controls whether the Ogg/Vorbis decoder is compiled into the library.
#define CAUDIO_COMPILE_WITH_OGG_DECODER #define CAUDIO_COMPILE_WITH_OGG_DECODER
//! This define controls whether the RIFF/Wav decoder is compiled into the library. //! This define controls whether the RIFF/Wav decoder is compiled into the library.
#define CAUDIO_COMPILE_WITH_WAV_DECODER #define CAUDIO_COMPILE_WITH_WAV_DECODER
//! This define controls whether the default filesystem data source is compiled into the library //! This define controls whether the default filesystem data source is compiled into the library
#define CAUDIO_COMPILE_WITH_FILE_SOURCE #define CAUDIO_COMPILE_WITH_FILE_SOURCE
//! This define controls whether the default file logger (html) is compiled into the library //! This define controls whether the default file logger (html) is compiled into the library
#define CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER #define CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER
//! This define controls whether the default console logger is compiled into the library //! This define controls whether the default console logger is compiled into the library
#define CAUDIO_COMPILE_WITH_CONSOLE_LOG_RECEIVER #define CAUDIO_COMPILE_WITH_CONSOLE_LOG_RECEIVER
//! This define controls whether plugin support is added into the library, commenting it out will prevent any plugins from working //! This define controls whether plugin support is added into the library, commenting it out will prevent any plugins from working
#define CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT #define CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
#ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT #ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
//! Define enabled support for plugins as dynamic libs //! Define enabled support for plugins as dynamic libs
#define CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT #define CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT
#endif //CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT #endif //CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
//! Size of the internal buffer per source for audio data (total amount buffered is CAUDIO_SOURCE_BUFFER_SIZE * CAUDIO_SOURCE_NUM_BUFFERS) //! Size of the internal buffer per source for audio data (total amount buffered is CAUDIO_SOURCE_BUFFER_SIZE * CAUDIO_SOURCE_NUM_BUFFERS)
#define CAUDIO_SOURCE_BUFFER_SIZE ( 1024 * 64 ) #define CAUDIO_SOURCE_BUFFER_SIZE ( 1024 * 64 )
//! Number of internal buffers to cycle through per source (Note: using only 1 leads to choppy sound or premature ending of sources) //! Number of internal buffers to cycle through per source (Note: using only 1 leads to choppy sound or premature ending of sources)
#define CAUDIO_SOURCE_NUM_BUFFERS 3 #define CAUDIO_SOURCE_NUM_BUFFERS 3
//! Comment out to remove all EFX support from the library //! Comment out to remove all EFX support from the library
//#define CAUDIO_EFX_ENABLED //#define CAUDIO_EFX_ENABLED
//! Max number of effects that can be attached to a single sound source //! Max number of effects that can be attached to a single sound source
#define CAUDIO_SOURCE_MAX_EFFECT_SLOTS 4 #define CAUDIO_SOURCE_MAX_EFFECT_SLOTS 4
//! Tells cAudio to use the C standard memory functions for allocations (memalloc and free) //! Tells cAudio to use the C standard memory functions for allocations (memalloc and free)
#define CAUDIO_MEMORY_USE_STD #define CAUDIO_MEMORY_USE_STD
//! Tells cAudio to reroute memory allocations from stl containers into the defined memory provider for cAudio, otherwise the standard std::allocator is used. //! Tells cAudio to reroute memory allocations from stl containers into the defined memory provider for cAudio, otherwise the standard std::allocator is used.
#define CAUDIO_REROUTE_STL_ALLOCATIONS #define CAUDIO_REROUTE_STL_ALLOCATIONS
//! Activates the internal memory tracker, which can be used to detect and locate memory leaks. //! Activates the internal memory tracker, which can be used to detect and locate memory leaks.
//#define CAUDIO_USE_MEMORYTRACKER //#define CAUDIO_USE_MEMORYTRACKER
//! Tells the memory tracker to generate statistics on memory usage by cAudio //! Tells the memory tracker to generate statistics on memory usage by cAudio
//#define CAUDIO_MEMORYTRACKER_GENERATE_STATISTICS //#define CAUDIO_MEMORYTRACKER_GENERATE_STATISTICS
//! Tells the memory tracker to log each and every allocation done by cAudio. This can be very slow, use only if you are debugging an issue. //! Tells the memory tracker to log each and every allocation done by cAudio. This can be very slow, use only if you are debugging an issue.
//#define CAUDIO_MEMORYTRACKER_LOG_ALL_ALLOCATIONS //#define CAUDIO_MEMORYTRACKER_LOG_ALL_ALLOCATIONS
#endif //CAUDIO_PLATFORM_WIN #endif //CAUDIO_PLATFORM_WIN
/////////////////////// ///////////////////////
// Mac OS X Settings // // Mac OS X Settings //
/////////////////////// ///////////////////////
#ifdef CAUDIO_PLATFORM_MAC #ifdef CAUDIO_PLATFORM_MAC
#define CAUDIO_API extern "C" #define CAUDIO_API extern "C"
//!Define for making the entire library Thread Safe, comment out to disable. Will also disable internal threading by the library. //!Define for making the entire library Thread Safe, comment out to disable. Will also disable internal threading by the library.
#define CAUDIO_MAKE_THREAD_SAFE #define CAUDIO_MAKE_THREAD_SAFE
#ifdef CAUDIO_MAKE_THREAD_SAFE #ifdef CAUDIO_MAKE_THREAD_SAFE
//! Define enables threading for the main update loop. Disable to run the internal update loop yourself. NOTE: Internal threading should NOT be used if the library is not thread safe! //! Define enables threading for the main update loop. Disable to run the internal update loop yourself. NOTE: Internal threading should NOT be used if the library is not thread safe!
#define CAUDIO_USE_INTERNAL_THREAD #define CAUDIO_USE_INTERNAL_THREAD
#endif //CAUDIO_MAKE_THREAD_SAFE #endif //CAUDIO_MAKE_THREAD_SAFE
//! This define controls whether the Ogg/Vorbis decoder is compiled into the library. //! This define controls whether the Ogg/Vorbis decoder is compiled into the library.
#define CAUDIO_COMPILE_WITH_OGG_DECODER #define CAUDIO_COMPILE_WITH_OGG_DECODER
//! This define controls whether the RIFF/Wav decoder is compiled into the library. //! This define controls whether the RIFF/Wav decoder is compiled into the library.
#define CAUDIO_COMPILE_WITH_WAV_DECODER #define CAUDIO_COMPILE_WITH_WAV_DECODER
//! This define controls whether the default filesystem data source is compiled into the library //! This define controls whether the default filesystem data source is compiled into the library
#define CAUDIO_COMPILE_WITH_FILE_SOURCE #define CAUDIO_COMPILE_WITH_FILE_SOURCE
//! This define controls whether the default file logger (html) is compiled into the library //! This define controls whether the default file logger (html) is compiled into the library
#define CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER #define CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER
//! This define controls whether the default console logger is compiled into the library //! This define controls whether the default console logger is compiled into the library
#define CAUDIO_COMPILE_WITH_CONSOLE_LOG_RECEIVER #define CAUDIO_COMPILE_WITH_CONSOLE_LOG_RECEIVER
//! This define controls whether plugin support is added into the library, commenting it out will prevent any plugins from working //! This define controls whether plugin support is added into the library, commenting it out will prevent any plugins from working
#define CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT #define CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
#ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT #ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
//! Define enabled support for plugins as dynamic libs //! Define enabled support for plugins as dynamic libs
#define CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT #define CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT
#endif //CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT #endif //CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
//! Size of the internal buffer per source for audio data (total amount buffered is CAUDIO_SOURCE_BUFFER_SIZE * CAUDIO_SOURCE_NUM_BUFFERS) //! Size of the internal buffer per source for audio data (total amount buffered is CAUDIO_SOURCE_BUFFER_SIZE * CAUDIO_SOURCE_NUM_BUFFERS)
#define CAUDIO_SOURCE_BUFFER_SIZE ( 1024 * 64 ) #define CAUDIO_SOURCE_BUFFER_SIZE ( 1024 * 64 )
//! Number of internal buffers to cycle through per source (Note: using only 1 leads to choppy sound or premature ending of sources) //! Number of internal buffers to cycle through per source (Note: using only 1 leads to choppy sound or premature ending of sources)
#define CAUDIO_SOURCE_NUM_BUFFERS 3 #define CAUDIO_SOURCE_NUM_BUFFERS 3
//! Max number of effects that can be attached to a single sound source //! Max number of effects that can be attached to a single sound source
#define CAUDIO_SOURCE_MAX_EFFECT_SLOTS 4 #define CAUDIO_SOURCE_MAX_EFFECT_SLOTS 4
//! Tells cAudio to use the C standard memory functions for allocations (memalloc and free) //! Tells cAudio to use the C standard memory functions for allocations (memalloc and free)
#define CAUDIO_MEMORY_USE_STD #define CAUDIO_MEMORY_USE_STD
//! Tells cAudio to reroute memory allocations from stl containers into the defined memory provider for cAudio, otherwise the standard std::allocator is used. //! Tells cAudio to reroute memory allocations from stl containers into the defined memory provider for cAudio, otherwise the standard std::allocator is used.
//#define CAUDIO_REROUTE_STL_ALLOCATIONS //#define CAUDIO_REROUTE_STL_ALLOCATIONS
//! Activates the internal memory tracker, which can be used to detect and locate memory leaks. //! Activates the internal memory tracker, which can be used to detect and locate memory leaks.
//#define CAUDIO_USE_MEMORYTRACKER //#define CAUDIO_USE_MEMORYTRACKER
//! Tells the memory tracker to generate statistics on memory usage by cAudio //! Tells the memory tracker to generate statistics on memory usage by cAudio
//#define CAUDIO_MEMORYTRACKER_GENERATE_STATISTICS //#define CAUDIO_MEMORYTRACKER_GENERATE_STATISTICS
//! Tells the memory tracker to log each and every allocation done by cAudio. This can be very slow, use only if you are debugging an issue. //! Tells the memory tracker to log each and every allocation done by cAudio. This can be very slow, use only if you are debugging an issue.
//#define CAUDIO_MEMORYTRACKER_LOG_ALL_ALLOCATIONS //#define CAUDIO_MEMORYTRACKER_LOG_ALL_ALLOCATIONS
#endif //CAUDIO_PLATFORM_MAC #endif //CAUDIO_PLATFORM_MAC
///////////////////// /////////////////////
// IPhone Settings // // IPhone Settings //
///////////////////// /////////////////////
#ifdef CAUDIO_PLATFORM_IPHONE #ifdef CAUDIO_PLATFORM_IPHONE
#define CAUDIO_API extern "C" #define CAUDIO_API extern "C"
//!Define for making the entire library Thread Safe, comment out to disable. Will also disable internal threading by the library. //!Define for making the entire library Thread Safe, comment out to disable. Will also disable internal threading by the library.
#define CAUDIO_MAKE_THREAD_SAFE #define CAUDIO_MAKE_THREAD_SAFE
#ifdef CAUDIO_MAKE_THREAD_SAFE #ifdef CAUDIO_MAKE_THREAD_SAFE
//! Define enables threading for the main update loop. Disable to run the internal update loop yourself. NOTE: Internal threading should NOT be used if the library is not thread safe! //! Define enables threading for the main update loop. Disable to run the internal update loop yourself. NOTE: Internal threading should NOT be used if the library is not thread safe!
#define CAUDIO_USE_INTERNAL_THREAD #define CAUDIO_USE_INTERNAL_THREAD
#endif //CAUDIO_MAKE_THREAD_SAFE #endif //CAUDIO_MAKE_THREAD_SAFE
//! This define controls whether the Ogg/Vorbis decoder is compiled into the library. //! This define controls whether the Ogg/Vorbis decoder is compiled into the library.
#define CAUDIO_COMPILE_WITH_OGG_DECODER #define CAUDIO_COMPILE_WITH_OGG_DECODER
//! This define controls whether the RIFF/Wav decoder is compiled into the library. //! This define controls whether the RIFF/Wav decoder is compiled into the library.
#define CAUDIO_COMPILE_WITH_WAV_DECODER #define CAUDIO_COMPILE_WITH_WAV_DECODER
//! This define controls whether the default filesystem data source is compiled into the library //! This define controls whether the default filesystem data source is compiled into the library
#define CAUDIO_COMPILE_WITH_FILE_SOURCE #define CAUDIO_COMPILE_WITH_FILE_SOURCE
//! This define controls whether the default file logger (html) is compiled into the library //! This define controls whether the default file logger (html) is compiled into the library
#define CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER #define CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER
//! This define controls whether the default console logger is compiled into the library //! This define controls whether the default console logger is compiled into the library
#define CAUDIO_COMPILE_WITH_CONSOLE_LOG_RECEIVER #define CAUDIO_COMPILE_WITH_CONSOLE_LOG_RECEIVER
//! Size of the internal buffer per source for audio data (total amount buffered is CAUDIO_SOURCE_BUFFER_SIZE * CAUDIO_SOURCE_NUM_BUFFERS) //! Size of the internal buffer per source for audio data (total amount buffered is CAUDIO_SOURCE_BUFFER_SIZE * CAUDIO_SOURCE_NUM_BUFFERS)
#define CAUDIO_SOURCE_BUFFER_SIZE ( 1024 * 64 ) #define CAUDIO_SOURCE_BUFFER_SIZE ( 1024 * 64 )
//! Number of internal buffers to cycle through per source (Note: using only 1 leads to choppy sound or premature ending of sources) //! Number of internal buffers to cycle through per source (Note: using only 1 leads to choppy sound or premature ending of sources)
#define CAUDIO_SOURCE_NUM_BUFFERS 3 #define CAUDIO_SOURCE_NUM_BUFFERS 3
//! Tells cAudio to use the C standard memory functions for allocations (memalloc and free) //! Tells cAudio to use the C standard memory functions for allocations (memalloc and free)
#define CAUDIO_MEMORY_USE_STD #define CAUDIO_MEMORY_USE_STD
//! Tells cAudio to reroute memory allocations from stl containers into the defined memory provider for cAudio, otherwise the standard std::allocator is used. //! Tells cAudio to reroute memory allocations from stl containers into the defined memory provider for cAudio, otherwise the standard std::allocator is used.
//#define CAUDIO_REROUTE_STL_ALLOCATIONS //#define CAUDIO_REROUTE_STL_ALLOCATIONS
//! Activates the internal memory tracker, which can be used to detect and locate memory leaks. //! Activates the internal memory tracker, which can be used to detect and locate memory leaks.
//#define CAUDIO_USE_MEMORYTRACKER //#define CAUDIO_USE_MEMORYTRACKER
//! Tells the memory tracker to generate statistics on memory usage by cAudio //! Tells the memory tracker to generate statistics on memory usage by cAudio
//#define CAUDIO_MEMORYTRACKER_GENERATE_STATISTICS //#define CAUDIO_MEMORYTRACKER_GENERATE_STATISTICS
//! Tells the memory tracker to log each and every allocation done by cAudio. This can be very slow, use only if you are debugging an issue. //! Tells the memory tracker to log each and every allocation done by cAudio. This can be very slow, use only if you are debugging an issue.
//#define CAUDIO_MEMORYTRACKER_LOG_ALL_ALLOCATIONS //#define CAUDIO_MEMORYTRACKER_LOG_ALL_ALLOCATIONS
#endif //CAUDIO_PLATFORM_IPHONE #endif //CAUDIO_PLATFORM_IPHONE
//////////////////// ////////////////////
// Linux Settings // // Linux Settings //
//////////////////// ////////////////////
#ifdef CAUDIO_PLATFORM_LINUX #ifdef CAUDIO_PLATFORM_LINUX
#define CAUDIO_API extern "C" #define CAUDIO_API extern "C"
//!Define for making the entire library Thread Safe, comment out to disable. Will also disable internal threading by the library. //!Define for making the entire library Thread Safe, comment out to disable. Will also disable internal threading by the library.
#define CAUDIO_MAKE_THREAD_SAFE #define CAUDIO_MAKE_THREAD_SAFE
#ifdef CAUDIO_MAKE_THREAD_SAFE #ifdef CAUDIO_MAKE_THREAD_SAFE
//! Define enables threading for the main update loop. Disable to run the internal update loop yourself. NOTE: Internal threading should NOT be used if the library is not thread safe! //! Define enables threading for the main update loop. Disable to run the internal update loop yourself. NOTE: Internal threading should NOT be used if the library is not thread safe!
#define CAUDIO_USE_INTERNAL_THREAD #define CAUDIO_USE_INTERNAL_THREAD
#endif //CAUDIO_MAKE_THREAD_SAFE #endif //CAUDIO_MAKE_THREAD_SAFE
//! This define controls whether the Ogg/Vorbis decoder is compiled into the library. //! This define controls whether the Ogg/Vorbis decoder is compiled into the library.
#define CAUDIO_COMPILE_WITH_OGG_DECODER #define CAUDIO_COMPILE_WITH_OGG_DECODER
//! This define controls whether the RIFF/Wav decoder is compiled into the library. //! This define controls whether the RIFF/Wav decoder is compiled into the library.
#define CAUDIO_COMPILE_WITH_WAV_DECODER #define CAUDIO_COMPILE_WITH_WAV_DECODER
//! This define controls whether the default filesystem data source is compiled into the library //! This define controls whether the default filesystem data source is compiled into the library
#define CAUDIO_COMPILE_WITH_FILE_SOURCE #define CAUDIO_COMPILE_WITH_FILE_SOURCE
//! This define controls whether the default file logger (html) is compiled into the library //! This define controls whether the default file logger (html) is compiled into the library
#define CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER #define CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER
//! This define controls whether the default console logger is compiled into the library //! This define controls whether the default console logger is compiled into the library
#define CAUDIO_COMPILE_WITH_CONSOLE_LOG_RECEIVER #define CAUDIO_COMPILE_WITH_CONSOLE_LOG_RECEIVER
//! This define controls whether plugin support is added into the library, commenting it out will prevent any plugins from working //! This define controls whether plugin support is added into the library, commenting it out will prevent any plugins from working
#define CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT #define CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
#ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT #ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
//! Define enabled support for plugins as dynamic libs //! Define enabled support for plugins as dynamic libs
#define CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT #define CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT
#endif //CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT #endif //CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
//! Size of the internal buffer per source for audio data (total amount buffered is CAUDIO_SOURCE_BUFFER_SIZE * CAUDIO_SOURCE_NUM_BUFFERS) //! Size of the internal buffer per source for audio data (total amount buffered is CAUDIO_SOURCE_BUFFER_SIZE * CAUDIO_SOURCE_NUM_BUFFERS)
#define CAUDIO_SOURCE_BUFFER_SIZE ( 1024 * 64 ) #define CAUDIO_SOURCE_BUFFER_SIZE ( 1024 * 64 )
//! Number of internal buffers to cycle through per source (Note: using only 1 leads to choppy sound or premature ending of sources) //! Number of internal buffers to cycle through per source (Note: using only 1 leads to choppy sound or premature ending of sources)
#define CAUDIO_SOURCE_NUM_BUFFERS 3 #define CAUDIO_SOURCE_NUM_BUFFERS 3
//! Since linux has license issues with OpenAL EFX, we cannot release the header files necessary for it. Therefore, we must disable EFX on linux. Uncomment this define if you have EFX available on linux. //! Since linux has license issues with OpenAL EFX, we cannot release the header files necessary for it. Therefore, we must disable EFX on linux. Uncomment this define if you have EFX available on linux.
//#define CAUDIO_EFX_ENABLED //#define CAUDIO_EFX_ENABLED
//! Max number of effects that can be attached to a single sound source //! Max number of effects that can be attached to a single sound source
//#define CAUDIO_SOURCE_MAX_EFFECT_SLOTS 4 //#define CAUDIO_SOURCE_MAX_EFFECT_SLOTS 4
//! Tells cAudio to use the C standard memory functions for allocations (memalloc and free) //! Tells cAudio to use the C standard memory functions for allocations (memalloc and free)
#define CAUDIO_MEMORY_USE_STD #define CAUDIO_MEMORY_USE_STD
//! Tells cAudio to reroute memory allocations from stl containers into the defined memory provider for cAudio, otherwise the standard std::allocator is used. //! Tells cAudio to reroute memory allocations from stl containers into the defined memory provider for cAudio, otherwise the standard std::allocator is used.
#define CAUDIO_REROUTE_STL_ALLOCATIONS #define CAUDIO_REROUTE_STL_ALLOCATIONS
//! Activates the internal memory tracker, which can be used to detect and locate memory leaks. //! Activates the internal memory tracker, which can be used to detect and locate memory leaks.
//#define CAUDIO_USE_MEMORYTRACKER //#define CAUDIO_USE_MEMORYTRACKER
//! Tells the memory tracker to generate statistics on memory usage by cAudio //! Tells the memory tracker to generate statistics on memory usage by cAudio
//#define CAUDIO_MEMORYTRACKER_GENERATE_STATISTICS //#define CAUDIO_MEMORYTRACKER_GENERATE_STATISTICS
//! Tells the memory tracker to log each and every allocation done by cAudio. This can be very slow, use only if you are debugging an issue. //! Tells the memory tracker to log each and every allocation done by cAudio. This can be very slow, use only if you are debugging an issue.
//#define CAUDIO_MEMORYTRACKER_LOG_ALL_ALLOCATIONS //#define CAUDIO_MEMORYTRACKER_LOG_ALL_ALLOCATIONS
#endif //CAUDIO_PLATFORM_LINUX #endif //CAUDIO_PLATFORM_LINUX
#endif //CAUDIODEFINES_H #endif //CAUDIODEFINES_H

View File

@ -1,27 +1,27 @@
#ifndef CAUDIOMEMORY_H_INCLUDED #ifndef CAUDIOMEMORY_H_INCLUDED
#define CAUDIOMEMORY_H_INCLUDED #define CAUDIOMEMORY_H_INCLUDED
#include "cAudioDefines.h" #include "cAudioDefines.h"
#include "IMemoryProvider.h" #include "IMemoryProvider.h"
#ifdef CAUDIO_DEBUG #ifdef CAUDIO_DEBUG
#define CAUDIO_NEW new (__FILE__, __LINE__, __FUNCTION__) #define CAUDIO_NEW new (__FILE__, __LINE__, __FUNCTION__)
#define CAUDIO_DELETE delete #define CAUDIO_DELETE delete
#define CAUDIO_MALLOC(size) cAudio::getMemoryProvider()->Allocate(size, __FILE__, __LINE__, __FUNCTION__) #define CAUDIO_MALLOC(size) cAudio::getMemoryProvider()->Allocate(size, __FILE__, __LINE__, __FUNCTION__)
#define CAUDIO_FREE(pointer) cAudio::getMemoryProvider()->Free((void*)pointer) #define CAUDIO_FREE(pointer) cAudio::getMemoryProvider()->Free((void*)pointer)
#else #else
#define CAUDIO_NEW new #define CAUDIO_NEW new
#define CAUDIO_DELETE delete #define CAUDIO_DELETE delete
#define CAUDIO_MALLOC(size) cAudio::getMemoryProvider()->Allocate(size, NULL, -1, NULL) #define CAUDIO_MALLOC(size) cAudio::getMemoryProvider()->Allocate(size, NULL, -1, NULL)
#define CAUDIO_FREE(pointer) cAudio::getMemoryProvider()->Free((void*)pointer) #define CAUDIO_FREE(pointer) cAudio::getMemoryProvider()->Free((void*)pointer)
#endif #endif
namespace cAudio namespace cAudio
{ {
//! Returns a pointer to the memory provider of cAudio //! Returns a pointer to the memory provider of cAudio
/** Used by cAudio for all allocations of memory /** Used by cAudio for all allocations of memory
\return A pointer to the memory provider */ \return A pointer to the memory provider */
CAUDIO_API IMemoryProvider* getMemoryProvider(); CAUDIO_API IMemoryProvider* getMemoryProvider();
}; };
#endif //! CAUDIOMEMORY_H_INCLUDED #endif //! CAUDIOMEMORY_H_INCLUDED

View File

@ -1,42 +1,42 @@
#ifndef CAUDIOPLATFORM_H_INCLUDED #ifndef CAUDIOPLATFORM_H_INCLUDED
#define CAUDIOPLATFORM_H_INCLUDED #define CAUDIOPLATFORM_H_INCLUDED
#if !defined( CAUDIO_PLATFORM_WIN ) #if !defined( CAUDIO_PLATFORM_WIN )
# if defined( WIN32 ) || defined( _WINDOWS ) || defined(_WIN32) # if defined( WIN32 ) || defined( _WINDOWS ) || defined(_WIN32)
# define CAUDIO_PLATFORM_WIN # define CAUDIO_PLATFORM_WIN
# endif # endif
#endif #endif
#if !defined( CAUDIO_PLATFORM_MAC ) || !defined( CAUDIO_PLATFORM_IPHONE ) #if !defined( CAUDIO_PLATFORM_MAC ) || !defined( CAUDIO_PLATFORM_IPHONE )
# if defined( __APPLE__ ) || defined( __APPLE_CC__ ) || defined( MACOSX ) # if defined( __APPLE__ ) || defined( __APPLE_CC__ ) || defined( MACOSX )
# if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 30000 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 30000 # if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 30000 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 30000
# define CAUDIO_PLATFORM_IPHONE # define CAUDIO_PLATFORM_IPHONE
# else # else
# define CAUDIO_PLATFORM_MAC # define CAUDIO_PLATFORM_MAC
# endif # endif
# endif # endif
#endif #endif
#if !defined( CAUDIO_PLATFORM_LINUX ) #if !defined( CAUDIO_PLATFORM_LINUX )
# if defined(_UNIX) || defined(__linux) # if defined(_UNIX) || defined(__linux)
# define CAUDIO_PLATFORM_LINUX # define CAUDIO_PLATFORM_LINUX
# endif # endif
#endif #endif
#ifndef CAUDIO_COMPILIER_GCC #ifndef CAUDIO_COMPILIER_GCC
# if defined(__GNUC__) || defined(__GCCXML__) # if defined(__GNUC__) || defined(__GCCXML__)
# define CAUDIO_COMPILIER_GCC # define CAUDIO_COMPILIER_GCC
# endif # endif
#endif #endif
#ifndef CAUDIO_COMPILIER_MSVC #ifndef CAUDIO_COMPILIER_MSVC
# if defined(_MSC_VER) # if defined(_MSC_VER)
# if _MSC_VER >= 1400 # if _MSC_VER >= 1400
# define CAUDIO_COMPILIER_MSVC # define CAUDIO_COMPILIER_MSVC
# else # else
# error This version of the MSVC compilier is not supported # error This version of the MSVC compilier is not supported
# endif # endif
# endif # endif
#endif #endif
#endif //! CAUDIOPLATFORM_H_INCLUDED #endif //! CAUDIOPLATFORM_H_INCLUDED

View File

@ -1,17 +1,17 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef CAUDIOSLEEP_H #ifndef CAUDIOSLEEP_H
#define CAUDIOSLEEP_H #define CAUDIOSLEEP_H
#include "cAudioDefines.h" #include "cAudioDefines.h"
namespace cAudio namespace cAudio
{ {
//! Causes the current thread to give up control for a certain duration. //! Causes the current thread to give up control for a certain duration.
/** \param ms: amount of miliseconds to sleep */ /** \param ms: amount of miliseconds to sleep */
CAUDIO_API void cAudioSleep(unsigned int ms); CAUDIO_API void cAudioSleep(unsigned int ms);
}; };
#endif //! CAUDIOSLEEP_H #endif //! CAUDIOSLEEP_H

View File

@ -0,0 +1,113 @@
#ifndef CAUDIOSTRING_H_INCLUDED
#define CAUDIOSTRING_H_INCLUDED
#include "cAudioDefines.h"
#include "cAudioPlatform.h"
#include "cAudioMemory.h"
#include "cSTLAllocator.h"
#include <string>
#ifdef CAUDIO_PLATFORM_WIN
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# include <direct.h>
# include <io.h>
#endif
namespace cAudio
{
#if defined(UNICODE) || defined(_UNICODE)
# define _CTEXT(x) L ## x
# define cstrcmp wcscmp
# define cAudioChar wchar_t
# define cfopen _wfopen
#else
# define _CTEXT(x) x
# define cstrcmp strcmp
# define cAudioChar char
# define cfopen fopen
#endif
#ifdef CAUDIO_REROUTE_STL_ALLOCATIONS
typedef std::basic_string< cAudioChar, std::char_traits<cAudioChar>, cSTLAllocator<cAudioChar> > cAudioString;
#else
//typedef std::string cAudioString;
typedef std::basic_string<cAudioChar> cAudioString;
#endif
static const TCHAR* toWINSTR(const char* str)
{
#if defined(CAUDIO_PLATFORM_WIN) && (defined(UNICODE) || defined(_UNICODE))
static int id = 0;
static wchar_t buffer[8][1024];
id = ++id & 0x7;
int slen = strlen(str);
int buff_size = MultiByteToWideChar(CP_UTF8, 0, str, (int)(slen < 1023 ? slen : 1023), buffer[id], 1023);
buffer[id][buff_size] = 0;
buffer[id][1023] = 0;
return buffer[id];
#else
return str;
#endif
}
static const TCHAR* toWINSTR(const wchar_t* str)
{
#if defined(CAUDIO_PLATFORM_WIN) && (defined(UNICODE) || defined(_UNICODE))
return str;
#else
static int id = 0;
static char buffer[8][1024];
id = ++id & 0x7;
int slen = wcslen(str);
int buff_size = WideCharToMultiByte(CP_UTF8, 0, str, (int)(slen < 1023 ? slen : 1023), buffer[id], 1023, 0, false);
buffer[id][buff_size] = 0;
buffer[id][1023] = 0;
return buffer[id];
#endif
}
static const char* toUTF8(const cAudioString& str)
{
#if defined(CAUDIO_PLATFORM_WIN) && (defined(UNICODE) || defined(_UNICODE))
static int id = 0;
static char buffer[8][1024];
id = ++id & 0x7;
int buff_size = WideCharToMultiByte(CP_UTF8, 0, str.c_str(), (int)(str.size() < 1023 ? str.size() : 1023), buffer[id], 1023, 0, false);
buffer[id][buff_size] = 0;
buffer[id][1023] = 0;
return buffer[id];
#else
return str.c_str();
#endif
}
static cAudioString fromUTF8(const char* str)
{
#if defined(CAUDIO_PLATFORM_WIN) && (defined(UNICODE) || defined(_UNICODE))
wchar_t* buffer = 0;
int buff_size = MultiByteToWideChar(CP_UTF8, 0, str, (int)strlen(str), 0, 0);
if (buff_size == 0)
return cAudioString();
else
{
buffer = new wchar_t[buff_size + 1];
memset((void*)buffer, 0, sizeof(wchar_t) * (buff_size + 1));
MultiByteToWideChar(CP_UTF8, 0, str, (int)strlen(str), buffer, buff_size);
cAudioString s(buffer);
delete[] buffer;
return s;
}
#else
return cAudioString(str);
#endif
}
};
#endif //! CAUDIOSTRING_H_INCLUDED

View File

@ -1,132 +1,134 @@
#ifndef CSTLALLOCATOR_H_INCLUDED #ifndef CSTLALLOCATOR_H_INCLUDED
#define CSTLALLOCATOR_H_INCLUDED #define CSTLALLOCATOR_H_INCLUDED
#include "../include/cAudioDefines.h" #include "cAudioDefines.h"
#include "../include/cAudioMemory.h" #include "cAudioMemory.h"
//#include "cAudioString.h"
#include <set>
#include <map> #include <set>
#include <list> #include <map>
#include <vector> #include <list>
#include <string> #include <vector>
#include <string>
namespace cAudio
{ namespace cAudio
#ifdef CAUDIO_REROUTE_STL_ALLOCATIONS {
//! Reroutes allocations from STL containers into cAudio's memory system #ifdef CAUDIO_REROUTE_STL_ALLOCATIONS
template <typename T> class cSTLAllocator //! Reroutes allocations from STL containers into cAudio's memory system
{ template <typename T> class cSTLAllocator
public: {
typedef T value_type; public:
typedef value_type* pointer; typedef T value_type;
typedef const value_type* const_pointer; typedef value_type* pointer;
typedef value_type& reference; typedef const value_type* const_pointer;
typedef const value_type& const_reference; typedef value_type& reference;
typedef std::size_t size_type; typedef const value_type& const_reference;
typedef std::ptrdiff_t difference_type; typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
template<typename U>
struct rebind template<typename U>
{ struct rebind
typedef cSTLAllocator<U> other; {
}; typedef cSTLAllocator<U> other;
};
cSTLAllocator()
{ } cSTLAllocator()
{ }
~cSTLAllocator() throw()
{ } ~cSTLAllocator() throw()
{ }
cSTLAllocator( const cSTLAllocator& ) throw()
{ } cSTLAllocator( const cSTLAllocator& ) throw()
{ }
template <typename U>
cSTLAllocator( const cSTLAllocator<U>& ) throw() template <typename U>
{ } cSTLAllocator( const cSTLAllocator<U>& ) throw()
{ }
pointer address(reference x) const
{ pointer address(reference x) const
return &x; {
} return &x;
}
const_pointer address(const_reference x) const
{ const_pointer address(const_reference x) const
return &x; {
} return &x;
}
pointer allocate( size_type count, typename std::allocator<void>::const_pointer ptr = 0 )
{ pointer allocate( size_type count, typename std::allocator<void>::const_pointer ptr = 0 )
(void)ptr; {
register size_type size = count*sizeof( T ); (void)ptr;
pointer p = static_cast<pointer>(CAUDIO_MALLOC(size)); register size_type size = count*sizeof( T );
return p; pointer p = static_cast<pointer>(CAUDIO_MALLOC(size));
} return p;
}
void deallocate( pointer p, size_type size )
{ void deallocate( pointer p, size_type size )
CAUDIO_FREE(p); {
} CAUDIO_FREE(p);
}
size_type max_size() const throw()
{ size_type max_size() const throw()
return cAudio::getMemoryProvider()->getMaxAllocationSize(); {
} return cAudio::getMemoryProvider()->getMaxAllocationSize();
}
void construct(pointer p, const T& val)
{ void construct(pointer p, const T& val)
// call placement new {
new(static_cast<void*>(p)) T(val); // call placement new
} new(static_cast<void*>(p)) T(val);
}
void destroy(pointer p)
{ void destroy(pointer p)
p->~T(); {
} p->~T();
}; }
};
template<> class cSTLAllocator<void>
{ template<> class cSTLAllocator<void>
public: {
typedef size_t size_type; public:
typedef ptrdiff_t difference_type; typedef size_t size_type;
typedef void* pointer; typedef ptrdiff_t difference_type;
typedef const void* const_pointer; typedef void* pointer;
typedef void value_type; typedef const void* const_pointer;
typedef void value_type;
template<typename U>
struct rebind template<typename U>
{ struct rebind
typedef cSTLAllocator<U> other; {
}; typedef cSTLAllocator<U> other;
}; };
};
template <typename T>
inline bool operator==(const cSTLAllocator<T>&, const cSTLAllocator<T>&) template <typename T>
{ inline bool operator==(const cSTLAllocator<T>&, const cSTLAllocator<T>&)
return true; {
} return true;
}
template <typename T>
inline bool operator!=(const cSTLAllocator<T>&, const cSTLAllocator<T>&) template <typename T>
{ inline bool operator!=(const cSTLAllocator<T>&, const cSTLAllocator<T>&)
return false; {
} return false;
#endif }
#endif
#ifdef CAUDIO_REROUTE_STL_ALLOCATIONS
typedef std::basic_string< char, std::char_traits<char>, cSTLAllocator<char> > cAudioString; #ifdef CAUDIO_REROUTE_STL_ALLOCATIONS
template<typename T1, typename T2> struct cAudioMap { typedef std::map< T1, T2, std::less< T1 >, cSTLAllocator< std::pair< T1, T2 > > > Type; }; //typedef std::basic_string< cAudioChar, std::char_traits<cAudioChar>, cSTLAllocator<cAudioChar> > cAudioString;
template<typename T> struct cAudioSet { typedef std::set< T, std::less< T >, cSTLAllocator< T > > Type; }; template<typename T1, typename T2> struct cAudioMap { typedef std::map< T1, T2, std::less< T1 >, cSTLAllocator< std::pair< T1, T2 > > > Type; };
template<typename T> struct cAudioList { typedef std::list< T, cSTLAllocator< T > > Type; }; template<typename T> struct cAudioSet { typedef std::set< T, std::less< T >, cSTLAllocator< T > > Type; };
template<typename T> struct cAudioVector { typedef std::vector< T, cSTLAllocator< T > > Type; }; template<typename T> struct cAudioList { typedef std::list< T, cSTLAllocator< T > > Type; };
#else template<typename T> struct cAudioVector { typedef std::vector< T, cSTLAllocator< T > > Type; };
typedef std::string cAudioString; #else
template<typename T1, typename T2> struct cAudioMap { typedef std::map< T1, T2> Type; }; //typedef std::string cAudioString;
template<typename T> struct cAudioSet { typedef std::set< T > Type; }; //typedef std::basic_string<cAudioChar> cAudioString;
template<typename T> struct cAudioList { typedef std::list< T > Type; }; template<typename T1, typename T2> struct cAudioMap { typedef std::map< T1, T2> Type; };
template<typename T> struct cAudioVector { typedef std::vector< T > Type; }; template<typename T> struct cAudioSet { typedef std::set< T > Type; };
#endif template<typename T> struct cAudioList { typedef std::list< T > Type; };
template<typename T> struct cAudioVector { typedef std::vector< T > Type; };
}; #endif
#endif //! CSTLALLOCATOR_H_INCLUDED };
#endif //! CSTLALLOCATOR_H_INCLUDED

View File

@ -1,156 +1,156 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine" // This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h // For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef CVECTOR3_H #ifndef CVECTOR3_H
#define CVECTOR3_H #define CVECTOR3_H
#include <math.h> #include <math.h>
namespace cAudio namespace cAudio
{ {
//! Smallest number that can be represented with a 32 bit float (may not match your compiler/os varient) //! Smallest number that can be represented with a 32 bit float (may not match your compiler/os varient)
const float Epsilon = 0.000001f; const float Epsilon = 0.000001f;
//! Internal function that compares two floats while keeping the Epsilon in mind. //! Internal function that compares two floats while keeping the Epsilon in mind.
inline bool float_equals(const float a, const float b) inline bool float_equals(const float a, const float b)
{ {
return (a + Epsilon >= b) && (a - Epsilon <= b); return (a + Epsilon >= b) && (a - Epsilon <= b);
} }
//! Class for manipulating vectors in 3D space. //! Class for manipulating vectors in 3D space.
class cVector3 class cVector3
{ {
public: public:
float x, y, z; float x, y, z;
//! Default constructor, initializes everything to 0. //! Default constructor, initializes everything to 0.
cVector3(void) : x(0), y(0), z(0) cVector3(void) : x(0), y(0), z(0)
{ {
} }
cVector3(float nx, float ny, float nz) : x(nx), y(ny), z(nz) cVector3(float nx, float ny, float nz) : x(nx), y(ny), z(nz)
{ {
} }
//! Constructor, initializes all 3 axes to the same value. //! Constructor, initializes all 3 axes to the same value.
cVector3(float n) : x(n), y(n), z(n) cVector3(float n) : x(n), y(n), z(n)
{ {
} }
cVector3(const cVector3& other) : x(other.x), y(other.y), z(other.z) cVector3(const cVector3& other) : x(other.x), y(other.y), z(other.z)
{ {
} }
cVector3(float* vector) : x(vector[0]), y(vector[1]), z(vector[2]) cVector3(float* vector) : x(vector[0]), y(vector[1]), z(vector[2])
{ {
} }
cVector3 operator-() const { return cVector3(-x, -y, -z); } cVector3 operator-() const { return cVector3(-x, -y, -z); }
cVector3& operator=(const cVector3& other) { x = other.x; y = other.y; z = other.z; return *this; } cVector3& operator=(const cVector3& other) { x = other.x; y = other.y; z = other.z; return *this; }
cVector3 operator+(const cVector3& other) const { return cVector3(x + other.x, y + other.y, z + other.z); } cVector3 operator+(const cVector3& other) const { return cVector3(x + other.x, y + other.y, z + other.z); }
cVector3& operator+=(const cVector3& other) { x+=other.x; y+=other.y; z+=other.z; return *this; } cVector3& operator+=(const cVector3& other) { x+=other.x; y+=other.y; z+=other.z; return *this; }
cVector3 operator+(const float val) const { return cVector3(x + val, y + val, z + val); } cVector3 operator+(const float val) const { return cVector3(x + val, y + val, z + val); }
cVector3& operator+=(const float val) { x+=val; y+=val; z+=val; return *this; } cVector3& operator+=(const float val) { x+=val; y+=val; z+=val; return *this; }
cVector3 operator-(const cVector3& other) const { return cVector3(x - other.x, y - other.y, z - other.z); } cVector3 operator-(const cVector3& other) const { return cVector3(x - other.x, y - other.y, z - other.z); }
cVector3& operator-=(const cVector3& other) { x-=other.x; y-=other.y; z-=other.z; return *this; } cVector3& operator-=(const cVector3& other) { x-=other.x; y-=other.y; z-=other.z; return *this; }
cVector3 operator-(const float val) const { return cVector3(x - val, y - val, z - val); } cVector3 operator-(const float val) const { return cVector3(x - val, y - val, z - val); }
cVector3& operator-=(const float val) { x-=val; y-=val; z-=val; return *this; } cVector3& operator-=(const float val) { x-=val; y-=val; z-=val; return *this; }
cVector3 operator*(const cVector3& other) const { return cVector3(x * other.x, y * other.y, z * other.z); } cVector3 operator*(const cVector3& other) const { return cVector3(x * other.x, y * other.y, z * other.z); }
cVector3& operator*=(const cVector3& other) { x*=other.x; y*=other.y; z*=other.z; return *this; } cVector3& operator*=(const cVector3& other) { x*=other.x; y*=other.y; z*=other.z; return *this; }
cVector3 operator*(const float v) const { return cVector3(x * v, y * v, z * v); } cVector3 operator*(const float v) const { return cVector3(x * v, y * v, z * v); }
cVector3& operator*=(const float v) { x*=v; y*=v; z*=v; return *this; } cVector3& operator*=(const float v) { x*=v; y*=v; z*=v; return *this; }
cVector3 operator/(const cVector3& other) const { return cVector3(x / other.x, y / other.y, z / other.z); } cVector3 operator/(const cVector3& other) const { return cVector3(x / other.x, y / other.y, z / other.z); }
cVector3& operator/=(const cVector3& other) { x/=other.x; y/=other.y; z/=other.z; return *this; } cVector3& operator/=(const cVector3& other) { x/=other.x; y/=other.y; z/=other.z; return *this; }
cVector3 operator/(const float v) const { float i=(float)1.0/v; return cVector3(x * i, y * i, z * i); } cVector3 operator/(const float v) const { float i=(float)1.0/v; return cVector3(x * i, y * i, z * i); }
cVector3& operator/=(const float v) { float i=(float)1.0/v; x*=i; y*=i; z*=i; return *this; } cVector3& operator/=(const float v) { float i=(float)1.0/v; x*=i; y*=i; z*=i; return *this; }
bool operator<=(const cVector3& other) const { return x<=other.x && y<=other.y && z<=other.z;} bool operator<=(const cVector3& other) const { return x<=other.x && y<=other.y && z<=other.z;}
bool operator>=(const cVector3& other) const { return x>=other.x && y>=other.y && z>=other.z;} bool operator>=(const cVector3& other) const { return x>=other.x && y>=other.y && z>=other.z;}
bool operator<(const cVector3& other) const { return x<other.x && y<other.y && z<other.z;} bool operator<(const cVector3& other) const { return x<other.x && y<other.y && z<other.z;}
bool operator>(const cVector3& other) const { return x>other.x && y>other.y && z>other.z;} bool operator>(const cVector3& other) const { return x>other.x && y>other.y && z>other.z;}
bool operator==(const cVector3& other) const bool operator==(const cVector3& other) const
{ {
return float_equals(x, other.x) && return float_equals(x, other.x) &&
float_equals(y, other.y) && float_equals(y, other.y) &&
float_equals(z, other.z); float_equals(z, other.z);
} }
bool operator!=(const cVector3& other) const bool operator!=(const cVector3& other) const
{ {
return !(float_equals(x, other.x) && return !(float_equals(x, other.x) &&
float_equals(y, other.y) && float_equals(y, other.y) &&
float_equals(z, other.z)); float_equals(z, other.z));
} }
operator const float*() const { return &x; } operator const float*() const { return &x; }
operator float*() { return &x; } operator float*() { return &x; }
const float operator[] ( int i ) const { return ( ( float* ) &x ) [i]; } const float operator[] ( int i ) const { return ( ( float* ) &x ) [i]; }
float &operator[] ( int i ) { return ( ( float* ) &x ) [i]; } float &operator[] ( int i ) { return ( ( float* ) &x ) [i]; }
//! Returns the length (magnitude) of the vector. //! Returns the length (magnitude) of the vector.
float length() const float length() const
{ {
return sqrtf( x*x + y*y + z*z ); return sqrtf( x*x + y*y + z*z );
} }
//! Forces the current vector to have a length of 1 while preserving the ratio of components. //! Forces the current vector to have a length of 1 while preserving the ratio of components.
void normalize() void normalize()
{ {
float invLen = 1.0f / length(); float invLen = 1.0f / length();
x *= invLen; x *= invLen;
y *= invLen; y *= invLen;
z *= invLen; z *= invLen;
} }
//! Returns the dot product of this vector with the input vector. //! Returns the dot product of this vector with the input vector.
float dot( const cVector3& other ) const float dot( const cVector3& other ) const
{ {
return ( x * other.x + y * other.y + z * other.z ); return ( x * other.x + y * other.y + z * other.z );
} }
//! Returns the cross product of this vector with the input vector. //! Returns the cross product of this vector with the input vector.
cVector3 cross( const cVector3& other ) const cVector3 cross( const cVector3& other ) const
{ {
return cVector3( y * other.z - z * other.y, z * other.x - x * other.z, x * other.y - y * other.x ); return cVector3( y * other.z - z * other.y, z * other.x - x * other.z, x * other.y - y * other.x );
} }
//! Sets the components of this vector. //! Sets the components of this vector.
void set( float nx, float ny, float nz ) void set( float nx, float ny, float nz )
{ {
x = nx; x = nx;
y = ny; y = ny;
z = nz; z = nz;
} }
//! Sets all components of this vector to the same number. //! Sets all components of this vector to the same number.
void set( float n ) void set( float n )
{ {
x = y = z = n; x = y = z = n;
} }
//! Sets this vector's components to match the input vector's. //! Sets this vector's components to match the input vector's.
void set( const cVector3& other ) void set( const cVector3& other )
{ {
x = other.x; x = other.x;
y = other.y; y = other.y;
z = other.z; z = other.z;
} }
void getAsArray(float* output) void getAsArray(float* output)
{ {
output[0] = x; output[0] = x;
output[1] = y; output[1] = y;
output[2] = z; output[2] = z;
} }
}; };
}; };
#endif //! CVECTOR3_H #endif //! CVECTOR3_H

File diff suppressed because it is too large Load Diff