style cleanup

This commit is contained in:
Campbell Barton
2012-09-14 23:11:47 +00:00
parent a77d048f66
commit a425790065
5 changed files with 371 additions and 405 deletions

View File

@@ -99,11 +99,11 @@ typedef AUD_Reference<AUD_SequencerEntry> AUD_SEntry;
#include "AUD_C-API.h"
#ifndef NULL
#define NULL 0
# define NULL (void *)0
#endif
static AUD_Reference<AUD_IDevice> AUD_device;
static AUD_I3DDevice* AUD_3ddevice;
static AUD_I3DDevice *AUD_3ddevice;
void AUD_initOnce()
{
@@ -116,13 +116,12 @@ int AUD_init(AUD_DeviceType device, AUD_DeviceSpecs specs, int buffersize)
{
AUD_Reference<AUD_IDevice> dev;
if(!AUD_device.isNull())
if (!AUD_device.isNull()) {
AUD_exit();
}
try
{
switch(device)
{
try {
switch(device) {
case AUD_NULL_DEVICE:
dev = new AUD_NULLDevice();
break;
@@ -140,8 +139,7 @@ int AUD_init(AUD_DeviceType device, AUD_DeviceSpecs specs, int buffersize)
case AUD_JACK_DEVICE:
#ifdef __APPLE__
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");
// No break, fall through to default, to return false
}
@@ -159,7 +157,7 @@ int AUD_init(AUD_DeviceType device, AUD_DeviceSpecs specs, int buffersize)
}
AUD_device = dev;
AUD_3ddevice = dynamic_cast<AUD_I3DDevice*>(AUD_device.get());
AUD_3ddevice = dynamic_cast<AUD_I3DDevice *>(AUD_device.get());
return true;
}
@@ -176,48 +174,44 @@ void AUD_exit()
}
#ifdef WITH_PYTHON
static PyObject* AUD_getCDevice(PyObject* self)
static PyObject *AUD_getCDevice(PyObject *self)
{
if(!AUD_device.isNull())
{
Device* device = (Device*)Device_empty();
if(device != NULL)
{
if (!AUD_device.isNull()) {
Device *device = (Device *)Device_empty();
if (device != NULL) {
device->device = new AUD_Reference<AUD_IDevice>(AUD_device);
return (PyObject*)device;
return (PyObject *)device;
}
}
Py_RETURN_NONE;
}
static PyMethodDef meth_getcdevice[] = {{ "device", (PyCFunction)AUD_getCDevice, METH_NOARGS,
"device()\n\n"
"Returns the application's :class:`Device`.\n\n"
":return: The application's :class:`Device`.\n"
":rtype: :class:`Device`"}};
static PyMethodDef meth_getcdevice[] = {
{"device", (PyCFunction)AUD_getCDevice, METH_NOARGS,
"device()\n\n"
"Returns the application's :class:`Device`.\n\n"
":return: The application's :class:`Device`.\n"
":rtype: :class:`Device`"}
};
extern "C" {
extern void* sound_get_factory(void* sound);
extern void *sound_get_factory(void *sound);
}
static PyObject* AUD_getSoundFromPointer(PyObject* self, PyObject* args)
static PyObject *AUD_getSoundFromPointer(PyObject *self, PyObject *args)
{
long int lptr;
if(PyArg_Parse(args, "l:_sound_from_pointer", &lptr))
{
if(lptr)
{
AUD_Reference<AUD_IFactory>* factory = (AUD_Reference<AUD_IFactory>*) sound_get_factory((void*) lptr);
if (PyArg_Parse(args, "l:_sound_from_pointer", &lptr)) {
if (lptr) {
AUD_Reference<AUD_IFactory>* factory = (AUD_Reference<AUD_IFactory>*) sound_get_factory((void *) lptr);
if(factory)
{
Factory* obj = (Factory*) Factory_empty();
if(obj)
{
if (factory) {
Factory *obj = (Factory *)Factory_empty();
if (obj) {
obj->factory = new AUD_Reference<AUD_IFactory>(*factory);
return (PyObject*) obj;
return (PyObject *) obj;
}
}
}
@@ -226,44 +220,44 @@ static PyObject* AUD_getSoundFromPointer(PyObject* self, PyObject* args)
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`"}};
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()
PyObject *AUD_initPython()
{
PyObject* module = PyInit_aud();
PyModule_AddObject(module, "device", (PyObject*)PyCFunction_New(meth_getcdevice, NULL));
PyModule_AddObject(module, "_sound_from_pointer", (PyObject*)PyCFunction_New(meth_sound_from_pointer, NULL));
PyObject *module = PyInit_aud();
PyModule_AddObject(module, "device", (PyObject *)PyCFunction_New(meth_getcdevice, NULL));
PyModule_AddObject(module, "_sound_from_pointer", (PyObject *)PyCFunction_New(meth_sound_from_pointer, NULL));
PyDict_SetItemString(PyImport_GetModuleDict(), "aud", module);
return module;
}
void* AUD_getPythonFactory(AUD_Sound* sound)
void *AUD_getPythonFactory(AUD_Sound *sound)
{
if(sound)
{
Factory* obj = (Factory*) Factory_empty();
if(obj)
{
if (sound) {
Factory *obj = (Factory *) Factory_empty();
if (obj) {
obj->factory = new AUD_Reference<AUD_IFactory>(*sound);
return (PyObject*) obj;
return (PyObject *) obj;
}
}
return NULL;
}
AUD_Sound* AUD_getPythonSound(void* sound)
AUD_Sound *AUD_getPythonSound(void *sound)
{
Factory* factory = checkFactory((PyObject *)sound);
Factory *factory = checkFactory((PyObject *)sound);
if(!factory)
if (!factory)
return NULL;
return new AUD_Reference<AUD_IFactory>(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(factory->factory));
@@ -281,7 +275,7 @@ void AUD_unlock()
AUD_device->unlock();
}
AUD_SoundInfo AUD_getInfo(AUD_Sound* sound)
AUD_SoundInfo AUD_getInfo(AUD_Sound *sound)
{
assert(sound);
@@ -290,12 +284,10 @@ AUD_SoundInfo AUD_getInfo(AUD_Sound* sound)
info.specs.rate = AUD_RATE_INVALID;
info.length = 0.0f;
try
{
try {
AUD_Reference<AUD_IReader> reader = (*sound)->createReader();
if(!reader.isNull())
{
if (!reader.isNull()) {
info.specs = reader->getSpecs();
info.length = reader->getLength() / (float) info.specs.rate;
}
@@ -307,24 +299,23 @@ AUD_SoundInfo AUD_getInfo(AUD_Sound* sound)
return info;
}
AUD_Sound* AUD_load(const char* filename)
AUD_Sound *AUD_load(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_loadBuffer(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_bufferSound(AUD_Sound *sound)
{
assert(sound);
try
{
try {
return new AUD_Sound(new AUD_StreamBufferFactory(*sound));
}
catch(AUD_Exception&)
@@ -333,12 +324,11 @@ AUD_Sound* AUD_bufferSound(AUD_Sound* sound)
}
}
AUD_Sound* AUD_monoSound(AUD_Sound* sound)
AUD_Sound *AUD_monoSound(AUD_Sound *sound)
{
assert(sound);
try
{
try {
AUD_DeviceSpecs specs;
specs.channels = AUD_CHANNELS_MONO;
specs.rate = AUD_RATE_INVALID;
@@ -351,12 +341,11 @@ AUD_Sound* AUD_monoSound(AUD_Sound* sound)
}
}
AUD_Sound* AUD_delaySound(AUD_Sound* sound, float delay)
AUD_Sound *AUD_delaySound(AUD_Sound *sound, float delay)
{
assert(sound);
try
{
try {
return new AUD_Sound(new AUD_DelayFactory(*sound, delay));
}
catch(AUD_Exception&)
@@ -365,12 +354,11 @@ AUD_Sound* AUD_delaySound(AUD_Sound* sound, float delay)
}
}
AUD_Sound* AUD_limitSound(AUD_Sound* sound, float start, float end)
AUD_Sound *AUD_limitSound(AUD_Sound *sound, float start, float end)
{
assert(sound);
try
{
try {
return new AUD_Sound(new AUD_LimiterFactory(*sound, start, end));
}
catch(AUD_Exception&)
@@ -379,12 +367,11 @@ AUD_Sound* AUD_limitSound(AUD_Sound* sound, float start, float end)
}
}
AUD_Sound* AUD_pingpongSound(AUD_Sound* sound)
AUD_Sound *AUD_pingpongSound(AUD_Sound *sound)
{
assert(sound);
try
{
try {
return new AUD_Sound(new AUD_PingPongFactory(*sound));
}
catch(AUD_Exception&)
@@ -393,12 +380,11 @@ AUD_Sound* AUD_pingpongSound(AUD_Sound* sound)
}
}
AUD_Sound* AUD_loopSound(AUD_Sound* sound)
AUD_Sound *AUD_loopSound(AUD_Sound *sound)
{
assert(sound);
try
{
try {
return new AUD_Sound(new AUD_LoopFactory(*sound));
}
catch(AUD_Exception&)
@@ -407,12 +393,11 @@ AUD_Sound* AUD_loopSound(AUD_Sound* sound)
}
}
int AUD_setLoop(AUD_Handle* handle, int loops)
int AUD_setLoop(AUD_Handle *handle, int loops)
{
assert(handle);
try
{
try {
return (*handle)->setLoopCount(loops);
}
catch(AUD_Exception&)
@@ -422,12 +407,11 @@ int AUD_setLoop(AUD_Handle* handle, int loops)
return false;
}
AUD_Sound* AUD_rectifySound(AUD_Sound* sound)
AUD_Sound *AUD_rectifySound(AUD_Sound *sound)
{
assert(sound);
try
{
try {
return new AUD_Sound(new AUD_RectifyFactory(*sound));
}
catch(AUD_Exception&)
@@ -436,20 +420,20 @@ AUD_Sound* AUD_rectifySound(AUD_Sound* sound)
}
}
void AUD_unload(AUD_Sound* sound)
void AUD_unload(AUD_Sound *sound)
{
assert(sound);
delete sound;
}
AUD_Handle* AUD_play(AUD_Sound* sound, int keep)
AUD_Handle *AUD_play(AUD_Sound *sound, int keep)
{
assert(sound);
try
{
try {
AUD_Handle handle = AUD_device->play(*sound, keep);
if(!handle.isNull())
if (!handle.isNull()) {
return new AUD_Handle(handle);
}
}
catch(AUD_Exception&)
{
@@ -457,19 +441,19 @@ AUD_Handle* AUD_play(AUD_Sound* sound, int keep)
return NULL;
}
int AUD_pause(AUD_Handle* handle)
int AUD_pause(AUD_Handle *handle)
{
assert(handle);
return (*handle)->pause();
}
int AUD_resume(AUD_Handle* handle)
int AUD_resume(AUD_Handle *handle)
{
assert(handle);
return (*handle)->resume();
}
int AUD_stop(AUD_Handle* handle)
int AUD_stop(AUD_Handle *handle)
{
assert(handle);
int result = (*handle)->stop();
@@ -477,34 +461,33 @@ int AUD_stop(AUD_Handle* handle)
return result;
}
int AUD_setKeep(AUD_Handle* handle, int keep)
int AUD_setKeep(AUD_Handle *handle, int keep)
{
assert(handle);
return (*handle)->setKeep(keep);
}
int AUD_seek(AUD_Handle* handle, float seekTo)
int AUD_seek(AUD_Handle *handle, float seekTo)
{
assert(handle);
return (*handle)->seek(seekTo);
}
float AUD_getPosition(AUD_Handle* handle)
float AUD_getPosition(AUD_Handle *handle)
{
assert(handle);
return (*handle)->getPosition();
}
AUD_Status AUD_getStatus(AUD_Handle* handle)
AUD_Status AUD_getStatus(AUD_Handle *handle)
{
assert(handle);
return (*handle)->getStatus();
}
int AUD_setListenerLocation(const float* location)
int AUD_setListenerLocation(const float location[3])
{
if(AUD_3ddevice)
{
if (AUD_3ddevice) {
AUD_Vector3 v(location[0], location[1], location[2]);
AUD_3ddevice->setListenerLocation(v);
return true;
@@ -513,10 +496,9 @@ int AUD_setListenerLocation(const float* location)
return false;
}
int AUD_setListenerVelocity(const float* velocity)
int AUD_setListenerVelocity(const float velocity[3])
{
if(AUD_3ddevice)
{
if (AUD_3ddevice) {
AUD_Vector3 v(velocity[0], velocity[1], velocity[2]);
AUD_3ddevice->setListenerVelocity(v);
return true;
@@ -525,10 +507,9 @@ int AUD_setListenerVelocity(const float* velocity)
return false;
}
int AUD_setListenerOrientation(const float* orientation)
int AUD_setListenerOrientation(const float orientation[4])
{
if(AUD_3ddevice)
{
if (AUD_3ddevice) {
AUD_Quaternion q(orientation[3], orientation[0], orientation[1], orientation[2]);
AUD_3ddevice->setListenerOrientation(q);
return true;
@@ -539,8 +520,7 @@ int AUD_setListenerOrientation(const float* orientation)
int AUD_setSpeedOfSound(float speed)
{
if(AUD_3ddevice)
{
if (AUD_3ddevice) {
AUD_3ddevice->setSpeedOfSound(speed);
return true;
}
@@ -550,8 +530,7 @@ int AUD_setSpeedOfSound(float speed)
int AUD_setDopplerFactor(float factor)
{
if(AUD_3ddevice)
{
if (AUD_3ddevice) {
AUD_3ddevice->setDopplerFactor(factor);
return true;
}
@@ -561,8 +540,7 @@ int AUD_setDopplerFactor(float factor)
int AUD_setDistanceModel(AUD_DistanceModel model)
{
if(AUD_3ddevice)
{
if (AUD_3ddevice) {
AUD_3ddevice->setDistanceModel(model);
return true;
}
@@ -570,13 +548,12 @@ int AUD_setDistanceModel(AUD_DistanceModel model)
return false;
}
int AUD_setSourceLocation(AUD_Handle* handle, const float* location)
int AUD_setSourceLocation(AUD_Handle *handle, const float location[3])
{
assert(handle);
AUD_Reference<AUD_I3DHandle> h(*handle);
if(!h.isNull())
{
if (!h.isNull()) {
AUD_Vector3 v(location[0], location[1], location[2]);
return h->setSourceLocation(v);
}
@@ -584,13 +561,12 @@ int AUD_setSourceLocation(AUD_Handle* handle, const float* location)
return false;
}
int AUD_setSourceVelocity(AUD_Handle* handle, const float* velocity)
int AUD_setSourceVelocity(AUD_Handle *handle, const float velocity[3])
{
assert(handle);
AUD_Reference<AUD_I3DHandle> h(*handle);
if(!h.isNull())
{
if (!h.isNull()) {
AUD_Vector3 v(velocity[0], velocity[1], velocity[2]);
return h->setSourceVelocity(v);
}
@@ -598,13 +574,12 @@ int AUD_setSourceVelocity(AUD_Handle* handle, const float* velocity)
return false;
}
int AUD_setSourceOrientation(AUD_Handle* handle, const float* orientation)
int AUD_setSourceOrientation(AUD_Handle *handle, const float orientation[4])
{
assert(handle);
AUD_Reference<AUD_I3DHandle> h(*handle);
if(!h.isNull())
{
if (!h.isNull()) {
AUD_Quaternion q(orientation[3], orientation[0], orientation[1], orientation[2]);
return h->setSourceOrientation(q);
}
@@ -612,149 +587,137 @@ int AUD_setSourceOrientation(AUD_Handle* handle, const float* orientation)
return false;
}
int AUD_setRelative(AUD_Handle* handle, int relative)
int AUD_setRelative(AUD_Handle *handle, int relative)
{
assert(handle);
AUD_Reference<AUD_I3DHandle> h(*handle);
if(!h.isNull())
{
if (!h.isNull()) {
return h->setRelative(relative);
}
return false;
}
int AUD_setVolumeMaximum(AUD_Handle* handle, float volume)
int AUD_setVolumeMaximum(AUD_Handle *handle, float volume)
{
assert(handle);
AUD_Reference<AUD_I3DHandle> h(*handle);
if(!h.isNull())
{
if (!h.isNull()) {
return h->setVolumeMaximum(volume);
}
return false;
}
int AUD_setVolumeMinimum(AUD_Handle* handle, float volume)
int AUD_setVolumeMinimum(AUD_Handle *handle, float volume)
{
assert(handle);
AUD_Reference<AUD_I3DHandle> h(*handle);
if(!h.isNull())
{
if (!h.isNull()) {
return h->setVolumeMinimum(volume);
}
return false;
}
int AUD_setDistanceMaximum(AUD_Handle* handle, float distance)
int AUD_setDistanceMaximum(AUD_Handle *handle, float distance)
{
assert(handle);
AUD_Reference<AUD_I3DHandle> h(*handle);
if(!h.isNull())
{
if (!h.isNull()) {
return h->setDistanceMaximum(distance);
}
return false;
}
int AUD_setDistanceReference(AUD_Handle* handle, float distance)
int AUD_setDistanceReference(AUD_Handle *handle, float distance)
{
assert(handle);
AUD_Reference<AUD_I3DHandle> h(*handle);
if(!h.isNull())
{
if (!h.isNull()) {
return h->setDistanceReference(distance);
}
return false;
}
int AUD_setAttenuation(AUD_Handle* handle, float factor)
int AUD_setAttenuation(AUD_Handle *handle, float factor)
{
assert(handle);
AUD_Reference<AUD_I3DHandle> h(*handle);
if(!h.isNull())
{
if (!h.isNull()) {
return h->setAttenuation(factor);
}
return false;
}
int AUD_setConeAngleOuter(AUD_Handle* handle, float angle)
int AUD_setConeAngleOuter(AUD_Handle *handle, float angle)
{
assert(handle);
AUD_Reference<AUD_I3DHandle> h(*handle);
if(!h.isNull())
{
if (!h.isNull()) {
return h->setConeAngleOuter(angle);
}
return false;
}
int AUD_setConeAngleInner(AUD_Handle* handle, float angle)
int AUD_setConeAngleInner(AUD_Handle *handle, float angle)
{
assert(handle);
AUD_Reference<AUD_I3DHandle> h(*handle);
if(!h.isNull())
{
if (!h.isNull()) {
return h->setConeAngleInner(angle);
}
return false;
}
int AUD_setConeVolumeOuter(AUD_Handle* handle, float volume)
int AUD_setConeVolumeOuter(AUD_Handle *handle, float volume)
{
assert(handle);
AUD_Reference<AUD_I3DHandle> h(*handle);
if(!h.isNull())
{
if (!h.isNull()) {
return h->setConeVolumeOuter(volume);
}
return false;
}
int AUD_setSoundVolume(AUD_Handle* handle, float volume)
int AUD_setSoundVolume(AUD_Handle *handle, float volume)
{
assert(handle);
try
{
try {
return (*handle)->setVolume(volume);
}
catch(AUD_Exception&) {}
return false;
}
int AUD_setSoundPitch(AUD_Handle* handle, float pitch)
int AUD_setSoundPitch(AUD_Handle *handle, float pitch)
{
assert(handle);
try
{
try {
return (*handle)->setPitch(pitch);
}
catch(AUD_Exception&) {}
return false;
}
AUD_Device* AUD_openReadDevice(AUD_DeviceSpecs specs)
AUD_Device *AUD_openReadDevice(AUD_DeviceSpecs specs)
{
try
{
try {
return new AUD_Device(new AUD_ReadDevice(specs));
}
catch(AUD_Exception&)
@@ -763,16 +726,14 @@ AUD_Device* AUD_openReadDevice(AUD_DeviceSpecs specs)
}
}
AUD_Handle* AUD_playDevice(AUD_Device* device, AUD_Sound* sound, float seek)
AUD_Handle *AUD_playDevice(AUD_Device *device, AUD_Sound *sound, float seek)
{
assert(device);
assert(sound);
try
{
try {
AUD_Handle handle = (*device)->play(*sound);
if(!handle.isNull())
{
if (!handle.isNull()) {
handle->seek(seek);
return new AUD_Handle(handle);
}
@@ -783,12 +744,11 @@ AUD_Handle* AUD_playDevice(AUD_Device* device, AUD_Sound* sound, float seek)
return NULL;
}
int AUD_setDeviceVolume(AUD_Device* device, float volume)
int AUD_setDeviceVolume(AUD_Device *device, float volume)
{
assert(device);
try
{
try {
(*device)->setVolume(volume);
return true;
}
@@ -797,13 +757,12 @@ int AUD_setDeviceVolume(AUD_Device* device, float volume)
return false;
}
int AUD_readDevice(AUD_Device* device, data_t* buffer, int length)
int AUD_readDevice(AUD_Device *device, data_t *buffer, int length)
{
assert(device);
assert(buffer);
try
{
try {
return (*device)->read(buffer, length);
}
catch(AUD_Exception&)
@@ -812,12 +771,11 @@ int AUD_readDevice(AUD_Device* device, data_t* buffer, int length)
}
}
void AUD_closeReadDevice(AUD_Device* device)
void AUD_closeReadDevice(AUD_Device *device)
{
assert(device);
try
{
try {
delete device;
}
catch(AUD_Exception&)
@@ -825,10 +783,10 @@ void AUD_closeReadDevice(AUD_Device* device)
}
}
float* AUD_readSoundBuffer(const char* filename, float low, float high,
float attack, float release, float threshold,
int accumulate, int additive, int square,
float sthreshold, double samplerate, int* length)
float *AUD_readSoundBuffer(const char *filename, float low, float high,
float attack, float release, float threshold,
int accumulate, int additive, int square,
float sthreshold, double samplerate, int *length)
{
AUD_Buffer buffer;
AUD_DeviceSpecs specs;
@@ -840,33 +798,32 @@ float* AUD_readSoundBuffer(const char* filename, float low, float high,
int position = 0;
try
{
try {
AUD_Reference<AUD_IReader> reader = file->createReader();
AUD_SampleRate rate = reader->getSpecs().rate;
sound = new AUD_ChannelMapperFactory(file, specs);
if(high < rate)
if (high < rate)
sound = new AUD_LowpassFactory(sound, high);
if(low > 0)
if (low > 0)
sound = new AUD_HighpassFactory(sound, low);
sound = new AUD_EnvelopeFactory(sound, attack, release, threshold, 0.1f);
sound = new AUD_LinearResampleFactory(sound, specs);
if(square)
if (square)
sound = new AUD_SquareFactory(sound, sthreshold);
if(accumulate)
if (accumulate)
sound = new AUD_AccumulatorFactory(sound, additive);
else if(additive)
else if (additive)
sound = new AUD_SumFactory(sound);
reader = sound->createReader();
if(reader.isNull())
if (reader.isNull())
return NULL;
int len;
@@ -884,30 +841,28 @@ float* AUD_readSoundBuffer(const char* filename, float low, float high,
return NULL;
}
float* result = (float*)malloc(position * sizeof(float));
float * result = (float *)malloc(position * sizeof(float));
memcpy(result, buffer.getBuffer(), position * sizeof(float));
*length = position;
return result;
}
static void pauseSound(AUD_Handle* handle)
static void pauseSound(AUD_Handle *handle)
{
assert(handle);
(*handle)->pause();
}
AUD_Handle* AUD_pauseAfter(AUD_Handle* handle, float seconds)
AUD_Handle *AUD_pauseAfter(AUD_Handle *handle, float seconds)
{
AUD_Reference<AUD_IFactory> silence = new AUD_SilenceFactory;
AUD_Reference<AUD_IFactory> limiter = new AUD_LimiterFactory(silence, 0, seconds);
AUD_device->lock();
try
{
try {
AUD_Handle handle2 = AUD_device->play(limiter);
if(!handle2.isNull())
{
if (!handle2.isNull()) {
handle2->setStopCallback((stopCallback)pauseSound, handle);
AUD_device->unlock();
return new AUD_Handle(handle2);
@@ -922,125 +877,127 @@ AUD_Handle* AUD_pauseAfter(AUD_Handle* handle, float seconds)
return NULL;
}
AUD_Sound* AUD_createSequencer(float fps, int muted)
AUD_Sound *AUD_createSequencer(float fps, int muted)
{
// specs are changed at a later point!
AUD_Specs specs;
specs.channels = AUD_CHANNELS_STEREO;
specs.rate = AUD_RATE_44100;
AUD_Sound* sequencer = new AUD_Sound(AUD_Reference<AUD_SequencerFactory>(new AUD_SequencerFactory(specs, fps, muted)));
AUD_Sound *sequencer = new AUD_Sound(AUD_Reference<AUD_SequencerFactory>(new AUD_SequencerFactory(specs, fps, muted)));
return sequencer;
}
void AUD_destroySequencer(AUD_Sound* sequencer)
void AUD_destroySequencer(AUD_Sound *sequencer)
{
delete sequencer;
}
void AUD_setSequencerMuted(AUD_Sound* sequencer, int muted)
void AUD_setSequencerMuted(AUD_Sound *sequencer, int muted)
{
dynamic_cast<AUD_SequencerFactory*>(sequencer->get())->mute(muted);
dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->mute(muted);
}
void AUD_setSequencerFPS(AUD_Sound* sequencer, float fps)
void AUD_setSequencerFPS(AUD_Sound *sequencer, float fps)
{
dynamic_cast<AUD_SequencerFactory*>(sequencer->get())->setFPS(fps);
dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->setFPS(fps);
}
AUD_SEntry* AUD_addSequence(AUD_Sound* sequencer, AUD_Sound* sound,
float begin, float end, float skip)
AUD_SEntry *AUD_addSequence(AUD_Sound *sequencer, AUD_Sound *sound,
float begin, float end, float skip)
{
if(!sound)
return new AUD_SEntry(((AUD_SequencerFactory*)sequencer->get())->add(AUD_Sound(), begin, end, skip));
return new AUD_SEntry(((AUD_SequencerFactory*)sequencer->get())->add(*sound, begin, end, skip));
if (!sound)
return new AUD_SEntry(((AUD_SequencerFactory *)sequencer->get())->add(AUD_Sound(), begin, end, skip));
return new AUD_SEntry(((AUD_SequencerFactory *)sequencer->get())->add(*sound, begin, end, skip));
}
void AUD_removeSequence(AUD_Sound* sequencer, AUD_SEntry* entry)
void AUD_removeSequence(AUD_Sound *sequencer, AUD_SEntry *entry)
{
dynamic_cast<AUD_SequencerFactory*>(sequencer->get())->remove(*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_moveSequence(AUD_SEntry *entry, float begin, float end, float skip)
{
(*entry)->move(begin, end, skip);
}
void AUD_muteSequence(AUD_SEntry* entry, char mute)
void AUD_muteSequence(AUD_SEntry *entry, char mute)
{
(*entry)->mute(mute);
}
void AUD_setRelativeSequence(AUD_SEntry* entry, char relative)
void AUD_setRelativeSequence(AUD_SEntry *entry, char relative)
{
(*entry)->setRelative(relative);
}
void AUD_updateSequenceSound(AUD_SEntry* entry, AUD_Sound* sound)
void AUD_updateSequenceSound(AUD_SEntry *entry, AUD_Sound *sound)
{
if(sound)
if (sound)
(*entry)->setSound(*sound);
else
(*entry)->setSound(AUD_Sound());
}
void AUD_setSequenceAnimData(AUD_SEntry* entry, AUD_AnimateablePropertyType type, int frame, float* data, char animated)
void AUD_setSequenceAnimData(AUD_SEntry *entry, AUD_AnimateablePropertyType type, int frame, float *data, char animated)
{
AUD_AnimateableProperty* prop = (*entry)->getAnimProperty(type);
if(animated)
{
if(frame >= 0)
AUD_AnimateableProperty *prop = (*entry)->getAnimProperty(type);
if (animated) {
if (frame >= 0)
prop->write(data, frame, 1);
}
else
else {
prop->write(data);
}
void AUD_setSequencerAnimData(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)
{
if(frame >= 0)
prop->write(data, frame, 1);
}
else
prop->write(data);
}
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_setSequencerAnimData(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) {
if (frame >= 0) {
prop->write(data, frame, 1);
}
}
else {
prop->write(data);
}
}
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)
{
(*entry)->updateAll(volume_max, volume_min, distance_max, distance_reference, attenuation,
cone_angle_outer, cone_angle_inner, cone_volume_outer);
cone_angle_outer, cone_angle_inner, cone_volume_outer);
}
void AUD_updateSequencerData(AUD_Sound* sequencer, float speed_of_sound,
float factor, AUD_DistanceModel model)
void AUD_updateSequencerData(AUD_Sound *sequencer, float speed_of_sound,
float factor, AUD_DistanceModel model)
{
AUD_SequencerFactory* f = dynamic_cast<AUD_SequencerFactory*>(sequencer->get());
AUD_SequencerFactory *f = dynamic_cast<AUD_SequencerFactory *>(sequencer->get());
f->setSpeedOfSound(speed_of_sound);
f->setDopplerFactor(factor);
f->setDistanceModel(model);
}
void AUD_setSequencerDeviceSpecs(AUD_Sound* sequencer)
void AUD_setSequencerDeviceSpecs(AUD_Sound *sequencer)
{
dynamic_cast<AUD_SequencerFactory*>(sequencer->get())->setSpecs(AUD_device->getSpecs().specs);
dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->setSpecs(AUD_device->getSpecs().specs);
}
void AUD_setSequencerSpecs(AUD_Sound* sequencer, AUD_Specs specs)
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_seekSequencer(AUD_Handle *handle, float time)
{
#ifdef WITH_JACK
AUD_JackDevice* device = dynamic_cast<AUD_JackDevice*>(AUD_device.get());
if(device)
AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
if (device) {
device->seekPlayback(time);
}
else
#endif
{
@@ -1049,12 +1006,13 @@ void AUD_seekSequencer(AUD_Handle* handle, float time)
}
}
float AUD_getSequencerPosition(AUD_Handle* handle)
float AUD_getSequencerPosition(AUD_Handle *handle)
{
#ifdef WITH_JACK
AUD_JackDevice* device = dynamic_cast<AUD_JackDevice*>(AUD_device.get());
if(device)
AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
if (device) {
return device->getPlaybackPosition();
}
else
#endif
{
@@ -1066,44 +1024,48 @@ float AUD_getSequencerPosition(AUD_Handle* handle)
void AUD_startPlayback()
{
#ifdef WITH_JACK
AUD_JackDevice* device = dynamic_cast<AUD_JackDevice*>(AUD_device.get());
if(device)
AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
if (device) {
device->startPlayback();
}
#endif
}
void AUD_stopPlayback()
{
#ifdef WITH_JACK
AUD_JackDevice* device = dynamic_cast<AUD_JackDevice*>(AUD_device.get());
if(device)
AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
if (device) {
device->stopPlayback();
}
#endif
}
#ifdef WITH_JACK
void AUD_setSyncCallback(AUD_syncFunction function, void* data)
void AUD_setSyncCallback(AUD_syncFunction function, void *data)
{
AUD_JackDevice* device = dynamic_cast<AUD_JackDevice*>(AUD_device.get());
if(device)
AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
if (device) {
device->setSyncCallback(function, data);
}
}
#endif
int AUD_doesPlayback()
{
#ifdef WITH_JACK
AUD_JackDevice* device = dynamic_cast<AUD_JackDevice*>(AUD_device.get());
if(device)
AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
if (device) {
return device->doesPlayback();
}
#endif
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)
{
AUD_DeviceSpecs specs;
sample_t* buf;
sample_t *buf;
AUD_Buffer aBuffer;
specs.rate = AUD_RATE_INVALID;
@@ -1120,8 +1082,7 @@ int AUD_readSound(AUD_Sound* sound, sample_t* buffer, int length, int samples_pe
overallmax = 0;
for(int i = 0; i < length; i++)
{
for (int i = 0; i < length; i++) {
len = floor(samplejump * (i+1)) - floor(samplejump * i);
aBuffer.assureSize(len * AUD_SAMPLE_SIZE(specs));
@@ -1131,11 +1092,10 @@ int AUD_readSound(AUD_Sound* sound, sample_t* buffer, int length, int samples_pe
max = min = *buf;
power = *buf * *buf;
for(int j = 1; j < len; j++)
{
if(buf[j] < min)
for (int j = 1; j < len; j++) {
if (buf[j] < min)
min = buf[j];
if(buf[j] > max)
if (buf[j] > max)
max = buf[j];
power += buf[j] * buf[j];
}
@@ -1144,22 +1104,19 @@ int AUD_readSound(AUD_Sound* sound, sample_t* buffer, int length, int samples_pe
buffer[i * 3 + 1] = max;
buffer[i * 3 + 2] = sqrt(power) / len;
if(overallmax < max)
if (overallmax < max)
overallmax = max;
if(overallmax < -min)
if (overallmax < -min)
overallmax = -min;
if(eos)
{
if (eos) {
length = i;
break;
}
}
if(overallmax > 1.0f)
{
for(int i = 0; i < length * 3; i++)
{
if (overallmax > 1.0f) {
for (int i = 0; i < length * 3; i++) {
buffer[i] /= overallmax;
}
}
@@ -1167,48 +1124,46 @@ 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_copy(AUD_Sound *sound)
{
return new AUD_Reference<AUD_IFactory>(*sound);
}
void AUD_freeHandle(AUD_Handle* handle)
void AUD_freeHandle(AUD_Handle *handle)
{
delete handle;
}
void* AUD_createSet()
void *AUD_createSet()
{
return new std::set<void*>();
return new std::set<void *>();
}
void AUD_destroySet(void* set)
void AUD_destroySet(void *set)
{
delete reinterpret_cast<std::set<void*>*>(set);
delete reinterpret_cast<std::set<void *>*>(set);
}
char AUD_removeSet(void* set, void* entry)
char AUD_removeSet(void *set, void *entry)
{
if(set)
return reinterpret_cast<std::set<void*>*>(set)->erase(entry);
if (set)
return reinterpret_cast<std::set<void *>*>(set)->erase(entry);
return 0;
}
void AUD_addSet(void* set, void* entry)
void AUD_addSet(void *set, void *entry)
{
if(entry)
reinterpret_cast<std::set<void*>*>(set)->insert(entry);
if (entry)
reinterpret_cast<std::set<void *>*>(set)->insert(entry);
}
void* AUD_getSet(void* set)
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;
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;
}
@@ -1217,11 +1172,10 @@ void* AUD_getSet(void* set)
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)
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
{
AUD_SequencerFactory* f = dynamic_cast<AUD_SequencerFactory*>(sound->get());
try {
AUD_SequencerFactory *f = dynamic_cast<AUD_SequencerFactory *>(sound->get());
f->setSpecs(specs.specs);
AUD_Reference<AUD_IReader> reader = f->createQualityReader();
@@ -1237,11 +1191,10 @@ const char* AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned int lengt
}
}
const char* AUD_mixdown_per_channel(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)
const char *AUD_mixdown_per_channel(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
{
AUD_SequencerFactory* f = dynamic_cast<AUD_SequencerFactory*>(sound->get());
try {
AUD_SequencerFactory *f = dynamic_cast<AUD_SequencerFactory *>(sound->get());
f->setSpecs(specs.specs);
@@ -1250,19 +1203,22 @@ const char* AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start, unsign
int channels = specs.channels;
specs.channels = AUD_CHANNELS_MONO;
for(int i = 0; i < channels; i++)
{
for (int i = 0; i < channels; i++) {
std::stringstream stream;
std::string fn = filename;
size_t index = fn.find_last_of('.');
size_t index_slash = fn.find_last_of('/');
size_t index_backslash = fn.find_last_of('\\');
if((index == std::string::npos) ||
((index < index_slash) && (index_slash != std::string::npos)) ||
((index < index_backslash) && (index_backslash != std::string::npos)))
if ((index == std::string::npos) ||
((index < index_slash) && (index_slash != std::string::npos)) ||
((index < index_backslash) && (index_backslash != std::string::npos)))
{
stream << filename << "_" << (i + 1);
else
}
else {
stream << fn.substr(0, index) << "_" << (i + 1) << fn.substr(index);
}
writers.push_back(AUD_FileWriter::createWriter(stream.str(), specs, format, codec, bitrate));
}
@@ -1278,19 +1234,19 @@ const char* AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start, unsign
}
}
AUD_Device* AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound* sequencer, float volume, float start)
AUD_Device *AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound *sequencer, float volume, float start)
{
try
{
AUD_ReadDevice* device = new AUD_ReadDevice(specs);
try {
AUD_ReadDevice *device = new AUD_ReadDevice(specs);
device->setQuality(true);
device->setVolume(volume);
dynamic_cast<AUD_SequencerFactory*>(sequencer->get())->setSpecs(specs.specs);
dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->setSpecs(specs.specs);
AUD_Handle handle = device->play(*sequencer);
if(!handle.isNull())
if (!handle.isNull()) {
handle->seek(start);
}
return new AUD_Device(device);
}
@@ -1305,7 +1261,7 @@ AUD_Reference<AUD_IDevice> AUD_getDevice()
return AUD_device;
}
AUD_I3DDevice* AUD_get3DDevice()
AUD_I3DDevice *AUD_get3DDevice()
{
return AUD_3ddevice;
}

View File

@@ -56,8 +56,8 @@ typedef struct
typedef void AUD_Handle;
typedef void AUD_Device;
typedef void AUD_SEntry;
typedef float (*AUD_volumeFunction)(void*, void*, float);
typedef void (*AUD_syncFunction)(void*, int, float);
typedef float (*AUD_volumeFunction)(void *, void *, float);
typedef void (*AUD_syncFunction)(void *, int, float);
#endif
/**
@@ -94,14 +94,14 @@ extern void AUD_unlock(void);
* \param sound The sound to get the info about.
* \return The AUD_SoundInfo structure with filled in data.
*/
extern AUD_SoundInfo AUD_getInfo(AUD_Sound* sound);
extern AUD_SoundInfo AUD_getInfo(AUD_Sound *sound);
/**
* Loads a sound file.
* \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_load(const char *filename);
/**
* Loads a sound file.
@@ -109,21 +109,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_loadBuffer(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_bufferSound(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_monoSound(AUD_Sound *sound);
/**
* Delays a sound.
@@ -131,7 +131,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_delaySound(AUD_Sound *sound, float delay);
/**
* Limits a sound.
@@ -140,21 +140,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_limitSound(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_pingpongSound(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_loopSound(AUD_Sound *sound);
/**
* Sets a remaining loop count of a looping sound that currently plays.
@@ -162,20 +162,20 @@ 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_setLoop(AUD_Handle *handle, int loops);
/**
* Rectifies a sound.
* \param sound The sound to rectify.
* \return A handle of the rectified sound.
*/
extern AUD_Sound* AUD_rectifySound(AUD_Sound* sound);
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_unload(AUD_Sound *sound);
/**
* Plays back a sound file.
@@ -184,28 +184,28 @@ 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_play(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_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_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_stop(AUD_Handle *handle);
/**
* Sets the end behaviour of a playing or paused sound.
@@ -214,7 +214,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_setKeep(AUD_Handle *handle, int keep);
/**
* Seeks a playing or paused sound.
@@ -222,7 +222,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_seek(AUD_Handle *handle, float seekTo);
/**
* Retrieves the playback position of a handle.
@@ -230,32 +230,32 @@ 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_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_getStatus(AUD_Handle *handle);
/**
* Sets the listener location.
* \param location The new location.
*/
extern int AUD_setListenerLocation(const float* location);
extern int AUD_setListenerLocation(const float location[3]);
/**
* Sets the listener velocity.
* \param velocity The new velocity.
*/
extern int AUD_setListenerVelocity(const float* velocity);
extern int AUD_setListenerVelocity(const float velocity[3]);
/**
* Sets the listener orientation.
* \param orientation The new orientation as quaternion.
*/
extern int AUD_setListenerOrientation(const float* orientation);
extern int AUD_setListenerOrientation(const float orientation[4]);
/**
* Sets the speed of sound.
@@ -284,7 +284,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);
extern int AUD_setSourceLocation(AUD_Handle *handle, const float location[3]);
/**
* Sets the velocity of a source.
@@ -292,7 +292,7 @@ extern int AUD_setSourceLocation(AUD_Handle* handle, const float* location);
* \param velocity The new velocity.
* \return Whether the action succeeded.
*/
extern int AUD_setSourceVelocity(AUD_Handle* handle, const float* velocity);
extern int AUD_setSourceVelocity(AUD_Handle *handle, const float velocity[3]);
/**
* Sets the orientation of a source.
@@ -300,7 +300,7 @@ extern int AUD_setSourceVelocity(AUD_Handle* handle, const float* velocity);
* \param orientation The new orientation as quaternion.
* \return Whether the action succeeded.
*/
extern int AUD_setSourceOrientation(AUD_Handle* handle, const float* orientation);
extern int AUD_setSourceOrientation(AUD_Handle *handle, const float orientation[4]);
/**
* Sets whether the source location, velocity and orientation are relative
@@ -309,7 +309,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_setRelative(AUD_Handle *handle, int relative);
/**
* Sets the maximum volume of a source.
@@ -317,7 +317,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_setVolumeMaximum(AUD_Handle *handle, float volume);
/**
* Sets the minimum volume of a source.
@@ -325,7 +325,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_setVolumeMinimum(AUD_Handle *handle, float volume);
/**
* Sets the maximum distance of a source.
@@ -335,7 +335,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_setDistanceMaximum(AUD_Handle *handle, float distance);
/**
* Sets the reference distance of a source.
@@ -343,7 +343,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_setDistanceReference(AUD_Handle *handle, float distance);
/**
* Sets the attenuation of a source.
@@ -352,7 +352,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_setAttenuation(AUD_Handle *handle, float factor);
/**
* Sets the outer angle of the cone of a source.
@@ -360,7 +360,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_setConeAngleOuter(AUD_Handle *handle, float angle);
/**
* Sets the inner angle of the cone of a source.
@@ -368,7 +368,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_setConeAngleInner(AUD_Handle *handle, float angle);
/**
* Sets the outer volume of the cone of a source.
@@ -378,7 +378,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_setConeVolumeOuter(AUD_Handle *handle, float volume);
/**
* Sets the volume of a played back sound.
@@ -386,7 +386,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_setSoundVolume(AUD_Handle *handle, float volume);
/**
* Sets the pitch of a played back sound.
@@ -394,14 +394,14 @@ 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_setSoundPitch(AUD_Handle *handle, float pitch);
/**
* Opens a read device, with which audio data can be read.
* \param specs The specification of the audio data.
* \return A device handle.
*/
extern AUD_Device* AUD_openReadDevice(AUD_DeviceSpecs specs);
extern AUD_Device *AUD_openReadDevice(AUD_DeviceSpecs specs);
/**
* Sets the main volume of a device.
@@ -409,7 +409,7 @@ extern AUD_Device* AUD_openReadDevice(AUD_DeviceSpecs specs);
* \param volume The new volume, must be between 0.0 and 1.0.
* \return Whether the action succeeded.
*/
extern int AUD_setDeviceVolume(AUD_Device* device, float volume);
extern int AUD_setDeviceVolume(AUD_Device *device, float volume);
/**
* Plays back a sound file through a read device.
@@ -418,7 +418,7 @@ extern int AUD_setDeviceVolume(AUD_Device* device, float volume);
* \param seek The position where the sound should be seeked to.
* \return A handle to the played back sound.
*/
extern AUD_Handle* AUD_playDevice(AUD_Device* device, AUD_Sound* sound, float seek);
extern AUD_Handle *AUD_playDevice(AUD_Device *device, AUD_Sound *sound, float seek);
/**
* Reads the next samples into the supplied buffer.
@@ -429,23 +429,23 @@ 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_readDevice(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_closeReadDevice(AUD_Device *device);
/**
* Reads a sound file into a newly created float buffer.
* The sound is therefore bandpassed, rectified and resampled.
*/
extern float* AUD_readSoundBuffer(const char* filename, float low, float high,
extern float *AUD_readSoundBuffer(const char *filename, float low, float high,
float attack, float release, float threshold,
int accumulate, int additive, int square,
float sthreshold, double samplerate,
int* length);
int *length);
/**
* Pauses a playing sound after a specific amount of time.
@@ -453,7 +453,7 @@ extern float* AUD_readSoundBuffer(const char* filename, float low, float high,
* \param seconds The time in seconds.
* \return The silence handle.
*/
extern AUD_Handle* AUD_pauseAfter(AUD_Handle* handle, float seconds);
extern AUD_Handle *AUD_pauseAfter(AUD_Handle *handle, float seconds);
/**
* Creates a new sequenced sound scene.
@@ -461,27 +461,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_createSequencer(float fps, int muted);
/**
* Deletes a sound scene.
* \param sequencer The sound scene.
*/
extern void AUD_destroySequencer(AUD_Sound* sequencer);
extern void AUD_destroySequencer(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_setSequencerMuted(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_setSequencerFPS(AUD_Sound *sequencer, float fps);
/**
* Adds a new entry to the scene.
@@ -492,7 +492,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_addSequence(AUD_Sound *sequencer, AUD_Sound *sound,
float begin, float end, float skip);
/**
@@ -500,7 +500,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_removeSequence(AUD_Sound *sequencer, AUD_SEntry *entry);
/**
* Moves the entry.
@@ -509,14 +509,14 @@ 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_moveSequence(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);
extern void AUD_muteSequence(AUD_SEntry *entry, char mute);
/**
* Sets whether the entrie's location, velocity and orientation are relative
@@ -525,14 +525,14 @@ extern void AUD_muteSequence(AUD_SEntry* entry, char mute);
* \param relative Whether the source is relative.
* \return Whether the action succeeded.
*/
extern void AUD_setRelativeSequence(AUD_SEntry* entry, char relative);
extern void AUD_setRelativeSequence(AUD_SEntry *entry, char relative);
/**
* 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_updateSequenceSound(AUD_SEntry *entry, AUD_Sound *sound);
/**
* Writes animation data to a sequenced entry.
@@ -542,7 +542,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_setSequenceAnimData(AUD_SEntry *entry, AUD_AnimateablePropertyType type, int frame, float *data, char animated);
/**
* Writes animation data to a sequenced entry.
@@ -552,7 +552,7 @@ 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_setSequencerAnimData(AUD_Sound *sequencer, AUD_AnimateablePropertyType type, int frame, float *data, char animated);
/**
* Updates all non-animated parameters of the entry.
@@ -566,7 +566,7 @@ extern void AUD_setSequencerAnimData(AUD_Sound* sequencer, AUD_AnimateableProper
* \param cone_angle_inner The inner cone opening angle.
* \param cone_volume_outer The volume outside the outer cone.
*/
extern void AUD_updateSequenceData(AUD_SEntry* entry, float volume_max, float volume_min,
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);
@@ -577,7 +577,7 @@ extern void AUD_updateSequenceData(AUD_SEntry* entry, float volume_max, float vo
* \param factor The doppler factor to control the effect's strength.
* \param model The distance model for distance calculation.
*/
extern void AUD_updateSequencerData(AUD_Sound* sequencer, float speed_of_sound,
extern void AUD_updateSequencerData(AUD_Sound *sequencer, float speed_of_sound,
float factor, AUD_DistanceModel model);
/**
@@ -585,28 +585,28 @@ extern void AUD_updateSequencerData(AUD_Sound* sequencer, float speed_of_sound,
* current playback device.
* \param sequencer The sound scene.
*/
extern void AUD_setSequencerDeviceSpecs(AUD_Sound* sequencer);
extern void AUD_setSequencerDeviceSpecs(AUD_Sound *sequencer);
/**
* Sets the audio output specification of the sound scene.
* \param sequencer The sound scene.
* \param specs The new specification.
*/
extern void AUD_setSequencerSpecs(AUD_Sound* sequencer, AUD_Specs specs);
extern void AUD_setSequencerSpecs(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_seekSequencer(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_getSequencerPosition(AUD_Handle *handle);
/**
* Starts the playback of jack transport if possible.
@@ -624,7 +624,7 @@ 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_setSyncCallback(AUD_syncFunction function, void *data);
#endif
/**
@@ -641,32 +641,32 @@ 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);
/**
* Copies a sound.
* \param sound Sound to copy.
* \return Copied sound.
*/
extern AUD_Sound* AUD_copy(AUD_Sound* sound);
extern AUD_Sound *AUD_copy(AUD_Sound *sound);
/**
* Frees a handle.
* \param channel Handle to free.
*/
extern void AUD_freeHandle(AUD_Handle* channel);
extern void AUD_freeHandle(AUD_Handle *channel);
/**
* Creates a new set.
* \return The new set.
*/
extern void* AUD_createSet(void);
extern void *AUD_createSet(void);
/**
* Deletes a set.
* \param set The set to delete.
*/
extern void AUD_destroySet(void* set);
extern void AUD_destroySet(void *set);
/**
* Removes an entry from a set.
@@ -674,21 +674,21 @@ extern void AUD_destroySet(void* set);
* \param entry The entry to remove.
* \return Whether the entry was in the set or not.
*/
extern char AUD_removeSet(void* set, void* entry);
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);
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);
extern void *AUD_getSet(void *set);
/**
* Mixes a sound down into a file.
@@ -703,7 +703,10 @@ extern void* AUD_getSet(void* set);
* \param bitrate The bitrate for encoding.
* \return An error message or NULL in case of success.
*/
extern 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);
extern 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);
/**
* Mixes a sound down into multiple files.
@@ -718,7 +721,10 @@ extern const char* AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned in
* \param bitrate The bitrate for encoding.
* \return An error message or NULL in case of success.
*/
extern const char* AUD_mixdown_per_channel(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);
extern const char *AUD_mixdown_per_channel(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);
/**
* Opens a read device and prepares it for mixdown of the sound scene.
@@ -728,7 +734,7 @@ extern const char* AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start,
* \param start The start time of the mixdown in the sound scene.
* \return The read device for the mixdown.
*/
extern AUD_Device* AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound* sequencer, float volume, float start);
extern AUD_Device *AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound *sequencer, float volume, float start);
#ifdef WITH_PYTHON
/**
@@ -736,14 +742,14 @@ 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_getPythonFactory(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_getPythonSound(void *sound);
#endif
#ifdef __cplusplus
@@ -763,7 +769,7 @@ AUD_Reference<AUD_IDevice> AUD_getDevice();
* Returns the current playback 3D device.
* \return The playback 3D device.
*/
AUD_I3DDevice* AUD_get3DDevice();
AUD_I3DDevice *AUD_get3DDevice();
#endif
#endif //__AUD_C_API_H__

View File

@@ -36,7 +36,7 @@ struct OSLGlobals {
/* use */
bool use;
/* shading system */
/* shading system */
OSL::ShadingSystem *ss;
OSLRenderServices *services;

View File

@@ -182,7 +182,8 @@ bool OSLRenderServices::get_array_attribute(void *renderstate, bool derivatives,
static void set_attribute_float3(float3 f[3], TypeDesc type, bool derivatives, void *val)
{
if (type == TypeDesc::TypePoint || type == TypeDesc::TypeVector ||
type == TypeDesc::TypeNormal || type == TypeDesc::TypeColor) {
type == TypeDesc::TypeNormal || type == TypeDesc::TypeColor)
{
float3 *fval = (float3 *)val;
fval[0] = f[0];
if (derivatives) {
@@ -203,7 +204,8 @@ static void set_attribute_float3(float3 f[3], TypeDesc type, bool derivatives, v
static void set_attribute_float(float f[3], TypeDesc type, bool derivatives, void *val)
{
if (type == TypeDesc::TypePoint || type == TypeDesc::TypeVector ||
type == TypeDesc::TypeNormal || type == TypeDesc::TypeColor) {
type == TypeDesc::TypeNormal || type == TypeDesc::TypeColor)
{
float3 *fval = (float3 *)val;
fval[0] = make_float3(f[0], f[0], f[0]);
if (derivatives) {
@@ -232,7 +234,8 @@ static bool get_mesh_attribute(KernelGlobals *kg, const ShaderData *sd, const OS
return true;
}
else if (attr.type == TypeDesc::TypePoint || attr.type == TypeDesc::TypeVector ||
attr.type == TypeDesc::TypeNormal || attr.type == TypeDesc::TypeColor) {
attr.type == TypeDesc::TypeNormal || attr.type == TypeDesc::TypeColor)
{
/* todo: this won't work when float3 has w component */
float3 fval[3];
fval[0] = triangle_attribute_float3(kg, sd, attr.elem, attr.offset,
@@ -419,15 +422,16 @@ bool OSLRenderServices::has_userdata(ustring name, TypeDesc type, void *renderst
}
int OSLRenderServices::pointcloud_search(OSL::ShaderGlobals *sg, ustring filename, const OSL::Vec3 &center,
float radius, int max_points, bool sort, size_t *out_indices, float *out_distances, int derivs_offset)
float radius, int max_points, bool sort,
size_t *out_indices, float *out_distances, int derivs_offset)
{
return 0;
return 0;
}
int OSLRenderServices::pointcloud_get(ustring filename, size_t *indices, int count,
ustring attr_name, TypeDesc attr_type, void *out_data)
ustring attr_name, TypeDesc attr_type, void *out_data)
{
return 0;
return 0;
}
CCL_NAMESPACE_END

View File

@@ -56,22 +56,22 @@ public:
bool get_matrix(OSL::Matrix44 &result, OSL::TransformationPtr xform);
bool get_matrix(OSL::Matrix44 &result, ustring from);
bool get_array_attribute(void *renderstate, bool derivatives,
bool get_array_attribute(void *renderstate, bool derivatives,
ustring object, TypeDesc type, ustring name,
int index, void *val);
bool get_attribute(void *renderstate, bool derivatives, ustring object,
TypeDesc type, ustring name, void *val);
bool get_userdata(bool derivatives, ustring name, TypeDesc type,
bool get_userdata(bool derivatives, ustring name, TypeDesc type,
void *renderstate, void *val);
bool has_userdata(ustring name, TypeDesc type, void *renderstate);
int pointcloud_search(OSL::ShaderGlobals *sg, ustring filename, const OSL::Vec3 &center,
float radius, int max_points, bool sort, size_t *out_indices,
float *out_distances, int derivs_offset);
float radius, int max_points, bool sort, size_t *out_indices,
float *out_distances, int derivs_offset);
int pointcloud_get(ustring filename, size_t *indices, int count, ustring attr_name,
TypeDesc attr_type, void *out_data);
TypeDesc attr_type, void *out_data);
private:
KernelGlobals *kernel_globals;