Mercurial > hg > vampy-host
comparison native/PyPluginObject.cpp @ 80:de501b7e165a
naming: PyPluginObject methods snake_case
author | Chris Cannam |
---|---|
date | Wed, 21 Jan 2015 12:31:32 +0000 |
parents | ee7542afa98e |
children | 0a2f2e7803ea |
comparison
equal
deleted
inserted
replaced
79:650f0697812f | 80:de501b7e165a |
---|---|
169 delete self->plugin; | 169 delete self->plugin; |
170 PyObject_Del(self); | 170 PyObject_Del(self); |
171 } | 171 } |
172 | 172 |
173 static PyObject * | 173 static PyObject * |
174 getOutputs(PyObject *self, PyObject *args) | 174 get_outputs(PyObject *self, PyObject *args) |
175 { | 175 { |
176 PyPluginObject *pd = getPluginObject(self); | 176 PyPluginObject *pd = getPluginObject(self); |
177 if (!pd) return 0; | 177 if (!pd) return 0; |
178 Plugin::OutputList ol = pd->plugin->getOutputDescriptors(); | 178 Plugin::OutputList ol = pd->plugin->getOutputDescriptors(); |
179 PyObject *outputs = PyList_New(ol.size()); | 179 PyObject *outputs = PyList_New(ol.size()); |
283 } | 283 } |
284 return false; | 284 return false; |
285 } | 285 } |
286 | 286 |
287 static PyObject * | 287 static PyObject * |
288 getParameterValue(PyObject *self, PyObject *args) | 288 get_parameter_value(PyObject *self, PyObject *args) |
289 { | 289 { |
290 PyObject *pyParam; | 290 PyObject *pyParam; |
291 | 291 |
292 if (!PyArg_ParseTuple(args, "S", &pyParam)) { | 292 if (!PyArg_ParseTuple(args, "S", &pyParam)) { |
293 PyErr_SetString(PyExc_TypeError, | 293 PyErr_SetString(PyExc_TypeError, |
294 "getParameterValue() takes parameter id (string) argument"); | 294 "get_parameter_value() takes parameter id (string) argument"); |
295 return 0; } | 295 return 0; } |
296 | 296 |
297 PyPluginObject *pd = getPluginObject(self); | 297 PyPluginObject *pd = getPluginObject(self); |
298 if (!pd) return 0; | 298 if (!pd) return 0; |
299 | 299 |
308 float value = pd->plugin->getParameter(param); | 308 float value = pd->plugin->getParameter(param); |
309 return PyFloat_FromDouble(double(value)); | 309 return PyFloat_FromDouble(double(value)); |
310 } | 310 } |
311 | 311 |
312 static PyObject * | 312 static PyObject * |
313 setParameterValue(PyObject *self, PyObject *args) | 313 set_parameter_value(PyObject *self, PyObject *args) |
314 { | 314 { |
315 PyObject *pyParam; | 315 PyObject *pyParam; |
316 float value; | 316 float value; |
317 | 317 |
318 if (!PyArg_ParseTuple(args, "Sf", &pyParam, &value)) { | 318 if (!PyArg_ParseTuple(args, "Sf", &pyParam, &value)) { |
319 PyErr_SetString(PyExc_TypeError, | 319 PyErr_SetString(PyExc_TypeError, |
320 "setParameterValue() takes parameter id (string), and value (float) arguments"); | 320 "set_parameter_value() takes parameter id (string), and value (float) arguments"); |
321 return 0; } | 321 return 0; } |
322 | 322 |
323 PyPluginObject *pd = getPluginObject(self); | 323 PyPluginObject *pd = getPluginObject(self); |
324 if (!pd) return 0; | 324 if (!pd) return 0; |
325 | 325 |
334 pd->plugin->setParameter(param, value); | 334 pd->plugin->setParameter(param, value); |
335 return Py_True; | 335 return Py_True; |
336 } | 336 } |
337 | 337 |
338 static PyObject * | 338 static PyObject * |
339 setParameterValues(PyObject *self, PyObject *args) | 339 set_parameter_values(PyObject *self, PyObject *args) |
340 { | 340 { |
341 PyObject *dict; | 341 PyObject *dict; |
342 | 342 |
343 if (!PyArg_ParseTuple(args, "O", &dict)) { | 343 if (!PyArg_ParseTuple(args, "O", &dict)) { |
344 PyErr_SetString(PyExc_TypeError, | 344 PyErr_SetString(PyExc_TypeError, |
345 "setParameterValues() takes dict argument"); | 345 "set_parameter_values() takes dict argument"); |
346 return 0; } | 346 return 0; } |
347 | 347 |
348 if (!PyDict_Check(dict)) { | 348 if (!PyDict_Check(dict)) { |
349 PyErr_SetString(PyExc_TypeError, | 349 PyErr_SetString(PyExc_TypeError, |
350 "setParameterValues() takes dict argument"); | 350 "set_parameter_values() takes dict argument"); |
351 return 0; } | 351 return 0; } |
352 | 352 |
353 PyPluginObject *pd = getPluginObject(self); | 353 PyPluginObject *pd = getPluginObject(self); |
354 if (!pd) return 0; | 354 if (!pd) return 0; |
355 | 355 |
383 | 383 |
384 return Py_True; | 384 return Py_True; |
385 } | 385 } |
386 | 386 |
387 static PyObject * | 387 static PyObject * |
388 selectProgram(PyObject *self, PyObject *args) | 388 select_program(PyObject *self, PyObject *args) |
389 { | 389 { |
390 PyObject *pyParam; | 390 PyObject *pyParam; |
391 | 391 |
392 if (!PyArg_ParseTuple(args, "S", &pyParam)) { | 392 if (!PyArg_ParseTuple(args, "S", &pyParam)) { |
393 PyErr_SetString(PyExc_TypeError, | 393 PyErr_SetString(PyExc_TypeError, |
394 "selectProgram() takes parameter id (string) argument"); | 394 "select_program() takes parameter id (string) argument"); |
395 return 0; } | 395 return 0; } |
396 | 396 |
397 PyPluginObject *pd = getPluginObject(self); | 397 PyPluginObject *pd = getPluginObject(self); |
398 if (!pd) return 0; | 398 if (!pd) return 0; |
399 | 399 |
507 | 507 |
508 return data; | 508 return data; |
509 } | 509 } |
510 | 510 |
511 static PyObject * | 511 static PyObject * |
512 processBlock(PyObject *self, PyObject *args) | 512 process_block(PyObject *self, PyObject *args) |
513 { | 513 { |
514 PyObject *pyBuffer; | 514 PyObject *pyBuffer; |
515 PyObject *pyRealTime; | 515 PyObject *pyRealTime; |
516 | 516 |
517 if (!PyArg_ParseTuple(args, "OO", | 517 if (!PyArg_ParseTuple(args, "OO", |
518 &pyBuffer, // Audio data | 518 &pyBuffer, // Audio data |
519 &pyRealTime)) { // TimeStamp | 519 &pyRealTime)) { // TimeStamp |
520 PyErr_SetString(PyExc_TypeError, | 520 PyErr_SetString(PyExc_TypeError, |
521 "processBlock() takes buffer (2D array or list of arrays, one row per channel) and timestamp (RealTime) arguments"); | 521 "process_block() takes buffer (2D array or list of arrays, one row per channel) and timestamp (RealTime) arguments"); |
522 return 0; } | 522 return 0; } |
523 | 523 |
524 if (!PyRealTime_Check(pyRealTime)) { | 524 if (!PyRealTime_Check(pyRealTime)) { |
525 PyErr_SetString(PyExc_TypeError, "Valid timestamp required."); | 525 PyErr_SetString(PyExc_TypeError, "Valid timestamp required."); |
526 return 0; } | 526 return 0; } |
549 | 549 |
550 return convertFeatureSet(fs); | 550 return convertFeatureSet(fs); |
551 } | 551 } |
552 | 552 |
553 static PyObject * | 553 static PyObject * |
554 getRemainingFeatures(PyObject *self, PyObject *) | 554 get_remaining_features(PyObject *self, PyObject *) |
555 { | 555 { |
556 PyPluginObject *pd = getPluginObject(self); | 556 PyPluginObject *pd = getPluginObject(self); |
557 if (!pd) return 0; | 557 if (!pd) return 0; |
558 | 558 |
559 if (!pd->isInitialised) { | 559 if (!pd->isInitialised) { |
566 | 566 |
567 return convertFeatureSet(fs); | 567 return convertFeatureSet(fs); |
568 } | 568 } |
569 | 569 |
570 static PyObject * | 570 static PyObject * |
571 getPreferredBlockSize(PyObject *self, PyObject *) | 571 get_preferred_block_size(PyObject *self, PyObject *) |
572 { | 572 { |
573 PyPluginObject *pd = getPluginObject(self); | 573 PyPluginObject *pd = getPluginObject(self); |
574 if (!pd) return 0; | 574 if (!pd) return 0; |
575 return PyInt_FromLong(pd->plugin->getPreferredBlockSize()); | 575 return PyInt_FromLong(pd->plugin->getPreferredBlockSize()); |
576 } | 576 } |
577 | 577 |
578 static PyObject * | 578 static PyObject * |
579 getPreferredStepSize(PyObject *self, PyObject *) | 579 get_preferred_step_size(PyObject *self, PyObject *) |
580 { | 580 { |
581 PyPluginObject *pd = getPluginObject(self); | 581 PyPluginObject *pd = getPluginObject(self); |
582 if (!pd) return 0; | 582 if (!pd) return 0; |
583 return PyInt_FromLong(pd->plugin->getPreferredStepSize()); | 583 return PyInt_FromLong(pd->plugin->getPreferredStepSize()); |
584 } | 584 } |
585 | 585 |
586 static PyObject * | 586 static PyObject * |
587 getMinChannelCount(PyObject *self, PyObject *) | 587 get_min_channel_count(PyObject *self, PyObject *) |
588 { | 588 { |
589 PyPluginObject *pd = getPluginObject(self); | 589 PyPluginObject *pd = getPluginObject(self); |
590 if (!pd) return 0; | 590 if (!pd) return 0; |
591 return PyInt_FromLong(pd->plugin->getMinChannelCount()); | 591 return PyInt_FromLong(pd->plugin->getMinChannelCount()); |
592 } | 592 } |
593 | 593 |
594 static PyObject * | 594 static PyObject * |
595 getMaxChannelCount(PyObject *self, PyObject *) | 595 get_max_channel_count(PyObject *self, PyObject *) |
596 { | 596 { |
597 PyPluginObject *pd = getPluginObject(self); | 597 PyPluginObject *pd = getPluginObject(self); |
598 if (!pd) return 0; | 598 if (!pd) return 0; |
599 return PyInt_FromLong(pd->plugin->getMaxChannelCount()); | 599 return PyInt_FromLong(pd->plugin->getMaxChannelCount()); |
600 } | 600 } |
629 {0, 0} | 629 {0, 0} |
630 }; | 630 }; |
631 | 631 |
632 static PyMethodDef PyPluginObject_methods[] = | 632 static PyMethodDef PyPluginObject_methods[] = |
633 { | 633 { |
634 {"getOutputs", getOutputs, METH_NOARGS, | 634 {"get_outputs", get_outputs, METH_NOARGS, |
635 "getOutputs() -> Obtain the output descriptors for all of the plugin's outputs."}, | 635 "get_outputs() -> Obtain the output descriptors for all of the plugin's outputs."}, |
636 | 636 |
637 {"getParameterValue", getParameterValue, METH_VARARGS, | 637 {"get_parameter_value", get_parameter_value, METH_VARARGS, |
638 "getParameterValue(identifier) -> Return the value of the parameter with the given identifier."}, | 638 "get_parameter_value(identifier) -> Return the value of the parameter with the given identifier."}, |
639 | 639 |
640 {"setParameterValue", setParameterValue, METH_VARARGS, | 640 {"set_parameter_value", set_parameter_value, METH_VARARGS, |
641 "setParameterValue(identifier, value) -> Set the parameter with the given identifier to the given value."}, | 641 "set_parameter_value(identifier, value) -> Set the parameter with the given identifier to the given value."}, |
642 | 642 |
643 {"setParameterValues", setParameterValues, METH_VARARGS, | 643 {"set_parameter_values", set_parameter_values, METH_VARARGS, |
644 "setParameterValues(dict) -> Set multiple parameters to values corresponding to the key/value pairs in the dict. Any parameters not mentioned in the dict are unchanged."}, | 644 "set_parameter_values(dict) -> Set multiple parameters to values corresponding to the key/value pairs in the dict. Any parameters not mentioned in the dict are unchanged."}, |
645 | 645 |
646 {"selectProgram", selectProgram, METH_VARARGS, | 646 {"select_program", select_program, METH_VARARGS, |
647 "selectProgram(name) -> Select the processing program with the given name."}, | 647 "select_program(name) -> Select the processing program with the given name."}, |
648 | 648 |
649 {"getPreferredBlockSize", getPreferredBlockSize, METH_VARARGS, | 649 {"get_preferred_block_size", get_preferred_block_size, METH_VARARGS, |
650 "getPreferredBlockSize() -> Return the plugin's preferred processing block size, or 0 if the plugin accepts any block size."}, | 650 "get_preferred_block_size() -> Return the plugin's preferred processing block size, or 0 if the plugin accepts any block size."}, |
651 | 651 |
652 {"getPreferredStepSize", getPreferredStepSize, METH_VARARGS, | 652 {"get_preferred_step_size", get_preferred_step_size, METH_VARARGS, |
653 "getPreferredStepSize() -> Return the plugin's preferred processing step size, or 0 if the plugin allows the host to select. If this is 0, the host should normally choose the same step as block size for time-domain plugins, or half the block size for frequency-domain plugins."}, | 653 "get_preferred_step_size() -> Return the plugin's preferred processing step size, or 0 if the plugin allows the host to select. If this is 0, the host should normally choose the same step as block size for time-domain plugins, or half the block size for frequency-domain plugins."}, |
654 | 654 |
655 {"getMinChannelCount", getMinChannelCount, METH_VARARGS, | 655 {"get_min_channel_count", get_min_channel_count, METH_VARARGS, |
656 "getMinChannelCount() -> Return the minimum number of channels of audio data the plugin accepts as input."}, | 656 "get_min_channel_count() -> Return the minimum number of channels of audio data the plugin accepts as input."}, |
657 | 657 |
658 {"getMaxChannelCount", getMaxChannelCount, METH_VARARGS, | 658 {"get_max_channel_count", get_max_channel_count, METH_VARARGS, |
659 "getMaxChannelCount() -> Return the maximum number of channels of audio data the plugin accepts as input."}, | 659 "get_max_channel_count() -> Return the maximum number of channels of audio data the plugin accepts as input."}, |
660 | 660 |
661 {"initialise", initialise, METH_VARARGS, | 661 {"initialise", initialise, METH_VARARGS, |
662 "initialise(channels, stepSize, blockSize) -> Initialise the plugin for the given number of channels and processing frame sizes. This must be called before processBlock() can be used."}, | 662 "initialise(channels, stepSize, blockSize) -> Initialise the plugin for the given number of channels and processing frame sizes. This must be called before process_block() can be used."}, |
663 | 663 |
664 {"reset", reset, METH_NOARGS, | 664 {"reset", reset, METH_NOARGS, |
665 "reset() -> Reset the plugin after processing, to prepare for another processing run with the same parameters."}, | 665 "reset() -> Reset the plugin after processing, to prepare for another processing run with the same parameters."}, |
666 | 666 |
667 {"processBlock", processBlock, METH_VARARGS, | 667 {"process_block", process_block, METH_VARARGS, |
668 "processBlock(block, timestamp) -> Provide one processing frame to the plugin, with its timestamp, and obtain any features that were extracted immediately from this frame."}, | 668 "process_block(block, timestamp) -> Provide one processing frame to the plugin, with its timestamp, and obtain any features that were extracted immediately from this frame."}, |
669 | 669 |
670 {"getRemainingFeatures", getRemainingFeatures, METH_NOARGS, | 670 {"get_remaining_features", get_remaining_features, METH_NOARGS, |
671 "getRemainingFeatures() -> Obtain any features extracted at the end of processing."}, | 671 "get_remaining_features() -> Obtain any features extracted at the end of processing."}, |
672 | 672 |
673 {"unload", unload, METH_NOARGS, | 673 {"unload", unload, METH_NOARGS, |
674 "unload() -> Dispose of the plugin. You cannot use the plugin object again after calling this. Note that unloading also happens automatically when the plugin object's reference count reaches zero; this function is only necessary if you wish to ensure the native part of the plugin is disposed of before then."}, | 674 "unload() -> Dispose of the plugin. You cannot use the plugin object again after calling this. Note that unloading also happens automatically when the plugin object's reference count reaches zero; this function is only necessary if you wish to ensure the native part of the plugin is disposed of before then."}, |
675 | 675 |
676 {0, 0} | 676 {0, 0} |