Revision: 30322 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30322 Author: nexyon Date: 2010-07-14 14:35:55 +0200 (Wed, 14 Jul 2010)
Log Message: ----------- Python API: * PEP8 fixes for aud. * Correction of doc strings. Modified Paths: -------------- branches/soc-2010-nexyon/intern/audaspace/Python/AUD_PyAPI.cpp branches/soc-2010-nexyon/intern/audaspace/intern/AUD_C-API.cpp Modified: branches/soc-2010-nexyon/intern/audaspace/Python/AUD_PyAPI.cpp =================================================================== --- branches/soc-2010-nexyon/intern/audaspace/Python/AUD_PyAPI.cpp 2010-07-14 12:16:23 UTC (rev 30321) +++ branches/soc-2010-nexyon/intern/audaspace/Python/AUD_PyAPI.cpp 2010-07-14 12:35:55 UTC (rev 30322) @@ -113,108 +113,159 @@ return (PyObject *)self; } +PyDoc_STRVAR(M_aud_Sound_sine_doc, + "Creates a sine sound at a specific frequency."); + static PyObject * Sound_sine(PyObject* nothing, PyObject* args); +PyDoc_STRVAR(M_aud_Sound_file_doc, + "Creates a sound object of a sound file."); + static PyObject * Sound_file(PyObject* nothing, PyObject* args); +PyDoc_STRVAR(M_aud_Sound_lowpass_doc, + "Creates a lowpass filter with a specific cut off frequency."); + static PyObject * Sound_lowpass(PyObject* nothing, PyObject* args); +PyDoc_STRVAR(M_aud_Sound_delay_doc, + "Delays a sound by a specific amount of seconds."); + static PyObject * Sound_delay(PyObject* nothing, PyObject* args); +PyDoc_STRVAR(M_aud_Sound_double_doc, + "Plays two sounds of the same specs in sequence."); + static PyObject * Sound_double(PyObject* nothing, PyObject* args); +PyDoc_STRVAR(M_aud_Sound_highpass_doc, + "Creates a highpass filter with a specific cut off frequency."); + static PyObject * Sound_highpass(PyObject* nothing, PyObject* args); +PyDoc_STRVAR(M_aud_Sound_limiter_doc, + "Limits a sound within a specific start and end time."); + static PyObject * Sound_limiter(PyObject* nothing, PyObject* args); +PyDoc_STRVAR(M_aud_Sound_pitch_doc, + "Changes the pitch of a sound with a specific factor."); + static PyObject * Sound_pitch(PyObject* nothing, PyObject* args); +PyDoc_STRVAR(M_aud_Sound_volume_doc, + "Changes the volume of a sound with a specific factor."); + static PyObject * Sound_volume(PyObject* nothing, PyObject* args); +PyDoc_STRVAR(M_aud_Sound_fadein_doc, + "Fades a sound in from a specific start time and with a specific length."); + static PyObject * Sound_fadein(PyObject* nothing, PyObject* args); +PyDoc_STRVAR(M_aud_Sound_fadeout_doc, + "Fades a sound out from a specific start time and with a specific length."); + static PyObject * Sound_fadeout(PyObject* nothing, PyObject* args); +PyDoc_STRVAR(M_aud_Sound_loop_doc, + "Loops a sound a specific amount of times, negative values mean endlessly."); + static PyObject * Sound_loop(PyObject* nothing, PyObject* args); +PyDoc_STRVAR(M_aud_Sound_superpose_doc, + "Mixes two sounds of the same specs."); + static PyObject * Sound_superpose(PyObject* nothing, PyObject* args); +PyDoc_STRVAR(M_aud_Sound_pingpong_doc, + "Plays a sound forward and then backward."); + static PyObject * Sound_pingpong(PyObject* nothing, PyObject* args); +PyDoc_STRVAR(M_aud_Sound_reverse_doc, + "Plays a sound reversed."); + static PyObject * Sound_reverse(PyObject* nothing, PyObject* args); +PyDoc_STRVAR(M_aud_Sound_buffer_doc, + "Buffers a sound into RAM."); + static PyObject * Sound_buffer(PyObject* nothing, PyObject* args); +PyDoc_STRVAR(M_aud_Sound_square_doc, + "Makes a square wave out of an audio wave depending on a threshold value."); + static PyObject * Sound_square(PyObject* nothing, PyObject* args); static PyMethodDef Sound_methods[] = { {"sine", (PyCFunction)Sound_sine, METH_VARARGS | METH_STATIC, - "Creates a sine sound at a specific frequency." + M_aud_Sound_sine_doc }, {"file", (PyCFunction)Sound_file, METH_VARARGS | METH_STATIC, - "Creates a sound object of a sound file." + M_aud_Sound_file_doc }, {"lowpass", (PyCFunction)Sound_lowpass, METH_VARARGS | METH_STATIC, - "Creates a lowpass filter with a specific cut off frequency." + M_aud_Sound_lowpass_doc }, {"delay", (PyCFunction)Sound_delay, METH_VARARGS | METH_STATIC, - "Delays a sound by a specific amount of seconds." + M_aud_Sound_delay_doc }, {"double", (PyCFunction)Sound_double, METH_VARARGS | METH_STATIC, - "Plays two sounds of the same specs in sequence." + M_aud_Sound_double_doc }, {"highpass", (PyCFunction)Sound_highpass, METH_VARARGS | METH_STATIC, - "Creates a highpass filter with a specific cut off frequency." + M_aud_Sound_highpass_doc }, {"limiter", (PyCFunction)Sound_limiter, METH_VARARGS | METH_STATIC, - "Limits a sound within a specific start and end time." + M_aud_Sound_limiter_doc }, {"pitch", (PyCFunction)Sound_pitch, METH_VARARGS | METH_STATIC, - "Changes the pitch of a sound with a specific factor." + M_aud_Sound_pitch_doc }, {"volume", (PyCFunction)Sound_volume, METH_VARARGS | METH_STATIC, - "Changes the volume of a sound with a specific factor." + M_aud_Sound_volume_doc }, {"fadein", (PyCFunction)Sound_fadein, METH_VARARGS | METH_STATIC, - "Fades a sound in from a specific start time and with a specific length." + M_aud_Sound_fadein_doc }, {"fadeout", (PyCFunction)Sound_fadeout, METH_VARARGS | METH_STATIC, - "Fades a sound out from a specific start time and with a specific length." + M_aud_Sound_fadeout_doc }, {"loop", (PyCFunction)Sound_loop, METH_VARARGS | METH_STATIC, - "Loops a sound a specific amount of times, negative values mean endlessly." + M_aud_Sound_loop_doc }, {"superpose", (PyCFunction)Sound_superpose, METH_VARARGS | METH_STATIC, - "Mixes two sounds of the same specs." + M_aud_Sound_superpose_doc }, {"pingpong", (PyCFunction)Sound_pingpong, METH_O | METH_STATIC, - "Plays a sound forward and then backward." + M_aud_Sound_pingpong_doc }, {"reverse", (PyCFunction)Sound_reverse, METH_O | METH_STATIC, - "Plays a sound reversed." + M_aud_Sound_reverse_doc }, {"buffer", (PyCFunction)Sound_buffer, METH_O | METH_STATIC, - "Buffers a sound into RAM." + M_aud_Sound_buffer_doc }, {"square", (PyCFunction)Sound_square, METH_VARARGS | METH_STATIC, - "Makes a square wave out of an audio wave depending on a threshold value." + M_aud_Sound_square_doc }, {NULL} /* Sentinel */ }; @@ -440,51 +491,6 @@ } static PyObject * -Sound_superpose(PyObject* nothing, PyObject* args) -{ - PyObject* object1; - PyObject* object2; - - if(!PyArg_ParseTuple(args, "OO", &object1, &object2)) - return NULL; - - if(!PyObject_TypeCheck(object1, &SoundType)) - { - PyErr_SetString(PyExc_TypeError, "First object is not of type aud.Sound!"); - return NULL; - } - - if(!PyObject_TypeCheck(object2, &SoundType)) - { - PyErr_SetString(PyExc_TypeError, "Second object is not of type aud.Sound!"); - return NULL; - } - - Sound *self; - Sound *child1 = (Sound*)object1; - Sound *child2 = (Sound*)object2; - - self = (Sound*)SoundType.tp_alloc(&SoundType, 0); - if(self != NULL) - { - self->child_list = Py_BuildValue("(OO)", object1, object2); - - try - { - self->factory = new AUD_SuperposeFactory(child1->factory, child2->factory); - } - catch(AUD_Exception&) - { - Py_DECREF(self); - PyErr_SetString(AUDError, "Superposefactory couldn't be created!"); - return NULL; - } - } - - return (PyObject *)self; -} - -static PyObject * Sound_highpass(PyObject* nothing, PyObject* args) { float frequency; @@ -641,12 +647,12 @@ } static PyObject * -Sound_square(PyObject* nothing, PyObject* args) +Sound_fadein(PyObject* nothing, PyObject* args) { - float threshold; + float start, length; PyObject* object; - if(!PyArg_ParseTuple(args, "Of", &object, &threshold)) + if(!PyArg_ParseTuple(args, "Off", &object, &start, &length)) return NULL; if(!PyObject_TypeCheck(object, &SoundType)) @@ -666,12 +672,12 @@ try { - self->factory = new AUD_SquareFactory(child->factory, threshold); + self->factory = new AUD_FaderFactory(child->factory, AUD_FADE_IN, start, length); } catch(AUD_Exception&) { Py_DECREF(self); - PyErr_SetString(AUDError, "Squarefactory couldn't be created!"); + PyErr_SetString(AUDError, "Faderfactory couldn't be created!"); return NULL; } } @@ -680,7 +686,7 @@ } static PyObject * -Sound_fadein(PyObject* nothing, PyObject* args) +Sound_fadeout(PyObject* nothing, PyObject* args) { float start, length; PyObject* object; @@ -705,7 +711,7 @@ try { - self->factory = new AUD_FaderFactory(child->factory, AUD_FADE_IN, start, length); + self->factory = new AUD_FaderFactory(child->factory, AUD_FADE_OUT, start, length); } catch(AUD_Exception&) { @@ -719,12 +725,12 @@ } static PyObject * -Sound_fadeout(PyObject* nothing, PyObject* args) +Sound_loop(PyObject* nothing, PyObject* args) { - float start, length; + int loop; PyObject* object; - if(!PyArg_ParseTuple(args, "Off", &object, &start, &length)) + if(!PyArg_ParseTuple(args, "Oi", &object, &loop)) return NULL; if(!PyObject_TypeCheck(object, &SoundType)) @@ -744,12 +750,12 @@ try { - self->factory = new AUD_FaderFactory(child->factory, AUD_FADE_OUT, start, length); + self->factory = new AUD_LoopFactory(child->factory, loop); } catch(AUD_Exception&) { Py_DECREF(self); - PyErr_SetString(AUDError, "Faderfactory couldn't be created!"); + PyErr_SetString(AUDError, "Loopfactory couldn't be created!"); return NULL; } } @@ -758,37 +764,43 @@ } static PyObject * -Sound_loop(PyObject* nothing, PyObject* args) +Sound_superpose(PyObject* nothing, PyObject* args) { - int loop; - PyObject* object; + PyObject* object1; + PyObject* object2; - if(!PyArg_ParseTuple(args, "Oi", &object, &loop)) + if(!PyArg_ParseTuple(args, "OO", &object1, &object2)) return NULL; - if(!PyObject_TypeCheck(object, &SoundType)) + if(!PyObject_TypeCheck(object1, &SoundType)) { - PyErr_SetString(PyExc_TypeError, "Object is not of type aud.Sound!"); + PyErr_SetString(PyExc_TypeError, "First object is not of type aud.Sound!"); return NULL; } + if(!PyObject_TypeCheck(object2, &SoundType)) + { + PyErr_SetString(PyExc_TypeError, "Second object is not of type aud.Sound!"); + return NULL; + } + Sound *self; - Sound *child = (Sound*)object; + Sound *child1 = (Sound*)object1; + Sound *child2 = (Sound*)object2; self = (Sound*)SoundType.tp_alloc(&SoundType, 0); if(self != NULL) { - Py_INCREF(object); - self->child_list = object; + self->child_list = Py_BuildValue("(OO)", object1, object2); try { - self->factory = new AUD_LoopFactory(child->factory, loop); + self->factory = new AUD_SuperposeFactory(child1->factory, child2->factory); } catch(AUD_Exception&) { Py_DECREF(self); - PyErr_SetString(AUDError, "Loopfactory couldn't be created!"); @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs