Permalink
Browse files

module with correct name and function

  • Loading branch information...
1 parent 1da35a9 commit 2525abe899d09922029aeb7e10a055a88c329668 @andrewrk committed May 15, 2010
View
@@ -1,2 +1,3 @@
*.swp
*.pyc
+build/
View
@@ -0,0 +1,57 @@
+#include "Python.h"
+
+static PyObject *
+cwaveform_draw(self, args, keywds)
+ PyObject *self; /* Not used */
+ PyObject *args;
+ PyObject *keywds;
+{
+ // arg list
+ char * inAudioFile;
+ char * outImageFile;
+ long imageWidth;
+ long imageHeight;
+ char bgColorRed;
+ char bgColorGreen;
+ char bgColorBlue;
+ char bgColorAlpha;
+ char fgColorRed;
+ char fgColorGreen;
+ char fgColorBlue;
+ char fgColorAlpha;
+ char cheat; //bool
+
+ // get arguments
+ if (!PyArg_ParseTuple(args, "ssllbbbbbbbbb",
+ &inAudioFile, &outImageFile, &imageWidth, &imageHeight,
+ &bgColorRed, &bgColorGreen, &bgColorBlue, &bgColorAlpha,
+ &fgColorRed, &fgColorGreen, &fgColorBlue, &fgColorAlpha,
+ &cheat))
+ {
+ return NULL;
+ }
+
+ // no return value
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+/* List of functions defined in the module */
+
+static PyMethodDef cwaveform_methods[] = {
+ {"draw", cwaveform_draw, METH_VARARGS|METH_KEYWORDS},
+ {NULL, NULL} /* sentinel */
+};
+
+
+/* Initialization function for the module (*must* be called initcwaveform) */
+
+DL_EXPORT(void)
+initcwaveform()
+{
+ PyObject *m, *d;
+
+ /* Create the module and add the functions */
+ m = Py_InitModule("cwaveform", cwaveform_methods);
+}
File renamed without changes.
File renamed without changes.
File renamed without changes.
View
@@ -0,0 +1,19 @@
+from distutils.core import setup, Extension
+
+cwaveform = Extension(
+ 'cwaveformmodule',
+ sources = [
+ 'cwaveformmodule.c',
+ ]
+)
+
+setup(
+ name='waveform',
+ version='0.1',
+ author="Andrew Kelley",
+ author_email="superjoe30@gmail.com",
+ description='Create an image of the waveform of an audio file.',
+ py_modules=["waveform"],
+ ext_modules=[cwaveform],
+)
+
View
@@ -0,0 +1,7 @@
+import cwaveform
+
+def draw(inAudioFile, outImageFile, (imageWidth, imageHeight), bgColor=(0, 0, 0, 0), fgColor=(0, 0, 0, 255), cheat=False):
+ return cwaveform.draw(inAudioFile, outImageFile, imageWidth, imageHeight,
+ bgColor[0], bgColor[1], bgColor[2], bgColor[3],
+ fgColor[0], fgColor[1], fgColor[2], fgColor[3],
+ cheat)

0 comments on commit 2525abe

Please sign in to comment.