mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-31 20:26:43 +00:00 
			
		
		
		
	Add a sound method to update the volume
This commit is contained in:
		
							parent
							
								
									7008bd2fe1
								
							
						
					
					
						commit
						a3291ef360
					
				
					 2 changed files with 17 additions and 0 deletions
				
			
		|  | @ -89,6 +89,7 @@ public: | |||
| 
 | ||||
|     virtual void stop(); | ||||
|     virtual bool isPlaying(); | ||||
|     virtual void setVolume(float volume); | ||||
|     virtual void update(const float *pos); | ||||
| 
 | ||||
|     void play(); | ||||
|  | @ -252,6 +253,13 @@ bool OpenAL_SoundStream::isPlaying() | |||
|     return !mIsFinished; | ||||
| } | ||||
| 
 | ||||
| void OpenAL_SoundStream::setVolume(float volume) | ||||
| { | ||||
|     alSourcef(mSource, AL_GAIN, volume*mBaseVolume); | ||||
|     throwALerror(); | ||||
|     mVolume = volume; | ||||
| } | ||||
| 
 | ||||
| void OpenAL_SoundStream::update(const float *pos) | ||||
| { | ||||
|     alSource3f(mSource, AL_POSITION, pos[0], pos[2], -pos[1]); | ||||
|  | @ -329,6 +337,7 @@ public: | |||
| 
 | ||||
|     virtual void stop(); | ||||
|     virtual bool isPlaying(); | ||||
|     virtual void setVolume(float volume); | ||||
|     virtual void update(const float *pos); | ||||
| }; | ||||
| 
 | ||||
|  | @ -361,6 +370,13 @@ bool OpenAL_Sound::isPlaying() | |||
|     return state==AL_PLAYING; | ||||
| } | ||||
| 
 | ||||
| void OpenAL_Sound::setVolume(float volume) | ||||
| { | ||||
|     alSourcef(mSource, AL_GAIN, volume*mBaseVolume); | ||||
|     throwALerror(); | ||||
|     mVolume = volume; | ||||
| } | ||||
| 
 | ||||
| void OpenAL_Sound::update(const float *pos) | ||||
| { | ||||
|     alSource3f(mSource, AL_POSITION, pos[0], pos[2], -pos[1]); | ||||
|  |  | |||
|  | @ -7,6 +7,7 @@ namespace MWSound | |||
|     { | ||||
|         virtual void stop() = 0; | ||||
|         virtual bool isPlaying() = 0; | ||||
|         virtual void setVolume(float volume) = 0; | ||||
|         virtual void update(const float *pos) = 0; | ||||
| 
 | ||||
|         Sound& operator=(const Sound &rhs); | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue