diff options
author | Joerg Mueller <nexyon@gmail.com> | 2010-07-26 15:17:43 +0400 |
---|---|---|
committer | Joerg Mueller <nexyon@gmail.com> | 2010-07-26 15:17:43 +0400 |
commit | 3e3f874a65e9c20353fdc26a20a2f5da9b41e90e (patch) | |
tree | 0467c417b328c459b79e9d928d8ed5e1d1ac6cf9 /intern/audaspace | |
parent | 409b79c5c44a112e53dd63fc83032f1408552fb4 (diff) |
Audaspace Py API:
* Renamed get_c_device() to device()
* Made the threshold parameter of Sound.square() optional
* Added a sample rate parameter for Sound.sine()
* Example updates
Diffstat (limited to 'intern/audaspace')
-rw-r--r-- | intern/audaspace/Python/AUD_PyAPI.cpp | 15 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_C-API.cpp | 10 |
2 files changed, 14 insertions, 11 deletions
diff --git a/intern/audaspace/Python/AUD_PyAPI.cpp b/intern/audaspace/Python/AUD_PyAPI.cpp index 010d5a7394f..f1c41bf2009 100644 --- a/intern/audaspace/Python/AUD_PyAPI.cpp +++ b/intern/audaspace/Python/AUD_PyAPI.cpp @@ -118,10 +118,12 @@ Sound_new(PyTypeObject *type, PyObject *args, PyObject *kwds) } PyDoc_STRVAR(M_aud_Sound_sine_doc, - "sine(frequency)\n\n" + "sine(frequency[, rate])\n\n" "Creates a sine sound wave.\n\n" ":arg frequency: The frequency of the sine wave in Hz.\n" ":type frequency: float\n" + ":arg rate: The sampling rate in Hz.\n" + ":type rate: int\n" ":return: The created aud.Sound object.\n" ":rtype: aud.Sound"); @@ -310,7 +312,7 @@ static PyObject * Sound_buffer(Sound* self); PyDoc_STRVAR(M_aud_Sound_square_doc, - "squre(threshold)\n\n" + "squre([threshold = 0])\n\n" "Makes a square wave out of an audio wave.\n\n" ":arg threshold: Threshold value over which an amplitude counts non-zero.\n" ":type threshold: float\n" @@ -424,8 +426,9 @@ static PyObject * Sound_sine(PyObject* nothing, PyObject* args) { double frequency; + int rate = 44100; - if(!PyArg_ParseTuple(args, "d", &frequency)) + if(!PyArg_ParseTuple(args, "d|i", &frequency, &rate)) return NULL; Sound *self; @@ -435,7 +438,7 @@ Sound_sine(PyObject* nothing, PyObject* args) { try { - self->factory = new AUD_SinusFactory(frequency, (AUD_SampleRate)44100); + self->factory = new AUD_SinusFactory(frequency, (AUD_SampleRate)rate); } catch(AUD_Exception&) { @@ -889,9 +892,9 @@ Sound_buffer(Sound* self) static PyObject * Sound_square(Sound* self, PyObject* args) { - float threshold; + float threshold = 0; - if(!PyArg_ParseTuple(args, "f", &threshold)) + if(!PyArg_ParseTuple(args, "|f", &threshold)) return NULL; Sound *parent = (Sound*)SoundType.tp_alloc(&SoundType, 0); diff --git a/intern/audaspace/intern/AUD_C-API.cpp b/intern/audaspace/intern/AUD_C-API.cpp index b0225109f3a..eb0e4fba8e9 100644 --- a/intern/audaspace/intern/AUD_C-API.cpp +++ b/intern/audaspace/intern/AUD_C-API.cpp @@ -204,16 +204,16 @@ static PyObject* AUD_getCDevice(PyObject* self) Py_RETURN_NONE; } -static PyMethodDef meth_getcdevice[] = {{ "get_c_device", (PyCFunction)AUD_getCDevice, METH_NOARGS, - "get_c_device()\n\n" - "Returns the C API Device.\n\n" - ":return: The C API Device.\n" +static PyMethodDef meth_getcdevice[] = {{ "device", (PyCFunction)AUD_getCDevice, METH_NOARGS, + "device()\n\n" + "Returns the application's Device.\n\n" + ":return: The application's Device.\n" ":rtype: aud.Device"}}; PyObject* AUD_initPython() { PyObject* module = PyInit_aud(); - PyModule_AddObject(module, "get_c_device", (PyObject *)PyCFunction_New(meth_getcdevice, NULL)); + PyModule_AddObject(module, "device", (PyObject *)PyCFunction_New(meth_getcdevice, NULL)); PyDict_SetItemString(PySys_GetObject("modules"), "aud", module); if(AUD_device) { |