Fix for [#25062] Sound Actuator - Positional Audio.
authorJoerg Mueller <nexyon@gmail.com>
Tue, 30 Aug 2011 10:09:10 +0000 (10:09 +0000)
committerJoerg Mueller <nexyon@gmail.com>
Tue, 30 Aug 2011 10:09:10 +0000 (10:09 +0000)
Now all sounds that are not mono but have 3D checked automatically get reduced to mono during BGE conversion time.
Also removed the now unneeded function sound_get_channels and added a missing header file to audaspace's CMakeLists.txt.

intern/audaspace/CMakeLists.txt
source/blender/blenkernel/BKE_sound.h
source/blender/blenkernel/intern/sound.c
source/gameengine/Converter/KX_ConvertActuators.cpp

index 8b7cb1d9e691ab80de64330ddeb101953db5d50c..25510ebd2a5f99a10889c777eff555efd04b6551 100644 (file)
@@ -116,6 +116,7 @@ set(SRC
        intern/AUD_ReadDevice.h
        intern/AUD_Reference.h
        intern/AUD_ReferenceHandler.cpp
+       intern/AUD_ResampleFactory.h
        intern/AUD_ResampleReader.cpp
        intern/AUD_ResampleReader.h
        intern/AUD_SequencerEntry.cpp
index e1b6ff02bc4f017ca546296890817d0baf986374..fac5bf1cfd2848ad42a1a57b9a0349bc7291e858 100644 (file)
@@ -134,8 +134,6 @@ void sound_free_waveform(struct bSound* sound);
 
 void sound_read_waveform(struct bSound* sound);
 
-int sound_get_channels(struct bSound* sound);
-
 void sound_update_scene(struct Scene* scene);
 
 void* sound_get_factory(void* sound);
index 985fef974d376db7f2d2e03dd94bc7bda2676f04..cdb509ab8e121075e4553e19f282011643fd14ab 100644 (file)
@@ -641,15 +641,6 @@ void sound_read_waveform(struct bSound* sound)
        }
 }
 
-int sound_get_channels(struct bSound* sound)
-{
-       AUD_SoundInfo info;
-
-       info = AUD_getInfo(sound->playback_handle);
-
-       return info.specs.channels;
-}
-
 void sound_update_scene(struct Scene* scene)
 {
        Object* ob;
@@ -769,6 +760,5 @@ void sound_seek_scene(struct bContext *UNUSED(C)) {}
 float sound_sync_scene(struct Scene *UNUSED(scene)) { return 0.0f; }
 int sound_scene_playing(struct Scene *UNUSED(scene)) { return -1; }
 int sound_read_sound_buffer(struct bSound* UNUSED(sound), float* UNUSED(buffer), int UNUSED(length), float UNUSED(start), float UNUSED(end)) { return 0; }
-int sound_get_channels(struct bSound* UNUSED(sound)) { return 1; }
 
 #endif // WITH_AUDASPACE
index 7b9cba7770bfed02da3660820c908dcf770f5fd5..9621d05b5cc6fb15b8534c216a04d935ff2065b2 100644 (file)
@@ -46,6 +46,7 @@
 
 #ifdef WITH_AUDASPACE
 #  include "AUD_C-API.h"
+#  include "AUD_ChannelMapperFactory.h"
 #endif
 
 // Actuators
@@ -406,7 +407,23 @@ void BL_ConvertActuators(char* maggiename,
                                                                                "\" has no sound datablock." << std::endl;
                                        }
                                        else
+                                       {
                                                snd_sound = *reinterpret_cast<AUD_Reference<AUD_IFactory>*>(sound->playback_handle);
+
+                                               // if sound shall be 3D but isn't mono, we have to make it mono!
+                                               if(is3d)
+                                               {
+                                                       AUD_Reference<AUD_IReader> reader = snd_sound->createReader();
+                                                       if(reader->getSpecs().channels != AUD_CHANNELS_MONO)
+                                                       {
+                                                               AUD_DeviceSpecs specs;
+                                                               specs.channels = AUD_CHANNELS_MONO;
+                                                               specs.rate = AUD_RATE_INVALID;
+                                                               specs.format = AUD_FORMAT_INVALID;
+                                                               snd_sound = new AUD_ChannelMapperFactory(snd_sound, specs);
+                                                       }
+                                               }
+                                       }
                                        KX_SoundActuator* tmpsoundact =
                                                new KX_SoundActuator(gameobj,
                                                snd_sound,