diff options
author | chirs241097@gmail.com <chirs241097@gmail.com@c17bf020-1265-9734-9302-a83f62007ddb> | 2014-07-10 13:47:24 +0000 |
---|---|---|
committer | chirs241097@gmail.com <chirs241097@gmail.com@c17bf020-1265-9734-9302-a83f62007ddb> | 2014-07-10 13:47:24 +0000 |
commit | 32a2523dd5c51b31b31f5e43a7cebdb16e7f5e84 (patch) | |
tree | c69ce4a4009caf59916400957a6ae7f7e18c86ba /hgewin/sound.cpp | |
parent | d726aac2d9bac76f095ad6559d7dc30d97c3a97f (diff) | |
download | bullet-lab-remix-32a2523dd5c51b31b31f5e43a7cebdb16e7f5e84.tar.xz |
Dear Pre-Release Candidate version(RC-0).
CLR will collect multiplier +1's in range now.
Multiplier +1's caught by player won't disappear now.
Add/Move background transitions.
Add volume control to options. This make the configuration file
not compatible with older versions. Just delete it!
Modify hge's API so that it can handle real volume and pan values.
Volume value varys from 0 to 1, pan value varys from -1 to 1.
Document...
Diffstat (limited to 'hgewin/sound.cpp')
-rw-r--r-- | hgewin/sound.cpp | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/hgewin/sound.cpp b/hgewin/sound.cpp index 2bde29e..9024652 100644 --- a/hgewin/sound.cpp +++ b/hgewin/sound.cpp @@ -16,7 +16,6 @@ // Channel functions are fully supported now. However music and streaming are // still not supported. Some APIs changed for OpenAL is different from BA$$. -#include <cassert> #include "hge_impl.h" #include "AL/al.h" @@ -218,23 +217,23 @@ HEFFECT CALL HGE_Impl::Effect_Load(const char *filename, DWORD size) HCHANNEL CALL HGE_Impl::Effect_Play(HEFFECT eff) { - return Effect_PlayEx(eff, 100, 0, 1.0f, false); + return Effect_PlayEx(eff, 1.0f, 0, 1.0f, false); } -HCHANNEL CALL HGE_Impl::Effect_PlayEx(HEFFECT eff, int volume, int pan, float pitch, bool loop) +HCHANNEL CALL HGE_Impl::Effect_PlayEx(HEFFECT eff, float volume, float pan, float pitch, bool loop) { if(hOpenAL) { const ALuint sid = get_source(); // find an unused sid, or generate a new one. if (sid != 0) { - if (volume < 0) volume = 0; else if (volume > 100) volume = 100; - if (pan < -100) pan = -100; else if (pan > 100) pan = 100; + if (volume < 0) volume = 0; else if (volume > 1.0) volume = 1.0; + if (pan < -1.0) pan = -1.0; else if (pan > 1.0) pan = 1.0; alSourceStop(sid); alSourcei(sid, AL_BUFFER, (ALint) eff); - alSourcef(sid, AL_GAIN, ((ALfloat) volume) / 100.0f); + alSourcef(sid, AL_GAIN, volume); alSourcef(sid, AL_PITCH, pitch); - alSource3f(sid, AL_POSITION, ((ALfloat) pan) / 100.0f, 0.0f, 0.0f); + alSource3f(sid, AL_POSITION, pan, 0.0f, 0.0f); alSourcei(sid, AL_LOOPING, loop ? AL_TRUE : AL_FALSE); alSourcePlay(sid); } @@ -282,22 +281,22 @@ void CALL HGE_Impl::Stream_Free(HSTREAM stream){} HCHANNEL CALL HGE_Impl::Stream_Play(HSTREAM stream, bool loop, int volume){return 0;} -void CALL HGE_Impl::Channel_SetPanning(HCHANNEL chn, int pan) +void CALL HGE_Impl::Channel_SetPanning(HCHANNEL chn, float pan) { - assert(pan >= -100); - assert(pan <= 100); + if(pan>1.0)pan=1.0; + if(pan<-1.0)pan=-1.0; if(hOpenAL) { - alSource3f((ALuint) chn, AL_POSITION, ((ALfloat) pan) / 100.0f, 0.0f, 0.0f); + alSource3f((ALuint) chn, AL_POSITION, pan, 0.0f, 0.0f); } } -void CALL HGE_Impl::Channel_SetVolume(HCHANNEL chn, int volume) +void CALL HGE_Impl::Channel_SetVolume(HCHANNEL chn, float volume) { if(hOpenAL) { - if (volume < 0) volume = 0; else if (volume > 100) volume = 100; - alSourcef((ALuint) chn, AL_GAIN, ((ALfloat) volume) / 100.0f); + if (volume < 0) volume = 0; else if (volume > 1.0f) volume = 1.0f; + alSourcef((ALuint) chn, AL_GAIN, volume); } } |