Audaspace: preparing to use standalone library.
- Renamed some functions. - Using C API instead of C++ in the game engine, as the standalone is C++11.
This commit is contained in:
@@ -130,7 +130,7 @@ void AUD_exitOnce()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int AUD_init(AUD_DeviceType device, AUD_DeviceSpecs specs, int buffersize)
|
int AUD_init(const char* device, const char* name, AUD_DeviceSpecs specs, int buffersize)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<AUD_IDevice> dev;
|
boost::shared_ptr<AUD_IDevice> dev;
|
||||||
|
|
||||||
@@ -138,47 +138,46 @@ int AUD_init(AUD_DeviceType device, AUD_DeviceSpecs specs, int buffersize)
|
|||||||
AUD_exit();
|
AUD_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string dname = device;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
switch(device) {
|
if(dname == "Null") {
|
||||||
case AUD_NULL_DEVICE:
|
|
||||||
dev = boost::shared_ptr<AUD_IDevice>(new AUD_NULLDevice());
|
dev = boost::shared_ptr<AUD_IDevice>(new AUD_NULLDevice());
|
||||||
break;
|
}
|
||||||
#ifdef WITH_SDL
|
#ifdef WITH_SDL
|
||||||
case AUD_SDL_DEVICE:
|
else if(dname == "SDL")
|
||||||
if (SDL_Init == (void *)0) {
|
{
|
||||||
printf("Warning: SDL libraries are not installed\n");
|
dev = boost::shared_ptr<AUD_IDevice>(new AUD_SDLDevice(specs, buffersize));
|
||||||
// No break, fall through to default, to return false
|
}
|
||||||
}
|
|
||||||
else {
|
|
||||||
dev = boost::shared_ptr<AUD_IDevice>(new AUD_SDLDevice(specs, buffersize));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef WITH_OPENAL
|
#ifdef WITH_OPENAL
|
||||||
case AUD_OPENAL_DEVICE:
|
else if(dname == "OpenAL")
|
||||||
|
{
|
||||||
dev = boost::shared_ptr<AUD_IDevice>(new AUD_OpenALDevice(specs, buffersize));
|
dev = boost::shared_ptr<AUD_IDevice>(new AUD_OpenALDevice(specs, buffersize));
|
||||||
break;
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef WITH_JACK
|
#ifdef WITH_JACK
|
||||||
case AUD_JACK_DEVICE:
|
else if(dname == "Jack")
|
||||||
|
{
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat("/Library/Frameworks/Jackmp.framework", &st) != 0) {
|
if (stat("/Library/Frameworks/Jackmp.framework", &st) != 0) {
|
||||||
printf("Warning: Jack Framework not installed\n");
|
printf("Warning: Jack Framework not installed\n");
|
||||||
// No break, fall through to default, to return false
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (!AUD_jack_supported()) {
|
if (!AUD_jack_supported()) {
|
||||||
printf("Warning: Jack client not installed\n");
|
printf("Warning: Jack cllient not installed\n");
|
||||||
// No break, fall through to default, to return false
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dev = boost::shared_ptr<AUD_IDevice>(new AUD_JackDevice("Blender", specs, buffersize));
|
dev = boost::shared_ptr<AUD_IDevice>(new AUD_JackDevice(name, specs, buffersize));
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
default:
|
else
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,7 +265,7 @@ PyObject *AUD_initPython()
|
|||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *AUD_getPythonFactory(AUD_Sound *sound)
|
void *AUD_getPythonSound(AUD_Sound *sound)
|
||||||
{
|
{
|
||||||
if (sound) {
|
if (sound) {
|
||||||
Factory *obj = (Factory *) Factory_empty();
|
Factory *obj = (Factory *) Factory_empty();
|
||||||
@@ -279,7 +278,7 @@ void *AUD_getPythonFactory(AUD_Sound *sound)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
AUD_Sound *AUD_getPythonSound(void *sound)
|
AUD_Sound *AUD_getSoundFromPython(void *sound)
|
||||||
{
|
{
|
||||||
Factory *factory = checkFactory((PyObject *)sound);
|
Factory *factory = checkFactory((PyObject *)sound);
|
||||||
|
|
||||||
@@ -488,6 +487,11 @@ int AUD_stop(AUD_Handle *handle)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AUD_stopAll(void)
|
||||||
|
{
|
||||||
|
AUD_device->stopAll();
|
||||||
|
}
|
||||||
|
|
||||||
int AUD_setKeep(AUD_Handle *handle, int keep)
|
int AUD_setKeep(AUD_Handle *handle, int keep)
|
||||||
{
|
{
|
||||||
assert(handle);
|
assert(handle);
|
||||||
@@ -1015,7 +1019,7 @@ void AUD_setSequencerSpecs(AUD_Sound *sequencer, AUD_Specs specs)
|
|||||||
dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->setSpecs(specs);
|
dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->setSpecs(specs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AUD_seekSequencer(AUD_Handle *handle, float time)
|
void AUD_seekSynchronizer(AUD_Handle *handle, float time)
|
||||||
{
|
{
|
||||||
#ifdef WITH_JACK
|
#ifdef WITH_JACK
|
||||||
AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
|
AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
|
||||||
@@ -1030,7 +1034,7 @@ void AUD_seekSequencer(AUD_Handle *handle, float time)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float AUD_getSequencerPosition(AUD_Handle *handle)
|
float AUD_getSynchronizerPosition(AUD_Handle *handle)
|
||||||
{
|
{
|
||||||
#ifdef WITH_JACK
|
#ifdef WITH_JACK
|
||||||
AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
|
AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
|
||||||
@@ -1045,7 +1049,7 @@ float AUD_getSequencerPosition(AUD_Handle *handle)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AUD_startPlayback()
|
void AUD_playSynchronizer()
|
||||||
{
|
{
|
||||||
#ifdef WITH_JACK
|
#ifdef WITH_JACK
|
||||||
AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
|
AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
|
||||||
@@ -1055,7 +1059,7 @@ void AUD_startPlayback()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void AUD_stopPlayback()
|
void AUD_stopSynchronizer()
|
||||||
{
|
{
|
||||||
#ifdef WITH_JACK
|
#ifdef WITH_JACK
|
||||||
AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
|
AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
|
||||||
@@ -1066,7 +1070,7 @@ void AUD_stopPlayback()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_JACK
|
#ifdef WITH_JACK
|
||||||
void AUD_setSyncCallback(AUD_syncFunction function, void *data)
|
void AUD_setSynchronizerCallback(AUD_syncFunction function, void *data)
|
||||||
{
|
{
|
||||||
AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
|
AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
|
||||||
if (device) {
|
if (device) {
|
||||||
@@ -1075,7 +1079,7 @@ void AUD_setSyncCallback(AUD_syncFunction function, void *data)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int AUD_doesPlayback()
|
int AUD_isSynchronizerPlaying()
|
||||||
{
|
{
|
||||||
#ifdef WITH_JACK
|
#ifdef WITH_JACK
|
||||||
AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
|
AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
|
||||||
@@ -1283,16 +1287,6 @@ AUD_Device *AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound *sequencer, f
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<AUD_IDevice> AUD_getDevice()
|
|
||||||
{
|
|
||||||
return AUD_device;
|
|
||||||
}
|
|
||||||
|
|
||||||
AUD_I3DDevice *AUD_get3DDevice()
|
|
||||||
{
|
|
||||||
return AUD_3ddevice;
|
|
||||||
}
|
|
||||||
|
|
||||||
int AUD_isJackSupported(void)
|
int AUD_isJackSupported(void)
|
||||||
{
|
{
|
||||||
#ifdef WITH_JACK
|
#ifdef WITH_JACK
|
||||||
|
@@ -77,7 +77,7 @@ extern void AUD_exitOnce(void);
|
|||||||
* \param buffersize The buffersize for the device.
|
* \param buffersize The buffersize for the device.
|
||||||
* \return Whether the device has been initialized.
|
* \return Whether the device has been initialized.
|
||||||
*/
|
*/
|
||||||
extern int AUD_init(AUD_DeviceType device, AUD_DeviceSpecs specs, int buffersize);
|
extern int AUD_init(const char* device, const char* name, AUD_DeviceSpecs specs, int buffersize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unitinitializes an audio device.
|
* Unitinitializes an audio device.
|
||||||
@@ -212,6 +212,8 @@ extern int AUD_resume(AUD_Handle *handle);
|
|||||||
*/
|
*/
|
||||||
extern int AUD_stop(AUD_Handle *handle);
|
extern int AUD_stop(AUD_Handle *handle);
|
||||||
|
|
||||||
|
extern void AUD_stopAll(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the end behaviour of a playing or paused sound.
|
* Sets the end behaviour of a playing or paused sound.
|
||||||
* \param handle The handle to the sound.
|
* \param handle The handle to the sound.
|
||||||
@@ -604,24 +606,24 @@ extern void AUD_setSequencerSpecs(AUD_Sound *sequencer, AUD_Specs specs);
|
|||||||
* \param handle Playback handle.
|
* \param handle Playback handle.
|
||||||
* \param time Time in seconds to seek to.
|
* \param time Time in seconds to seek to.
|
||||||
*/
|
*/
|
||||||
extern void AUD_seekSequencer(AUD_Handle *handle, float time);
|
extern void AUD_seekSynchronizer(AUD_Handle *handle, float time);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current sound scene playback time.
|
* Returns the current sound scene playback time.
|
||||||
* \param handle Playback handle.
|
* \param handle Playback handle.
|
||||||
* \return The playback time in seconds.
|
* \return The playback time in seconds.
|
||||||
*/
|
*/
|
||||||
extern float AUD_getSequencerPosition(AUD_Handle *handle);
|
extern float AUD_getSynchronizerPosition(AUD_Handle *handle);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the playback of jack transport if possible.
|
* Starts the playback of jack transport if possible.
|
||||||
*/
|
*/
|
||||||
extern void AUD_startPlayback(void);
|
extern void AUD_playSynchronizer(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stops the playback of jack transport if possible.
|
* Stops the playback of jack transport if possible.
|
||||||
*/
|
*/
|
||||||
extern void AUD_stopPlayback(void);
|
extern void AUD_stopSynchronizer(void);
|
||||||
|
|
||||||
#ifdef WITH_JACK
|
#ifdef WITH_JACK
|
||||||
/**
|
/**
|
||||||
@@ -629,14 +631,14 @@ extern void AUD_stopPlayback(void);
|
|||||||
* \param function The callback function.
|
* \param function The callback function.
|
||||||
* \param data The data parameter for the callback.
|
* \param data The data parameter for the callback.
|
||||||
*/
|
*/
|
||||||
extern void AUD_setSyncCallback(AUD_syncFunction function, void *data);
|
extern void AUD_setSynchronizerCallback(AUD_syncFunction function, void *data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether jack transport is currently playing.
|
* Returns whether jack transport is currently playing.
|
||||||
* \return Whether jack transport is currently playing.
|
* \return Whether jack transport is currently playing.
|
||||||
*/
|
*/
|
||||||
extern int AUD_doesPlayback(void);
|
extern int AUD_isSynchronizerPlaying(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a sound into a buffer for drawing at a specific sampling rate.
|
* Reads a sound into a buffer for drawing at a specific sampling rate.
|
||||||
@@ -747,36 +749,20 @@ extern AUD_Device *AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound *seque
|
|||||||
* \param sound The sound factory.
|
* \param sound The sound factory.
|
||||||
* \return The python factory.
|
* \return The python factory.
|
||||||
*/
|
*/
|
||||||
extern void *AUD_getPythonFactory(AUD_Sound *sound);
|
extern void *AUD_getPythonSound(AUD_Sound *sound);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the sound factory of a python factory.
|
* Retrieves the sound factory of a python factory.
|
||||||
* \param sound The python factory.
|
* \param sound The python factory.
|
||||||
* \return The sound factory.
|
* \return The sound factory.
|
||||||
*/
|
*/
|
||||||
extern AUD_Sound *AUD_getPythonSound(void *sound);
|
extern AUD_Sound *AUD_getSoundFromPython(void *sound);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int AUD_isJackSupported(void);
|
extern int AUD_isJackSupported(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
|
||||||
class AUD_IDevice;
|
|
||||||
class AUD_I3DDevice;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the current playback device.
|
|
||||||
* \return The playback device.
|
|
||||||
*/
|
|
||||||
boost::shared_ptr<AUD_IDevice> AUD_getDevice();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the current playback 3D device.
|
|
||||||
* \return The playback 3D device.
|
|
||||||
*/
|
|
||||||
AUD_I3DDevice *AUD_get3DDevice();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif //__AUD_C_API_H__
|
#endif //__AUD_C_API_H__
|
||||||
|
@@ -176,6 +176,7 @@ void BKE_sound_init(struct Main *bmain)
|
|||||||
{
|
{
|
||||||
AUD_DeviceSpecs specs;
|
AUD_DeviceSpecs specs;
|
||||||
int device, buffersize;
|
int device, buffersize;
|
||||||
|
const char* device_name;
|
||||||
|
|
||||||
device = U.audiodevice;
|
device = U.audiodevice;
|
||||||
buffersize = U.mixbufsize;
|
buffersize = U.mixbufsize;
|
||||||
@@ -186,6 +187,22 @@ void BKE_sound_init(struct Main *bmain)
|
|||||||
if (force_device >= 0)
|
if (force_device >= 0)
|
||||||
device = force_device;
|
device = force_device;
|
||||||
|
|
||||||
|
switch(device)
|
||||||
|
{
|
||||||
|
case AUD_SDL_DEVICE:
|
||||||
|
device_name = "SDL";
|
||||||
|
break;
|
||||||
|
case AUD_OPENAL_DEVICE:
|
||||||
|
device_name = "OpenAL";
|
||||||
|
break;
|
||||||
|
case AUD_JACK_DEVICE:
|
||||||
|
device_name = "Jack";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
device_name = "Null";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (buffersize < 128)
|
if (buffersize < 128)
|
||||||
buffersize = AUD_DEFAULT_BUFFER_SIZE;
|
buffersize = AUD_DEFAULT_BUFFER_SIZE;
|
||||||
|
|
||||||
@@ -198,8 +215,8 @@ void BKE_sound_init(struct Main *bmain)
|
|||||||
if (specs.channels <= AUD_CHANNELS_INVALID)
|
if (specs.channels <= AUD_CHANNELS_INVALID)
|
||||||
specs.channels = AUD_CHANNELS_STEREO;
|
specs.channels = AUD_CHANNELS_STEREO;
|
||||||
|
|
||||||
if (!AUD_init(device, specs, buffersize))
|
if (!AUD_init(device_name, "Blender", specs, buffersize))
|
||||||
AUD_init(AUD_NULL_DEVICE, specs, buffersize);
|
AUD_init("Null", "Blender", specs, buffersize);
|
||||||
|
|
||||||
BKE_sound_init_main(bmain);
|
BKE_sound_init_main(bmain);
|
||||||
}
|
}
|
||||||
@@ -207,7 +224,7 @@ void BKE_sound_init(struct Main *bmain)
|
|||||||
void BKE_sound_init_main(struct Main *bmain)
|
void BKE_sound_init_main(struct Main *bmain)
|
||||||
{
|
{
|
||||||
#ifdef WITH_JACK
|
#ifdef WITH_JACK
|
||||||
AUD_setSyncCallback(sound_sync_callback, bmain);
|
AUD_setSynchronizerCallback(sound_sync_callback, bmain);
|
||||||
#else
|
#else
|
||||||
(void)bmain; /* unused */
|
(void)bmain; /* unused */
|
||||||
#endif
|
#endif
|
||||||
@@ -557,7 +574,7 @@ void BKE_sound_play_scene(struct Scene *scene)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (scene->audio.flag & AUDIO_SYNC)
|
if (scene->audio.flag & AUDIO_SYNC)
|
||||||
AUD_startPlayback();
|
AUD_playSynchronizer();
|
||||||
|
|
||||||
AUD_unlock();
|
AUD_unlock();
|
||||||
}
|
}
|
||||||
@@ -568,7 +585,7 @@ void BKE_sound_stop_scene(struct Scene *scene)
|
|||||||
AUD_pause(scene->playback_handle);
|
AUD_pause(scene->playback_handle);
|
||||||
|
|
||||||
if (scene->audio.flag & AUDIO_SYNC)
|
if (scene->audio.flag & AUDIO_SYNC)
|
||||||
AUD_stopPlayback();
|
AUD_stopSynchronizer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -607,7 +624,7 @@ void BKE_sound_seek_scene(struct Main *bmain, struct Scene *scene)
|
|||||||
if (scene->audio.flag & AUDIO_SCRUB && !animation_playing) {
|
if (scene->audio.flag & AUDIO_SCRUB && !animation_playing) {
|
||||||
if (scene->audio.flag & AUDIO_SYNC) {
|
if (scene->audio.flag & AUDIO_SYNC) {
|
||||||
AUD_seek(scene->playback_handle, cur_time);
|
AUD_seek(scene->playback_handle, cur_time);
|
||||||
AUD_seekSequencer(scene->playback_handle, cur_time);
|
AUD_seekSynchronizer(scene->playback_handle, cur_time);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
AUD_seek(scene->playback_handle, cur_time);
|
AUD_seek(scene->playback_handle, cur_time);
|
||||||
@@ -625,7 +642,7 @@ void BKE_sound_seek_scene(struct Main *bmain, struct Scene *scene)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (scene->audio.flag & AUDIO_SYNC) {
|
if (scene->audio.flag & AUDIO_SYNC) {
|
||||||
AUD_seekSequencer(scene->playback_handle, cur_time);
|
AUD_seekSynchronizer(scene->playback_handle, cur_time);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (status == AUD_STATUS_PLAYING) {
|
if (status == AUD_STATUS_PLAYING) {
|
||||||
@@ -641,7 +658,7 @@ float BKE_sound_sync_scene(struct Scene *scene)
|
|||||||
{
|
{
|
||||||
if (scene->playback_handle) {
|
if (scene->playback_handle) {
|
||||||
if (scene->audio.flag & AUDIO_SYNC)
|
if (scene->audio.flag & AUDIO_SYNC)
|
||||||
return AUD_getSequencerPosition(scene->playback_handle);
|
return AUD_getSynchronizerPosition(scene->playback_handle);
|
||||||
else
|
else
|
||||||
return AUD_getPosition(scene->playback_handle);
|
return AUD_getPosition(scene->playback_handle);
|
||||||
}
|
}
|
||||||
@@ -651,7 +668,7 @@ float BKE_sound_sync_scene(struct Scene *scene)
|
|||||||
int BKE_sound_scene_playing(struct Scene *scene)
|
int BKE_sound_scene_playing(struct Scene *scene)
|
||||||
{
|
{
|
||||||
if (scene->audio.flag & AUDIO_SYNC)
|
if (scene->audio.flag & AUDIO_SYNC)
|
||||||
return AUD_doesPlayback();
|
return AUD_isSynchronizerPlaying();
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@@ -102,8 +102,6 @@ typedef void * wmUIHandlerRemoveFunc;
|
|||||||
|
|
||||||
#ifdef WITH_AUDASPACE
|
#ifdef WITH_AUDASPACE
|
||||||
# include "AUD_C-API.h"
|
# include "AUD_C-API.h"
|
||||||
# include "AUD_I3DDevice.h"
|
|
||||||
# include "AUD_IDevice.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static BlendFileData *load_game_data(char *filename)
|
static BlendFileData *load_game_data(char *filename)
|
||||||
@@ -502,13 +500,9 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
|
|||||||
ketsjiengine->InitDome(scene->gm.dome.res, scene->gm.dome.mode, scene->gm.dome.angle, scene->gm.dome.resbuf, scene->gm.dome.tilt, scene->gm.dome.warptext);
|
ketsjiengine->InitDome(scene->gm.dome.res, scene->gm.dome.mode, scene->gm.dome.angle, scene->gm.dome.resbuf, scene->gm.dome.tilt, scene->gm.dome.warptext);
|
||||||
|
|
||||||
// initialize 3D Audio Settings
|
// initialize 3D Audio Settings
|
||||||
AUD_I3DDevice* dev = AUD_get3DDevice();
|
AUD_setSpeedOfSound(scene->audio.speed_of_sound);
|
||||||
if (dev)
|
AUD_setDopplerFactor(scene->audio.doppler_factor);
|
||||||
{
|
AUD_setDistanceModel(AUD_DistanceModel(scene->audio.distance_model));
|
||||||
dev->setSpeedOfSound(scene->audio.speed_of_sound);
|
|
||||||
dev->setDopplerFactor(scene->audio.doppler_factor);
|
|
||||||
dev->setDistanceModel(AUD_DistanceModel(scene->audio.distance_model));
|
|
||||||
}
|
|
||||||
|
|
||||||
// from see blender.c:
|
// from see blender.c:
|
||||||
// FIXME: this version patching should really be part of the file-reading code,
|
// FIXME: this version patching should really be part of the file-reading code,
|
||||||
@@ -675,7 +669,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
|
|||||||
}
|
}
|
||||||
|
|
||||||
// stop all remaining playing sounds
|
// stop all remaining playing sounds
|
||||||
AUD_getDevice()->stopAll();
|
AUD_stopAll();
|
||||||
|
|
||||||
} while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME);
|
} while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME);
|
||||||
|
|
||||||
|
@@ -43,7 +43,6 @@
|
|||||||
|
|
||||||
#ifdef WITH_AUDASPACE
|
#ifdef WITH_AUDASPACE
|
||||||
# include "AUD_C-API.h"
|
# include "AUD_C-API.h"
|
||||||
# include "AUD_ChannelMapperFactory.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Actuators
|
// Actuators
|
||||||
@@ -385,7 +384,7 @@ void BL_ConvertActuators(const char* maggiename,
|
|||||||
{
|
{
|
||||||
bSound* sound = soundact->sound;
|
bSound* sound = soundact->sound;
|
||||||
bool is3d = soundact->flag & ACT_SND_3D_SOUND ? true : false;
|
bool is3d = soundact->flag & ACT_SND_3D_SOUND ? true : false;
|
||||||
boost::shared_ptr<AUD_IFactory> snd_sound;
|
AUD_Sound* snd_sound = NULL;
|
||||||
KX_3DSoundSettings settings;
|
KX_3DSoundSettings settings;
|
||||||
settings.cone_inner_angle = RAD2DEGF(soundact->sound3D.cone_inner_angle);
|
settings.cone_inner_angle = RAD2DEGF(soundact->sound3D.cone_inner_angle);
|
||||||
settings.cone_outer_angle = RAD2DEGF(soundact->sound3D.cone_outer_angle);
|
settings.cone_outer_angle = RAD2DEGF(soundact->sound3D.cone_outer_angle);
|
||||||
@@ -404,27 +403,12 @@ void BL_ConvertActuators(const char* maggiename,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
snd_sound = *reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(sound->playback_handle);
|
snd_sound = sound->playback_handle;
|
||||||
|
|
||||||
// if sound shall be 3D but isn't mono, we have to make it mono!
|
// if sound shall be 3D but isn't mono, we have to make it mono!
|
||||||
if (is3d)
|
if (is3d)
|
||||||
{
|
{
|
||||||
try
|
snd_sound = AUD_monoSound(snd_sound);
|
||||||
{
|
|
||||||
boost::shared_ptr<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 = boost::shared_ptr<AUD_IFactory>(new AUD_ChannelMapperFactory(snd_sound, specs));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(AUD_Exception&)
|
|
||||||
{
|
|
||||||
// sound cannot be played... ignore
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
KX_SoundActuator* tmpsoundact =
|
KX_SoundActuator* tmpsoundact =
|
||||||
@@ -436,6 +420,10 @@ void BL_ConvertActuators(const char* maggiename,
|
|||||||
settings,
|
settings,
|
||||||
soundActuatorType);
|
soundActuatorType);
|
||||||
|
|
||||||
|
// if we made it mono, we have to free it
|
||||||
|
if(snd_sound != sound->playback_handle && snd_sound != NULL)
|
||||||
|
AUD_unload(snd_sound);
|
||||||
|
|
||||||
tmpsoundact->SetName(bact->name);
|
tmpsoundact->SetName(bact->name);
|
||||||
baseact = tmpsoundact;
|
baseact = tmpsoundact;
|
||||||
}
|
}
|
||||||
|
@@ -101,8 +101,6 @@ extern "C"
|
|||||||
|
|
||||||
#ifdef WITH_AUDASPACE
|
#ifdef WITH_AUDASPACE
|
||||||
# include "AUD_C-API.h"
|
# include "AUD_C-API.h"
|
||||||
# include "AUD_I3DDevice.h"
|
|
||||||
# include "AUD_IDevice.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void frameTimerProc(GHOST_ITimerTask* task, GHOST_TUns64 time);
|
static void frameTimerProc(GHOST_ITimerTask* task, GHOST_TUns64 time);
|
||||||
@@ -746,13 +744,9 @@ bool GPG_Application::startEngine(void)
|
|||||||
m_ketsjiengine->InitDome(m_startScene->gm.dome.res, m_startScene->gm.dome.mode, m_startScene->gm.dome.angle, m_startScene->gm.dome.resbuf, m_startScene->gm.dome.tilt, m_startScene->gm.dome.warptext);
|
m_ketsjiengine->InitDome(m_startScene->gm.dome.res, m_startScene->gm.dome.mode, m_startScene->gm.dome.angle, m_startScene->gm.dome.resbuf, m_startScene->gm.dome.tilt, m_startScene->gm.dome.warptext);
|
||||||
|
|
||||||
// initialize 3D Audio Settings
|
// initialize 3D Audio Settings
|
||||||
AUD_I3DDevice* dev = AUD_get3DDevice();
|
AUD_setSpeedOfSound(m_startScene->audio.speed_of_sound);
|
||||||
if (dev)
|
AUD_setDopplerFactor(m_startScene->audio.doppler_factor);
|
||||||
{
|
AUD_setDistanceModel(AUD_DistanceModel(m_startScene->audio.distance_model));
|
||||||
dev->setSpeedOfSound(m_startScene->audio.speed_of_sound);
|
|
||||||
dev->setDopplerFactor(m_startScene->audio.doppler_factor);
|
|
||||||
dev->setDistanceModel(AUD_DistanceModel(m_startScene->audio.distance_model));
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
// Set the GameLogic.globalDict from marshal'd data, so we can
|
// Set the GameLogic.globalDict from marshal'd data, so we can
|
||||||
|
@@ -64,7 +64,6 @@
|
|||||||
|
|
||||||
#ifdef WITH_AUDASPACE
|
#ifdef WITH_AUDASPACE
|
||||||
# include "AUD_C-API.h"
|
# include "AUD_C-API.h"
|
||||||
# include "AUD_I3DDevice.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "NG_NetworkScene.h"
|
#include "NG_NetworkScene.h"
|
||||||
|
@@ -38,9 +38,6 @@
|
|||||||
|
|
||||||
#ifdef WITH_AUDASPACE
|
#ifdef WITH_AUDASPACE
|
||||||
# include "AUD_C-API.h"
|
# include "AUD_C-API.h"
|
||||||
# include "AUD_PingPongFactory.h"
|
|
||||||
# include "AUD_IDevice.h"
|
|
||||||
# include "AUD_I3DHandle.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "KX_GameObject.h"
|
#include "KX_GameObject.h"
|
||||||
@@ -53,7 +50,7 @@
|
|||||||
/* Native functions */
|
/* Native functions */
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
KX_SoundActuator::KX_SoundActuator(SCA_IObject* gameobj,
|
KX_SoundActuator::KX_SoundActuator(SCA_IObject* gameobj,
|
||||||
boost::shared_ptr<AUD_IFactory> sound,
|
AUD_Sound* sound,
|
||||||
float volume,
|
float volume,
|
||||||
float pitch,
|
float pitch,
|
||||||
bool is3d,
|
bool is3d,
|
||||||
@@ -61,7 +58,8 @@ KX_SoundActuator::KX_SoundActuator(SCA_IObject* gameobj,
|
|||||||
KX_SOUNDACT_TYPE type)//,
|
KX_SOUNDACT_TYPE type)//,
|
||||||
: SCA_IActuator(gameobj, KX_ACT_SOUND)
|
: SCA_IActuator(gameobj, KX_ACT_SOUND)
|
||||||
{
|
{
|
||||||
m_sound = sound;
|
m_sound = AUD_copy(sound);
|
||||||
|
m_handle = NULL;
|
||||||
m_volume = volume;
|
m_volume = volume;
|
||||||
m_pitch = pitch;
|
m_pitch = pitch;
|
||||||
m_is3d = is3d;
|
m_is3d = is3d;
|
||||||
@@ -74,20 +72,30 @@ KX_SoundActuator::KX_SoundActuator(SCA_IObject* gameobj,
|
|||||||
|
|
||||||
KX_SoundActuator::~KX_SoundActuator()
|
KX_SoundActuator::~KX_SoundActuator()
|
||||||
{
|
{
|
||||||
if (m_handle.get())
|
if(m_handle)
|
||||||
m_handle->stop();
|
{
|
||||||
|
AUD_stop(m_handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_sound)
|
||||||
|
{
|
||||||
|
AUD_unload(m_sound);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KX_SoundActuator::play()
|
void KX_SoundActuator::play()
|
||||||
{
|
{
|
||||||
if (m_handle.get())
|
if(m_handle)
|
||||||
m_handle->stop();
|
{
|
||||||
|
AUD_stop(m_handle);
|
||||||
|
m_handle = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_sound.get())
|
if (!m_sound)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// this is the sound that will be played and not deleted afterwards
|
// this is the sound that will be played and not deleted afterwards
|
||||||
boost::shared_ptr<AUD_IFactory> sound = m_sound;
|
AUD_Sound* sound = m_sound;
|
||||||
|
|
||||||
bool loop = false;
|
bool loop = false;
|
||||||
|
|
||||||
@@ -95,7 +103,7 @@ void KX_SoundActuator::play()
|
|||||||
{
|
{
|
||||||
case KX_SOUNDACT_LOOPBIDIRECTIONAL:
|
case KX_SOUNDACT_LOOPBIDIRECTIONAL:
|
||||||
case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP:
|
case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP:
|
||||||
sound = boost::shared_ptr<AUD_IFactory>(new AUD_PingPongFactory(sound));
|
sound = AUD_pingpongSound(sound);
|
||||||
// fall through
|
// fall through
|
||||||
case KX_SOUNDACT_LOOPEND:
|
case KX_SOUNDACT_LOOPEND:
|
||||||
case KX_SOUNDACT_LOOPSTOP:
|
case KX_SOUNDACT_LOOPSTOP:
|
||||||
@@ -107,36 +115,31 @@ void KX_SoundActuator::play()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
m_handle = AUD_play(sound, false);
|
||||||
{
|
|
||||||
m_handle = AUD_getDevice()->play(sound);
|
|
||||||
}
|
|
||||||
catch(AUD_Exception&)
|
|
||||||
{
|
|
||||||
// cannot play back, ignore
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
boost::shared_ptr<AUD_I3DHandle> handle3d = boost::dynamic_pointer_cast<AUD_I3DHandle>(m_handle);
|
// in case of pingpong, we have to free the sound
|
||||||
|
if(sound != m_sound)
|
||||||
|
AUD_unload(sound);
|
||||||
|
|
||||||
if (m_is3d && handle3d.get())
|
if (m_handle != NULL)
|
||||||
{
|
{
|
||||||
handle3d->setRelative(true);
|
if (m_is3d)
|
||||||
handle3d->setVolumeMaximum(m_3d.max_gain);
|
{
|
||||||
handle3d->setVolumeMinimum(m_3d.min_gain);
|
AUD_setRelative(m_handle, true);
|
||||||
handle3d->setDistanceReference(m_3d.reference_distance);
|
AUD_setVolumeMaximum(m_handle, m_3d.max_gain);
|
||||||
handle3d->setDistanceMaximum(m_3d.max_distance);
|
AUD_setVolumeMinimum(m_handle, m_3d.min_gain);
|
||||||
handle3d->setAttenuation(m_3d.rolloff_factor);
|
AUD_setDistanceReference(m_handle, m_3d.reference_distance);
|
||||||
handle3d->setConeAngleInner(m_3d.cone_inner_angle);
|
AUD_setDistanceMaximum(m_handle, m_3d.max_distance);
|
||||||
handle3d->setConeAngleOuter(m_3d.cone_outer_angle);
|
AUD_setAttenuation(m_handle, m_3d.rolloff_factor);
|
||||||
handle3d->setConeVolumeOuter(m_3d.cone_outer_gain);
|
AUD_setConeAngleInner(m_handle, m_3d.cone_inner_angle);
|
||||||
}
|
AUD_setConeAngleOuter(m_handle, m_3d.cone_outer_angle);
|
||||||
|
AUD_setConeVolumeOuter(m_handle, m_3d.cone_outer_gain);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_handle.get()) {
|
|
||||||
if (loop)
|
if (loop)
|
||||||
m_handle->setLoopCount(-1);
|
AUD_setLoop(m_handle, -1);
|
||||||
m_handle->setPitch(m_pitch);
|
AUD_setSoundPitch(m_handle, m_pitch);
|
||||||
m_handle->setVolume(m_volume);
|
AUD_setSoundVolume(m_handle, m_volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_isplaying = true;
|
m_isplaying = true;
|
||||||
@@ -152,7 +155,8 @@ CValue* KX_SoundActuator::GetReplica()
|
|||||||
void KX_SoundActuator::ProcessReplica()
|
void KX_SoundActuator::ProcessReplica()
|
||||||
{
|
{
|
||||||
SCA_IActuator::ProcessReplica();
|
SCA_IActuator::ProcessReplica();
|
||||||
m_handle = boost::shared_ptr<AUD_IHandle>();
|
m_handle = NULL;
|
||||||
|
m_sound = AUD_copy(m_sound);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KX_SoundActuator::Update(double curtime, bool frame)
|
bool KX_SoundActuator::Update(double curtime, bool frame)
|
||||||
@@ -167,11 +171,11 @@ bool KX_SoundActuator::Update(double curtime, bool frame)
|
|||||||
|
|
||||||
RemoveAllEvents();
|
RemoveAllEvents();
|
||||||
|
|
||||||
if (!m_sound.get())
|
if (!m_sound)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// actual audio device playing state
|
// actual audio device playing state
|
||||||
bool isplaying = m_handle.get() ? (m_handle->getStatus() == AUD_STATUS_PLAYING) : false;
|
bool isplaying = m_handle ? (AUD_getStatus(m_handle) == AUD_STATUS_PLAYING) : false;
|
||||||
|
|
||||||
if (bNegativeEvent)
|
if (bNegativeEvent)
|
||||||
{
|
{
|
||||||
@@ -185,9 +189,11 @@ bool KX_SoundActuator::Update(double curtime, bool frame)
|
|||||||
case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP:
|
case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP:
|
||||||
{
|
{
|
||||||
// stop immediately
|
// stop immediately
|
||||||
if (m_handle.get())
|
if (m_handle)
|
||||||
m_handle->stop();
|
{
|
||||||
m_handle = boost::shared_ptr<AUD_IHandle>();
|
AUD_stop(m_handle);
|
||||||
|
m_handle = NULL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KX_SOUNDACT_PLAYEND:
|
case KX_SOUNDACT_PLAYEND:
|
||||||
@@ -199,8 +205,8 @@ bool KX_SoundActuator::Update(double curtime, bool frame)
|
|||||||
case KX_SOUNDACT_LOOPBIDIRECTIONAL:
|
case KX_SOUNDACT_LOOPBIDIRECTIONAL:
|
||||||
{
|
{
|
||||||
// stop the looping so that the sound stops when it finished
|
// stop the looping so that the sound stops when it finished
|
||||||
if (m_handle.get())
|
if (m_handle)
|
||||||
m_handle->setLoopCount(0);
|
AUD_setLoop(m_handle, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -227,13 +233,11 @@ bool KX_SoundActuator::Update(double curtime, bool frame)
|
|||||||
play();
|
play();
|
||||||
}
|
}
|
||||||
// verify that the sound is still playing
|
// verify that the sound is still playing
|
||||||
isplaying = m_handle.get() ? (m_handle->getStatus() == AUD_STATUS_PLAYING) : false;
|
isplaying = m_handle ? (AUD_getStatus(m_handle) == AUD_STATUS_PLAYING) : false;
|
||||||
|
|
||||||
if (isplaying)
|
if (isplaying)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<AUD_I3DHandle> handle3d = boost::dynamic_pointer_cast<AUD_I3DHandle>(m_handle);
|
if (m_is3d)
|
||||||
|
|
||||||
if (m_is3d && handle3d.get())
|
|
||||||
{
|
{
|
||||||
KX_Camera* cam = KX_GetActiveScene()->GetActiveCamera();
|
KX_Camera* cam = KX_GetActiveScene()->GetActiveCamera();
|
||||||
if (cam)
|
if (cam)
|
||||||
@@ -241,20 +245,19 @@ bool KX_SoundActuator::Update(double curtime, bool frame)
|
|||||||
KX_GameObject* obj = (KX_GameObject*)this->GetParent();
|
KX_GameObject* obj = (KX_GameObject*)this->GetParent();
|
||||||
MT_Point3 p;
|
MT_Point3 p;
|
||||||
MT_Matrix3x3 Mo;
|
MT_Matrix3x3 Mo;
|
||||||
AUD_Vector3 v;
|
float data[4];
|
||||||
float q[4];
|
|
||||||
|
|
||||||
Mo = cam->NodeGetWorldOrientation().inverse();
|
Mo = cam->NodeGetWorldOrientation().inverse();
|
||||||
p = (obj->NodeGetWorldPosition() - cam->NodeGetWorldPosition());
|
p = (obj->NodeGetWorldPosition() - cam->NodeGetWorldPosition());
|
||||||
p = Mo * p;
|
p = Mo * p;
|
||||||
p.getValue(v.get());
|
p.getValue(data);
|
||||||
handle3d->setSourceLocation(v);
|
AUD_setSourceLocation(m_handle, data);
|
||||||
p = (obj->GetLinearVelocity() - cam->GetLinearVelocity());
|
p = (obj->GetLinearVelocity() - cam->GetLinearVelocity());
|
||||||
p = Mo * p;
|
p = Mo * p;
|
||||||
p.getValue(v.get());
|
p.getValue(data);
|
||||||
handle3d->setSourceVelocity(v);
|
AUD_setSourceVelocity(m_handle, data);
|
||||||
(Mo * obj->NodeGetWorldOrientation()).getRotation().getValue(q);
|
(Mo * obj->NodeGetWorldOrientation()).getRotation().getValue(data);
|
||||||
handle3d->setSourceOrientation(AUD_Quaternion(q[3], q[0], q[1], q[2]));
|
AUD_setSourceOrientation(m_handle, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result = true;
|
result = true;
|
||||||
@@ -329,11 +332,11 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, startSound,
|
|||||||
"startSound()\n"
|
"startSound()\n"
|
||||||
"\tStarts the sound.\n")
|
"\tStarts the sound.\n")
|
||||||
{
|
{
|
||||||
switch (m_handle.get() ? m_handle->getStatus() : AUD_STATUS_INVALID) {
|
switch (m_handle ? AUD_getStatus(m_handle) : AUD_STATUS_INVALID) {
|
||||||
case AUD_STATUS_PLAYING:
|
case AUD_STATUS_PLAYING:
|
||||||
break;
|
break;
|
||||||
case AUD_STATUS_PAUSED:
|
case AUD_STATUS_PAUSED:
|
||||||
m_handle->resume();
|
AUD_resume(m_handle);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
play();
|
play();
|
||||||
@@ -345,8 +348,8 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, pauseSound,
|
|||||||
"pauseSound()\n"
|
"pauseSound()\n"
|
||||||
"\tPauses the sound.\n")
|
"\tPauses the sound.\n")
|
||||||
{
|
{
|
||||||
if (m_handle.get())
|
if (m_handle)
|
||||||
m_handle->pause();
|
AUD_pause(m_handle);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,9 +357,11 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, stopSound,
|
|||||||
"stopSound()\n"
|
"stopSound()\n"
|
||||||
"\tStops the sound.\n")
|
"\tStops the sound.\n")
|
||||||
{
|
{
|
||||||
if (m_handle.get())
|
if (m_handle)
|
||||||
m_handle->stop();
|
{
|
||||||
m_handle = boost::shared_ptr<AUD_IHandle>();
|
AUD_stop(m_handle);
|
||||||
|
m_handle = NULL;
|
||||||
|
}
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,8 +409,8 @@ PyObject *KX_SoundActuator::pyattr_get_audposition(void *self, const struct KX_P
|
|||||||
KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
|
KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
|
||||||
float position = 0.0;
|
float position = 0.0;
|
||||||
|
|
||||||
if (actuator->m_handle.get())
|
if (actuator->m_handle)
|
||||||
position = actuator->m_handle->getPosition();
|
position = AUD_getPosition(actuator->m_handle);
|
||||||
|
|
||||||
PyObject *result = PyFloat_FromDouble(position);
|
PyObject *result = PyFloat_FromDouble(position);
|
||||||
|
|
||||||
@@ -435,8 +440,8 @@ PyObject *KX_SoundActuator::pyattr_get_pitch(void *self, const struct KX_PYATTRI
|
|||||||
PyObject *KX_SoundActuator::pyattr_get_sound(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
|
PyObject *KX_SoundActuator::pyattr_get_sound(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
|
||||||
{
|
{
|
||||||
KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
|
KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
|
||||||
if (actuator->m_sound.get())
|
if (actuator->m_sound)
|
||||||
return (PyObject *)AUD_getPythonFactory(&actuator->m_sound);
|
return (PyObject *)AUD_getPythonSound(actuator->m_sound);
|
||||||
else
|
else
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
@@ -450,50 +455,49 @@ int KX_SoundActuator::pyattr_set_3d_property(void *self, const struct KX_PYATTRI
|
|||||||
if (!PyArg_Parse(value, "f", &prop_value))
|
if (!PyArg_Parse(value, "f", &prop_value))
|
||||||
return PY_SET_ATTR_FAIL;
|
return PY_SET_ATTR_FAIL;
|
||||||
|
|
||||||
boost::shared_ptr<AUD_I3DHandle> handle3d = boost::dynamic_pointer_cast<AUD_I3DHandle>(actuator->m_handle);
|
|
||||||
// if sound is working and 3D, set the new setting
|
// if sound is working and 3D, set the new setting
|
||||||
if (!actuator->m_is3d)
|
if (!actuator->m_is3d)
|
||||||
return PY_SET_ATTR_FAIL;
|
return PY_SET_ATTR_FAIL;
|
||||||
|
|
||||||
if (!strcmp(prop, "volume_maximum")) {
|
if (!strcmp(prop, "volume_maximum")) {
|
||||||
actuator->m_3d.max_gain = prop_value;
|
actuator->m_3d.max_gain = prop_value;
|
||||||
if (handle3d.get())
|
if (actuator->m_handle)
|
||||||
handle3d->setVolumeMaximum(prop_value);
|
AUD_setVolumeMaximum(actuator->m_handle, prop_value);
|
||||||
|
|
||||||
} else if (!strcmp(prop, "volume_minimum")) {
|
} else if (!strcmp(prop, "volume_minimum")) {
|
||||||
actuator->m_3d.min_gain = prop_value;
|
actuator->m_3d.min_gain = prop_value;
|
||||||
if (handle3d.get())
|
if (actuator->m_handle)
|
||||||
handle3d->setVolumeMinimum(prop_value);
|
AUD_setVolumeMinimum(actuator->m_handle, prop_value);
|
||||||
|
|
||||||
} else if (!strcmp(prop, "distance_reference")) {
|
} else if (!strcmp(prop, "distance_reference")) {
|
||||||
actuator->m_3d.reference_distance = prop_value;
|
actuator->m_3d.reference_distance = prop_value;
|
||||||
if (handle3d.get())
|
if (actuator->m_handle)
|
||||||
handle3d->setDistanceReference(prop_value);
|
AUD_setDistanceReference(actuator->m_handle, prop_value);
|
||||||
|
|
||||||
} else if (!strcmp(prop, "distance_maximum")) {
|
} else if (!strcmp(prop, "distance_maximum")) {
|
||||||
actuator->m_3d.max_distance = prop_value;
|
actuator->m_3d.max_distance = prop_value;
|
||||||
if (handle3d.get())
|
if (actuator->m_handle)
|
||||||
handle3d->setDistanceMaximum(prop_value);
|
AUD_setDistanceMaximum(actuator->m_handle, prop_value);
|
||||||
|
|
||||||
} else if (!strcmp(prop, "attenuation")) {
|
} else if (!strcmp(prop, "attenuation")) {
|
||||||
actuator->m_3d.rolloff_factor = prop_value;
|
actuator->m_3d.rolloff_factor = prop_value;
|
||||||
if (handle3d.get())
|
if (actuator->m_handle)
|
||||||
handle3d->setAttenuation(prop_value);
|
AUD_setAttenuation(actuator->m_handle, prop_value);
|
||||||
|
|
||||||
} else if (!!strcmp(prop, "cone_angle_inner")) {
|
} else if (!!strcmp(prop, "cone_angle_inner")) {
|
||||||
actuator->m_3d.cone_inner_angle = prop_value;
|
actuator->m_3d.cone_inner_angle = prop_value;
|
||||||
if (handle3d.get())
|
if (actuator->m_handle)
|
||||||
handle3d->setConeAngleInner(prop_value);
|
AUD_setConeAngleInner(actuator->m_handle, prop_value);
|
||||||
|
|
||||||
} else if (!strcmp(prop, "cone_angle_outer")) {
|
} else if (!strcmp(prop, "cone_angle_outer")) {
|
||||||
actuator->m_3d.cone_outer_angle = prop_value;
|
actuator->m_3d.cone_outer_angle = prop_value;
|
||||||
if (handle3d.get())
|
if (actuator->m_handle)
|
||||||
handle3d->setConeAngleOuter(prop_value);
|
AUD_setConeAngleOuter(actuator->m_handle, prop_value);
|
||||||
|
|
||||||
} else if (!strcmp(prop, "cone_volume_outer")) {
|
} else if (!strcmp(prop, "cone_volume_outer")) {
|
||||||
actuator->m_3d.cone_outer_gain = prop_value;
|
actuator->m_3d.cone_outer_gain = prop_value;
|
||||||
if (handle3d.get())
|
if (actuator->m_handle)
|
||||||
handle3d->setConeVolumeOuter(prop_value);
|
AUD_setConeVolumeOuter(actuator->m_handle, prop_value);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return PY_SET_ATTR_FAIL;
|
return PY_SET_ATTR_FAIL;
|
||||||
@@ -510,8 +514,8 @@ int KX_SoundActuator::pyattr_set_audposition(void *self, const struct KX_PYATTRI
|
|||||||
if (!PyArg_Parse(value, "f", &position))
|
if (!PyArg_Parse(value, "f", &position))
|
||||||
return PY_SET_ATTR_FAIL;
|
return PY_SET_ATTR_FAIL;
|
||||||
|
|
||||||
if (actuator->m_handle.get())
|
if (actuator->m_handle)
|
||||||
actuator->m_handle->seek(position);
|
AUD_seek(actuator->m_handle, position);
|
||||||
return PY_SET_ATTR_SUCCESS;
|
return PY_SET_ATTR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -523,8 +527,8 @@ int KX_SoundActuator::pyattr_set_gain(void *self, const struct KX_PYATTRIBUTE_DE
|
|||||||
return PY_SET_ATTR_FAIL;
|
return PY_SET_ATTR_FAIL;
|
||||||
|
|
||||||
actuator->m_volume = gain;
|
actuator->m_volume = gain;
|
||||||
if (actuator->m_handle.get())
|
if (actuator->m_handle)
|
||||||
actuator->m_handle->setVolume(gain);
|
AUD_setSoundVolume(actuator->m_handle, gain);
|
||||||
|
|
||||||
return PY_SET_ATTR_SUCCESS;
|
return PY_SET_ATTR_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -537,8 +541,8 @@ int KX_SoundActuator::pyattr_set_pitch(void *self, const struct KX_PYATTRIBUTE_D
|
|||||||
return PY_SET_ATTR_FAIL;
|
return PY_SET_ATTR_FAIL;
|
||||||
|
|
||||||
actuator->m_pitch = pitch;
|
actuator->m_pitch = pitch;
|
||||||
if (actuator->m_handle.get())
|
if (actuator->m_handle)
|
||||||
actuator->m_handle->setPitch(pitch);
|
AUD_setSoundPitch(actuator->m_handle, pitch);
|
||||||
|
|
||||||
return PY_SET_ATTR_SUCCESS;
|
return PY_SET_ATTR_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -550,11 +554,12 @@ int KX_SoundActuator::pyattr_set_sound(void *self, const struct KX_PYATTRIBUTE_D
|
|||||||
if (!PyArg_Parse(value, "O", &sound))
|
if (!PyArg_Parse(value, "O", &sound))
|
||||||
return PY_SET_ATTR_FAIL;
|
return PY_SET_ATTR_FAIL;
|
||||||
|
|
||||||
boost::shared_ptr<AUD_IFactory>* snd = reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(AUD_getPythonSound((void *)sound));
|
AUD_Sound *snd = AUD_getSoundFromPython((void *)sound);
|
||||||
|
|
||||||
if (snd)
|
if (snd)
|
||||||
{
|
{
|
||||||
actuator->m_sound = *snd;
|
AUD_unload(actuator->m_sound);
|
||||||
delete snd;
|
actuator->m_sound = snd;
|
||||||
return PY_SET_ATTR_SUCCESS;
|
return PY_SET_ATTR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -36,9 +36,6 @@
|
|||||||
|
|
||||||
#ifdef WITH_AUDASPACE
|
#ifdef WITH_AUDASPACE
|
||||||
# include "AUD_C-API.h"
|
# include "AUD_C-API.h"
|
||||||
# include "AUD_IFactory.h"
|
|
||||||
# include "AUD_IHandle.h"
|
|
||||||
# include <boost/shared_ptr.hpp>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "BKE_sound.h"
|
#include "BKE_sound.h"
|
||||||
@@ -58,12 +55,12 @@ class KX_SoundActuator : public SCA_IActuator
|
|||||||
{
|
{
|
||||||
Py_Header
|
Py_Header
|
||||||
bool m_isplaying;
|
bool m_isplaying;
|
||||||
boost::shared_ptr<AUD_IFactory> m_sound;
|
AUD_Sound* m_sound;
|
||||||
float m_volume;
|
float m_volume;
|
||||||
float m_pitch;
|
float m_pitch;
|
||||||
bool m_is3d;
|
bool m_is3d;
|
||||||
KX_3DSoundSettings m_3d;
|
KX_3DSoundSettings m_3d;
|
||||||
boost::shared_ptr<AUD_IHandle> m_handle;
|
AUD_Handle* m_handle;
|
||||||
|
|
||||||
void play();
|
void play();
|
||||||
|
|
||||||
@@ -84,7 +81,7 @@ public:
|
|||||||
KX_SOUNDACT_TYPE m_type;
|
KX_SOUNDACT_TYPE m_type;
|
||||||
|
|
||||||
KX_SoundActuator(SCA_IObject* gameobj,
|
KX_SoundActuator(SCA_IObject* gameobj,
|
||||||
boost::shared_ptr<AUD_IFactory> sound,
|
AUD_Sound *sound,
|
||||||
float volume,
|
float volume,
|
||||||
float pitch,
|
float pitch,
|
||||||
bool is3d,
|
bool is3d,
|
||||||
|
Reference in New Issue
Block a user