diff engine/core/audio/soundemitter.h @ 173:454ed60ad7b2

* Added a setRoleoff() function to the SoundEmitter class This function sets AL_ROLEOFF_FACTOR. Rolloff factor judges the strength of attenuation over distance. It effect's the volume of the emitter over distance to the listener. You'll have to do plenty of testing to find a good value.
author nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
date Sat, 24 Jan 2009 22:26:46 +0000
parents 90005975cdbb
children 362fe23920b9
line wrap: on
line diff
--- a/engine/core/audio/soundemitter.h	Thu Jan 22 15:35:22 2009 +0000
+++ b/engine/core/audio/soundemitter.h	Sat Jan 24 22:26:46 2009 +0000
@@ -18,7 +18,7 @@
  *   Free Software Foundation, Inc.,                                       *
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
  ***************************************************************************/
- 
+
 #ifndef FIFE_SOUNDEMITTER_H_
 #define FIFE_SOUNDEMITTER_H_
 
@@ -41,38 +41,46 @@
 
 	class SoundManager;
 	class SoundClipPool;
-	
+
 	/** The class for playing audio files
 	 */
 	class SoundEmitter : private TimeEvent {
 	public:
 		SoundEmitter(SoundManager* manager, SoundClipPool* pool, unsigned int uid);
-		
+
 		~SoundEmitter();
-		
+
 		/** Returns the emitter-id
 		 */
 		unsigned int getID() {
 			return m_emitterid;
 		}
-		
+
 		/** Sets Positioning-Type
 		 * Default is false
-		 * 
+		 *
 		 * @param relative If set to true, the emitters position will be interpreted relative to the listener object
-		 * 
+		 *
 		 */
 		void setPositioning(bool relative) {
 			alSourcei(m_source, AL_SOURCE_RELATIVE, relative ? AL_TRUE : AL_FALSE);
 		}
 
+		/** Sets the AL_ROLEOFF_FACTOR. Rolloff factor judges the strength of attenuation over distance.
+		 *
+		 * @param roleoff Roleoff factor. You'll need to do a lot of testing to find a value which suits your needs.
+		 */
+		void setRoleoff(float roleoff) {
+			alSourcef (m_source, AL_ROLLOFF_FACTOR,  roleoff);
+		}
+
 		/** Sets the sound clip to be used by this emitter.
 		 * @param sound_id SoundClipPool id of the sound to be used.
 		 */
 		void setSoundClip(unsigned int sound_id);
-		
+
 		/** Reset the emitter, free all internal buffers
-		 *  
+		 *
 		 * @param defaultall If set to true, emitter position, velocity, gain and type will be set to the default values
 		 */
 		void reset(bool defaultall = false);
@@ -80,19 +88,19 @@
 		/** Releases the emitter
 		 */
 		void release();
-		
+
 		/** Sets the playing mode
 		 */
 		void setLooping(bool loop);
-		
+
 		/** Plays the associated audio file.
 		 */
 		void play();
-		
+
 		/** Stops playing the audio file and rewinds to the beginning
 		 */
 		void stop();
-		
+
 		/** Pauses playing the audio file
 		 */
 		void pause() {
@@ -100,7 +108,7 @@
 				alSourcePause(m_source);
 			}
 		}
-		
+
 		/** Sets the gain of the emitter
 		 *
 		 * @param gain The gain value. 0=silence ... 1.0=normal loudness.
@@ -108,7 +116,7 @@
 		void setGain(float gain) {
 			alSourcef(m_source, AL_GAIN, gain);
 		}
-		
+
 		/** Returns the gain of the emitter
 		 *
 		 * @return The gain value. 0=silence ... 1.0=normal loudness.
@@ -118,18 +126,18 @@
 			alGetSourcef(m_source, AL_GAIN, &tmp);
 			return tmp;
 		}
-		
+
 		/** Tests if the audio data is stereo data or mono.
-		 * 
+		 *
 		 * @return Returns true if the audio data is stereo, false if mono.
-		 */		
+		 */
 		bool isStereo() {
 			if (m_soundclip) {
 				return m_soundclip->getDecoder()->isStereo();
 			}
 			return false;
 		}
-		
+
 		/** Returns the bit resolution
 		 */
 		short getBitResolution() {
@@ -138,7 +146,7 @@
 			}
 			return 0;
 		}
-		
+
 		/** Returns the sample rate
 		 */
 		unsigned long getSampleRate() {
@@ -147,27 +155,27 @@
 			}
 			return 0;
 		}
-		
+
 		/** Sets the cursor position in the audio file
 		 */
 		void setCursor(SoundPositionType type, float value);
-		
+
 		/** Returns the cursor position in the audio file
 		 */
 		float getCursor(SoundPositionType type);
-		
+
 		/** Sets the position of the SoundEmitter in the virtual audio space.
 		 */
 		void setPosition(float x, float y, float z) {
 			alSource3f(m_source, AL_POSITION, x, y, z);
 		}
-		
+
 		/** Sets the velocity of the SoundEmitter in the virtual audio space.
 		 */
 		void setVelocity(float x, float y, float z) {
 			alSource3f(m_source, AL_VELOCITY, x, y, z);
 		}
-		
+
 	private:
 		/** Implementation of the pure virtual function from TimeEvent to update streaming
 		 */