Mercurial > hg > vampy-host
diff PyPluginObject.cpp @ 41:55fcd0e3e513
Fix handling of 2D NumPy arrays
author | Chris Cannam |
---|---|
date | Wed, 26 Nov 2014 18:08:53 +0000 |
parents | fa3f80d4e340 |
children | 9dd449a19004 |
line wrap: on
line diff
--- a/PyPluginObject.cpp Wed Nov 26 15:58:46 2014 +0000 +++ b/PyPluginObject.cpp Wed Nov 26 18:08:53 2014 +0000 @@ -392,6 +392,12 @@ return data; } + if ((int)data.size() != channels) { +// cerr << "Wrong number of channels: got " << data.size() << ", expected " << channels << endl; + PyErr_SetString(PyExc_TypeError, "Wrong number of channels"); + return vector<vector<float> >(); + } + } else { if (!PyList_Check(pyBuffer)) { @@ -400,7 +406,7 @@ } if (PyList_GET_SIZE(pyBuffer) != channels) { - cerr << "Wrong number of channels: got " << PyList_GET_SIZE(pyBuffer) << ", expected " << channels << endl; +// cerr << "Wrong number of channels: got " << PyList_GET_SIZE(pyBuffer) << ", expected " << channels << endl; PyErr_SetString(PyExc_TypeError, "Wrong number of channels"); return data; } @@ -409,13 +415,13 @@ PyObject *cbuf = PyList_GET_ITEM(pyBuffer, c); data.push_back(conv.PyValue_To_FloatVector(cbuf)); } + } - for (int c = 0; c < channels; ++c) { - if ((int)data[c].size() != blockSize) { - cerr << "Wrong number of samples on channel " << c << ": expected " << blockSize << " (plugin's block size), got " << data[c].size() << endl; - PyErr_SetString(PyExc_TypeError, "Wrong number of samples"); - return vector<vector<float> >(); - } + for (int c = 0; c < channels; ++c) { + if ((int)data[c].size() != blockSize) { +// cerr << "Wrong number of samples on channel " << c << ": expected " << blockSize << " (plugin's block size), got " << data[c].size() << endl; + PyErr_SetString(PyExc_TypeError, "Wrong number of samples"); + return vector<vector<float> >(); } }