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
//****************************************************************
@ -14,7 +14,7 @@ using namespace std;
int main(int argc, char* argv[]) {
//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
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
//****************************************************************
@ -16,7 +16,7 @@ using namespace std;
int main(int argc, char* argv[])
{
//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
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*
//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
//****************************************************************

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,135 +1,135 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef IAUDIOCAPTURE_H
#define IAUDIOCAPTURE_H
#include "EAudioFormats.h"
#include "cAudioDefines.h"
#include "ICaptureEventHandler.h"
namespace cAudio
{
//! Interface for capturing operations in the cAudio Engine.
class IAudioCapture
{
public:
IAudioCapture() { }
virtual ~IAudioCapture() { }
//! 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.
\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 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.
\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;
//! Returns true if the current OpenAL implementation supports capturing audio.
virtual bool isSupported() = 0;
//! Returns true if the capture device is ready to be used. False may indicate an error with the current settings.
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.
/** \param force: Force capturing data from the buffer, even if the buffer is not half full. */
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.
virtual void shutdown() = 0;
//! Returns the name of an available capture device.
/** \param index: Specify which name to retrieve ( Range: 0 to getAvailableDeviceCount()-1 ).
\return Name of the selected device. */
virtual const char* getAvailableDeviceName(unsigned int index) = 0;
//! Returns the number of capture devices available for use.
/** \return Number of capture devices available. */
virtual unsigned int getAvailableDeviceCount() = 0;
//! Returns the name of the default system playback device.
/** \return Name of the default capture device. */
virtual const char* getDefaultDeviceName() = 0;
//! Returns the name of the audio device being used to capture audio.
virtual const char* getDeviceName() = 0;
//! Returns the frequency that the captured audio will be at.
virtual unsigned int getFrequency() = 0;
//! Returns the format of the captured audio.
virtual AudioFormats getFormat() = 0;
//! Returns the internal OpenAL buffer size in bytes.
/** \return Size of the buffer in bytes. */
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.
/** \return Size of a sample in bytes. */
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.
/**
\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. */
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.
/**
\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. */
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.
/**
\param format: Format of the captured audio.
\return True on success, False if the capture device failed to initialize. */
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.
/**
\param internalBufferSize: Size of the internal OpenAL buffer in bytes.
\return True on success, False if the capture device failed to initialize. */
virtual bool setInternalBufferSize(unsigned int internalBufferSize) = 0;
//! Starts capturing audio data to an internal buffer. Will clear any old data in the buffer.
/** \return True if capture was successfully started. */
virtual bool beginCapture() = 0;
//! Stops capturing audio data to an internal buffer.
virtual void stopCapture() = 0;
//! 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.
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 outputBufferSize: Size of the output array in bytes.
\return Size in bytes of the data actually copied to the output buffer.
*/
virtual unsigned int getCapturedAudio(void* outputBuffer, unsigned int outputBufferSize) = 0;
//! Returns the current size of the internal audio buffer in bytes.
virtual unsigned int getCurrentCapturedAudioSize() = 0;
//!Registers a new event handler to this manager.
/** \param handler: Pointer to an event handler to attach. */
virtual void registerEventHandler(ICaptureEventHandler* handler) = 0;
//!Removes the specified event handler from this manager.
/** \param handler: Pointer to an event handler to remove. */
virtual void unRegisterEventHandler(ICaptureEventHandler* handler) = 0;
//!Removes all event handlers attached to this manager.
virtual void unRegisterAllEventHandlers() = 0;
};
//! Creates an interface to an Audio Capture Object.
/** 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.
\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.
*/
CAUDIO_API IAudioCapture* createAudioCapture(bool initializeDefault = true);
//! Destroys an interface to a previously created Audio Capture Object and frees the memory allocated for it.
/**
\param capture: The object to destroy
*/
CAUDIO_API void destroyAudioCapture(IAudioCapture* capture);
//! Returns if the thread used to update all Audio Capture Objects is running.
/** 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.
\return True if the thread is currently running, false otherwise.
*/
CAUDIO_API bool isAudioCaptureThreadRunning();
};
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef IAUDIOCAPTURE_H
#define IAUDIOCAPTURE_H
#include "EAudioFormats.h"
#include "cAudioDefines.h"
#include "ICaptureEventHandler.h"
namespace cAudio
{
//! Interface for capturing operations in the cAudio Engine.
class IAudioCapture
{
public:
IAudioCapture() { }
virtual ~IAudioCapture() { }
//! 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.
\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 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.
\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;
//! Returns true if the current OpenAL implementation supports capturing audio.
virtual bool isSupported() = 0;
//! Returns true if the capture device is ready to be used. False may indicate an error with the current settings.
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.
/** \param force: Force capturing data from the buffer, even if the buffer is not half full. */
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.
virtual void shutdown() = 0;
//! Returns the name of an available capture device.
/** \param index: Specify which name to retrieve ( Range: 0 to getAvailableDeviceCount()-1 ).
\return Name of the selected device. */
virtual const char* getAvailableDeviceName(unsigned int index) = 0;
//! Returns the number of capture devices available for use.
/** \return Number of capture devices available. */
virtual unsigned int getAvailableDeviceCount() = 0;
//! Returns the name of the default system playback device.
/** \return Name of the default capture device. */
virtual const char* getDefaultDeviceName() = 0;
//! Returns the name of the audio device being used to capture audio.
virtual const char* getDeviceName() = 0;
//! Returns the frequency that the captured audio will be at.
virtual unsigned int getFrequency() = 0;
//! Returns the format of the captured audio.
virtual AudioFormats getFormat() = 0;
//! Returns the internal OpenAL buffer size in bytes.
/** \return Size of the buffer in bytes. */
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.
/** \return Size of a sample in bytes. */
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.
/**
\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. */
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.
/**
\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. */
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.
/**
\param format: Format of the captured audio.
\return True on success, False if the capture device failed to initialize. */
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.
/**
\param internalBufferSize: Size of the internal OpenAL buffer in bytes.
\return True on success, False if the capture device failed to initialize. */
virtual bool setInternalBufferSize(unsigned int internalBufferSize) = 0;
//! Starts capturing audio data to an internal buffer. Will clear any old data in the buffer.
/** \return True if capture was successfully started. */
virtual bool beginCapture() = 0;
//! Stops capturing audio data to an internal buffer.
virtual void stopCapture() = 0;
//! 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.
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 outputBufferSize: Size of the output array in bytes.
\return Size in bytes of the data actually copied to the output buffer.
*/
virtual unsigned int getCapturedAudio(void* outputBuffer, unsigned int outputBufferSize) = 0;
//! Returns the current size of the internal audio buffer in bytes.
virtual unsigned int getCurrentCapturedAudioSize() = 0;
//!Registers a new event handler to this manager.
/** \param handler: Pointer to an event handler to attach. */
virtual void registerEventHandler(ICaptureEventHandler* handler) = 0;
//!Removes the specified event handler from this manager.
/** \param handler: Pointer to an event handler to remove. */
virtual void unRegisterEventHandler(ICaptureEventHandler* handler) = 0;
//!Removes all event handlers attached to this manager.
virtual void unRegisterAllEventHandlers() = 0;
};
//! Creates an interface to an Audio Capture Object.
/** 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.
\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.
*/
CAUDIO_API IAudioCapture* createAudioCapture(bool initializeDefault = true);
//! Destroys an interface to a previously created Audio Capture Object and frees the memory allocated for it.
/**
\param capture: The object to destroy
*/
CAUDIO_API void destroyAudioCapture(IAudioCapture* capture);
//! Returns if the thread used to update all Audio Capture Objects is running.
/** 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.
\return True if the thread is currently running, false otherwise.
*/
CAUDIO_API bool isAudioCaptureThreadRunning();
};
#endif //! IAUDIOCAPTURE_H

View File

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

View File

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

View File

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

View File

@ -1,202 +1,202 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef IAUDIOMANAGER_H
#define IAUDIOMANAGER_H
#include "IListener.h"
#include "cAudioDefines.h"
#include "EAudioFormats.h"
#include "IAudioEffects.h"
#include "IDataSourceFactory.h"
#include "IManagerEventHandler.h"
#include <string>
namespace cAudio
{
class IAudioSource;
class IAudioDecoderFactory;
//! Interface for the playback capabilities of cAudio.
class IAudioManager
{
public:
IAudioManager() { }
virtual ~IAudioManager() { }
//! Initializes the manager.
/**
\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 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. */
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.
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.
virtual void update() = 0;
//! Returns an Audio Source by its "name" and NULL if the name is not found
/**
\param name: Name of the audio source to retrieve.
\return Pointer to the audio source object or NULL if it could not be found.*/
virtual IAudioSource* getSoundByName(const char* name) = 0;
//! Releases ALL Audio Sources (but does not shutdown the manager)
virtual void releaseAllSources() = 0;
//! Releases a single Audio Source, removing it from the manager.
/** \param source: Pointer to the source to release. */
virtual void release(IAudioSource* source) = 0;
//! Returns the name of an available playback device.
/** \param index: Specify which name to retrieve ( Range: 0 to getAvailableDeviceCount()-1 )
\return Name of the selected device. */
virtual const char* getAvailableDeviceName(unsigned int index) = 0;
//! Returns the number of playback devices available for use.
/** \return Number of playback devices available. */
virtual unsigned int getAvailableDeviceCount() = 0;
//! Returns the name of the default system playback device.
/** \return Name of the default playback device. */
virtual const char* getDefaultDeviceName() = 0;
//! Creates an Audio Source object using the highest priority data source that has the referenced filename
/**
\param name: Name of the audio source.
\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.
\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;
//! Creates an Audio Source from a memory buffer using a specific audio codec.
/**
\param name: Name of the audio source.
\param data: Pointer to a buffer in memory to load the data from.
\param length: Length of the data 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.
*/
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.
/**
\param name: Name of the audio source.
\param data: Pointer to a buffer in memory to load the data from.
\param length: Length of the data buffer.
\param frequency: Frequency (or sample rate) of the audio data.
\param format: Format of the audio data.
\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;
//! Register an Audio Decoder.
/**
\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.
\return True on seccess, False if registration failed. */
virtual bool registerAudioDecoder(IAudioDecoderFactory* factory, const char* extension) = 0;
//! 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.
\param extension: Extension for the audio decoder to remove. */
virtual void unRegisterAudioDecoder(const char* extension) = 0;
//! Returns whether an audio decoder is currently registered for this file type
/**
\param extension: Extension for the audio decoder to check for.
\return True if the specified decoder is registered or False if not. */
virtual bool isAudioDecoderRegistered(const char* extension) = 0;
//! Returns a registered audio decoder factory.
/**
\param extension: Extension for the audio decoder to return.
\return A pointer to the found factory or NULL if it could not be found. */
virtual IAudioDecoderFactory* getAudioDecoderFactory(const char* extension) = 0;
//! 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. */
virtual void unRegisterAllAudioDecoders() = 0;
//! 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.
\param factory: Pointer to the data source factory to register.
\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.
\return True on success, False on failure to register. */
virtual bool registerDataSource(IDataSourceFactory* factory, const char* name, int priority) = 0;
//! 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.
\param name: Name of the data source to unregister. */
virtual void unRegisterDataSource(const char* name) = 0;
//! Returns whether a data source is currently registered under a certain name.
/**
\param name: Name of the data source to check for.
\return True if the specified data source is registered or False if not. */
virtual bool isDataSourceRegistered(const char* name) = 0;
//! Returns a previously registered data source factory.
/**
\param name: Name of the data source to return.
\return A pointer to the found factory or NULL if it could not be found. */
virtual IDataSourceFactory* getDataSourceFactory(const char* name) = 0;
//! 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. */
virtual void unRegisterAllDataSources() = 0;
//! Registers a new event handler with the manager.
/**
\param handler: Pointer to an event handler instance to register. */
virtual void registerEventHandler(IManagerEventHandler* handler) = 0;
//! Unregisters a previously registered event handler from the manager.
/** Note: Will not delete your event handler, you must take care of that yourself.
\param handler: Pointer to the event handler to remove. */
virtual void unRegisterEventHandler(IManagerEventHandler* handler) = 0;
//! Unregisters all previously registered event handlers from the manager.
/** Note: Will not delete your event handler, you must take care of that yourself. */
virtual void unRegisterAllEventHandlers() = 0;
//! Returns the interface for the listener.
virtual IListener* getListener() = 0;
#ifdef CAUDIO_EFX_ENABLED
//! Returns the interface for audio effects.
virtual IAudioEffects* getEffects() = 0;
#endif
protected:
private:
};
//! Creates an interface to an Audio Manager.
/** 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.
\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.
*/
CAUDIO_API IAudioManager* createAudioManager(bool initializeDefault = true);
//! Destroys an interface to a previously created Audio Manager and frees the memory allocated for it.
/**
\param capture: The object to destroy.
*/
CAUDIO_API void destroyAudioManager(IAudioManager* manager);
//! Returns if the thread used to update all Audio Managers is running.
/** 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.
\return True if the thread is currently running, false otherwise.
*/
CAUDIO_API bool isAudioManagerThreadRunning();
}
#endif //! IAUDIOMANAGER_H
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef IAUDIOMANAGER_H
#define IAUDIOMANAGER_H
#include "IListener.h"
#include "cAudioDefines.h"
#include "EAudioFormats.h"
#include "IAudioEffects.h"
#include "IDataSourceFactory.h"
#include "IManagerEventHandler.h"
#include <string>
namespace cAudio
{
class IAudioSource;
class IAudioDecoderFactory;
//! Interface for the playback capabilities of cAudio.
class IAudioManager
{
public:
IAudioManager() { }
virtual ~IAudioManager() { }
//! Initializes the manager.
/**
\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 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. */
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.
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.
virtual void update() = 0;
//! Returns an Audio Source by its "name" and NULL if the name is not found
/**
\param name: Name of the audio source to retrieve.
\return Pointer to the audio source object or NULL if it could not be found.*/
virtual IAudioSource* getSoundByName(const char* name) = 0;
//! Releases ALL Audio Sources (but does not shutdown the manager)
virtual void releaseAllSources() = 0;
//! Releases a single Audio Source, removing it from the manager.
/** \param source: Pointer to the source to release. */
virtual void release(IAudioSource* source) = 0;
//! Returns the name of an available playback device.
/** \param index: Specify which name to retrieve ( Range: 0 to getAvailableDeviceCount()-1 )
\return Name of the selected device. */
virtual const char* getAvailableDeviceName(unsigned int index) = 0;
//! Returns the number of playback devices available for use.
/** \return Number of playback devices available. */
virtual unsigned int getAvailableDeviceCount() = 0;
//! Returns the name of the default system playback device.
/** \return Name of the default playback device. */
virtual const char* getDefaultDeviceName() = 0;
//! Creates an Audio Source object using the highest priority data source that has the referenced filename
/**
\param name: Name of the audio source.
\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.
\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;
//! Creates an Audio Source from a memory buffer using a specific audio codec.
/**
\param name: Name of the audio source.
\param data: Pointer to a buffer in memory to load the data from.
\param length: Length of the data 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.
*/
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.
/**
\param name: Name of the audio source.
\param data: Pointer to a buffer in memory to load the data from.
\param length: Length of the data buffer.
\param frequency: Frequency (or sample rate) of the audio data.
\param format: Format of the audio data.
\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;
//! Register an Audio Decoder.
/**
\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.
\return True on seccess, False if registration failed. */
virtual bool registerAudioDecoder(IAudioDecoderFactory* factory, const char* extension) = 0;
//! 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.
\param extension: Extension for the audio decoder to remove. */
virtual void unRegisterAudioDecoder(const char* extension) = 0;
//! Returns whether an audio decoder is currently registered for this file type
/**
\param extension: Extension for the audio decoder to check for.
\return True if the specified decoder is registered or False if not. */
virtual bool isAudioDecoderRegistered(const char* extension) = 0;
//! Returns a registered audio decoder factory.
/**
\param extension: Extension for the audio decoder to return.
\return A pointer to the found factory or NULL if it could not be found. */
virtual IAudioDecoderFactory* getAudioDecoderFactory(const char* extension) = 0;
//! 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. */
virtual void unRegisterAllAudioDecoders() = 0;
//! 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.
\param factory: Pointer to the data source factory to register.
\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.
\return True on success, False on failure to register. */
virtual bool registerDataSource(IDataSourceFactory* factory, const char* name, int priority) = 0;
//! 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.
\param name: Name of the data source to unregister. */
virtual void unRegisterDataSource(const char* name) = 0;
//! Returns whether a data source is currently registered under a certain name.
/**
\param name: Name of the data source to check for.
\return True if the specified data source is registered or False if not. */
virtual bool isDataSourceRegistered(const char* name) = 0;
//! Returns a previously registered data source factory.
/**
\param name: Name of the data source to return.
\return A pointer to the found factory or NULL if it could not be found. */
virtual IDataSourceFactory* getDataSourceFactory(const char* name) = 0;
//! 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. */
virtual void unRegisterAllDataSources() = 0;
//! Registers a new event handler with the manager.
/**
\param handler: Pointer to an event handler instance to register. */
virtual void registerEventHandler(IManagerEventHandler* handler) = 0;
//! Unregisters a previously registered event handler from the manager.
/** Note: Will not delete your event handler, you must take care of that yourself.
\param handler: Pointer to the event handler to remove. */
virtual void unRegisterEventHandler(IManagerEventHandler* handler) = 0;
//! Unregisters all previously registered event handlers from the manager.
/** Note: Will not delete your event handler, you must take care of that yourself. */
virtual void unRegisterAllEventHandlers() = 0;
//! Returns the interface for the listener.
virtual IListener* getListener() = 0;
#ifdef CAUDIO_EFX_ENABLED
//! Returns the interface for audio effects.
virtual IAudioEffects* getEffects() = 0;
#endif
protected:
private:
};
//! Creates an interface to an Audio Manager.
/** 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.
\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.
*/
CAUDIO_API IAudioManager* createAudioManager(bool initializeDefault = true);
//! Destroys an interface to a previously created Audio Manager and frees the memory allocated for it.
/**
\param capture: The object to destroy.
*/
CAUDIO_API void destroyAudioManager(IAudioManager* manager);
//! Returns if the thread used to update all Audio Managers is running.
/** 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.
\return True if the thread is currently running, false otherwise.
*/
CAUDIO_API bool isAudioManagerThreadRunning();
}
#endif //! IAUDIOMANAGER_H

View File

@ -1,54 +1,54 @@
#ifndef IAUDIOPLUGIN_H_INCLUDED
#define IAUDIOPLUGIN_H_INCLUDED
#include "IRefCounted.h"
#include "IAudioManager.h"
#include "IAudioCapture.h"
#include "ILogger.h"
namespace cAudio
{
//! Interface for all plugins in cAudio.
class IAudioPlugin : public IRefCounted
{
public:
IAudioPlugin() { }
~IAudioPlugin() { }
//! Called to initialize the plugin. Use this for any initial setup that needs to be done.
/**
\param logger: Pointer to the logger singleton.
\return True if plugin initialization was successful, false if there was an error. */
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).
/**
\return Name of the plugin. */
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.
virtual void uninstallPlugin() = 0;
//! 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.
\param manager: Pointer to the newly created manager. */
virtual void onCreateAudioManager(IAudioManager* 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.
\param capture: Pointer to the newly created capture interface. */
virtual void onCreateAudioCapture(IAudioCapture* capture) { }
//! Called on destruction of an Audio Playback Manager.
/** Use this to remove anything you added to the playback manger earlier.
\param manager: Pointer to the soon to be destroyed playback interface. */
virtual void onDestroyAudioManager(IAudioManager* manager) { }
//! Called on destruction of an Audio Capture Manager.
/** Use this to remove anything you added to a capture manger earlier.
\param capture: Pointer to the soon to be destroyed capture interface. */
virtual void onDestoryAudioCapture(IAudioCapture* capture) { }
};
};
#ifndef IAUDIOPLUGIN_H_INCLUDED
#define IAUDIOPLUGIN_H_INCLUDED
#include "IRefCounted.h"
#include "IAudioManager.h"
#include "IAudioCapture.h"
#include "ILogger.h"
namespace cAudio
{
//! Interface for all plugins in cAudio.
class IAudioPlugin : public IRefCounted
{
public:
IAudioPlugin() { }
~IAudioPlugin() { }
//! Called to initialize the plugin. Use this for any initial setup that needs to be done.
/**
\param logger: Pointer to the logger singleton.
\return True if plugin initialization was successful, false if there was an error. */
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).
/**
\return Name of the plugin. */
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.
virtual void uninstallPlugin() = 0;
//! 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.
\param manager: Pointer to the newly created manager. */
virtual void onCreateAudioManager(IAudioManager* 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.
\param capture: Pointer to the newly created capture interface. */
virtual void onCreateAudioCapture(IAudioCapture* capture) { }
//! Called on destruction of an Audio Playback Manager.
/** Use this to remove anything you added to the playback manger earlier.
\param manager: Pointer to the soon to be destroyed playback interface. */
virtual void onDestroyAudioManager(IAudioManager* manager) { }
//! Called on destruction of an Audio Capture Manager.
/** Use this to remove anything you added to a capture manger earlier.
\param capture: Pointer to the soon to be destroyed capture interface. */
virtual void onDestoryAudioCapture(IAudioCapture* capture) { }
};
};
#endif //! IAUDIOPLUGIN_H_INCLUDED

View File

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

View File

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

View File

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

View File

@ -1,30 +1,30 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef IDATASOURCEFACTORY_H
#define IDATASOURCEFACTORY_H
#include "IDataSource.h"
namespace cAudio
{
//! Interface for creating data sources for use with the engine.
class IDataSourceFactory
{
public:
IDataSourceFactory() { }
virtual ~IDataSourceFactory() { }
//! Creates a data source instance for use with the engine.
/**
\param filename: Filename of the file to get a stream for.
\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. */
virtual IDataSource* CreateDataSource(const char* filename, bool streamingRequested) = 0;
protected:
private:
};
};
#endif //! IDATASOURCEFACTORY_H
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef IDATASOURCEFACTORY_H
#define IDATASOURCEFACTORY_H
#include "IDataSource.h"
namespace cAudio
{
//! Interface for creating data sources for use with the engine.
class IDataSourceFactory
{
public:
IDataSourceFactory() { }
virtual ~IDataSourceFactory() { }
//! Creates a data source instance for use with the engine.
/**
\param filename: Filename of the file to get a stream for.
\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. */
virtual IDataSource* CreateDataSource(const char* filename, bool streamingRequested) = 0;
protected:
private:
};
};
#endif //! IDATASOURCEFACTORY_H

View File

@ -1,195 +1,195 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef IEFFECT_H
#define IEFFECT_H
#include "IRefCounted.h"
#include "IFilter.h"
#include "IEffectParameters.h"
#include "cAudioDefines.h"
#ifdef CAUDIO_EFX_ENABLED
namespace cAudio
{
//! Enum of all available effect types in cAudio.
enum EffectTypes
{
EET_NULL,
EET_EAX_REVERB,
EET_REVERB,
EET_CHORUS,
EET_DISTORTION,
EET_ECHO,
EET_FLANGER,
EET_FREQUENCY_SHIFTER,
EET_VOCAL_MORPHER,
EET_PITCH_SHIFTER,
EET_RING_MODULATOR,
EET_AUTOWAH,
EET_COMPRESSOR,
EET_EQUALIZER,
EET_COUNT
};
//! Interface for a single effect in cAudio.
class IEffect : public IRefCounted
{
public:
IEffect() { }
virtual ~IEffect() { }
//! Returns the current type this effect object is set to.
virtual const EffectTypes& getType() const = 0;
//! Sets the type of this effect object.
/**
\param type: Type of effect to switch to. */
virtual void setType(const EffectTypes& type) = 0;
//! Returns the current parameters for the EAX Reverb Effect.
virtual const sEAXReverbParameters& getEAXReverbParameters() const = 0;
//! Sets the parameters for the EAX Reverb Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setEAXReverbParameters(const sEAXReverbParameters& param) = 0;
//! Returns the current parameters for the Reverb Effect.
virtual const sReverbParameters& getReverbParameters() const = 0;
//! Sets the parameters for the Reverb Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setReverbParameters(const sReverbParameters& param) = 0;
//! Returns the current parameters for the Chorus Effect.
virtual const sChorusParameters& getChorusParameters() const = 0;
//! Sets the parameters for the Chorus Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setChorusParameters(const sChorusParameters& param) = 0;
//! Returns the current parameters for the Distortion Effect.
virtual const sDistortionParameters& getDistortionParameters() const = 0;
//! Sets the parameters for the Distortion Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setDistortionParameters(const sDistortionParameters& param) = 0;
//! Returns the current parameters for the Echo Effect.
virtual const sEchoParameters& getEchoParameters() const = 0;
//! Sets the parameters for the Echo Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setEchoParameters(const sEchoParameters& param) = 0;
//! Returns the current parameters for the Flanger Effect.
virtual const sFlangerParameters& getFlangerParameters() const = 0;
//! Sets the parameters for the Flanger Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setFlangerParameters(const sFlangerParameters& param) = 0;
//! Returns the current parameters for the Frequency Shift Effect.
virtual const sFrequencyShiftParameters& getFrequencyShiftParameters() const = 0;
//! Sets the parameters for the Frequency Shift Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setFrequencyShiftParameters(const sFrequencyShiftParameters& param) = 0;
//! Returns the current parameters for the Vocal Morpher Effect.
virtual const sVocalMorpherParameters& getVocalMorpherParameters() const = 0;
//! Sets the parameters for the Vocal Morpher Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setVocalMorpherParameters(const sVocalMorpherParameters& param) = 0;
//! Returns the current parameters for the Pitch Shifter Effect.
virtual const sPitchShifterParameters& getPitchShifterParameters() const = 0;
//! Sets the parameters for the Pitch Shifter Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setPitchShifterParameters(const sPitchShifterParameters& param) = 0;
//! Returns the current parameters for the Ring Modulator Effect.
virtual const sRingModulatorParameters& getRingModulatorParameters() const = 0;
//! Sets the parameters for the Ring Modulator Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setRingModulatorParameters(const sRingModulatorParameters& param) = 0;
//! Returns the current parameters for the Autowah Effect.
virtual const sAutowahParameters& getAutowahParameters() const = 0;
//! Sets the parameters for the Autowah Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setAutowahParameters(const sAutowahParameters& param) = 0;
//! Returns the current parameters for the Compressor Effect.
virtual const sCompressorParameters& getCompressorParameters() const = 0;
//! Sets the parameters for the Compressor Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setCompressorParameters(const sCompressorParameters& param) = 0;
//! Returns the current parameters for the Equalizer Effect.
virtual const sEqualizerParameters& getEqualizerParameters() const = 0;
//! Sets the parameters for the Equalizer Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setEqualizerParameters(const sEqualizerParameters& param) = 0;
//! Returns the master volume for this effect.
/** This volume scales the amount of effect audible from all attached sources.
\return Currently set volume. */
virtual float getMasterVolume() const = 0;
//! Sets the master volume for this effect.
/** 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.*/
virtual void setMasterVolume(const float& volume) = 0;
//! Returns if the effect for each attached source is attenuated by distance.
virtual bool isIgnoringAttenuation() const = 0;
//! 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.
\param ignore: Whether to ignore attenuation. */
virtual void ignoreAttenuation(const bool& ignore) = 0;
//! Returns the attached filter to this audio effect.
virtual IFilter* getFilter() const = 0;
//! Attaches a filter to this effect.
/**
\param filter: A Pointer to the filter to attach. */
virtual void attachFilter(IFilter* filter) = 0;
//! Removes the currently attached filter.
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.
virtual unsigned int getLastUpdated() const = 0;
//! Returns if this effect is ready to be used or if it has encountered a fatal error.
virtual bool isValid() const = 0;
};
};
#endif
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef IEFFECT_H
#define IEFFECT_H
#include "IRefCounted.h"
#include "IFilter.h"
#include "IEffectParameters.h"
#include "cAudioDefines.h"
#ifdef CAUDIO_EFX_ENABLED
namespace cAudio
{
//! Enum of all available effect types in cAudio.
enum EffectTypes
{
EET_NULL,
EET_EAX_REVERB,
EET_REVERB,
EET_CHORUS,
EET_DISTORTION,
EET_ECHO,
EET_FLANGER,
EET_FREQUENCY_SHIFTER,
EET_VOCAL_MORPHER,
EET_PITCH_SHIFTER,
EET_RING_MODULATOR,
EET_AUTOWAH,
EET_COMPRESSOR,
EET_EQUALIZER,
EET_COUNT
};
//! Interface for a single effect in cAudio.
class IEffect : public IRefCounted
{
public:
IEffect() { }
virtual ~IEffect() { }
//! Returns the current type this effect object is set to.
virtual const EffectTypes& getType() const = 0;
//! Sets the type of this effect object.
/**
\param type: Type of effect to switch to. */
virtual void setType(const EffectTypes& type) = 0;
//! Returns the current parameters for the EAX Reverb Effect.
virtual const sEAXReverbParameters& getEAXReverbParameters() const = 0;
//! Sets the parameters for the EAX Reverb Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setEAXReverbParameters(const sEAXReverbParameters& param) = 0;
//! Returns the current parameters for the Reverb Effect.
virtual const sReverbParameters& getReverbParameters() const = 0;
//! Sets the parameters for the Reverb Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setReverbParameters(const sReverbParameters& param) = 0;
//! Returns the current parameters for the Chorus Effect.
virtual const sChorusParameters& getChorusParameters() const = 0;
//! Sets the parameters for the Chorus Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setChorusParameters(const sChorusParameters& param) = 0;
//! Returns the current parameters for the Distortion Effect.
virtual const sDistortionParameters& getDistortionParameters() const = 0;
//! Sets the parameters for the Distortion Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setDistortionParameters(const sDistortionParameters& param) = 0;
//! Returns the current parameters for the Echo Effect.
virtual const sEchoParameters& getEchoParameters() const = 0;
//! Sets the parameters for the Echo Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setEchoParameters(const sEchoParameters& param) = 0;
//! Returns the current parameters for the Flanger Effect.
virtual const sFlangerParameters& getFlangerParameters() const = 0;
//! Sets the parameters for the Flanger Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setFlangerParameters(const sFlangerParameters& param) = 0;
//! Returns the current parameters for the Frequency Shift Effect.
virtual const sFrequencyShiftParameters& getFrequencyShiftParameters() const = 0;
//! Sets the parameters for the Frequency Shift Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setFrequencyShiftParameters(const sFrequencyShiftParameters& param) = 0;
//! Returns the current parameters for the Vocal Morpher Effect.
virtual const sVocalMorpherParameters& getVocalMorpherParameters() const = 0;
//! Sets the parameters for the Vocal Morpher Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setVocalMorpherParameters(const sVocalMorpherParameters& param) = 0;
//! Returns the current parameters for the Pitch Shifter Effect.
virtual const sPitchShifterParameters& getPitchShifterParameters() const = 0;
//! Sets the parameters for the Pitch Shifter Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setPitchShifterParameters(const sPitchShifterParameters& param) = 0;
//! Returns the current parameters for the Ring Modulator Effect.
virtual const sRingModulatorParameters& getRingModulatorParameters() const = 0;
//! Sets the parameters for the Ring Modulator Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setRingModulatorParameters(const sRingModulatorParameters& param) = 0;
//! Returns the current parameters for the Autowah Effect.
virtual const sAutowahParameters& getAutowahParameters() const = 0;
//! Sets the parameters for the Autowah Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setAutowahParameters(const sAutowahParameters& param) = 0;
//! Returns the current parameters for the Compressor Effect.
virtual const sCompressorParameters& getCompressorParameters() const = 0;
//! Sets the parameters for the Compressor Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setCompressorParameters(const sCompressorParameters& param) = 0;
//! Returns the current parameters for the Equalizer Effect.
virtual const sEqualizerParameters& getEqualizerParameters() const = 0;
//! Sets the parameters for the Equalizer Effect.
/**
\param param: Parameter struct to set this effect to.*/
virtual void setEqualizerParameters(const sEqualizerParameters& param) = 0;
//! Returns the master volume for this effect.
/** This volume scales the amount of effect audible from all attached sources.
\return Currently set volume. */
virtual float getMasterVolume() const = 0;
//! Sets the master volume for this effect.
/** 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.*/
virtual void setMasterVolume(const float& volume) = 0;
//! Returns if the effect for each attached source is attenuated by distance.
virtual bool isIgnoringAttenuation() const = 0;
//! 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.
\param ignore: Whether to ignore attenuation. */
virtual void ignoreAttenuation(const bool& ignore) = 0;
//! Returns the attached filter to this audio effect.
virtual IFilter* getFilter() const = 0;
//! Attaches a filter to this effect.
/**
\param filter: A Pointer to the filter to attach. */
virtual void attachFilter(IFilter* filter) = 0;
//! Removes the currently attached filter.
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.
virtual unsigned int getLastUpdated() const = 0;
//! Returns if this effect is ready to be used or if it has encountered a fatal error.
virtual bool isValid() const = 0;
};
};
#endif
#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
// This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef IFILTER_H
#define IFILTER_H
#include "IRefCounted.h"
#include "cAudioDefines.h"
#ifdef CAUDIO_EFX_ENABLED
namespace cAudio
{
//! Enum of all available filter types in cAudio.
enum FilterTypes
{
EFT_NULL,
EFT_LOWPASS,
EFT_HIGHPASS,
EFT_BANDPASS,
EFT_COUNT
};
//! Interface for a filter in cAudio.
class IFilter : public IRefCounted
{
public:
IFilter() { }
virtual ~IFilter() { }
//! Returns the type of the filter.
virtual const FilterTypes& getType() const = 0;
//! Sets the type of this filter.
/**
\param type: Type of filter to set this filter up as. */
virtual void setType(const FilterTypes& type) = 0;
//! Returns the master volume of this filter.
virtual float getVolume() const = 0;
//! Sets the master volume of this filter.
/** This volume scales all audio that goes through it by this amount.
\param volume: New volume amount. Range: 0.0f to 1.0. */
virtual void setVolume(const float& volume) = 0;
//! Returns the volume for low frequencies.
virtual float getLowFrequencyVolume() const = 0;
//! Sets the volume for low frequencies.
/** This volume scales lower frequency audio that goes through it by this amount.
\param volume: New volume amount. Range: 0.0f to 1.0. */
virtual void setLowFrequencyVolume(const float& volumeLF) = 0;
//! Returns the volume for high frequencies.
virtual float getHighFrequencyVolume() const = 0;
//! Sets the volume for high frequencies.
/** This volume scales higher frequency audio that goes through it by this amount.
\param volume: New volume amount. Range: 0.0f to 1.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.
virtual unsigned int getLastUpdated() const = 0;
//! Returns if this filter is ready to be used or if it has encountered a fatal error.
virtual bool isValid() const = 0;
};
};
#endif
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef IFILTER_H
#define IFILTER_H
#include "IRefCounted.h"
#include "cAudioDefines.h"
#ifdef CAUDIO_EFX_ENABLED
namespace cAudio
{
//! Enum of all available filter types in cAudio.
enum FilterTypes
{
EFT_NULL,
EFT_LOWPASS,
EFT_HIGHPASS,
EFT_BANDPASS,
EFT_COUNT
};
//! Interface for a filter in cAudio.
class IFilter : public IRefCounted
{
public:
IFilter() { }
virtual ~IFilter() { }
//! Returns the type of the filter.
virtual const FilterTypes& getType() const = 0;
//! Sets the type of this filter.
/**
\param type: Type of filter to set this filter up as. */
virtual void setType(const FilterTypes& type) = 0;
//! Returns the master volume of this filter.
virtual float getVolume() const = 0;
//! Sets the master volume of this filter.
/** This volume scales all audio that goes through it by this amount.
\param volume: New volume amount. Range: 0.0f to 1.0. */
virtual void setVolume(const float& volume) = 0;
//! Returns the volume for low frequencies.
virtual float getLowFrequencyVolume() const = 0;
//! Sets the volume for low frequencies.
/** This volume scales lower frequency audio that goes through it by this amount.
\param volume: New volume amount. Range: 0.0f to 1.0. */
virtual void setLowFrequencyVolume(const float& volumeLF) = 0;
//! Returns the volume for high frequencies.
virtual float getHighFrequencyVolume() const = 0;
//! Sets the volume for high frequencies.
/** This volume scales higher frequency audio that goes through it by this amount.
\param volume: New volume amount. Range: 0.0f to 1.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.
virtual unsigned int getLastUpdated() const = 0;
//! Returns if this filter is ready to be used or if it has encountered a fatal error.
virtual bool isValid() const = 0;
};
};
#endif
#endif //! IFILTER_H

View File

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

View File

@ -1,48 +1,48 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef ILOGRECEIVER_H_INCLUDED
#define ILOGRECEIVER_H_INCLUDED
namespace cAudio
{
//! Enum of all supported log levels in cAudio.
enum LogLevel
{
ELL_DEBUG,
ELL_INFO,
ELL_WARNING,
ELL_ERROR,
ELL_CRITICAL,
ELL_COUNT
};
//! Contains strings for each log level to make them easier to print to a stream.
const char* const LogLevelStrings[] =
{
"Debug",
"Information",
"Warning",
"Error",
"Critical",
0
};
//! Interface for receiving log messages and relaying them to some kind of output device or stream.
class ILogReceiver
{
public:
ILogReceiver() { }
~ILogReceiver() { }
//! 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 message: The log message itself.
\param level: Log level of the message.
\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;
};
};
#endif //! ILOGRECEIVER_H_INCLUDED
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef ILOGRECEIVER_H_INCLUDED
#define ILOGRECEIVER_H_INCLUDED
namespace cAudio
{
//! Enum of all supported log levels in cAudio.
enum LogLevel
{
ELL_DEBUG,
ELL_INFO,
ELL_WARNING,
ELL_ERROR,
ELL_CRITICAL,
ELL_COUNT
};
//! Contains strings for each log level to make them easier to print to a stream.
const char* const LogLevelStrings[] =
{
"Debug",
"Information",
"Warning",
"Error",
"Critical",
0
};
//! Interface for receiving log messages and relaying them to some kind of output device or stream.
class ILogReceiver
{
public:
ILogReceiver() { }
~ILogReceiver() { }
//! 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 message: The log message itself.
\param level: Log level of the message.
\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;
};
};
#endif //! ILOGRECEIVER_H_INCLUDED

View File

@ -1,92 +1,92 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef ILOGGER_H_INCLUDED
#define ILOGGER_H_INCLUDED
#include "ILogReceiver.h"
#include "cAudioDefines.h"
namespace cAudio
{
//! Interface for all logging operations in cAudio.
class ILogger
{
public:
ILogger() { }
virtual ~ILogger() { }
//! Used to log a critical error message to the logging system.
/**
\param sender: Name of the class/component sending the message.
\param msg: The message to send. */
virtual void logCritical( const char* sender, const char *msg, ... ) = 0;
//! Used to log an error message to the logging system.
/**
\param sender: Name of the class/component sending the message.
\param msg: The message to send. */
virtual void logError( const char* sender, const char *msg, ... ) = 0;
//! Used to log a warning to the logging system.
/**
\param sender: Name of the class/component sending the message.
\param msg: The message to send. */
virtual void logWarning( const char* sender, const char *msg, ... ) = 0;
//! Used to log an informational message to the logging system.
/**
\param sender: Name of the class/component sending the message.
\param msg: The message to send. */
virtual void logInfo( const char* sender, const char *msg, ... ) = 0;
//! Used to log a debug message to the logging system.
/**
\param sender: Name of the class/component sending the message.
\param msg: The message to send. */
virtual void logDebug( const char* sender, const char *msg, ... ) = 0;
//! Returns the minimum log level that will be sent to the log receivers.
virtual const LogLevel& getLogLevel() const = 0;
//! 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.
\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;
//! Register Log Receiver.
/** 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.
\param receiver: Pointer to your implementation of ILogReceiver.
\param name: Name of the log receiver.
\return True on success, False on failure. */
virtual bool registerLogReceiver(ILogReceiver* receiver, const char* name) = 0;
//! Unregister a Log Receiver.
/** Will NOT delete any user added receiver, you must do that yourself.
\param name: Name of the log receiver to remove. */
virtual void unRegisterLogReceiver(const char* name) = 0;
//! Returns whether an log receiver is currently registered.
/**
\param name: Name of the log receiver to check for. */
virtual bool isLogReceiverRegistered(const char* name) = 0;
//! Returns a registered log receiver.
/**
\param name: Name of the log receiver to return.
\return Pointer to the found log receiver or NULL if it could not be found. */
virtual ILogReceiver* getLogReceiver(const char* name) = 0;
protected:
private:
};
//! Gets the interface to the logger.
/** Note: This is the only way to get access to the logging capabilities of cAudio.
\return A pointer to the logger interface.
*/
CAUDIO_API ILogger* getLogger();
};
#endif //! ILOGGER_H_INCLUDED
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef ILOGGER_H_INCLUDED
#define ILOGGER_H_INCLUDED
#include "ILogReceiver.h"
#include "cAudioDefines.h"
namespace cAudio
{
//! Interface for all logging operations in cAudio.
class ILogger
{
public:
ILogger() { }
virtual ~ILogger() { }
//! Used to log a critical error message to the logging system.
/**
\param sender: Name of the class/component sending the message.
\param msg: The message to send. */
virtual void logCritical( const char* sender, const char *msg, ... ) = 0;
//! Used to log an error message to the logging system.
/**
\param sender: Name of the class/component sending the message.
\param msg: The message to send. */
virtual void logError( const char* sender, const char *msg, ... ) = 0;
//! Used to log a warning to the logging system.
/**
\param sender: Name of the class/component sending the message.
\param msg: The message to send. */
virtual void logWarning( const char* sender, const char *msg, ... ) = 0;
//! Used to log an informational message to the logging system.
/**
\param sender: Name of the class/component sending the message.
\param msg: The message to send. */
virtual void logInfo( const char* sender, const char *msg, ... ) = 0;
//! Used to log a debug message to the logging system.
/**
\param sender: Name of the class/component sending the message.
\param msg: The message to send. */
virtual void logDebug( const char* sender, const char *msg, ... ) = 0;
//! Returns the minimum log level that will be sent to the log receivers.
virtual const LogLevel& getLogLevel() const = 0;
//! 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.
\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;
//! Register Log Receiver.
/** 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.
\param receiver: Pointer to your implementation of ILogReceiver.
\param name: Name of the log receiver.
\return True on success, False on failure. */
virtual bool registerLogReceiver(ILogReceiver* receiver, const char* name) = 0;
//! Unregister a Log Receiver.
/** Will NOT delete any user added receiver, you must do that yourself.
\param name: Name of the log receiver to remove. */
virtual void unRegisterLogReceiver(const char* name) = 0;
//! Returns whether an log receiver is currently registered.
/**
\param name: Name of the log receiver to check for. */
virtual bool isLogReceiverRegistered(const char* name) = 0;
//! Returns a registered log receiver.
/**
\param name: Name of the log receiver to return.
\return Pointer to the found log receiver or NULL if it could not be found. */
virtual ILogReceiver* getLogReceiver(const char* name) = 0;
protected:
private:
};
//! Gets the interface to the logger.
/** Note: This is the only way to get access to the logging capabilities of cAudio.
\return A pointer to the logger interface.
*/
CAUDIO_API ILogger* getLogger();
};
#endif //! ILOGGER_H_INCLUDED

View File

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

View File

@ -1,31 +1,31 @@
#ifndef IMEMORYPROVIDER_H_INCLUDED
#define IMEMORYPROVIDER_H_INCLUDED
#include "cAudioDefines.h"
#include <cstring>
namespace cAudio
{
//! Interface for a class that allocates and frees memory used by cAudio.
class IMemoryProvider
{
public:
//! Allocates memory and returns a pointer to it.
/**
\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 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.
\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;
//! Frees memory previously allocated.
/**
\param pointer: Pointer to the memory location to free. */
virtual void Free(void* pointer) = 0;
//! Returns the largest possible single allocation that can be made.
virtual size_t getMaxAllocationSize() = 0;
};
};
#ifndef IMEMORYPROVIDER_H_INCLUDED
#define IMEMORYPROVIDER_H_INCLUDED
#include "cAudioDefines.h"
#include <cstring>
namespace cAudio
{
//! Interface for a class that allocates and frees memory used by cAudio.
class IMemoryProvider
{
public:
//! Allocates memory and returns a pointer to it.
/**
\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 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.
\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;
//! Frees memory previously allocated.
/**
\param pointer: Pointer to the memory location to free. */
virtual void Free(void* pointer) = 0;
//! Returns the largest possible single allocation that can be made.
virtual size_t getMaxAllocationSize() = 0;
};
};
#endif //! IMEMORYPROVIDER_H_INCLUDED

View File

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

View File

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

View File

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

View File

@ -1,111 +1,111 @@
/* cAudio.h -- interface of the 'cAudio Engine'
Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
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
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef CAUDIO_H
#define CAUDIO_H
#include "cAudioDefines.h"
#include "cAudioPlatform.h"
#include "cAudioSleep.h"
#include "EAudioFormats.h"
#include "IAudioSource.h"
#include "IAudioCapture.h"
#include "IAudioDecoder.h"
#include "IAudioDecoderFactory.h"
#include "IAudioEffects.h"
#include "IAudioManager.h"
#include "IDataSource.h"
#include "IEffect.h"
#include "IEffectParameters.h"
#include "IFilter.h"
#include "IListener.h"
#include "ILogger.h"
#include "ILogReceiver.h"
#include "IPluginManager.h"
#include "IRefCounted.h"
/*! \mainpage cAudio 2.1.0 API documentation
*
* <img src="../cAudioLogo.jpg"></img>
*
* \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
* 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
* 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.
*
* 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
* at <A HREF="http://www.deathtouchstudios.com/phpBB3/index.php" >http://www.deathtouchstudios.com/phpBB3/index.php</A>.
*
* \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="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>
*
* \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"
* when it comes to what cAudio is capable of.
*
* \code
* #include <cAudio.h>
*
* int main()
* {
* //Create an Audio Manager
* cAudio::IAudioManager* manager = cAudio::createAudioManager(true);
*
* //Create an audio source and load a sound from a file
* cAudio::IAudioSource* mysound = manager->create("music","../../media/cAudioTheme1.ogg",true);
*
* if(mysound)
* {
* //Play our source in 2D once.
* mysound->play2d(false);
*
* //Wait for the sound to finish playing
* while(mysound->isPlaying())
* cAudio::cAudioSleep(10);
* }
*
* //Shutdown cAudio
* manager->shutDown();
* cAudio::destroyAudioManager(manager);
*
* return 0;
* }
* \endcode
*/
//! Main namespace for the entire cAudio library
namespace cAudio
{
};
/* cAudio.h -- interface of the 'cAudio Engine'
Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
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
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef CAUDIO_H
#define CAUDIO_H
#include "cAudioDefines.h"
#include "cAudioPlatform.h"
#include "cAudioSleep.h"
#include "EAudioFormats.h"
#include "IAudioSource.h"
#include "IAudioCapture.h"
#include "IAudioDecoder.h"
#include "IAudioDecoderFactory.h"
#include "IAudioEffects.h"
#include "IAudioManager.h"
#include "IDataSource.h"
#include "IEffect.h"
#include "IEffectParameters.h"
#include "IFilter.h"
#include "IListener.h"
#include "ILogger.h"
#include "ILogReceiver.h"
#include "IPluginManager.h"
#include "IRefCounted.h"
/*! \mainpage cAudio 2.1.0 API documentation
*
* <img src="../cAudioLogo.jpg"></img>
*
* \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
* 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
* 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.
*
* 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
* at <A HREF="http://www.deathtouchstudios.com/phpBB3/index.php" >http://www.deathtouchstudios.com/phpBB3/index.php</A>.
*
* \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="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>
*
* \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"
* when it comes to what cAudio is capable of.
*
* \code
* #include <cAudio.h>
*
* int main()
* {
* //Create an Audio Manager
* cAudio::IAudioManager* manager = cAudio::createAudioManager(true);
*
* //Create an audio source and load a sound from a file
* cAudio::IAudioSource* mysound = manager->create("music","../../media/cAudioTheme1.ogg",true);
*
* if(mysound)
* {
* //Play our source in 2D once.
* mysound->play2d(false);
*
* //Wait for the sound to finish playing
* while(mysound->isPlaying())
* cAudio::cAudioSleep(10);
* }
*
* //Shutdown cAudio
* manager->shutDown();
* cAudio::destroyAudioManager(manager);
*
* return 0;
* }
* \endcode
*/
//! Main namespace for the entire cAudio library
namespace cAudio
{
};
#endif

View File

@ -1,251 +1,251 @@
#ifndef CAUDIODEFINES_H
#define CAUDIODEFINES_H
#include "cAudioPlatform.h"
//! Global define for the version of cAudio.
//! This is used primarily by plugins to make sure they are linking to the right library.
#define CAUDIO_VERSION "2.1.0"
#if !defined( CAUDIO_DEBUG )
#if defined( DEBUG ) || defined( _DEBUG )
#define CAUDIO_DEBUG
#endif
#endif
//////////////////////
// Windows Settings //
//////////////////////
#ifdef CAUDIO_PLATFORM_WIN
#ifndef CAUDIO_STATIC_LIB
#define CAUDIO_API __declspec(dllexport)
#else
#define CAUDIO_API extern "C"
#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 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 CAUDIO_USE_INTERNAL_THREAD
#endif //CAUDIO_MAKE_THREAD_SAFE
//! This define controls whether the Ogg/Vorbis decoder is compiled into the library.
#define CAUDIO_COMPILE_WITH_OGG_DECODER
//! This define controls whether the RIFF/Wav decoder is compiled into the library.
#define CAUDIO_COMPILE_WITH_WAV_DECODER
//! This define controls whether the default filesystem data source is compiled into the library
#define CAUDIO_COMPILE_WITH_FILE_SOURCE
//! This define controls whether the default file logger (html) is compiled into the library
#define CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER
//! This define controls whether the default console logger is compiled into the library
#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
#define CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
#ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
//! Define enabled support for plugins as dynamic libs
#define CAUDIO_COMPILE_WITH_DYNAMIC_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)
#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)
#define CAUDIO_SOURCE_NUM_BUFFERS 3
//! Comment out to remove all EFX support from the library
//#define CAUDIO_EFX_ENABLED
//! Max number of effects that can be attached to a single sound source
#define CAUDIO_SOURCE_MAX_EFFECT_SLOTS 4
//! Tells cAudio to use the C standard memory functions for allocations (memalloc and free)
#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.
#define CAUDIO_REROUTE_STL_ALLOCATIONS
//! Activates the internal memory tracker, which can be used to detect and locate memory leaks.
//#define CAUDIO_USE_MEMORYTRACKER
//! Tells the memory tracker to generate statistics on memory usage by cAudio
//#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.
//#define CAUDIO_MEMORYTRACKER_LOG_ALL_ALLOCATIONS
#endif //CAUDIO_PLATFORM_WIN
///////////////////////
// Mac OS X Settings //
///////////////////////
#ifdef CAUDIO_PLATFORM_MAC
#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 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 CAUDIO_USE_INTERNAL_THREAD
#endif //CAUDIO_MAKE_THREAD_SAFE
//! This define controls whether the Ogg/Vorbis decoder is compiled into the library.
#define CAUDIO_COMPILE_WITH_OGG_DECODER
//! This define controls whether the RIFF/Wav decoder is compiled into the library.
#define CAUDIO_COMPILE_WITH_WAV_DECODER
//! This define controls whether the default filesystem data source is compiled into the library
#define CAUDIO_COMPILE_WITH_FILE_SOURCE
//! This define controls whether the default file logger (html) is compiled into the library
#define CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER
//! This define controls whether the default console logger is compiled into the library
#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
#define CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
#ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
//! Define enabled support for plugins as dynamic libs
#define CAUDIO_COMPILE_WITH_DYNAMIC_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)
#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)
#define CAUDIO_SOURCE_NUM_BUFFERS 3
//! Max number of effects that can be attached to a single sound source
#define CAUDIO_SOURCE_MAX_EFFECT_SLOTS 4
//! Tells cAudio to use the C standard memory functions for allocations (memalloc and free)
#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.
//#define CAUDIO_REROUTE_STL_ALLOCATIONS
//! Activates the internal memory tracker, which can be used to detect and locate memory leaks.
//#define CAUDIO_USE_MEMORYTRACKER
//! Tells the memory tracker to generate statistics on memory usage by cAudio
//#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.
//#define CAUDIO_MEMORYTRACKER_LOG_ALL_ALLOCATIONS
#endif //CAUDIO_PLATFORM_MAC
/////////////////////
// IPhone Settings //
/////////////////////
#ifdef CAUDIO_PLATFORM_IPHONE
#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 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 CAUDIO_USE_INTERNAL_THREAD
#endif //CAUDIO_MAKE_THREAD_SAFE
//! This define controls whether the Ogg/Vorbis decoder is compiled into the library.
#define CAUDIO_COMPILE_WITH_OGG_DECODER
//! This define controls whether the RIFF/Wav decoder is compiled into the library.
#define CAUDIO_COMPILE_WITH_WAV_DECODER
//! This define controls whether the default filesystem data source is compiled into the library
#define CAUDIO_COMPILE_WITH_FILE_SOURCE
//! This define controls whether the default file logger (html) is compiled into the library
#define CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER
//! This define controls whether the default console logger is compiled into the library
#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)
#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)
#define CAUDIO_SOURCE_NUM_BUFFERS 3
//! Tells cAudio to use the C standard memory functions for allocations (memalloc and free)
#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.
//#define CAUDIO_REROUTE_STL_ALLOCATIONS
//! Activates the internal memory tracker, which can be used to detect and locate memory leaks.
//#define CAUDIO_USE_MEMORYTRACKER
//! Tells the memory tracker to generate statistics on memory usage by cAudio
//#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.
//#define CAUDIO_MEMORYTRACKER_LOG_ALL_ALLOCATIONS
#endif //CAUDIO_PLATFORM_IPHONE
////////////////////
// Linux Settings //
////////////////////
#ifdef CAUDIO_PLATFORM_LINUX
#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 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 CAUDIO_USE_INTERNAL_THREAD
#endif //CAUDIO_MAKE_THREAD_SAFE
//! This define controls whether the Ogg/Vorbis decoder is compiled into the library.
#define CAUDIO_COMPILE_WITH_OGG_DECODER
//! This define controls whether the RIFF/Wav decoder is compiled into the library.
#define CAUDIO_COMPILE_WITH_WAV_DECODER
//! This define controls whether the default filesystem data source is compiled into the library
#define CAUDIO_COMPILE_WITH_FILE_SOURCE
//! This define controls whether the default file logger (html) is compiled into the library
#define CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER
//! This define controls whether the default console logger is compiled into the library
#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
#define CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
#ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
//! Define enabled support for plugins as dynamic libs
#define CAUDIO_COMPILE_WITH_DYNAMIC_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)
#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)
#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.
//#define CAUDIO_EFX_ENABLED
//! Max number of effects that can be attached to a single sound source
//#define CAUDIO_SOURCE_MAX_EFFECT_SLOTS 4
//! Tells cAudio to use the C standard memory functions for allocations (memalloc and free)
#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.
#define CAUDIO_REROUTE_STL_ALLOCATIONS
//! Activates the internal memory tracker, which can be used to detect and locate memory leaks.
//#define CAUDIO_USE_MEMORYTRACKER
//! Tells the memory tracker to generate statistics on memory usage by cAudio
//#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.
//#define CAUDIO_MEMORYTRACKER_LOG_ALL_ALLOCATIONS
#endif //CAUDIO_PLATFORM_LINUX
#endif //CAUDIODEFINES_H
#ifndef CAUDIODEFINES_H
#define CAUDIODEFINES_H
#include "cAudioPlatform.h"
//! Global define for the version of cAudio.
//! This is used primarily by plugins to make sure they are linking to the right library.
#define CAUDIO_VERSION "2.2.0"
#if !defined( CAUDIO_DEBUG )
#if defined( DEBUG ) || defined( _DEBUG )
#define CAUDIO_DEBUG
#endif
#endif
//////////////////////
// Windows Settings //
//////////////////////
#ifdef CAUDIO_PLATFORM_WIN
#ifndef CAUDIO_STATIC_LIB
#define CAUDIO_API __declspec(dllexport)
#else
#define CAUDIO_API extern "C"
#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 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 CAUDIO_USE_INTERNAL_THREAD
#endif //CAUDIO_MAKE_THREAD_SAFE
//! This define controls whether the Ogg/Vorbis decoder is compiled into the library.
#define CAUDIO_COMPILE_WITH_OGG_DECODER
//! This define controls whether the RIFF/Wav decoder is compiled into the library.
#define CAUDIO_COMPILE_WITH_WAV_DECODER
//! This define controls whether the default filesystem data source is compiled into the library
#define CAUDIO_COMPILE_WITH_FILE_SOURCE
//! This define controls whether the default file logger (html) is compiled into the library
#define CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER
//! This define controls whether the default console logger is compiled into the library
#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
#define CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
#ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
//! Define enabled support for plugins as dynamic libs
#define CAUDIO_COMPILE_WITH_DYNAMIC_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)
#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)
#define CAUDIO_SOURCE_NUM_BUFFERS 3
//! Comment out to remove all EFX support from the library
//#define CAUDIO_EFX_ENABLED
//! Max number of effects that can be attached to a single sound source
#define CAUDIO_SOURCE_MAX_EFFECT_SLOTS 4
//! Tells cAudio to use the C standard memory functions for allocations (memalloc and free)
#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.
#define CAUDIO_REROUTE_STL_ALLOCATIONS
//! Activates the internal memory tracker, which can be used to detect and locate memory leaks.
//#define CAUDIO_USE_MEMORYTRACKER
//! Tells the memory tracker to generate statistics on memory usage by cAudio
//#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.
//#define CAUDIO_MEMORYTRACKER_LOG_ALL_ALLOCATIONS
#endif //CAUDIO_PLATFORM_WIN
///////////////////////
// Mac OS X Settings //
///////////////////////
#ifdef CAUDIO_PLATFORM_MAC
#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 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 CAUDIO_USE_INTERNAL_THREAD
#endif //CAUDIO_MAKE_THREAD_SAFE
//! This define controls whether the Ogg/Vorbis decoder is compiled into the library.
#define CAUDIO_COMPILE_WITH_OGG_DECODER
//! This define controls whether the RIFF/Wav decoder is compiled into the library.
#define CAUDIO_COMPILE_WITH_WAV_DECODER
//! This define controls whether the default filesystem data source is compiled into the library
#define CAUDIO_COMPILE_WITH_FILE_SOURCE
//! This define controls whether the default file logger (html) is compiled into the library
#define CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER
//! This define controls whether the default console logger is compiled into the library
#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
#define CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
#ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
//! Define enabled support for plugins as dynamic libs
#define CAUDIO_COMPILE_WITH_DYNAMIC_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)
#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)
#define CAUDIO_SOURCE_NUM_BUFFERS 3
//! Max number of effects that can be attached to a single sound source
#define CAUDIO_SOURCE_MAX_EFFECT_SLOTS 4
//! Tells cAudio to use the C standard memory functions for allocations (memalloc and free)
#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.
//#define CAUDIO_REROUTE_STL_ALLOCATIONS
//! Activates the internal memory tracker, which can be used to detect and locate memory leaks.
//#define CAUDIO_USE_MEMORYTRACKER
//! Tells the memory tracker to generate statistics on memory usage by cAudio
//#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.
//#define CAUDIO_MEMORYTRACKER_LOG_ALL_ALLOCATIONS
#endif //CAUDIO_PLATFORM_MAC
/////////////////////
// IPhone Settings //
/////////////////////
#ifdef CAUDIO_PLATFORM_IPHONE
#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 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 CAUDIO_USE_INTERNAL_THREAD
#endif //CAUDIO_MAKE_THREAD_SAFE
//! This define controls whether the Ogg/Vorbis decoder is compiled into the library.
#define CAUDIO_COMPILE_WITH_OGG_DECODER
//! This define controls whether the RIFF/Wav decoder is compiled into the library.
#define CAUDIO_COMPILE_WITH_WAV_DECODER
//! This define controls whether the default filesystem data source is compiled into the library
#define CAUDIO_COMPILE_WITH_FILE_SOURCE
//! This define controls whether the default file logger (html) is compiled into the library
#define CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER
//! This define controls whether the default console logger is compiled into the library
#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)
#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)
#define CAUDIO_SOURCE_NUM_BUFFERS 3
//! Tells cAudio to use the C standard memory functions for allocations (memalloc and free)
#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.
//#define CAUDIO_REROUTE_STL_ALLOCATIONS
//! Activates the internal memory tracker, which can be used to detect and locate memory leaks.
//#define CAUDIO_USE_MEMORYTRACKER
//! Tells the memory tracker to generate statistics on memory usage by cAudio
//#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.
//#define CAUDIO_MEMORYTRACKER_LOG_ALL_ALLOCATIONS
#endif //CAUDIO_PLATFORM_IPHONE
////////////////////
// Linux Settings //
////////////////////
#ifdef CAUDIO_PLATFORM_LINUX
#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 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 CAUDIO_USE_INTERNAL_THREAD
#endif //CAUDIO_MAKE_THREAD_SAFE
//! This define controls whether the Ogg/Vorbis decoder is compiled into the library.
#define CAUDIO_COMPILE_WITH_OGG_DECODER
//! This define controls whether the RIFF/Wav decoder is compiled into the library.
#define CAUDIO_COMPILE_WITH_WAV_DECODER
//! This define controls whether the default filesystem data source is compiled into the library
#define CAUDIO_COMPILE_WITH_FILE_SOURCE
//! This define controls whether the default file logger (html) is compiled into the library
#define CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER
//! This define controls whether the default console logger is compiled into the library
#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
#define CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
#ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
//! Define enabled support for plugins as dynamic libs
#define CAUDIO_COMPILE_WITH_DYNAMIC_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)
#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)
#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.
//#define CAUDIO_EFX_ENABLED
//! Max number of effects that can be attached to a single sound source
//#define CAUDIO_SOURCE_MAX_EFFECT_SLOTS 4
//! Tells cAudio to use the C standard memory functions for allocations (memalloc and free)
#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.
#define CAUDIO_REROUTE_STL_ALLOCATIONS
//! Activates the internal memory tracker, which can be used to detect and locate memory leaks.
//#define CAUDIO_USE_MEMORYTRACKER
//! Tells the memory tracker to generate statistics on memory usage by cAudio
//#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.
//#define CAUDIO_MEMORYTRACKER_LOG_ALL_ALLOCATIONS
#endif //CAUDIO_PLATFORM_LINUX
#endif //CAUDIODEFINES_H

View File

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

View File

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

View File

@ -1,17 +1,17 @@
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef CAUDIOSLEEP_H
#define CAUDIOSLEEP_H
#include "cAudioDefines.h"
namespace cAudio
{
//! Causes the current thread to give up control for a certain duration.
/** \param ms: amount of miliseconds to sleep */
CAUDIO_API void cAudioSleep(unsigned int ms);
};
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef CAUDIOSLEEP_H
#define CAUDIOSLEEP_H
#include "cAudioDefines.h"
namespace cAudio
{
//! Causes the current thread to give up control for a certain duration.
/** \param ms: amount of miliseconds to sleep */
CAUDIO_API void cAudioSleep(unsigned int ms);
};
#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
#define CSTLALLOCATOR_H_INCLUDED
#include "../include/cAudioDefines.h"
#include "../include/cAudioMemory.h"
#include <set>
#include <map>
#include <list>
#include <vector>
#include <string>
namespace cAudio
{
#ifdef CAUDIO_REROUTE_STL_ALLOCATIONS
//! Reroutes allocations from STL containers into cAudio's memory system
template <typename T> class cSTLAllocator
{
public:
typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
template<typename U>
struct rebind
{
typedef cSTLAllocator<U> other;
};
cSTLAllocator()
{ }
~cSTLAllocator() throw()
{ }
cSTLAllocator( const cSTLAllocator& ) throw()
{ }
template <typename U>
cSTLAllocator( const cSTLAllocator<U>& ) throw()
{ }
pointer address(reference x) const
{
return &x;
}
const_pointer address(const_reference x) const
{
return &x;
}
pointer allocate( size_type count, typename std::allocator<void>::const_pointer ptr = 0 )
{
(void)ptr;
register size_type size = count*sizeof( T );
pointer p = static_cast<pointer>(CAUDIO_MALLOC(size));
return p;
}
void deallocate( pointer p, size_type size )
{
CAUDIO_FREE(p);
}
size_type max_size() const throw()
{
return cAudio::getMemoryProvider()->getMaxAllocationSize();
}
void construct(pointer p, const T& val)
{
// call placement new
new(static_cast<void*>(p)) T(val);
}
void destroy(pointer p)
{
p->~T();
}
};
template<> class cSTLAllocator<void>
{
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef void* pointer;
typedef const void* const_pointer;
typedef void value_type;
template<typename U>
struct rebind
{
typedef cSTLAllocator<U> other;
};
};
template <typename T>
inline bool operator==(const cSTLAllocator<T>&, const cSTLAllocator<T>&)
{
return true;
}
template <typename T>
inline bool operator!=(const cSTLAllocator<T>&, const cSTLAllocator<T>&)
{
return false;
}
#endif
#ifdef CAUDIO_REROUTE_STL_ALLOCATIONS
typedef std::basic_string< char, std::char_traits<char>, cSTLAllocator<char> > cAudioString;
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 cAudioSet { typedef std::set< T, std::less< T >, cSTLAllocator< T > > Type; };
template<typename T> struct cAudioList { typedef std::list< T, cSTLAllocator< T > > Type; };
template<typename T> struct cAudioVector { typedef std::vector< T, cSTLAllocator< T > > Type; };
#else
typedef std::string cAudioString;
template<typename T1, typename T2> struct cAudioMap { typedef std::map< T1, T2> Type; };
template<typename T> struct cAudioSet { typedef std::set< T > Type; };
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
#ifndef CSTLALLOCATOR_H_INCLUDED
#define CSTLALLOCATOR_H_INCLUDED
#include "cAudioDefines.h"
#include "cAudioMemory.h"
//#include "cAudioString.h"
#include <set>
#include <map>
#include <list>
#include <vector>
#include <string>
namespace cAudio
{
#ifdef CAUDIO_REROUTE_STL_ALLOCATIONS
//! Reroutes allocations from STL containers into cAudio's memory system
template <typename T> class cSTLAllocator
{
public:
typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
template<typename U>
struct rebind
{
typedef cSTLAllocator<U> other;
};
cSTLAllocator()
{ }
~cSTLAllocator() throw()
{ }
cSTLAllocator( const cSTLAllocator& ) throw()
{ }
template <typename U>
cSTLAllocator( const cSTLAllocator<U>& ) throw()
{ }
pointer address(reference x) const
{
return &x;
}
const_pointer address(const_reference x) const
{
return &x;
}
pointer allocate( size_type count, typename std::allocator<void>::const_pointer ptr = 0 )
{
(void)ptr;
register size_type size = count*sizeof( T );
pointer p = static_cast<pointer>(CAUDIO_MALLOC(size));
return p;
}
void deallocate( pointer p, size_type size )
{
CAUDIO_FREE(p);
}
size_type max_size() const throw()
{
return cAudio::getMemoryProvider()->getMaxAllocationSize();
}
void construct(pointer p, const T& val)
{
// call placement new
new(static_cast<void*>(p)) T(val);
}
void destroy(pointer p)
{
p->~T();
}
};
template<> class cSTLAllocator<void>
{
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef void* pointer;
typedef const void* const_pointer;
typedef void value_type;
template<typename U>
struct rebind
{
typedef cSTLAllocator<U> other;
};
};
template <typename T>
inline bool operator==(const cSTLAllocator<T>&, const cSTLAllocator<T>&)
{
return true;
}
template <typename T>
inline bool operator!=(const cSTLAllocator<T>&, const cSTLAllocator<T>&)
{
return false;
}
#endif
#ifdef CAUDIO_REROUTE_STL_ALLOCATIONS
//typedef std::basic_string< cAudioChar, std::char_traits<cAudioChar>, cSTLAllocator<cAudioChar> > cAudioString;
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 cAudioSet { typedef std::set< T, std::less< T >, cSTLAllocator< T > > Type; };
template<typename T> struct cAudioList { typedef std::list< T, cSTLAllocator< T > > Type; };
template<typename T> struct cAudioVector { typedef std::vector< T, cSTLAllocator< T > > Type; };
#else
//typedef std::string cAudioString;
//typedef std::basic_string<cAudioChar> cAudioString;
template<typename T1, typename T2> struct cAudioMap { typedef std::map< T1, T2> Type; };
template<typename T> struct cAudioSet { typedef std::set< T > Type; };
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

View File

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

File diff suppressed because it is too large Load Diff