diff options
Diffstat (limited to 'intern/audaspace/intern')
-rw-r--r-- | intern/audaspace/intern/AUD_AnimateableProperty.cpp | 10 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_C-API.cpp | 341 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_C-API.h | 264 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_ConverterFunctions.h | 9 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_PyInit.cpp | 78 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_Sequencer.cpp | 2 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_SequencerHandle.cpp | 256 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_SequencerHandle.h | 18 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_Set.cpp | 69 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_Set.h | 74 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_SoftwareDevice.cpp | 2 |
11 files changed, 758 insertions, 365 deletions
diff --git a/intern/audaspace/intern/AUD_AnimateableProperty.cpp b/intern/audaspace/intern/AUD_AnimateableProperty.cpp index 9f399a0b99f..e0bc18ea520 100644 --- a/intern/audaspace/intern/AUD_AnimateableProperty.cpp +++ b/intern/audaspace/intern/AUD_AnimateableProperty.cpp @@ -119,13 +119,11 @@ void AUD_AnimateableProperty::write(const float* data, int position, int count) { m_unknown.push_back(Unknown(pos, position - 1)); + // if the buffer was not animated before, we copy the previous static value if(pos == 0) - { - for(int i = 0; i < position; i++) - memcpy(buf + i * m_count, data, m_count * sizeof(float)); - } - else - updateUnknownCache(pos, position - 1); + pos = 1; + + updateUnknownCache(pos, position - 1); } // otherwise it's not at the end, let's check if some unknown part got filled else diff --git a/intern/audaspace/intern/AUD_C-API.cpp b/intern/audaspace/intern/AUD_C-API.cpp index aa82e1da678..341f1cd3f6b 100644 --- a/intern/audaspace/intern/AUD_C-API.cpp +++ b/intern/audaspace/intern/AUD_C-API.cpp @@ -41,11 +41,11 @@ # include "AUD_PyAPI.h" #endif -#include <set> #include <cstdlib> #include <cstring> #include <cmath> #include <sstream> +#include <iostream> #include "AUD_NULLDevice.h" #include "AUD_I3DDevice.h" @@ -75,6 +75,7 @@ #include "AUD_MutexLock.h" #ifdef WITH_SDL +#include <SDL.h> #include "AUD_SDLDevice.h" #endif @@ -97,7 +98,7 @@ extern "C" { #include <cassert> typedef boost::shared_ptr<AUD_IFactory> AUD_Sound; -typedef boost::shared_ptr<AUD_ReadDevice> AUD_Device; +typedef boost::shared_ptr<AUD_IDevice> AUD_Device; typedef boost::shared_ptr<AUD_IHandle> AUD_Handle; typedef boost::shared_ptr<AUD_SequencerEntry> AUD_SEntry; @@ -128,64 +129,69 @@ void AUD_exitOnce() #endif } -int AUD_init(AUD_DeviceType device, AUD_DeviceSpecs specs, int buffersize) +AUD_Device* AUD_init(const char* device, AUD_DeviceSpecs specs, int buffersize, const char* name) { boost::shared_ptr<AUD_IDevice> dev; if (AUD_device.get()) { - AUD_exit(); + AUD_exit(NULL); } + std::string dname = device; + try { - switch(device) { - case AUD_NULL_DEVICE: + if(dname == "Null") { dev = boost::shared_ptr<AUD_IDevice>(new AUD_NULLDevice()); - break; + } #ifdef WITH_SDL - case AUD_SDL_DEVICE: + else if(dname == "SDL") + { dev = boost::shared_ptr<AUD_IDevice>(new AUD_SDLDevice(specs, buffersize)); - break; + } #endif #ifdef WITH_OPENAL - case AUD_OPENAL_DEVICE: + else if(dname == "OpenAL") + { dev = boost::shared_ptr<AUD_IDevice>(new AUD_OpenALDevice(specs, buffersize)); - break; + } #endif #ifdef WITH_JACK - case AUD_JACK_DEVICE: + else if(dname == "Jack") + { #ifdef __APPLE__ struct stat st; if (stat("/Library/Frameworks/Jackmp.framework", &st) != 0) { printf("Warning: Jack Framework not installed\n"); - // No break, fall through to default, to return false + return NULL; } else #endif if (!AUD_jack_supported()) { printf("Warning: Jack cllient not installed\n"); - // No break, fall through to default, to return false + return NULL; } else { - dev = boost::shared_ptr<AUD_IDevice>(new AUD_JackDevice("Blender", specs, buffersize)); - break; + dev = boost::shared_ptr<AUD_IDevice>(new AUD_JackDevice(name, specs, buffersize)); } + } #endif - default: - return false; + else + { + return NULL; } AUD_device = dev; AUD_3ddevice = dynamic_cast<AUD_I3DDevice *>(AUD_device.get()); - return true; + return (AUD_Device*)1; } catch(AUD_Exception&) { - return false; + return NULL; } } -void AUD_exit() +void AUD_exit(AUD_Device* device) { AUD_device = boost::shared_ptr<AUD_IDevice>(); AUD_3ddevice = NULL; @@ -214,7 +220,7 @@ static PyMethodDef meth_getcdevice[] = { }; extern "C" { -extern void *sound_get_factory(void *sound); +extern void *BKE_sound_get_factory(void *sound); } static PyObject *AUD_getSoundFromPointer(PyObject *self, PyObject *args) @@ -223,7 +229,7 @@ static PyObject *AUD_getSoundFromPointer(PyObject *self, PyObject *args) if (PyArg_Parse(args, "l:_sound_from_pointer", &lptr)) { if (lptr) { - boost::shared_ptr<AUD_IFactory>* factory = (boost::shared_ptr<AUD_IFactory>*) sound_get_factory((void *) lptr); + boost::shared_ptr<AUD_IFactory>* factory = (boost::shared_ptr<AUD_IFactory>*) BKE_sound_get_factory((void *) lptr); if (factory) { Factory *obj = (Factory *)Factory_empty(); @@ -258,7 +264,7 @@ PyObject *AUD_initPython() return module; } -void *AUD_getPythonFactory(AUD_Sound *sound) +void *AUD_getPythonSound(AUD_Sound *sound) { if (sound) { Factory *obj = (Factory *) Factory_empty(); @@ -271,7 +277,7 @@ void *AUD_getPythonFactory(AUD_Sound *sound) return NULL; } -AUD_Sound *AUD_getPythonSound(void *sound) +AUD_Sound *AUD_getSoundFromPython(void *sound) { Factory *factory = checkFactory((PyObject *)sound); @@ -283,16 +289,26 @@ AUD_Sound *AUD_getPythonSound(void *sound) #endif -void AUD_lock() +void AUD_Device_lock(AUD_Device* device) { AUD_device->lock(); } -void AUD_unlock() +void AUD_Device_unlock(AUD_Device* device) { AUD_device->unlock(); } +AUD_Channels AUD_Device_getChannels(AUD_Device* device) +{ + return AUD_device->getSpecs().channels; +} + +AUD_SampleRate AUD_Device_getRate(AUD_Device* device) +{ + return AUD_device->getSpecs().rate; +} + AUD_SoundInfo AUD_getInfo(AUD_Sound *sound) { assert(sound); @@ -310,26 +326,27 @@ AUD_SoundInfo AUD_getInfo(AUD_Sound *sound) info.length = reader->getLength() / (float) info.specs.rate; } } - catch(AUD_Exception&) + catch(AUD_Exception &ae) { + std::cout << ae.str << std::endl; } return info; } -AUD_Sound *AUD_load(const char *filename) +AUD_Sound *AUD_Sound_file(const char *filename) { assert(filename); return new AUD_Sound(new AUD_FileFactory(filename)); } -AUD_Sound *AUD_loadBuffer(unsigned char *buffer, int size) +AUD_Sound *AUD_Sound_bufferFile(unsigned char *buffer, int size) { assert(buffer); return new AUD_Sound(new AUD_FileFactory(buffer, size)); } -AUD_Sound *AUD_bufferSound(AUD_Sound *sound) +AUD_Sound *AUD_Sound_cache(AUD_Sound *sound) { assert(sound); @@ -342,13 +359,13 @@ AUD_Sound *AUD_bufferSound(AUD_Sound *sound) } } -AUD_Sound *AUD_monoSound(AUD_Sound *sound) +AUD_Sound *AUD_Sound_rechannel(AUD_Sound *sound, AUD_Channels channels) { assert(sound); try { AUD_DeviceSpecs specs; - specs.channels = AUD_CHANNELS_MONO; + specs.channels = channels; specs.rate = AUD_RATE_INVALID; specs.format = AUD_FORMAT_INVALID; return new AUD_Sound(new AUD_ChannelMapperFactory(*sound, specs)); @@ -359,7 +376,7 @@ AUD_Sound *AUD_monoSound(AUD_Sound *sound) } } -AUD_Sound *AUD_delaySound(AUD_Sound *sound, float delay) +AUD_Sound *AUD_Sound_delay(AUD_Sound *sound, float delay) { assert(sound); @@ -372,7 +389,7 @@ AUD_Sound *AUD_delaySound(AUD_Sound *sound, float delay) } } -AUD_Sound *AUD_limitSound(AUD_Sound *sound, float start, float end) +AUD_Sound *AUD_Sound_limit(AUD_Sound *sound, float start, float end) { assert(sound); @@ -385,7 +402,7 @@ AUD_Sound *AUD_limitSound(AUD_Sound *sound, float start, float end) } } -AUD_Sound *AUD_pingpongSound(AUD_Sound *sound) +AUD_Sound *AUD_Sound_pingpong(AUD_Sound *sound) { assert(sound); @@ -398,7 +415,7 @@ AUD_Sound *AUD_pingpongSound(AUD_Sound *sound) } } -AUD_Sound *AUD_loopSound(AUD_Sound *sound) +AUD_Sound *AUD_Sound_loop(AUD_Sound *sound) { assert(sound); @@ -411,7 +428,7 @@ AUD_Sound *AUD_loopSound(AUD_Sound *sound) } } -int AUD_setLoop(AUD_Handle *handle, int loops) +int AUD_Handle_setLoopCount(AUD_Handle *handle, int loops) { assert(handle); @@ -438,13 +455,13 @@ AUD_Sound *AUD_rectifySound(AUD_Sound *sound) } } -void AUD_unload(AUD_Sound *sound) +void AUD_Sound_free(AUD_Sound *sound) { assert(sound); delete sound; } -AUD_Handle *AUD_play(AUD_Sound *sound, int keep) +AUD_Handle *AUD_Device_play(AUD_Device* device, AUD_Sound *sound, int keep) { assert(sound); try { @@ -459,19 +476,19 @@ AUD_Handle *AUD_play(AUD_Sound *sound, int keep) return NULL; } -int AUD_pause(AUD_Handle *handle) +int AUD_Handle_pause(AUD_Handle *handle) { assert(handle); return (*handle)->pause(); } -int AUD_resume(AUD_Handle *handle) +int AUD_Handle_resume(AUD_Handle *handle) { assert(handle); return (*handle)->resume(); } -int AUD_stop(AUD_Handle *handle) +int AUD_Handle_stop(AUD_Handle *handle) { assert(handle); int result = (*handle)->stop(); @@ -479,31 +496,36 @@ int AUD_stop(AUD_Handle *handle) return result; } -int AUD_setKeep(AUD_Handle *handle, int keep) +void AUD_Device_stopAll(void* device) +{ + AUD_device->stopAll(); +} + +int AUD_Handle_setKeep(AUD_Handle *handle, int keep) { assert(handle); return (*handle)->setKeep(keep); } -int AUD_seek(AUD_Handle *handle, float seekTo) +int AUD_Handle_setPosition(AUD_Handle *handle, float seekTo) { assert(handle); return (*handle)->seek(seekTo); } -float AUD_getPosition(AUD_Handle *handle) +float AUD_Handle_getPosition(AUD_Handle *handle) { assert(handle); return (*handle)->getPosition(); } -AUD_Status AUD_getStatus(AUD_Handle *handle) +AUD_Status AUD_Handle_getStatus(AUD_Handle *handle) { assert(handle); return (*handle)->getStatus(); } -int AUD_setListenerLocation(const float location[3]) +int AUD_Device_setListenerLocation(const float location[3]) { if (AUD_3ddevice) { AUD_Vector3 v(location[0], location[1], location[2]); @@ -514,7 +536,7 @@ int AUD_setListenerLocation(const float location[3]) return false; } -int AUD_setListenerVelocity(const float velocity[3]) +int AUD_Device_setListenerVelocity(const float velocity[3]) { if (AUD_3ddevice) { AUD_Vector3 v(velocity[0], velocity[1], velocity[2]); @@ -525,7 +547,7 @@ int AUD_setListenerVelocity(const float velocity[3]) return false; } -int AUD_setListenerOrientation(const float orientation[4]) +int AUD_Device_setListenerOrientation(const float orientation[4]) { if (AUD_3ddevice) { AUD_Quaternion q(orientation[3], orientation[0], orientation[1], orientation[2]); @@ -536,7 +558,7 @@ int AUD_setListenerOrientation(const float orientation[4]) return false; } -int AUD_setSpeedOfSound(float speed) +int AUD_Device_setSpeedOfSound(void* device, float speed) { if (AUD_3ddevice) { AUD_3ddevice->setSpeedOfSound(speed); @@ -546,7 +568,7 @@ int AUD_setSpeedOfSound(float speed) return false; } -int AUD_setDopplerFactor(float factor) +int AUD_Device_setDopplerFactor(void* device, float factor) { if (AUD_3ddevice) { AUD_3ddevice->setDopplerFactor(factor); @@ -556,7 +578,7 @@ int AUD_setDopplerFactor(float factor) return false; } -int AUD_setDistanceModel(AUD_DistanceModel model) +int AUD_Device_setDistanceModel(void* device, AUD_DistanceModel model) { if (AUD_3ddevice) { AUD_3ddevice->setDistanceModel(model); @@ -566,7 +588,7 @@ int AUD_setDistanceModel(AUD_DistanceModel model) return false; } -int AUD_setSourceLocation(AUD_Handle *handle, const float location[3]) +int AUD_Handle_setLocation(AUD_Handle *handle, const float location[3]) { assert(handle); boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle); @@ -579,7 +601,7 @@ int AUD_setSourceLocation(AUD_Handle *handle, const float location[3]) return false; } -int AUD_setSourceVelocity(AUD_Handle *handle, const float velocity[3]) +int AUD_Handle_setVelocity(AUD_Handle *handle, const float velocity[3]) { assert(handle); boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle); @@ -592,7 +614,7 @@ int AUD_setSourceVelocity(AUD_Handle *handle, const float velocity[3]) return false; } -int AUD_setSourceOrientation(AUD_Handle *handle, const float orientation[4]) +int AUD_Handle_setOrientation(AUD_Handle *handle, const float orientation[4]) { assert(handle); boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle); @@ -605,7 +627,7 @@ int AUD_setSourceOrientation(AUD_Handle *handle, const float orientation[4]) return false; } -int AUD_setRelative(AUD_Handle *handle, int relative) +int AUD_Handle_setRelative(AUD_Handle *handle, int relative) { assert(handle); boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle); @@ -617,7 +639,7 @@ int AUD_setRelative(AUD_Handle *handle, int relative) return false; } -int AUD_setVolumeMaximum(AUD_Handle *handle, float volume) +int AUD_Handle_setVolumeMaximum(AUD_Handle *handle, float volume) { assert(handle); boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle); @@ -629,7 +651,7 @@ int AUD_setVolumeMaximum(AUD_Handle *handle, float volume) return false; } -int AUD_setVolumeMinimum(AUD_Handle *handle, float volume) +int AUD_Handle_setVolumeMinimum(AUD_Handle *handle, float volume) { assert(handle); boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle); @@ -641,7 +663,7 @@ int AUD_setVolumeMinimum(AUD_Handle *handle, float volume) return false; } -int AUD_setDistanceMaximum(AUD_Handle *handle, float distance) +int AUD_Handle_setDistanceMaximum(AUD_Handle *handle, float distance) { assert(handle); boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle); @@ -653,7 +675,7 @@ int AUD_setDistanceMaximum(AUD_Handle *handle, float distance) return false; } -int AUD_setDistanceReference(AUD_Handle *handle, float distance) +int AUD_Handle_setDistanceReference(AUD_Handle *handle, float distance) { assert(handle); boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle); @@ -665,7 +687,7 @@ int AUD_setDistanceReference(AUD_Handle *handle, float distance) return false; } -int AUD_setAttenuation(AUD_Handle *handle, float factor) +int AUD_Handle_setAttenuation(AUD_Handle *handle, float factor) { assert(handle); boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle); @@ -677,7 +699,7 @@ int AUD_setAttenuation(AUD_Handle *handle, float factor) return false; } -int AUD_setConeAngleOuter(AUD_Handle *handle, float angle) +int AUD_Handle_setConeAngleOuter(AUD_Handle *handle, float angle) { assert(handle); boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle); @@ -689,7 +711,7 @@ int AUD_setConeAngleOuter(AUD_Handle *handle, float angle) return false; } -int AUD_setConeAngleInner(AUD_Handle *handle, float angle) +int AUD_Handle_setConeAngleInner(AUD_Handle *handle, float angle) { assert(handle); boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle); @@ -701,7 +723,7 @@ int AUD_setConeAngleInner(AUD_Handle *handle, float angle) return false; } -int AUD_setConeVolumeOuter(AUD_Handle *handle, float volume) +int AUD_Handle_setConeVolumeOuter(AUD_Handle *handle, float volume) { assert(handle); boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle); @@ -713,7 +735,7 @@ int AUD_setConeVolumeOuter(AUD_Handle *handle, float volume) return false; } -int AUD_setSoundVolume(AUD_Handle *handle, float volume) +int AUD_Handle_setVolume(AUD_Handle *handle, float volume) { assert(handle); try { @@ -723,7 +745,7 @@ int AUD_setSoundVolume(AUD_Handle *handle, float volume) return false; } -int AUD_setSoundPitch(AUD_Handle *handle, float pitch) +int AUD_Handle_setPitch(AUD_Handle *handle, float pitch) { assert(handle); try { @@ -775,13 +797,13 @@ int AUD_setDeviceVolume(AUD_Device *device, float volume) return false; } -int AUD_readDevice(AUD_Device *device, data_t *buffer, int length) +int AUD_Device_read(AUD_Device *device, data_t *buffer, int length) { assert(device); assert(buffer); try { - return (*device)->read(buffer, length); + return boost::dynamic_pointer_cast<AUD_ReadDevice>(*device)->read(buffer, length); } catch(AUD_Exception&) { @@ -789,12 +811,11 @@ int AUD_readDevice(AUD_Device *device, data_t *buffer, int length) } } -void AUD_closeReadDevice(AUD_Device *device) +void AUD_Device_free(AUD_Device *device) { - assert(device); - try { - delete device; + if(device != &AUD_device) + delete device; } catch(AUD_Exception&) { @@ -892,7 +913,7 @@ AUD_Handle *AUD_pauseAfter(AUD_Handle *handle, float seconds) return NULL; } -AUD_Sound *AUD_createSequencer(float fps, int muted) +AUD_Sound *AUD_Sequence_create(float fps, int muted) { // specs are changed at a later point! AUD_Specs specs; @@ -902,22 +923,22 @@ AUD_Sound *AUD_createSequencer(float fps, int muted) return sequencer; } -void AUD_destroySequencer(AUD_Sound *sequencer) +void AUD_Sequence_free(AUD_Sound *sequencer) { delete sequencer; } -void AUD_setSequencerMuted(AUD_Sound *sequencer, int muted) +void AUD_Sequence_setMuted(AUD_Sound *sequencer, int muted) { dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->mute(muted); } -void AUD_setSequencerFPS(AUD_Sound *sequencer, float fps) +void AUD_Sequence_setFPS(AUD_Sound *sequencer, float fps) { dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->setFPS(fps); } -AUD_SEntry *AUD_addSequence(AUD_Sound *sequencer, AUD_Sound *sound, +AUD_SEntry *AUD_Sequence_add(AUD_Sound *sequencer, AUD_Sound *sound, float begin, float end, float skip) { if (!sound) @@ -925,28 +946,23 @@ AUD_SEntry *AUD_addSequence(AUD_Sound *sequencer, AUD_Sound *sound, return new AUD_SEntry(((AUD_SequencerFactory *)sequencer->get())->add(*sound, begin, end, skip)); } -void AUD_removeSequence(AUD_Sound *sequencer, AUD_SEntry *entry) +void AUD_Sequence_remove(AUD_Sound *sequencer, AUD_SEntry *entry) { dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->remove(*entry); delete entry; } -void AUD_moveSequence(AUD_SEntry *entry, float begin, float end, float skip) +void AUD_SequenceEntry_move(AUD_SEntry *entry, float begin, float end, float skip) { (*entry)->move(begin, end, skip); } -void AUD_muteSequence(AUD_SEntry *entry, char mute) +void AUD_SequenceEntry_setMuted(AUD_SEntry *entry, char mute) { (*entry)->mute(mute); } -void AUD_setRelativeSequence(AUD_SEntry *entry, char relative) -{ - (*entry)->setRelative(relative); -} - -void AUD_updateSequenceSound(AUD_SEntry *entry, AUD_Sound *sound) +void AUD_SequenceEntry_setSound(AUD_SEntry *entry, AUD_Sound *sound) { if (sound) (*entry)->setSound(*sound); @@ -954,7 +970,7 @@ void AUD_updateSequenceSound(AUD_SEntry *entry, AUD_Sound *sound) (*entry)->setSound(AUD_Sound()); } -void AUD_setSequenceAnimData(AUD_SEntry *entry, AUD_AnimateablePropertyType type, int frame, float *data, char animated) +void AUD_SequenceEntry_setAnimationData(AUD_SEntry *entry, AUD_AnimateablePropertyType type, int frame, float *data, char animated) { AUD_AnimateableProperty *prop = (*entry)->getAnimProperty(type); if (animated) { @@ -966,7 +982,7 @@ void AUD_setSequenceAnimData(AUD_SEntry *entry, AUD_AnimateablePropertyType type } } -void AUD_setSequencerAnimData(AUD_Sound *sequencer, AUD_AnimateablePropertyType type, int frame, float *data, char animated) +void AUD_Sequence_setAnimationData(AUD_Sound *sequencer, AUD_AnimateablePropertyType type, int frame, float *data, char animated) { AUD_AnimateableProperty *prop = dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->getAnimProperty(type); if (animated) { @@ -979,21 +995,76 @@ void AUD_setSequencerAnimData(AUD_Sound *sequencer, AUD_AnimateablePropertyType } } -void AUD_updateSequenceData(AUD_SEntry *entry, float volume_max, float volume_min, - float distance_max, float distance_reference, float attenuation, - float cone_angle_outer, float cone_angle_inner, float cone_volume_outer) +void AUD_Sequence_setDistanceModel(AUD_Sound* sequence, AUD_DistanceModel value) +{ + assert(sequence); + dynamic_cast<AUD_SequencerFactory *>(sequence->get())->setDistanceModel(static_cast<AUD_DistanceModel>(value)); +} + +void AUD_Sequence_setDopplerFactor(AUD_Sound* sequence, float value) +{ + assert(sequence); + dynamic_cast<AUD_SequencerFactory *>(sequence->get())->setDopplerFactor(value); +} + +void AUD_Sequence_setSpeedOfSound(AUD_Sound* sequence, float value) +{ + assert(sequence); + dynamic_cast<AUD_SequencerFactory *>(sequence->get())->setSpeedOfSound(value); +} + +void AUD_SequenceEntry_setAttenuation(AUD_SEntry* sequence_entry, float value) +{ + assert(sequence_entry); + (*sequence_entry)->setAttenuation(value); +} + +void AUD_SequenceEntry_setConeAngleInner(AUD_SEntry* sequence_entry, float value) +{ + assert(sequence_entry); + (*sequence_entry)->setConeAngleInner(value); +} + +void AUD_SequenceEntry_setConeAngleOuter(AUD_SEntry* sequence_entry, float value) +{ + assert(sequence_entry); + (*sequence_entry)->setConeAngleOuter(value); +} + +void AUD_SequenceEntry_setConeVolumeOuter(AUD_SEntry* sequence_entry, float value) +{ + assert(sequence_entry); + (*sequence_entry)->setConeVolumeOuter(value); +} + +void AUD_SequenceEntry_setDistanceMaximum(AUD_SEntry* sequence_entry, float value) +{ + assert(sequence_entry); + (*sequence_entry)->setDistanceMaximum(value); +} + +void AUD_SequenceEntry_setDistanceReference(AUD_SEntry* sequence_entry, float value) +{ + assert(sequence_entry); + (*sequence_entry)->setDistanceReference(value); +} + +void AUD_SequenceEntry_setRelative(AUD_SEntry* sequence_entry, int value) { - (*entry)->updateAll(volume_max, volume_min, distance_max, distance_reference, attenuation, - cone_angle_outer, cone_angle_inner, cone_volume_outer); + assert(sequence_entry); + (*sequence_entry)->setRelative(value); } -void AUD_updateSequencerData(AUD_Sound *sequencer, float speed_of_sound, - float factor, AUD_DistanceModel model) +void AUD_SequenceEntry_setVolumeMaximum(AUD_SEntry* sequence_entry, float value) { - AUD_SequencerFactory *f = dynamic_cast<AUD_SequencerFactory *>(sequencer->get()); - f->setSpeedOfSound(speed_of_sound); - f->setDopplerFactor(factor); - f->setDistanceModel(model); + assert(sequence_entry); + (*sequence_entry)->setVolumeMaximum(value); +} + +void AUD_SequenceEntry_setVolumeMinimum(AUD_SEntry* sequence_entry, float value) +{ + assert(sequence_entry); + (*sequence_entry)->setVolumeMinimum(value); } void AUD_setSequencerDeviceSpecs(AUD_Sound *sequencer) @@ -1001,12 +1072,12 @@ void AUD_setSequencerDeviceSpecs(AUD_Sound *sequencer) dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->setSpecs(AUD_device->getSpecs().specs); } -void AUD_setSequencerSpecs(AUD_Sound *sequencer, AUD_Specs specs) +void AUD_Sequence_setSpecs(AUD_Sound *sequencer, AUD_Specs 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 AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get()); @@ -1021,7 +1092,7 @@ void AUD_seekSequencer(AUD_Handle *handle, float time) } } -float AUD_getSequencerPosition(AUD_Handle *handle) +float AUD_getSynchronizerPosition(AUD_Handle *handle) { #ifdef WITH_JACK AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get()); @@ -1036,7 +1107,7 @@ float AUD_getSequencerPosition(AUD_Handle *handle) } } -void AUD_startPlayback() +void AUD_playSynchronizer() { #ifdef WITH_JACK AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get()); @@ -1046,7 +1117,7 @@ void AUD_startPlayback() #endif } -void AUD_stopPlayback() +void AUD_stopSynchronizer() { #ifdef WITH_JACK AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get()); @@ -1057,7 +1128,7 @@ void AUD_stopPlayback() } #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()); if (device) { @@ -1066,7 +1137,7 @@ void AUD_setSyncCallback(AUD_syncFunction function, void *data) } #endif -int AUD_doesPlayback() +int AUD_isSynchronizerPlaying() { #ifdef WITH_JACK AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get()); @@ -1077,7 +1148,7 @@ int AUD_doesPlayback() return -1; } -int AUD_readSound(AUD_Sound *sound, sample_t *buffer, int length, int samples_per_second) +int AUD_readSound(AUD_Sound *sound, sample_t *buffer, int length, int samples_per_second, short *interrupt) { AUD_DeviceSpecs specs; sample_t *buf; @@ -1100,6 +1171,9 @@ int AUD_readSound(AUD_Sound *sound, sample_t *buffer, int length, int samples_pe for (int i = 0; i < length; i++) { len = floor(samplejump * (i+1)) - floor(samplejump * i); + if (*interrupt) { + return 0; + } aBuffer.assureSize(len * AUD_SAMPLE_SIZE(specs)); buf = aBuffer.getBuffer(); @@ -1139,54 +1213,16 @@ int AUD_readSound(AUD_Sound *sound, sample_t *buffer, int length, int samples_pe return length; } -AUD_Sound *AUD_copy(AUD_Sound *sound) +AUD_Sound *AUD_Sound_copy(AUD_Sound *sound) { return new boost::shared_ptr<AUD_IFactory>(*sound); } -void AUD_freeHandle(AUD_Handle *handle) +void AUD_Handle_free(AUD_Handle *handle) { delete handle; } -void *AUD_createSet() -{ - return new std::set<void *>(); -} - -void AUD_destroySet(void *set) -{ - delete reinterpret_cast<std::set<void *>*>(set); -} - -char AUD_removeSet(void *set, void *entry) -{ - if (set) - return reinterpret_cast<std::set<void *>*>(set)->erase(entry); - return 0; -} - -void AUD_addSet(void *set, void *entry) -{ - if (entry) - reinterpret_cast<std::set<void *>*>(set)->insert(entry); -} - -void *AUD_getSet(void *set) -{ - if (set) { - std::set<void *>* rset = reinterpret_cast<std::set<void *>*>(set); - if (!rset->empty()) { - std::set<void *>::iterator it = rset->begin(); - void *result = *it; - rset->erase(it); - return result; - } - } - - return NULL; -} - const char *AUD_mixdown(AUD_Sound *sound, unsigned int start, unsigned int length, unsigned int buffersize, const char *filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate) { try { @@ -1271,14 +1307,9 @@ 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() +AUD_Device *AUD_Device_getCurrent(void) { - return AUD_3ddevice; + return &AUD_device; } int AUD_isJackSupported(void) diff --git a/intern/audaspace/intern/AUD_C-API.h b/intern/audaspace/intern/AUD_C-API.h index 64a3d06bd5f..bdbe751b140 100644 --- a/intern/audaspace/intern/AUD_C-API.h +++ b/intern/audaspace/intern/AUD_C-API.h @@ -77,22 +77,26 @@ extern void AUD_exitOnce(void); * \param buffersize The buffersize for the device. * \return Whether the device has been initialized. */ -extern int AUD_init(AUD_DeviceType device, AUD_DeviceSpecs specs, int buffersize); +extern AUD_Device* AUD_init(const char* device, AUD_DeviceSpecs specs, int buffersize, const char* name); /** * Unitinitializes an audio device. */ -extern void AUD_exit(void); +extern void AUD_exit(AUD_Device* device); /** * Locks the playback device. */ -extern void AUD_lock(void); +extern void AUD_Device_lock(AUD_Device* device); /** * Unlocks the device. */ -extern void AUD_unlock(void); +extern void AUD_Device_unlock(AUD_Device* device); + +extern AUD_Channels AUD_Device_getChannels(AUD_Device* device); + +extern AUD_SampleRate AUD_Device_getRate(AUD_Device* device); /** * Returns information about a sound. @@ -106,7 +110,7 @@ extern AUD_SoundInfo AUD_getInfo(AUD_Sound *sound); * \param filename The filename of the sound file. * \return A handle of the sound file. */ -extern AUD_Sound *AUD_load(const char *filename); +extern AUD_Sound *AUD_Sound_file(const char *filename); /** * Loads a sound file. @@ -114,21 +118,21 @@ extern AUD_Sound *AUD_load(const char *filename); * \param size The size of the buffer. * \return A handle of the sound file. */ -extern AUD_Sound *AUD_loadBuffer(unsigned char *buffer, int size); +extern AUD_Sound *AUD_Sound_bufferFile(unsigned char *buffer, int size); /** * Buffers a sound. * \param sound The sound to buffer. * \return A handle of the sound buffer. */ -extern AUD_Sound *AUD_bufferSound(AUD_Sound *sound); +extern AUD_Sound *AUD_Sound_cache(AUD_Sound *sound); /** * Rechannels the sound to be mono. * \param sound The sound to rechannel. * \return The mono sound. */ -extern AUD_Sound *AUD_monoSound(AUD_Sound *sound); +extern AUD_Sound *AUD_Sound_rechannel(AUD_Sound *sound, AUD_Channels channels); /** * Delays a sound. @@ -136,7 +140,7 @@ extern AUD_Sound *AUD_monoSound(AUD_Sound *sound); * \param delay The delay in seconds. * \return A handle of the delayed sound. */ -extern AUD_Sound *AUD_delaySound(AUD_Sound *sound, float delay); +extern AUD_Sound *AUD_Sound_delay(AUD_Sound *sound, float delay); /** * Limits a sound. @@ -145,21 +149,21 @@ extern AUD_Sound *AUD_delaySound(AUD_Sound *sound, float delay); * \param end The stop time in seconds. * \return A handle of the limited sound. */ -extern AUD_Sound *AUD_limitSound(AUD_Sound *sound, float start, float end); +extern AUD_Sound *AUD_Sound_limit(AUD_Sound *sound, float start, float end); /** * Ping pongs a sound. * \param sound The sound to ping pong. * \return A handle of the ping pong sound. */ -extern AUD_Sound *AUD_pingpongSound(AUD_Sound *sound); +extern AUD_Sound *AUD_Sound_pingpong(AUD_Sound *sound); /** * Loops a sound. * \param sound The sound to loop. * \return A handle of the looped sound. */ -extern AUD_Sound *AUD_loopSound(AUD_Sound *sound); +extern AUD_Sound *AUD_Sound_loop(AUD_Sound *sound); /** * Sets a remaining loop count of a looping sound that currently plays. @@ -167,7 +171,7 @@ extern AUD_Sound *AUD_loopSound(AUD_Sound *sound); * \param loops The count of remaining loops, -1 for infinity. * \return Whether the handle is valid. */ -extern int AUD_setLoop(AUD_Handle *handle, int loops); +extern int AUD_Handle_setLoopCount(AUD_Handle *handle, int loops); /** * Rectifies a sound. @@ -180,7 +184,7 @@ extern AUD_Sound *AUD_rectifySound(AUD_Sound *sound); * Unloads a sound of any type. * \param sound The handle of the sound. */ -extern void AUD_unload(AUD_Sound *sound); +extern void AUD_Sound_free(AUD_Sound *sound); /** * Plays back a sound file. @@ -189,28 +193,30 @@ extern void AUD_unload(AUD_Sound *sound); * paused when its end has been reached. * \return A handle to the played back sound. */ -extern AUD_Handle *AUD_play(AUD_Sound *sound, int keep); +extern AUD_Handle *AUD_Device_play(AUD_Device* device, AUD_Sound *sound, int keep); /** * Pauses a played back sound. * \param handle The handle to the sound. * \return Whether the handle has been playing or not. */ -extern int AUD_pause(AUD_Handle *handle); +extern int AUD_Handle_pause(AUD_Handle *handle); /** * Resumes a paused sound. * \param handle The handle to the sound. * \return Whether the handle has been paused or not. */ -extern int AUD_resume(AUD_Handle *handle); +extern int AUD_Handle_resume(AUD_Handle *handle); /** * Stops a playing or paused sound. * \param handle The handle to the sound. * \return Whether the handle has been valid or not. */ -extern int AUD_stop(AUD_Handle *handle); +extern int AUD_Handle_stop(AUD_Handle *handle); + +extern void AUD_Device_stopAll(void* device); /** * Sets the end behaviour of a playing or paused sound. @@ -219,7 +225,7 @@ extern int AUD_stop(AUD_Handle *handle); * paused when its end has been reached. * \return Whether the handle has been valid or not. */ -extern int AUD_setKeep(AUD_Handle *handle, int keep); +extern int AUD_Handle_setKeep(AUD_Handle *handle, int keep); /** * Seeks a playing or paused sound. @@ -227,7 +233,7 @@ extern int AUD_setKeep(AUD_Handle *handle, int keep); * \param seekTo From where the sound file should be played back in seconds. * \return Whether the handle has been valid or not. */ -extern int AUD_seek(AUD_Handle *handle, float seekTo); +extern int AUD_Handle_setPosition(AUD_Handle *handle, float seekTo); /** * Retrieves the playback position of a handle. @@ -235,39 +241,39 @@ extern int AUD_seek(AUD_Handle *handle, float seekTo); * \return The current playback position in seconds or 0.0 if the handle is * invalid. */ -extern float AUD_getPosition(AUD_Handle *handle); +extern float AUD_Handle_getPosition(AUD_Handle *handle); /** * Returns the status of a playing, paused or stopped sound. * \param handle The handle to the sound. * \return The status of the sound behind the handle. */ -extern AUD_Status AUD_getStatus(AUD_Handle *handle); +extern AUD_Status AUD_Handle_getStatus(AUD_Handle *handle); /** * Sets the listener location. * \param location The new location. */ -extern int AUD_setListenerLocation(const float location[3]); +extern int AUD_Device_setListenerLocation(const float location[3]); /** * Sets the listener velocity. * \param velocity The new velocity. */ -extern int AUD_setListenerVelocity(const float velocity[3]); +extern int AUD_Device_setListenerVelocity(const float velocity[3]); /** * Sets the listener orientation. * \param orientation The new orientation as quaternion. */ -extern int AUD_setListenerOrientation(const float orientation[4]); +extern int AUD_Device_setListenerOrientation(const float orientation[4]); /** * Sets the speed of sound. * This value is needed for doppler effect calculation. * \param speed The new speed of sound. */ -extern int AUD_setSpeedOfSound(float speed); +extern int AUD_Device_setSpeedOfSound(void* device, float speed); /** * Sets the doppler factor. @@ -275,13 +281,13 @@ extern int AUD_setSpeedOfSound(float speed); * listener which is used while calculating the doppler effect. * \param factor The new doppler factor. */ -extern int AUD_setDopplerFactor(float factor); +extern int AUD_Device_setDopplerFactor(void* device, float factor); /** * Sets the distance model. * \param model distance model. */ -extern int AUD_setDistanceModel(AUD_DistanceModel model); +extern int AUD_Device_setDistanceModel(void* device, AUD_DistanceModel model); /** * Sets the location of a source. @@ -289,7 +295,7 @@ extern int AUD_setDistanceModel(AUD_DistanceModel model); * \param location The new location. * \return Whether the action succeeded. */ -extern int AUD_setSourceLocation(AUD_Handle *handle, const float location[3]); +extern int AUD_Handle_setLocation(AUD_Handle *handle, const float location[3]); /** * Sets the velocity of a source. @@ -297,7 +303,7 @@ extern int AUD_setSourceLocation(AUD_Handle *handle, const float location[3]); * \param velocity The new velocity. * \return Whether the action succeeded. */ -extern int AUD_setSourceVelocity(AUD_Handle *handle, const float velocity[3]); +extern int AUD_Handle_setVelocity(AUD_Handle *handle, const float velocity[3]); /** * Sets the orientation of a source. @@ -305,7 +311,7 @@ extern int AUD_setSourceVelocity(AUD_Handle *handle, const float velocity[3]); * \param orientation The new orientation as quaternion. * \return Whether the action succeeded. */ -extern int AUD_setSourceOrientation(AUD_Handle *handle, const float orientation[4]); +extern int AUD_Handle_setOrientation(AUD_Handle *handle, const float orientation[4]); /** * Sets whether the source location, velocity and orientation are relative @@ -314,7 +320,7 @@ extern int AUD_setSourceOrientation(AUD_Handle *handle, const float orientation[ * \param relative Whether the source is relative. * \return Whether the action succeeded. */ -extern int AUD_setRelative(AUD_Handle *handle, int relative); +extern int AUD_Handle_setRelative(AUD_Handle *handle, int relative); /** * Sets the maximum volume of a source. @@ -322,7 +328,7 @@ extern int AUD_setRelative(AUD_Handle *handle, int relative); * \param volume The new maximum volume. * \return Whether the action succeeded. */ -extern int AUD_setVolumeMaximum(AUD_Handle *handle, float volume); +extern int AUD_Handle_setVolumeMaximum(AUD_Handle *handle, float volume); /** * Sets the minimum volume of a source. @@ -330,7 +336,7 @@ extern int AUD_setVolumeMaximum(AUD_Handle *handle, float volume); * \param volume The new minimum volume. * \return Whether the action succeeded. */ -extern int AUD_setVolumeMinimum(AUD_Handle *handle, float volume); +extern int AUD_Handle_setVolumeMinimum(AUD_Handle *handle, float volume); /** * Sets the maximum distance of a source. @@ -340,7 +346,7 @@ extern int AUD_setVolumeMinimum(AUD_Handle *handle, float volume); * \param distance The new maximum distance. * \return Whether the action succeeded. */ -extern int AUD_setDistanceMaximum(AUD_Handle *handle, float distance); +extern int AUD_Handle_setDistanceMaximum(AUD_Handle *handle, float distance); /** * Sets the reference distance of a source. @@ -348,7 +354,7 @@ extern int AUD_setDistanceMaximum(AUD_Handle *handle, float distance); * \param distance The new reference distance. * \return Whether the action succeeded. */ -extern int AUD_setDistanceReference(AUD_Handle *handle, float distance); +extern int AUD_Handle_setDistanceReference(AUD_Handle *handle, float distance); /** * Sets the attenuation of a source. @@ -357,7 +363,7 @@ extern int AUD_setDistanceReference(AUD_Handle *handle, float distance); * \param factor The new attenuation. * \return Whether the action succeeded. */ -extern int AUD_setAttenuation(AUD_Handle *handle, float factor); +extern int AUD_Handle_setAttenuation(AUD_Handle *handle, float factor); /** * Sets the outer angle of the cone of a source. @@ -365,7 +371,7 @@ extern int AUD_setAttenuation(AUD_Handle *handle, float factor); * \param angle The new outer angle of the cone. * \return Whether the action succeeded. */ -extern int AUD_setConeAngleOuter(AUD_Handle *handle, float angle); +extern int AUD_Handle_setConeAngleOuter(AUD_Handle *handle, float angle); /** * Sets the inner angle of the cone of a source. @@ -373,7 +379,7 @@ extern int AUD_setConeAngleOuter(AUD_Handle *handle, float angle); * \param angle The new inner angle of the cone. * \return Whether the action succeeded. */ -extern int AUD_setConeAngleInner(AUD_Handle *handle, float angle); +extern int AUD_Handle_setConeAngleInner(AUD_Handle *handle, float angle); /** * Sets the outer volume of the cone of a source. @@ -383,7 +389,7 @@ extern int AUD_setConeAngleInner(AUD_Handle *handle, float angle); * \param volume The new outer volume of the cone. * \return Whether the action succeeded. */ -extern int AUD_setConeVolumeOuter(AUD_Handle *handle, float volume); +extern int AUD_Handle_setConeVolumeOuter(AUD_Handle *handle, float volume); /** * Sets the volume of a played back sound. @@ -391,7 +397,7 @@ extern int AUD_setConeVolumeOuter(AUD_Handle *handle, float volume); * \param volume The new volume, must be between 0.0 and 1.0. * \return Whether the action succeeded. */ -extern int AUD_setSoundVolume(AUD_Handle *handle, float volume); +extern int AUD_Handle_setVolume(AUD_Handle *handle, float volume); /** * Sets the pitch of a played back sound. @@ -399,7 +405,7 @@ extern int AUD_setSoundVolume(AUD_Handle *handle, float volume); * \param pitch The new pitch. * \return Whether the action succeeded. */ -extern int AUD_setSoundPitch(AUD_Handle *handle, float pitch); +extern int AUD_Handle_setPitch(AUD_Handle *handle, float pitch); /** * Opens a read device, with which audio data can be read. @@ -434,13 +440,13 @@ extern AUD_Handle *AUD_playDevice(AUD_Device *device, AUD_Sound *sound, float se * played back currently, in that case the buffer is filled with * silence. */ -extern int AUD_readDevice(AUD_Device *device, data_t *buffer, int length); +extern int AUD_Device_read(AUD_Device *device, data_t *buffer, int length); /** * Closes a read device. * \param device The read device. */ -extern void AUD_closeReadDevice(AUD_Device *device); +extern void AUD_Device_free(AUD_Device *device); /** * Reads a sound file into a newly created float buffer. @@ -466,27 +472,27 @@ extern AUD_Handle *AUD_pauseAfter(AUD_Handle *handle, float seconds); * \param muted Whether the scene is muted. * \return The new sound scene. */ -extern AUD_Sound *AUD_createSequencer(float fps, int muted); +extern AUD_Sound *AUD_Sequence_create(float fps, int muted); /** * Deletes a sound scene. * \param sequencer The sound scene. */ -extern void AUD_destroySequencer(AUD_Sound *sequencer); +extern void AUD_Sequence_free(AUD_Sound *sequencer); /** * Sets the muting state of the scene. * \param sequencer The sound scene. * \param muted Whether the scene is muted. */ -extern void AUD_setSequencerMuted(AUD_Sound *sequencer, int muted); +extern void AUD_Sequence_setMuted(AUD_Sound *sequencer, int muted); /** * Sets the scene's FPS. * \param sequencer The sound scene. * \param fps The new FPS. */ -extern void AUD_setSequencerFPS(AUD_Sound *sequencer, float fps); +extern void AUD_Sequence_setFPS(AUD_Sound *sequencer, float fps); /** * Adds a new entry to the scene. @@ -497,7 +503,7 @@ extern void AUD_setSequencerFPS(AUD_Sound *sequencer, float fps); * \param skip How much seconds should be skipped at the beginning. * \return The entry added. */ -extern AUD_SEntry *AUD_addSequence(AUD_Sound *sequencer, AUD_Sound *sound, +extern AUD_SEntry *AUD_Sequence_add(AUD_Sound *sequencer, AUD_Sound *sound, float begin, float end, float skip); /** @@ -505,7 +511,7 @@ extern AUD_SEntry *AUD_addSequence(AUD_Sound *sequencer, AUD_Sound *sound, * \param sequencer The sound scene. * \param entry The entry to remove. */ -extern void AUD_removeSequence(AUD_Sound *sequencer, AUD_SEntry *entry); +extern void AUD_Sequence_remove(AUD_Sound *sequencer, AUD_SEntry *entry); /** * Moves the entry. @@ -514,30 +520,21 @@ extern void AUD_removeSequence(AUD_Sound *sequencer, AUD_SEntry *entry); * \param end The new end time or a negative value if unknown. * \param skip How many seconds to skip at the beginning. */ -extern void AUD_moveSequence(AUD_SEntry *entry, float begin, float end, float skip); +extern void AUD_SequenceEntry_move(AUD_SEntry *entry, float begin, float end, float skip); /** * Sets the muting state of the entry. * \param entry The sequenced entry. * \param mute Whether the entry should be muted or not. */ -extern void AUD_muteSequence(AUD_SEntry *entry, char mute); - -/** - * Sets whether the entrie's location, velocity and orientation are relative - * to the listener. - * \param entry The sequenced entry. - * \param relative Whether the source is relative. - * \return Whether the action succeeded. - */ -extern void AUD_setRelativeSequence(AUD_SEntry *entry, char relative); +extern void AUD_SequenceEntry_setMuted(AUD_SEntry *entry, char mute); /** * Sets the sound of the entry. * \param entry The sequenced entry. * \param sound The new sound. */ -extern void AUD_updateSequenceSound(AUD_SEntry *entry, AUD_Sound *sound); +extern void AUD_SequenceEntry_setSound(AUD_SEntry *entry, AUD_Sound *sound); /** * Writes animation data to a sequenced entry. @@ -547,7 +544,7 @@ extern void AUD_updateSequenceSound(AUD_SEntry *entry, AUD_Sound *sound); * \param data The data to write. * \param animated Whether the attribute is animated. */ -extern void AUD_setSequenceAnimData(AUD_SEntry *entry, AUD_AnimateablePropertyType type, int frame, float *data, char animated); +extern void AUD_SequenceEntry_setAnimationData(AUD_SEntry *entry, AUD_AnimateablePropertyType type, int frame, float *data, char animated); /** * Writes animation data to a sequenced entry. @@ -557,33 +554,90 @@ extern void AUD_setSequenceAnimData(AUD_SEntry *entry, AUD_AnimateablePropertyTy * \param data The data to write. * \param animated Whether the attribute is animated. */ -extern void AUD_setSequencerAnimData(AUD_Sound *sequencer, AUD_AnimateablePropertyType type, int frame, float *data, char animated); +extern void AUD_Sequence_setAnimationData(AUD_Sound *sequencer, AUD_AnimateablePropertyType type, int frame, float *data, char animated); /** - * Updates all non-animated parameters of the entry. - * \param entry The sequenced entry. - * \param volume_max The maximum volume. - * \param volume_min The minimum volume. - * \param distance_max The maximum distance. - * \param distance_reference The reference distance. - * \param attenuation The attenuation. - * \param cone_angle_outer The outer cone opening angle. - * \param cone_angle_inner The inner cone opening angle. - * \param cone_volume_outer The volume outside the outer cone. + * Sets the distance model of a sequence. + * param sequence The sequence to set the distance model from. + * param value The new distance model to set. */ -extern void AUD_updateSequenceData(AUD_SEntry *entry, float volume_max, float volume_min, - float distance_max, float distance_reference, float attenuation, - float cone_angle_outer, float cone_angle_inner, float cone_volume_outer); +extern void AUD_Sequence_setDistanceModel(AUD_Sound* sequence, AUD_DistanceModel value); /** - * Updates all non-animated parameters of the entry. - * \param sequencer The sound scene. - * \param speed_of_sound The speed of sound for doppler calculation. - * \param factor The doppler factor to control the effect's strength. - * \param model The distance model for distance calculation. + * Sets the doppler factor of a sequence. + * param sequence The sequence to set the doppler factor from. + * param value The new doppler factor to set. */ -extern void AUD_updateSequencerData(AUD_Sound *sequencer, float speed_of_sound, - float factor, AUD_DistanceModel model); +extern void AUD_Sequence_setDopplerFactor(AUD_Sound* sequence, float value); + +/** + * Sets the speed of sound of a sequence. + * param sequence The sequence to set the speed of sound from. + * param value The new speed of sound to set. + */ +extern void AUD_Sequence_setSpeedOfSound(AUD_Sound* sequence, float value); +/** + * Sets the attenuation of a sequence_entry. + * param sequence_entry The sequence_entry to set the attenuation from. + * param value The new attenuation to set. + */ +extern void AUD_SequenceEntry_setAttenuation(AUD_SEntry* sequence_entry, float value); + +/** + * Sets the cone angle inner of a sequence_entry. + * param sequence_entry The sequence_entry to set the cone angle inner from. + * param value The new cone angle inner to set. + */ +extern void AUD_SequenceEntry_setConeAngleInner(AUD_SEntry* sequence_entry, float value); + +/** + * Sets the cone angle outer of a sequence_entry. + * param sequence_entry The sequence_entry to set the cone angle outer from. + * param value The new cone angle outer to set. + */ +extern void AUD_SequenceEntry_setConeAngleOuter(AUD_SEntry* sequence_entry, float value); + +/** + * Sets the cone volume outer of a sequence_entry. + * param sequence_entry The sequence_entry to set the cone volume outer from. + * param value The new cone volume outer to set. + */ +extern void AUD_SequenceEntry_setConeVolumeOuter(AUD_SEntry* sequence_entry, float value); + +/** + * Sets the distance maximum of a sequence_entry. + * param sequence_entry The sequence_entry to set the distance maximum from. + * param value The new distance maximum to set. + */ +extern void AUD_SequenceEntry_setDistanceMaximum(AUD_SEntry* sequence_entry, float value); + +/** + * Sets the distance reference of a sequence_entry. + * param sequence_entry The sequence_entry to set the distance reference from. + * param value The new distance reference to set. + */ +extern void AUD_SequenceEntry_setDistanceReference(AUD_SEntry* sequence_entry, float value); + +/** + * Sets the relative of a sequence_entry. + * param sequence_entry The sequence_entry to set the relative from. + * param value The new relative to set. + */ +extern void AUD_SequenceEntry_setRelative(AUD_SEntry* sequence_entry, int value); + +/** + * Sets the volume maximum of a sequence_entry. + * param sequence_entry The sequence_entry to set the volume maximum from. + * param value The new volume maximum to set. + */ +extern void AUD_SequenceEntry_setVolumeMaximum(AUD_SEntry* sequence_entry, float value); + +/** + * Sets the volume minimum of a sequence_entry. + * param sequence_entry The sequence_entry to set the volume minimum from. + * param value The new volume minimum to set. + */ +extern void AUD_SequenceEntry_setVolumeMinimum(AUD_SEntry* sequence_entry, float value); /** * Sets the audio output specification of the sound scene to the specs of the @@ -597,31 +651,31 @@ extern void AUD_setSequencerDeviceSpecs(AUD_Sound *sequencer); * \param sequencer The sound scene. * \param specs The new specification. */ -extern void AUD_setSequencerSpecs(AUD_Sound *sequencer, AUD_Specs specs); +extern void AUD_Sequence_setSpecs(AUD_Sound *sequencer, AUD_Specs specs); /** * Seeks sequenced sound scene playback. * \param handle Playback handle. * \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. * \param handle Playback handle. * \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. */ -extern void AUD_startPlayback(void); +extern void AUD_playSynchronizer(void); /** * Stops the playback of jack transport if possible. */ -extern void AUD_stopPlayback(void); +extern void AUD_stopSynchronizer(void); #ifdef WITH_JACK /** @@ -629,14 +683,14 @@ extern void AUD_stopPlayback(void); * \param function The callback function. * \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 /** * Returns 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. @@ -646,20 +700,20 @@ extern int AUD_doesPlayback(void); * \param samples_per_second How many samples to read per second of the sound. * \return How many samples really have been read. Always <= length. */ -extern int AUD_readSound(AUD_Sound *sound, sample_t *buffer, int length, int samples_per_second); +extern int AUD_readSound(AUD_Sound *sound, sample_t *buffer, int length, int samples_per_second, short *interrupt); /** * Copies a sound. * \param sound Sound to copy. * \return Copied sound. */ -extern AUD_Sound *AUD_copy(AUD_Sound *sound); +extern AUD_Sound *AUD_Sound_copy(AUD_Sound *sound); /** * Frees a handle. * \param channel Handle to free. */ -extern void AUD_freeHandle(AUD_Handle *channel); +extern void AUD_Handle_free(AUD_Handle *channel); /** * Creates a new set. @@ -747,36 +801,22 @@ extern AUD_Device *AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound *seque * \param sound The sound 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. * \param sound The python factory. * \return The sound factory. */ -extern AUD_Sound *AUD_getPythonSound(void *sound); +extern AUD_Sound *AUD_getSoundFromPython(void *sound); #endif +extern AUD_Device *AUD_Device_getCurrent(void); + extern int AUD_isJackSupported(void); #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 //__AUD_C_API_H__ diff --git a/intern/audaspace/intern/AUD_ConverterFunctions.h b/intern/audaspace/intern/AUD_ConverterFunctions.h index 7817ee88c07..eca2b327b8c 100644 --- a/intern/audaspace/intern/AUD_ConverterFunctions.h +++ b/intern/audaspace/intern/AUD_ConverterFunctions.h @@ -33,16 +33,7 @@ #include "AUD_Space.h" #include <cstring> -#ifdef _MSC_VER -#if (_MSC_VER <= 1500) - typedef short int16_t; - typedef int int32_t; -#else -# include <stdint.h> -#endif -#else #include <stdint.h> -#endif typedef void (*AUD_convert_f)(data_t* target, data_t* source, int length); diff --git a/intern/audaspace/intern/AUD_PyInit.cpp b/intern/audaspace/intern/AUD_PyInit.cpp new file mode 100644 index 00000000000..4e27c31b838 --- /dev/null +++ b/intern/audaspace/intern/AUD_PyInit.cpp @@ -0,0 +1,78 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * Copyright 2009-2011 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * Audaspace is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * AudaSpace is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Audaspace; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file audaspace/intern/AUD_PyInit.cpp + * \ingroup audaspaceintern + */ + +#include "AUD_PyInit.h" + +#include <AUD_Sound.h> +#include <python/PySound.h> +#include <python/PyAPI.h> + +extern "C" { +extern void *BKE_sound_get_factory(void *sound); +} + +static PyObject *AUD_getSoundFromPointer(PyObject *self, PyObject *args) +{ + long int lptr; + + if (PyArg_Parse(args, "l:_sound_from_pointer", &lptr)) { + if (lptr) { + AUD_Sound* sound = BKE_sound_get_factory((void *) lptr); + + if (sound) { + Sound *obj = (Sound *)Sound_empty(); + if (obj) { + obj->sound = AUD_Sound_copy(sound); + return (PyObject *) obj; + } + } + } + } + + Py_RETURN_NONE; +} + +static PyMethodDef meth_sound_from_pointer[] = { + {"_sound_from_pointer", (PyCFunction)AUD_getSoundFromPointer, METH_O, + "_sound_from_pointer(pointer)\n\n" + "Returns the corresponding :class:`Factory` object.\n\n" + ":arg pointer: The pointer to the bSound object as long.\n" + ":type pointer: long\n" + ":return: The corresponding :class:`Factory` object.\n" + ":rtype: :class:`Factory`"} +}; + +PyObject *AUD_initPython(void) +{ + PyObject *module = PyInit_aud(); + PyModule_AddObject(module, "_sound_from_pointer", (PyObject *)PyCFunction_New(meth_sound_from_pointer, NULL)); + PyDict_SetItemString(PyImport_GetModuleDict(), "aud", module); + + return module; +} + diff --git a/intern/audaspace/intern/AUD_Sequencer.cpp b/intern/audaspace/intern/AUD_Sequencer.cpp index 6c5e48c73f0..ddcf97e2ea1 100644 --- a/intern/audaspace/intern/AUD_Sequencer.cpp +++ b/intern/audaspace/intern/AUD_Sequencer.cpp @@ -39,7 +39,7 @@ AUD_Sequencer::AUD_Sequencer(AUD_Specs specs, float fps, bool muted) : m_id(0), m_muted(muted), m_fps(fps), - m_speed_of_sound(434), + m_speed_of_sound(343.3f), m_doppler_factor(1), m_distance_model(AUD_DISTANCE_MODEL_INVERSE_CLAMPED), m_volume(1, 1.0f), diff --git a/intern/audaspace/intern/AUD_SequencerHandle.cpp b/intern/audaspace/intern/AUD_SequencerHandle.cpp index 135c960471c..aa742f7b8db 100644 --- a/intern/audaspace/intern/AUD_SequencerHandle.cpp +++ b/intern/audaspace/intern/AUD_SequencerHandle.cpp @@ -31,18 +31,99 @@ #include "AUD_ReadDevice.h" #include "AUD_MutexLock.h" +#define KEEP_TIME 10 + +void AUD_SequencerHandle::start() +{ + // we already tried to start, aborting + if(!m_valid) + return; + + // in case the sound is playing, we need to stop first + stop(); + + AUD_MutexLock lock(*m_entry); + + // let's try playing + if(m_entry->m_sound.get()) + { + try + { + m_handle = m_device.play(m_entry->m_sound, true); + m_3dhandle = boost::dynamic_pointer_cast<AUD_I3DHandle>(m_handle); + } + catch(AUD_Exception&) + { + // handle stays invalid in case we get an exception + } + + // after starting we have to set the properties, so let's ensure that + m_status--; + } + + // if the sound could not be played, we invalidate + m_valid = m_handle.get(); +} + +bool AUD_SequencerHandle::updatePosition(float position) +{ + AUD_MutexLock lock(*m_entry); + + if(m_handle.get()) + { + // we currently have a handle, let's check where we are + if(position >= m_entry->m_end) + { + if(position >= m_entry->m_end + KEEP_TIME) + // far end, stopping + stop(); + else + { + // close end, just pausing + m_handle->pause(); + return true; + } + } + else if(position >= m_entry->m_begin) + { + // inside, resuming + m_handle->resume(); + return true; + } + else + { + if(position < m_entry->m_begin - KEEP_TIME) + // far beginning, stopping + stop(); + else + { + // close beginning, just pausing + m_handle->pause(); + return true; + } + } + } + else + { + // we don't have a handle, let's start if we should be playing + if(position >= m_entry->m_begin && position <= m_entry->m_end) + { + start(); + return m_valid; + } + } + + return false; +} + AUD_SequencerHandle::AUD_SequencerHandle(boost::shared_ptr<AUD_SequencerEntry> entry, AUD_ReadDevice& device) : m_entry(entry), + m_valid(true), m_status(0), m_pos_status(0), m_sound_status(0), m_device(device) { - if(entry->m_sound.get()) - { - m_handle = device.play(entry->m_sound, true); - m_3dhandle = boost::dynamic_pointer_cast<AUD_I3DHandle>(m_handle); - } } AUD_SequencerHandle::~AUD_SequencerHandle() @@ -63,101 +144,116 @@ void AUD_SequencerHandle::stop() { if(m_handle.get()) m_handle->stop(); + m_handle = boost::shared_ptr<AUD_IHandle>(); + m_3dhandle = boost::shared_ptr<AUD_I3DHandle>(); } void AUD_SequencerHandle::update(float position, float frame, float fps) { - if(m_handle.get()) + if(m_sound_status != m_entry->m_sound_status) { - AUD_MutexLock lock(*m_entry); - if(position >= m_entry->m_end) - m_handle->pause(); - else if(position >= m_entry->m_begin) - m_handle->resume(); + // if a new sound has been set, it's possible to get valid again! + m_sound_status = m_entry->m_sound_status; + m_valid = true; - if(m_sound_status != m_entry->m_sound_status) - { - if(m_handle.get()) - m_handle->stop(); - - if(m_entry->m_sound.get()) - { - m_handle = m_device.play(m_entry->m_sound, true); - m_3dhandle = boost::dynamic_pointer_cast<AUD_I3DHandle>(m_handle); - } + // stop whatever sound has been playing + stop(); - m_sound_status = m_entry->m_sound_status; - m_pos_status--; - m_status--; - } + // seek starts and seeks to the correct position + if(!seek(position)) + // no handle, aborting + return; + } + else + { + if(!m_valid) + // invalid, aborting + return; - if(m_pos_status != m_entry->m_pos_status) + if(m_handle.get()) { - seek(position); - - m_pos_status = m_entry->m_pos_status; + // we have a handle, let's update the position + if(!updatePosition(position)) + // lost handle, aborting + return; } - - if(m_status != m_entry->m_status) + else { - m_3dhandle->setRelative(m_entry->m_relative); - m_3dhandle->setVolumeMaximum(m_entry->m_volume_max); - m_3dhandle->setVolumeMinimum(m_entry->m_volume_min); - m_3dhandle->setDistanceMaximum(m_entry->m_distance_max); - m_3dhandle->setDistanceReference(m_entry->m_distance_reference); - m_3dhandle->setAttenuation(m_entry->m_attenuation); - m_3dhandle->setConeAngleOuter(m_entry->m_cone_angle_outer); - m_3dhandle->setConeAngleInner(m_entry->m_cone_angle_inner); - m_3dhandle->setConeVolumeOuter(m_entry->m_cone_volume_outer); - - m_status = m_entry->m_status; + // we don't have a handle, let's see if we can start + if(!seek(position)) + return; } + } - float value; + AUD_MutexLock lock(*m_entry); + if(m_pos_status != m_entry->m_pos_status) + { + m_pos_status = m_entry->m_pos_status; - m_entry->m_volume.read(frame, &value); - m_handle->setVolume(value); - m_entry->m_pitch.read(frame, &value); - m_handle->setPitch(value); - m_entry->m_panning.read(frame, &value); - AUD_SoftwareDevice::setPanning(m_handle.get(), value); + // position changed, need to seek + if(!seek(position)) + // lost handle, aborting + return; + } - AUD_Vector3 v, v2; - AUD_Quaternion q; + // so far everything alright and handle is there, let's keep going - m_entry->m_orientation.read(frame, q.get()); - m_3dhandle->setSourceOrientation(q); - m_entry->m_location.read(frame, v.get()); - m_3dhandle->setSourceLocation(v); - m_entry->m_location.read(frame + 1, v2.get()); - v2 -= v; - m_3dhandle->setSourceVelocity(v2 * fps); + if(m_status != m_entry->m_status) + { + m_status = m_entry->m_status; - if(m_entry->m_muted) - m_handle->setVolume(0); + m_3dhandle->setRelative(m_entry->m_relative); + m_3dhandle->setVolumeMaximum(m_entry->m_volume_max); + m_3dhandle->setVolumeMinimum(m_entry->m_volume_min); + m_3dhandle->setDistanceMaximum(m_entry->m_distance_max); + m_3dhandle->setDistanceReference(m_entry->m_distance_reference); + m_3dhandle->setAttenuation(m_entry->m_attenuation); + m_3dhandle->setConeAngleOuter(m_entry->m_cone_angle_outer); + m_3dhandle->setConeAngleInner(m_entry->m_cone_angle_inner); + m_3dhandle->setConeVolumeOuter(m_entry->m_cone_volume_outer); } + + float value; + + m_entry->m_volume.read(frame, &value); + m_handle->setVolume(value); + m_entry->m_pitch.read(frame, &value); + m_handle->setPitch(value); + m_entry->m_panning.read(frame, &value); + AUD_SoftwareDevice::setPanning(m_handle.get(), value); + + AUD_Vector3 v, v2; + AUD_Quaternion q; + + m_entry->m_orientation.read(frame, q.get()); + m_3dhandle->setSourceOrientation(q); + m_entry->m_location.read(frame, v.get()); + m_3dhandle->setSourceLocation(v); + m_entry->m_location.read(frame + 1, v2.get()); + v2 -= v; + m_3dhandle->setSourceVelocity(v2 * fps); + + if(m_entry->m_muted) + m_handle->setVolume(0); } -void AUD_SequencerHandle::seek(float position) +bool AUD_SequencerHandle::seek(float position) { - if(m_handle.get()) - { - AUD_MutexLock lock(*m_entry); - if(position >= m_entry->m_end) - { - m_handle->pause(); - return; - } + if(!m_valid) + // sound not valid, aborting + return false; - float seekpos = position - m_entry->m_begin; - if(seekpos < 0) - seekpos = 0; - seekpos += m_entry->m_skip; - m_handle->setPitch(1.0f); - m_handle->seek(seekpos); - if(position < m_entry->m_begin) - m_handle->pause(); - else - m_handle->resume(); - } + if(!updatePosition(position)) + // no handle, aborting + return false; + + AUD_MutexLock lock(*m_entry); + float seekpos = position - m_entry->m_begin; + if(seekpos < 0) + seekpos = 0; + seekpos += m_entry->m_skip; + m_handle->setPitch(1.0f); + m_handle->seek(seekpos); + + return true; } diff --git a/intern/audaspace/intern/AUD_SequencerHandle.h b/intern/audaspace/intern/AUD_SequencerHandle.h index 881bbdd43dc..306df4a84b9 100644 --- a/intern/audaspace/intern/AUD_SequencerHandle.h +++ b/intern/audaspace/intern/AUD_SequencerHandle.h @@ -51,6 +51,9 @@ private: /// The 3D handle in the read device. boost::shared_ptr<AUD_I3DHandle> m_3dhandle; + /// Whether the sound is playable. + bool m_valid; + /// The last read status from the entry. int m_status; @@ -63,6 +66,18 @@ private: /// The read device this handle is played on. AUD_ReadDevice& m_device; + /** + * Starts playing back the handle. + */ + void start(); + + /** + * Updates the handle state depending on position. + * \param position Current playback position in seconds. + * \return Whether the handle is valid. + */ + bool updatePosition(float position); + public: /** * Creates a new sequenced handle. @@ -99,8 +114,9 @@ public: /** * Seeks the handle to a specific time position. * \param position The time to seek to. + * \return Whether the handle is valid. */ - void seek(float position); + bool seek(float position); }; #endif //__AUD_SEQUENCERHANDLE_H__ diff --git a/intern/audaspace/intern/AUD_Set.cpp b/intern/audaspace/intern/AUD_Set.cpp new file mode 100644 index 00000000000..eb04e37f666 --- /dev/null +++ b/intern/audaspace/intern/AUD_Set.cpp @@ -0,0 +1,69 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * Copyright 2009-2011 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * Audaspace is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * AudaSpace is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Audaspace; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file audaspace/intern/AUD_Set.cpp + * \ingroup audaspaceintern + */ + +#include <set> + +#include "AUD_Set.h" + +void *AUD_createSet() +{ + return new std::set<void *>(); +} + +void AUD_destroySet(void *set) +{ + delete reinterpret_cast<std::set<void *>*>(set); +} + +char AUD_removeSet(void *set, void *entry) +{ + if (set) + return reinterpret_cast<std::set<void *>*>(set)->erase(entry); + return 0; +} + +void AUD_addSet(void *set, void *entry) +{ + if (entry) + reinterpret_cast<std::set<void *>*>(set)->insert(entry); +} + +void *AUD_getSet(void *set) +{ + if (set) { + std::set<void *>* rset = reinterpret_cast<std::set<void *>*>(set); + if (!rset->empty()) { + std::set<void *>::iterator it = rset->begin(); + void *result = *it; + rset->erase(it); + return result; + } + } + + return (void*) 0; +} diff --git a/intern/audaspace/intern/AUD_Set.h b/intern/audaspace/intern/AUD_Set.h new file mode 100644 index 00000000000..ca1419293b0 --- /dev/null +++ b/intern/audaspace/intern/AUD_Set.h @@ -0,0 +1,74 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * Copyright 2009-2011 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * Audaspace is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * AudaSpace is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Audaspace; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file AUD_Set.h + * \ingroup audaspace + */ + +#ifndef __AUD_SET_H__ +#define __AUD_SET_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Creates a new set. + * \return The new set. + */ +extern void *AUD_createSet(void); + +/** + * Deletes a set. + * \param set The set to delete. + */ +extern void AUD_destroySet(void *set); + +/** + * Removes an entry from a set. + * \param set The set work on. + * \param entry The entry to remove. + * \return Whether the entry was in the set or not. + */ +extern char AUD_removeSet(void *set, void *entry); + +/** + * Adds a new entry to a set. + * \param set The set work on. + * \param entry The entry to add. + */ +extern void AUD_addSet(void *set, void *entry); + +/** + * Removes one entry from a set and returns it. + * \param set The set work on. + * \return The entry or NULL if the set is empty. + */ +extern void *AUD_getSet(void *set); + +#ifdef __cplusplus +} +#endif + +#endif //__AUD_SET_H__ diff --git a/intern/audaspace/intern/AUD_SoftwareDevice.cpp b/intern/audaspace/intern/AUD_SoftwareDevice.cpp index 6ffa5e1fcae..c4277a6d02e 100644 --- a/intern/audaspace/intern/AUD_SoftwareDevice.cpp +++ b/intern/audaspace/intern/AUD_SoftwareDevice.cpp @@ -705,7 +705,7 @@ void AUD_SoftwareDevice::create() m_playback = false; m_volume = 1.0f; m_mixer = boost::shared_ptr<AUD_Mixer>(new AUD_Mixer(m_specs)); - m_speed_of_sound = 343.0f; + m_speed_of_sound = 343.3f; m_doppler_factor = 1.0f; m_distance_model = AUD_DISTANCE_MODEL_INVERSE_CLAMPED; m_flags = 0; |