comparison PyPlugin.cpp @ 7:a4c955e9a70b

* housekeeping: VAMP -> Vamp throughout (not an acronym)
author cannam
date Wed, 11 Jun 2008 16:04:52 +0000
parents e1b508f2f914
children 3af6b5990ad8
comparison
equal deleted inserted replaced
6:e1b508f2f914 7:a4c955e9a70b
33 */ 33 */
34 34
35 35
36 36
37 /** 37 /**
38 * This VAMP plugin is a wrapper for Python Scripts. (vampy) 38 * This Vamp plugin is a wrapper for Python Scripts. (vampy)
39 * Centre for Digital Music, Queen Mary, University of London. 39 * Centre for Digital Music, Queen Mary, University of London.
40 * Copyright 2008, George Fazekas. 40 * Copyright 2008, George Fazekas.
41 41
42 TODO: needs more complete error checking 42 TODO: needs more complete error checking
43 needs correct implementation of Python threading 43 needs correct implementation of Python threading
44 more efficient data conversion using the buffering interface or ctypes 44 more efficient data conversion using the buffering interface or ctypes
45 VAMP programs not implemented 45 Vamp programs not implemented
46 support multiple plugins per script in scanner 46 support multiple plugins per script in scanner
47 ensure proper cleanup, host do a good job though 47 ensure proper cleanup, host do a good job though
48 48
49 */ 49 */
50 50
513 PyObject *pyDict, *pyKey, *pyValue; 513 PyObject *pyDict, *pyKey, *pyValue;
514 514
515 //Parse Output List 515 //Parse Output List
516 for (Py_ssize_t i = 0; i < PyList_GET_SIZE(pyList); ++i) { 516 for (Py_ssize_t i = 0; i < PyList_GET_SIZE(pyList); ++i) {
517 517
518 //Get i-th VAMP output descriptor (Borrowed Reference) 518 //Get i-th Vamp output descriptor (Borrowed Reference)
519 pyDict = PyList_GET_ITEM(pyList,i); 519 pyDict = PyList_GET_ITEM(pyList,i);
520 520
521 //We only care about dictionaries holding output descriptors 521 //We only care about dictionaries holding output descriptors
522 if ( !PyDict_Check(pyDict) ) continue; 522 if ( !PyDict_Check(pyDict) ) continue;
523 523
528 while (PyDict_Next(pyDict, &pyPos, &pyKey, &pyValue)) 528 while (PyDict_Next(pyDict, &pyPos, &pyKey, &pyValue))
529 { 529 {
530 switch (outKeys[PyString_AsString(pyKey)]) 530 switch (outKeys[PyString_AsString(pyKey)])
531 { 531 {
532 case not_found : 532 case not_found :
533 cerr << "Unknown key in VAMP OutputDescriptor: " << PyString_AsString(pyKey) << endl; 533 cerr << "Unknown key in Vamp OutputDescriptor: " << PyString_AsString(pyKey) << endl;
534 break; 534 break;
535 case identifier: 535 case identifier:
536 od.identifier = PyString_AsString(pyValue); 536 od.identifier = PyString_AsString(pyValue);
537 break; 537 break;
538 case name: 538 case name:
573 break; 573 break;
574 case sampleRate: 574 case sampleRate:
575 od.sampleRate = (float) PyFloat_AS_DOUBLE(pyValue); 575 od.sampleRate = (float) PyFloat_AS_DOUBLE(pyValue);
576 break; 576 break;
577 default : 577 default :
578 cerr << "Invalid key in VAMP OutputDescriptor: " << PyString_AsString(pyKey) << endl; 578 cerr << "Invalid key in Vamp OutputDescriptor: " << PyString_AsString(pyKey) << endl;
579 } 579 }
580 } // while dict 580 } // while dict
581 list.push_back(od); 581 list.push_back(od);
582 } // for list 582 } // for list
583 Py_CLEAR(pyList); 583 Py_CLEAR(pyList);
614 PyObject *pyDict, *pyKey, *pyValue; 614 PyObject *pyDict, *pyKey, *pyValue;
615 615
616 //Parse Output List 616 //Parse Output List
617 for (Py_ssize_t i = 0; i < PyList_GET_SIZE(pyList); ++i) { 617 for (Py_ssize_t i = 0; i < PyList_GET_SIZE(pyList); ++i) {
618 618
619 //Get i-th VAMP output descriptor (Borrowed Reference) 619 //Get i-th Vamp output descriptor (Borrowed Reference)
620 pyDict = PyList_GET_ITEM(pyList,i); 620 pyDict = PyList_GET_ITEM(pyList,i);
621 621
622 //We only care about dictionaries holding output descriptors 622 //We only care about dictionaries holding output descriptors
623 if ( !PyDict_Check(pyDict) ) continue; 623 if ( !PyDict_Check(pyDict) ) continue;
624 624
629 while (PyDict_Next(pyDict, &pyPos, &pyKey, &pyValue)) 629 while (PyDict_Next(pyDict, &pyPos, &pyKey, &pyValue))
630 { 630 {
631 switch (parmKeys[PyString_AsString(pyKey)]) 631 switch (parmKeys[PyString_AsString(pyKey)])
632 { 632 {
633 case not_found : 633 case not_found :
634 cerr << "Unknown key in VAMP OutputDescriptor: " << PyString_AsString(pyKey) << endl; 634 cerr << "Unknown key in Vamp OutputDescriptor: " << PyString_AsString(pyKey) << endl;
635 break; 635 break;
636 case p::identifier: 636 case p::identifier:
637 pd.identifier = PyString_AsString(pyValue); 637 pd.identifier = PyString_AsString(pyValue);
638 break; 638 break;
639 case p::name: 639 case p::name:
656 break; 656 break;
657 case p::isQuantized: 657 case p::isQuantized:
658 pd.isQuantized = (bool) PyInt_AS_LONG(pyValue); 658 pd.isQuantized = (bool) PyInt_AS_LONG(pyValue);
659 break; 659 break;
660 default : 660 default :
661 cerr << "Invalid key in VAMP OutputDescriptor: " << PyString_AsString(pyKey) << endl; 661 cerr << "Invalid key in Vamp OutputDescriptor: " << PyString_AsString(pyKey) << endl;
662 } 662 }
663 } // while dict 663 } // while dict
664 list.push_back(pd); 664 list.push_back(pd);
665 } // for list 665 } // for list
666 Py_CLEAR(pyList); 666 Py_CLEAR(pyList);
862 { 862 {
863 emptyFeature = false; 863 emptyFeature = false;
864 switch (ffKeys[PyString_AsString(pyKey)]) 864 switch (ffKeys[PyString_AsString(pyKey)])
865 { 865 {
866 case not_found : 866 case not_found :
867 cerr << "Unknown key in VAMP FeatureSet: " 867 cerr << "Unknown key in Vamp FeatureSet: "
868 << PyString_AsString(pyKey) << endl; 868 << PyString_AsString(pyKey) << endl;
869 break; 869 break;
870 case hasTimestamp: 870 case hasTimestamp:
871 feature.hasTimestamp = (bool) PyInt_AS_LONG(pyValue); 871 feature.hasTimestamp = (bool) PyInt_AS_LONG(pyValue);
872 break; 872 break;
880 break; 880 break;
881 case label: 881 case label:
882 feature.label = PyString_AsString(pyValue); 882 feature.label = PyString_AsString(pyValue);
883 break; 883 break;
884 default : 884 default :
885 cerr << "Invalid key in VAMP FeatureSet: " 885 cerr << "Invalid key in Vamp FeatureSet: "
886 << PyString_AsString(pyKey) << endl; 886 << PyString_AsString(pyKey) << endl;
887 } // switch 887 } // switch
888 888
889 } // while 889 } // while
890 if (emptyFeature) cerr << "Warning: This feature is empty or badly formatted." << endl; 890 if (emptyFeature) cerr << "Warning: This feature is empty or badly formatted." << endl;
954 { 954 {
955 emptyFeature = false; 955 emptyFeature = false;
956 switch (ffKeys[PyString_AsString(pyKey)]) 956 switch (ffKeys[PyString_AsString(pyKey)])
957 { 957 {
958 case not_found : 958 case not_found :
959 cerr << "Unknown key in VAMP FeatureSet: " 959 cerr << "Unknown key in Vamp FeatureSet: "
960 << PyString_AsString(pyKey) << endl; 960 << PyString_AsString(pyKey) << endl;
961 break; 961 break;
962 case hasTimestamp: 962 case hasTimestamp:
963 feature.hasTimestamp = (bool) PyInt_AS_LONG(pyValue); 963 feature.hasTimestamp = (bool) PyInt_AS_LONG(pyValue);
964 break; 964 break;