source.h

Go to the documentation of this file.
00001 
00012 /* Copyright, 2001 Nevrax Ltd.
00013  *
00014  * This file is part of NEVRAX NEL.
00015  * NEVRAX NEL is free software; you can redistribute it and/or modify
00016  * it under the terms of the GNU General Public License as published by
00017  * the Free Software Foundation; either version 2, or (at your option)
00018  * any later version.
00019 
00020  * NEVRAX NEL is distributed in the hope that it will be useful, but
00021  * WITHOUT ANY WARRANTY; without even the implied warranty of
00022  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00023  * General Public License for more details.
00024 
00025  * You should have received a copy of the GNU General Public License
00026  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00027  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00028  * MA 02111-1307, USA.
00029  */
00030 
00031 #ifndef NL_SOURCE_H
00032 #define NL_SOURCE_H
00033 #include <nel/misc/types_nl.h>
00034 
00035 #include <nel/misc/vector.h>
00036 #include "sound_driver.h"
00037 
00043 #define NLSOUND_MIN_GAIN 0.0f
00044 
00052 #define NLSOUND_MAX_GAIN 1.0f
00053 
00060 #define NLSOUND_MIN_PITCH 0.0f
00061 
00071 #define NLSOUND_MAX_PITCH 8.0f
00072 
00079 #define NLSOUND_DEFAULT_GAIN 1.0f
00080 
00085 #define NLSOUND_DEFAULT_PITCH 1.0f
00086 
00092 #define NLSOUND_DEFAULT_DIRECT_GAIN 1.0f
00093 
00098 #define NLSOUND_DEFAULT_EFFECT_GAIN 1.0f
00099 
00105 #define NLSOUND_DEFAULT_FILTER_PASS_HF 5000.0f
00106 
00111 #define NLSOUND_DEFAULT_FILTER_PASS_LF 250.0f
00112 
00119 #define NLSOUND_DEFAULT_FILTER_PASS_GAIN 1.0f
00120 
00121 namespace NLSOUND {
00122     class IBuffer;
00123     class ILoader;
00124     class IEffect;
00125 
00148 class ISource
00149 {
00150 public:
00151     enum TFilter
00152     {
00153         FilterLowPass, 
00154         FilterBandPass, 
00155         FilterHighPass, 
00156     };
00157     
00159     ISource() { }
00161     virtual ~ISource() { }
00162     
00164 
00165 
00184     virtual void setStreaming(bool streaming = true) = 0;
00212     virtual void setStaticBuffer(IBuffer *buffer) = 0;
00221     virtual IBuffer *getStaticBuffer() = 0;
00224     virtual void submitStreamingBuffer(IBuffer *buffer) = 0;
00242     virtual uint countStreamingBuffers() const = 0;
00244     
00246 
00247 
00263     virtual void setLooping(bool l = true) = 0;
00273     virtual bool getLooping() const = 0;
00274     
00301     virtual bool play() = 0;
00316     virtual void stop() = 0;
00324     virtual void pause() = 0;
00335     virtual bool isPlaying() const = 0;
00344     virtual bool isStopped() const = 0;
00352     virtual bool isPaused() const = 0;
00374     virtual uint32 getTime() = 0;
00376     
00378 
00379 
00380     virtual void setPos(const NLMISC::CVector& pos, bool deffered = true) = 0;
00382     virtual const NLMISC::CVector &getPos() const = 0;
00384     virtual void setVelocity(const NLMISC::CVector& vel, bool deferred = true) = 0;
00386     virtual void getVelocity(NLMISC::CVector& vel) const = 0;
00388     virtual void setDirection(const NLMISC::CVector& dir) = 0;
00390     virtual void getDirection(NLMISC::CVector& dir) const = 0;
00392     virtual void setGain(float gain = NLSOUND_DEFAULT_GAIN) = 0;
00394     virtual float getGain() const = 0;
00396     virtual void setPitch(float pitch = NLSOUND_DEFAULT_PITCH) = 0;
00398     virtual float getPitch() const = 0;
00400     virtual void setSourceRelativeMode(bool mode = true) = 0;
00402     virtual bool getSourceRelativeMode() const = 0;
00404     virtual void setMinMaxDistances(float mindist, float maxdist, bool deferred = true) = 0;
00406     virtual void getMinMaxDistances(float& mindist, float& maxdist) const = 0;
00408     virtual void setCone(float innerAngle, float outerAngle, float outerGain) = 0;
00410     virtual void getCone(float& innerAngle, float& outerAngle, float& outerGain) const = 0;
00431     virtual void setAlpha(double a) = 0;
00433     
00435 
00436 
00437     virtual void setDirect(bool enable = true) = 0;
00439     virtual bool getDirect() const = 0;
00441     virtual void setDirectGain(float gain = NLSOUND_DEFAULT_DIRECT_GAIN) = 0;
00443     virtual float getDirectGain() const = 0;
00444     
00446     virtual void enableDirectFilter(bool enable = true) = 0;
00448     virtual bool isDirectFilterEnabled() const = 0;
00450     virtual void setDirectFilter(TFilter filter, float lowFrequency = NLSOUND_DEFAULT_FILTER_PASS_LF, float highFrequency = NLSOUND_DEFAULT_FILTER_PASS_HF, float passGain = NLSOUND_DEFAULT_FILTER_PASS_GAIN) = 0;
00452     virtual void getDirectFilter(TFilter &filterType, float &lowFrequency, float &highFrequency, float &passGain) const = 0;
00454     virtual void setDirectFilterPassGain(float passGain = NLSOUND_DEFAULT_FILTER_PASS_GAIN) = 0;
00456     virtual float getDirectFilterPassGain() const = 0;
00458     
00460 
00461 
00462     virtual void setEffect(IReverbEffect *reverbEffect) = 0;
00464     virtual IEffect *getEffect() const = 0;
00466     virtual void setEffectGain(float gain = NLSOUND_DEFAULT_EFFECT_GAIN) = 0;
00468     virtual float getEffectGain() const = 0;
00469     
00471     virtual void enableEffectFilter(bool enable = true) = 0;
00473     virtual bool isEffectFilterEnabled() const = 0;
00475     virtual void setEffectFilter(TFilter filter, float lowFrequency = NLSOUND_DEFAULT_FILTER_PASS_LF, float highFrequency = NLSOUND_DEFAULT_FILTER_PASS_HF, float passGain = NLSOUND_DEFAULT_FILTER_PASS_GAIN) = 0;
00477     virtual void getEffectFilter(TFilter &filterType, float &lowFrequency, float &highFrequency, float &passGain) const = 0;
00479     virtual void setEffectFilterPassGain(float passGain = NLSOUND_DEFAULT_FILTER_PASS_GAIN) = 0;
00481     virtual float getEffectFilterPassGain() const = 0;
00483     
00484 protected:
00485     
00486     // common method used only with OptionManualRolloff. return the volume in 1/100th DB  ( = mB)modified
00487     static sint32 computeManualRollOff(sint32 volumeMB, sint32 mbMin, sint32 mbMax, double alpha, float sqrdist, float distMin, float distMax);
00488     // common method used only with OptionManualRolloff. return the rolloff in amplitude ratio (gain)
00489     static float computeManualRolloff(double alpha, float sqrdist, float distMin, float distMax);
00490 };
00491 
00492 
00493 } // NLSOUND
00494 
00495 
00496 #endif // NL_SOURCE_H
00497 
00498 /* End of source.h */

Generated on Thu Jan 7 08:26:37 2010 for NeL by  doxygen 1.6.1