illume avatar illume committed 0996a28

Fixed a bug where garbage collection after an Input or Output are closed would cause an error. Also many code style clean ups and documentation added.

Thanks Christopher Arndt!

Comments (0)

Files changed (2)

-/* Generated by Cython 0.11.2 on Mon Jun  1 16:21:31 2009 */
+/* Generated by Cython 0.11.2 on Fri Mar  4 09:48:56 2011 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
 static INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
 static INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
 
+static INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
+
+static INLINE void __Pyx_RaiseTooManyValuesError(void);
+
+static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t index); /*proto*/
+static int __Pyx_EndUnpack(PyObject *); /*proto*/
+
 static INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
     if (likely(PyList_CheckExact(L))) {
         if (PyList_Append(L, x) < 0) return NULL;
 
 /* Type declarations */
 
-/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":201
- *     return Pm_Channel(chan-1)
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":248
+ * 
  * 
  * cdef class Output:             # <<<<<<<<<<<<<<
- *     """
- * class Output:
+ *     """Represents an output MIDI stream device.
+ * 
  */
 
 struct __pyx_obj_4pypm_Output {
   PyObject_HEAD
-  int i;
+  int device;
   PmStream *midi;
   int debug;
   int _aborted;
 };
 
-/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":394
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":509
  * 
  * 
  * cdef class Input:             # <<<<<<<<<<<<<<
- *     """
- * class Input:
+ *     """Represents an input MIDI stream device.
+ * 
  */
 
 struct __pyx_obj_4pypm_Input {
   PyObject_HEAD
+  int device;
   PmStream *midi;
   int debug;
-  int i;
 };
 /* Module declarations from pypm */
 
 int __pyx_module_is_main_pypm = 0;
 
 /* Implementation of pypm */
-static char __pyx_k_3[] = "0.05";
+static char __pyx_k_3[] = "0.0.6";
 static PyObject *__pyx_int_0x1;
 static PyObject *__pyx_int_0x2;
 static PyObject *__pyx_int_0x4;
 static PyObject *__pyx_kp_Poll;
 static char __pyx_k_Read[] = "Read";
 static PyObject *__pyx_kp_Read;
-static char __pyx_k_i[] = "i";
-static PyObject *__pyx_kp_i;
+static char __pyx_k_device_no[] = "device_no";
+static PyObject *__pyx_kp_device_no;
 static char __pyx_k_err[] = "err";
 static PyObject *__pyx_kp_err;
 static char __pyx_k_chan[] = "chan";
 static PyObject *__pyx_kp_chan;
-static char __pyx_k_OutputDevice[] = "OutputDevice";
-static PyObject *__pyx_kp_OutputDevice;
+static char __pyx_k_output_device[] = "output_device";
+static PyObject *__pyx_kp_output_device;
 static char __pyx_k_latency[] = "latency";
 static PyObject *__pyx_kp_latency;
 static char __pyx_k_data[] = "data";
 static PyObject *__pyx_kp_when;
 static char __pyx_k_msg[] = "msg";
 static PyObject *__pyx_kp_msg;
-static char __pyx_k_InputDevice[] = "InputDevice";
-static PyObject *__pyx_kp_InputDevice;
+static char __pyx_k_input_device[] = "input_device";
+static PyObject *__pyx_kp_input_device;
 static char __pyx_k_buffersize[] = "buffersize";
 static PyObject *__pyx_kp_buffersize;
 static char __pyx_k_filters[] = "filters";
 static PyObject *__pyx_kp_filters;
 static char __pyx_k_mask[] = "mask";
 static PyObject *__pyx_kp_mask;
-static char __pyx_k_length[] = "length";
-static PyObject *__pyx_kp_length;
+static char __pyx_k_max_events[] = "max_events";
+static PyObject *__pyx_kp_max_events;
 static char __pyx_k___version__[] = "__version__";
 static PyObject *__pyx_kp___version__;
 static char __pyx_k_array[] = "array";
 static PyObject *__pyx_kp_Exception;
 static char __pyx_k_IndexError[] = "IndexError";
 static PyObject *__pyx_kp_IndexError;
+static char __pyx_k_enumerate[] = "enumerate";
+static PyObject *__pyx_kp_enumerate;
+static char __pyx_k_ValueError[] = "ValueError";
+static PyObject *__pyx_kp_ValueError;
 static char __pyx_k_range[] = "range";
 static PyObject *__pyx_kp_range;
-static char __pyx_k_19[] = "B";
-static PyObject *__pyx_kp_19;
+static char __pyx_k_18[] = "B";
+static PyObject *__pyx_kp_18;
 static char __pyx_k_tostring[] = "tostring";
 static PyObject *__pyx_kp_tostring;
 static char __pyx_k_append[] = "append";
 static PyObject *__pyx_kp_3;
 static PyObject *__pyx_builtin_Exception;
 static PyObject *__pyx_builtin_IndexError;
+static PyObject *__pyx_builtin_enumerate;
+static PyObject *__pyx_builtin_ValueError;
 static PyObject *__pyx_builtin_range;
 static PyObject *__pyx_kp_7;
 static PyObject *__pyx_kp_8;
+static char __pyx_k_7[] = "Opening Midi Output";
+static char __pyx_k_8[] = "Unable to open Midi OutputDevice=%i: %s";
 static PyObject *__pyx_kp_9;
-static char __pyx_k_7[] = "Opening Midi Output";
-static char __pyx_k_8[] = "Unable to open Midi OutputDevice=";
-static char __pyx_k_9[] = " err=";
+static char __pyx_k_9[] = "Closing MIDI output stream and destroying instance.";
 static PyObject *__pyx_kp_10;
-static char __pyx_k_10[] = "Closing MIDI output stream and destroying instance";
 static PyObject *__pyx_kp_11;
+static char __pyx_k_10[] = "midi Output not open.";
+static char __pyx_k_11[] = "midi Output aborted. Need to call Close after Abort.";
 static PyObject *__pyx_kp_12;
-static char __pyx_k_11[] = "midi Output not open.";
-static char __pyx_k_12[] = "midi Output aborted.  Need to call Close after Abort.";
 static PyObject *__pyx_kp_13;
 static PyObject *__pyx_kp_14;
 static PyObject *__pyx_kp_15;
 static PyObject *__pyx_kp_16;
+static char __pyx_k_12[] = "Maximum event list length is 1024.";
+static char __pyx_k_13[] = "No data in event no. %i.";
+static char __pyx_k_14[] = "Too many data bytes (%i) in event no. %i.";
+static char __pyx_k_15[] = "%i : %r : %s";
+static char __pyx_k_16[] = "Writing to midi buffer.";
 static PyObject *__pyx_kp_17;
-static char __pyx_k_13[] = "maximum list length is 1024";
-static char __pyx_k_14[] = " arguments in event list";
-static char __pyx_k_15[] = " : ";
-static char __pyx_k_16[] = " : ";
-static char __pyx_k_17[] = "writing to midi buffer";
-static PyObject *__pyx_kp_18;
-static char __pyx_k_18[] = "Writing to MIDI buffer";
+static char __pyx_k_17[] = "Writing to MIDI buffer.";
+static PyObject *__pyx_kp_19;
+static char __pyx_k_19[] = "MIDI input opened.";
 static PyObject *__pyx_kp_20;
-static char __pyx_k_20[] = "MIDI input opened.";
+static char __pyx_k_20[] = "Closing MIDI input stream and destroying instance";
 static PyObject *__pyx_kp_21;
-static char __pyx_k_21[] = "Closing MIDI input stream and destroying instance";
+static char __pyx_k_21[] = "midi Input not open.";
 static PyObject *__pyx_kp_22;
-static char __pyx_k_22[] = "midi Input not open.";
 static PyObject *__pyx_kp_23;
-static PyObject *__pyx_kp_24;
-static char __pyx_k_23[] = "maximum buffer length is 1024";
-static char __pyx_k_24[] = "minimum buffer length is 1";
-
-/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":132
- * TRUE=1
+static char __pyx_k_22[] = "Maximum buffer length is 1024.";
+static char __pyx_k_23[] = "Minimum buffer length is 1.";
+
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":149
+ * 
  * 
  * def Initialize():             # <<<<<<<<<<<<<<
- *     """
- * Initialize: call this first
+ *     """Initialize PortMidi library.
+ * 
  */
 
 static PyObject *__pyx_pf_4pypm_Initialize(PyObject *__pyx_self, PyObject *unused); /*proto*/
-static char __pyx_doc_4pypm_Initialize[] = "\nInitialize: call this first\n    ";
+static char __pyx_doc_4pypm_Initialize[] = "Initialize PortMidi library.\n\n    This function must be called once before any other function or class from\n    this module can be used.\n\n    ";
 static PyObject *__pyx_pf_4pypm_Initialize(PyObject *__pyx_self, PyObject *unused) {
   PyObject *__pyx_r = NULL;
   __Pyx_SetupRefcountContext("Initialize");
   __pyx_self = __pyx_self;
 
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":136
- * Initialize: call this first
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":156
+ * 
  *     """
  *     Pm_Initialize()             # <<<<<<<<<<<<<<
- *     Pt_Start(1, NULL, NULL) # /[inserted by cython to avoid comment start]* equiv to TIME_START: start timer w/ ms accuracy *[inserted by cython to avoid comment closer]/
- * 
+ *     # equiv to TIME_START: start timer w/ ms accuracy
+ *     Pt_Start(1, NULL, NULL)
  */
   Pm_Initialize();
 
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":137
- *     """
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":158
  *     Pm_Initialize()
- *     Pt_Start(1, NULL, NULL) # /[inserted by cython to avoid comment start]* equiv to TIME_START: start timer w/ ms accuracy *[inserted by cython to avoid comment closer]/             # <<<<<<<<<<<<<<
+ *     # equiv to TIME_START: start timer w/ ms accuracy
+ *     Pt_Start(1, NULL, NULL)             # <<<<<<<<<<<<<<
  * 
  * def Terminate():
  */
   return __pyx_r;
 }
 
-/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":139
- *     Pt_Start(1, NULL, NULL) # /[inserted by cython to avoid comment start]* equiv to TIME_START: start timer w/ ms accuracy *[inserted by cython to avoid comment closer]/
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":160
+ *     Pt_Start(1, NULL, NULL)
  * 
  * def Terminate():             # <<<<<<<<<<<<<<
- *     """
- * Terminate: call this to clean up Midi streams when done.
+ *     """Terminate use of PortMidi library.
+ * 
  */
 
 static PyObject *__pyx_pf_4pypm_Terminate(PyObject *__pyx_self, PyObject *unused); /*proto*/
-static char __pyx_doc_4pypm_Terminate[] = "\nTerminate: call this to clean up Midi streams when done.\nIf you do not call this on Windows machines when you are\ndone with MIDI, your system may crash.\n    ";
+static char __pyx_doc_4pypm_Terminate[] = "Terminate use of PortMidi library.\n\n    Call this to clean up Midi streams when done.\n\n    If you do not call this on Windows machines when you are done with MIDI,\n    your system may crash.\n\n    ";
 static PyObject *__pyx_pf_4pypm_Terminate(PyObject *__pyx_self, PyObject *unused) {
   PyObject *__pyx_r = NULL;
   __Pyx_SetupRefcountContext("Terminate");
   __pyx_self = __pyx_self;
 
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":145
- * done with MIDI, your system may crash.
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":169
+ * 
  *     """
  *     Pm_Terminate()             # <<<<<<<<<<<<<<
  * 
   return __pyx_r;
 }
 
-/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":147
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":171
  *     Pm_Terminate()
  * 
  * def GetDefaultInputDeviceID():             # <<<<<<<<<<<<<<
- *     return Pm_GetDefaultInputDeviceID()
+ *     """Return the number of the default MIDI input device.
  * 
  */
 
 static PyObject *__pyx_pf_4pypm_GetDefaultInputDeviceID(PyObject *__pyx_self, PyObject *unused); /*proto*/
+static char __pyx_doc_4pypm_GetDefaultInputDeviceID[] = "Return the number of the default MIDI input device.\n\n    See the PortMidi documentation on how the default device is set and\n    determined.\n\n    ";
 static PyObject *__pyx_pf_4pypm_GetDefaultInputDeviceID(PyObject *__pyx_self, PyObject *unused) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   __Pyx_SetupRefcountContext("GetDefaultInputDeviceID");
   __pyx_self = __pyx_self;
 
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":148
- * 
- * def GetDefaultInputDeviceID():
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":178
+ * 
+ *     """
  *     return Pm_GetDefaultInputDeviceID()             # <<<<<<<<<<<<<<
  * 
  * def GetDefaultOutputDeviceID():
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(Pm_GetDefaultInputDeviceID()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(Pm_GetDefaultInputDeviceID()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
   return __pyx_r;
 }
 
-/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":150
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":180
  *     return Pm_GetDefaultInputDeviceID()
  * 
  * def GetDefaultOutputDeviceID():             # <<<<<<<<<<<<<<
- *     return Pm_GetDefaultOutputDeviceID()
+ *     """Return the number of the default MIDI output device.
  * 
  */
 
 static PyObject *__pyx_pf_4pypm_GetDefaultOutputDeviceID(PyObject *__pyx_self, PyObject *unused); /*proto*/
+static char __pyx_doc_4pypm_GetDefaultOutputDeviceID[] = "Return the number of the default MIDI output device.\n\n    See the PortMidi documentation on how the default device is set and\n    determined.\n\n    ";
 static PyObject *__pyx_pf_4pypm_GetDefaultOutputDeviceID(PyObject *__pyx_self, PyObject *unused) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   __Pyx_SetupRefcountContext("GetDefaultOutputDeviceID");
   __pyx_self = __pyx_self;
 
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":151
- * 
- * def GetDefaultOutputDeviceID():
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":187
+ * 
+ *     """
  *     return Pm_GetDefaultOutputDeviceID()             # <<<<<<<<<<<<<<
  * 
  * def CountDevices():
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(Pm_GetDefaultOutputDeviceID()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(Pm_GetDefaultOutputDeviceID()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
   return __pyx_r;
 }
 
-/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":153
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":189
  *     return Pm_GetDefaultOutputDeviceID()
  * 
  * def CountDevices():             # <<<<<<<<<<<<<<
- *     return Pm_CountDevices()
+ *     """Return number of available MIDI (input and output) devices."""
  * 
  */
 
 static PyObject *__pyx_pf_4pypm_CountDevices(PyObject *__pyx_self, PyObject *unused); /*proto*/
+static char __pyx_doc_4pypm_CountDevices[] = "Return number of available MIDI (input and output) devices.";
 static PyObject *__pyx_pf_4pypm_CountDevices(PyObject *__pyx_self, PyObject *unused) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   __Pyx_SetupRefcountContext("CountDevices");
   __pyx_self = __pyx_self;
 
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":154
- * 
- * def CountDevices():
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":192
+ *     """Return number of available MIDI (input and output) devices."""
+ * 
  *     return Pm_CountDevices()             # <<<<<<<<<<<<<<
  * 
- * def GetDeviceInfo(i):
+ * def GetDeviceInfo(device_no):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(Pm_CountDevices()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(Pm_CountDevices()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
   return __pyx_r;
 }
 
-/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":156
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":194
  *     return Pm_CountDevices()
  * 
- * def GetDeviceInfo(i):             # <<<<<<<<<<<<<<
- *     """
- * GetDeviceInfo(<device number>): returns 5 parameters
- */
-
-static PyObject *__pyx_pf_4pypm_GetDeviceInfo(PyObject *__pyx_self, PyObject *__pyx_v_i); /*proto*/
-static char __pyx_doc_4pypm_GetDeviceInfo[] = "\nGetDeviceInfo(<device number>): returns 5 parameters\n  - underlying MIDI API\n  - device name\n  - TRUE iff input is available\n  - TRUE iff output is available\n  - TRUE iff device stream is already open\n    ";
-static PyObject *__pyx_pf_4pypm_GetDeviceInfo(PyObject *__pyx_self, PyObject *__pyx_v_i) {
+ * def GetDeviceInfo(device_no):             # <<<<<<<<<<<<<<
+ *     """Return device info tuple for MIDI device given by device_no.
+ * 
+ */
+
+static PyObject *__pyx_pf_4pypm_GetDeviceInfo(PyObject *__pyx_self, PyObject *__pyx_v_device_no); /*proto*/
+static char __pyx_doc_4pypm_GetDeviceInfo[] = "Return device info tuple for MIDI device given by device_no.\n\n    The returned tuple has the following five items:\n\n    * underlying MIDI API (string)\n    * device name (string)\n    * whether device can be opened as input (1) or not (0)\n    * whether device can be opened as output (1) or not (0)\n    * whether device is currently opened (1) or not (0)\n\n    ";
+static PyObject *__pyx_pf_4pypm_GetDeviceInfo(PyObject *__pyx_self, PyObject *__pyx_v_device_no) {
   PmDeviceInfo *__pyx_v_info;
   PyObject *__pyx_r = NULL;
   PmDeviceID __pyx_t_1;
   __Pyx_SetupRefcountContext("GetDeviceInfo");
   __pyx_self = __pyx_self;
 
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":168
- * 
- *     # disregarding the constness from Pm_GetDeviceInfo, since pyrex doesn't do const.
- *     info = <PmDeviceInfo *>Pm_GetDeviceInfo(i)             # <<<<<<<<<<<<<<
- * 
- *     if info <> NULL: return info.interf, info.name, info.input, info.output, info.opened
- */
-  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_i); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":210
+ *     # disregarding the constness from Pm_GetDeviceInfo,
+ *     # since pyrex doesn't do const.
+ *     info = <PmDeviceInfo *>Pm_GetDeviceInfo(device_no)             # <<<<<<<<<<<<<<
+ * 
+ *     if info != NULL:
+ */
+  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_device_no); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_info = ((PmDeviceInfo *)Pm_GetDeviceInfo(__pyx_t_1));
 
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":170
- *     info = <PmDeviceInfo *>Pm_GetDeviceInfo(i)
- * 
- *     if info <> NULL: return info.interf, info.name, info.input, info.output, info.opened             # <<<<<<<<<<<<<<
- *     else: return
- * 
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":212
+ *     info = <PmDeviceInfo *>Pm_GetDeviceInfo(device_no)
+ * 
+ *     if info != NULL:             # <<<<<<<<<<<<<<
+ *         return info.interf, info.name, info.input, info.output, info.opened
+ *     # return None
  */
   __pyx_t_2 = (__pyx_v_info != NULL);
   if (__pyx_t_2) {
+
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":213
+ * 
+ *     if info != NULL:
+ *         return info.interf, info.name, info.input, info.output, info.opened             # <<<<<<<<<<<<<<
+ *     # return None
+ * 
+ */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_info->interf); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_info->interf); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_info->name); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_info->name); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_5 = PyInt_FromLong(__pyx_v_info->input); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyInt_FromLong(__pyx_v_info->input); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
-    __pyx_t_6 = PyInt_FromLong(__pyx_v_info->output); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyInt_FromLong(__pyx_v_info->output); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_7 = PyInt_FromLong(__pyx_v_info->opened); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyInt_FromLong(__pyx_v_info->opened); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
-    __pyx_t_8 = PyTuple_New(5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyTuple_New(5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_8));
     PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3);
     __Pyx_GIVEREF(__pyx_t_3);
     goto __pyx_L0;
     goto __pyx_L5;
   }
-  /*else*/ {
-
-    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":171
- * 
- *     if info <> NULL: return info.interf, info.name, info.input, info.output, info.opened
- *     else: return             # <<<<<<<<<<<<<<
- * 
- * def Time():
- */
-    __Pyx_XDECREF(__pyx_r);
-    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
-    goto __pyx_L0;
-  }
   __pyx_L5:;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   return __pyx_r;
 }
 
-/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":173
- *     else: return
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":216
+ *     # return None
  * 
  * def Time():             # <<<<<<<<<<<<<<
- *     """
- * Time() returns the current time in ms
+ *     """Return the current time in ms of the PortMidi timer."""
+ * 
  */
 
 static PyObject *__pyx_pf_4pypm_Time(PyObject *__pyx_self, PyObject *unused); /*proto*/
-static char __pyx_doc_4pypm_Time[] = "\nTime() returns the current time in ms\nof the PortMidi timer\n    ";
+static char __pyx_doc_4pypm_Time[] = "Return the current time in ms of the PortMidi timer.";
 static PyObject *__pyx_pf_4pypm_Time(PyObject *__pyx_self, PyObject *unused) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   __Pyx_SetupRefcountContext("Time");
   __pyx_self = __pyx_self;
 
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":178
- * of the PortMidi timer
- *     """
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":219
+ *     """Return the current time in ms of the PortMidi timer."""
+ * 
  *     return Pt_Time()             # <<<<<<<<<<<<<<
  * 
  * def GetErrorText(err):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(Pt_Time()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(Pt_Time()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
   return __pyx_r;
 }
 
-/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":180
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":221
  *     return Pt_Time()
  * 
  * def GetErrorText(err):             # <<<<<<<<<<<<<<
- *     """
- * GetErrorText(<err num>) returns human-readable error
+ *     """Return human-readable error message translated from error number."""
+ * 
  */
 
 static PyObject *__pyx_pf_4pypm_GetErrorText(PyObject *__pyx_self, PyObject *__pyx_v_err); /*proto*/
-static char __pyx_doc_4pypm_GetErrorText[] = "\nGetErrorText(<err num>) returns human-readable error\nmessages translated from error numbers\n    ";
+static char __pyx_doc_4pypm_GetErrorText[] = "Return human-readable error message translated from error number.";
 static PyObject *__pyx_pf_4pypm_GetErrorText(PyObject *__pyx_self, PyObject *__pyx_v_err) {
   PyObject *__pyx_r = NULL;
   PmError __pyx_t_1;
   __Pyx_SetupRefcountContext("GetErrorText");
   __pyx_self = __pyx_self;
 
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":185
- * messages translated from error numbers
- *     """
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":224
+ *     """Return human-readable error message translated from error number."""
+ * 
  *     return Pm_GetErrorText(err)             # <<<<<<<<<<<<<<
  * 
  * def Channel(chan):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = ((PmError)PyInt_AsLong(__pyx_v_err)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_2 = __Pyx_PyBytes_FromString(Pm_GetErrorText(__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((PmError)PyInt_AsLong(__pyx_v_err)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyBytes_FromString(Pm_GetErrorText(__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
   return __pyx_r;
 }
 
-/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":187
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":226
  *     return Pm_GetErrorText(err)
  * 
  * def Channel(chan):             # <<<<<<<<<<<<<<
- *     """
- * Channel(<chan>) is used with ChannelMask on input MIDI streams.
+ *     """Return Channel object for given MIDI channel number 1 - 16.
+ * 
  */
 
 static PyObject *__pyx_pf_4pypm_Channel(PyObject *__pyx_self, PyObject *__pyx_v_chan); /*proto*/
-static char __pyx_doc_4pypm_Channel[] = "\nChannel(<chan>) is used with ChannelMask on input MIDI streams.\nExample: to receive input on channels 1 and 10 on a MIDI\n         stream called MidiIn:\nMidiIn.SetChannelMask(pypm.Channel(1) | pypm.Channel(10))\n\nnote: PyPortMidi Channel function has been altered from\n      the original PortMidi c call to correct for what\n      seems to be a bug --- i.e. channel filters were\n      all numbered from 0 to 15 instead of 1 to 16.\n    ";
+static char __pyx_doc_4pypm_Channel[] = "Return Channel object for given MIDI channel number 1 - 16.\n\n    Channel(<chan>) is used with ChannelMask on input MIDI streams.\n\n    Example:\n\n    To receive input on channels 1 and 10 on a MIDI stream called\n    MidiIn::\n\n        MidiIn.SetChannelMask(pypm.Channel(1) | pypm.Channel(10))\n\n    .. note::\n        PyPortMidi Channel function has been altered from\n        the original PortMidi c call to correct for what\n        seems to be a bug --- i.e. channel filters were\n        all numbered from 0 to 15 instead of 1 to 16.\n\n    ";
 static PyObject *__pyx_pf_4pypm_Channel(PyObject *__pyx_self, PyObject *__pyx_v_chan) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   __Pyx_SetupRefcountContext("Channel");
   __pyx_self = __pyx_self;
 
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":199
- *       all numbered from 0 to 15 instead of 1 to 16.
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":245
+ * 
  *     """
- *     return Pm_Channel(chan-1)             # <<<<<<<<<<<<<<
- * 
- * cdef class Output:
+ *     return Pm_Channel(chan - 1)             # <<<<<<<<<<<<<<
+ * 
+ * 
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyNumber_Subtract(__pyx_v_chan, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyNumber_Subtract(__pyx_v_chan, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyInt_FromLong(Pm_Channel(__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(Pm_Channel(__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
   return __pyx_r;
 }
 
-/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":214
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":263
  *     cdef int _aborted
  * 
- *     def __init__(self, OutputDevice, latency=0):             # <<<<<<<<<<<<<<
- * 
- *         cdef PmError err
+ *     def __init__(self, output_device, latency=0):             # <<<<<<<<<<<<<<
+ *         """Instantiate MIDI output stream object."""
+ * 
  */
 
 static int __pyx_pf_4pypm_6Output___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_4pypm_6Output___init__[] = "Instantiate MIDI output stream object.";
 static int __pyx_pf_4pypm_6Output___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
-  PyObject *__pyx_v_OutputDevice = 0;
+  PyObject *__pyx_v_output_device = 0;
   PyObject *__pyx_v_latency = 0;
   PmError __pyx_v_err;
   PmTimeProcPtr __pyx_v_PmPtr;
-  PyObject *__pyx_v_s;
+  PyObject *__pyx_v_errmsg;
   int __pyx_r;
   int __pyx_t_1;
   PyObject *__pyx_t_2 = NULL;
   int __pyx_t_3;
-  long __pyx_t_4;
-  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_OutputDevice,&__pyx_kp_latency,0};
+  PmDeviceID __pyx_t_4;
+  long __pyx_t_5;
+  PyObject *__pyx_t_6 = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_output_device,&__pyx_kp_latency,0};
   __Pyx_SetupRefcountContext("__init__");
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     }
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  0:
-      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_OutputDevice);
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_output_device);
       if (likely(values[0])) kw_args--;
       else goto __pyx_L5_argtuple_error;
       case  1:
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
-    __pyx_v_OutputDevice = values[0];
+    __pyx_v_output_device = values[0];
     __pyx_v_latency = values[1];
   } else {
     __pyx_v_latency = __pyx_int_0;
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  2: __pyx_v_latency = PyTuple_GET_ITEM(__pyx_args, 1);
-      case  1: __pyx_v_OutputDevice = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  1: __pyx_v_output_device = PyTuple_GET_ITEM(__pyx_args, 0);
       break;
       default: goto __pyx_L5_argtuple_error;
     }
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("pypm.Output.__init__");
   return -1;
   __pyx_L4_argument_unpacking_done:;
-  __pyx_v_s = Py_None; __Pyx_INCREF(Py_None);
-
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":220
+  __pyx_v_errmsg = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":270
  *         cdef PmTimeProcPtr PmPtr
  * 
- *         self.i = OutputDevice             # <<<<<<<<<<<<<<
+ *         self.device = output_device             # <<<<<<<<<<<<<<
  *         self.debug = 0
  *         self._aborted = 0
  */
-  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_OutputDevice); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  ((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->i = __pyx_t_1;
-
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":221
- * 
- *         self.i = OutputDevice
+  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_output_device); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  ((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->device = __pyx_t_1;
+
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":271
+ * 
+ *         self.device = output_device
  *         self.debug = 0             # <<<<<<<<<<<<<<
  *         self._aborted = 0
  * 
  */
   ((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->debug = 0;
 
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":222
- *         self.i = OutputDevice
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":272
+ *         self.device = output_device
  *         self.debug = 0
  *         self._aborted = 0             # <<<<<<<<<<<<<<
  * 
  */
   ((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->_aborted = 0;
 
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":224
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":274
  *         self._aborted = 0
  * 
  *         if latency == 0:             # <<<<<<<<<<<<<<
  *             PmPtr = NULL
  *         else:
  */
-  __pyx_t_2 = PyObject_RichCompare(__pyx_v_latency, __pyx_int_0, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_RichCompare(__pyx_v_latency, __pyx_int_0, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (__pyx_t_3) {
 
-    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":225
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":275
  * 
  *         if latency == 0:
  *             PmPtr = NULL             # <<<<<<<<<<<<<<
   }
   /*else*/ {
 
-    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":227
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":277
  *             PmPtr = NULL
  *         else:
  *             PmPtr = <PmTimeProcPtr>&Pt_Time             # <<<<<<<<<<<<<<
- *         if self.debug: print "Opening Midi Output"
- * 	# Why is bufferSize 0 here?
+ * 
+ *         if self.debug:
  */
     __pyx_v_PmPtr = ((PmTimestamp (*)(void *))(&Pt_Time));
   }
   __pyx_L6:;
 
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":228
- *         else:
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":279
  *             PmPtr = <PmTimeProcPtr>&Pt_Time
- *         if self.debug: print "Opening Midi Output"             # <<<<<<<<<<<<<<
- * 	# Why is bufferSize 0 here?
- *         err = Pm_OpenOutput(&(self.midi), self.i, NULL, 0, PmPtr, NULL, latency)
+ * 
+ *         if self.debug:             # <<<<<<<<<<<<<<
+ *             print "Opening Midi Output"
+ * 
  */
   __pyx_t_1 = ((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->debug;
   if (__pyx_t_1) {
-    if (__Pyx_PrintOne(__pyx_kp_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":280
+ * 
+ *         if self.debug:
+ *             print "Opening Midi Output"             # <<<<<<<<<<<<<<
+ * 
+ *         # Why is buffer size 0 here?
+ */
+    if (__Pyx_PrintOne(__pyx_kp_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L7;
   }
   __pyx_L7:;
 
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":230
- *         if self.debug: print "Opening Midi Output"
- * 	# Why is bufferSize 0 here?
- *         err = Pm_OpenOutput(&(self.midi), self.i, NULL, 0, PmPtr, NULL, latency)             # <<<<<<<<<<<<<<
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":283
+ * 
+ *         # Why is buffer size 0 here?
+ *         err = Pm_OpenOutput(&(self.midi), output_device, NULL, 0, PmPtr, NULL,             # <<<<<<<<<<<<<<
+ *                             latency)
  *         if err < 0:
- *                 s = Pm_GetErrorText(err)
- */
-  __pyx_t_4 = __Pyx_PyInt_AsLong(__pyx_v_latency); if (unlikely((__pyx_t_4 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_v_err = Pm_OpenOutput((&((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->midi), ((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->i, NULL, 0, __pyx_v_PmPtr, NULL, __pyx_t_4);
-
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":231
- * 	# Why is bufferSize 0 here?
- *         err = Pm_OpenOutput(&(self.midi), self.i, NULL, 0, PmPtr, NULL, latency)
+ */
+  __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_v_output_device); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":284
+ *         # Why is buffer size 0 here?
+ *         err = Pm_OpenOutput(&(self.midi), output_device, NULL, 0, PmPtr, NULL,
+ *                             latency)             # <<<<<<<<<<<<<<
+ *         if err < 0:
+ *             errmsg = Pm_GetErrorText(err)
+ */
+  __pyx_t_5 = __Pyx_PyInt_AsLong(__pyx_v_latency); if (unlikely((__pyx_t_5 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_err = Pm_OpenOutput((&((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->midi), __pyx_t_4, NULL, 0, __pyx_v_PmPtr, NULL, __pyx_t_5);
+
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":285
+ *         err = Pm_OpenOutput(&(self.midi), output_device, NULL, 0, PmPtr, NULL,
+ *                             latency)
  *         if err < 0:             # <<<<<<<<<<<<<<
- *                 s = Pm_GetErrorText(err)
- *                 # Something's amiss here - if we try to throw an Exception
+ *             errmsg = Pm_GetErrorText(err)
+ *             # Something's amiss here - if we try to throw an Exception
  */
   __pyx_t_3 = (__pyx_v_err < 0);
   if (__pyx_t_3) {
 
-    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":232
- *         err = Pm_OpenOutput(&(self.midi), self.i, NULL, 0, PmPtr, NULL, latency)
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":286
+ *                             latency)
  *         if err < 0:
- *                 s = Pm_GetErrorText(err)             # <<<<<<<<<<<<<<
- *                 # Something's amiss here - if we try to throw an Exception
- *                	# here, we crash.
- */
-    __pyx_t_2 = __Pyx_PyBytes_FromString(Pm_GetErrorText(__pyx_v_err)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ *             errmsg = Pm_GetErrorText(err)             # <<<<<<<<<<<<<<
+ *             # Something's amiss here - if we try to throw an Exception
+ *             # here, we crash.
+ */
+    __pyx_t_2 = __Pyx_PyBytes_FromString(Pm_GetErrorText(__pyx_v_err)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_DECREF(__pyx_v_s);
-    __pyx_v_s = __pyx_t_2;
+    __Pyx_DECREF(__pyx_v_errmsg);
+    __pyx_v_errmsg = __pyx_t_2;
     __pyx_t_2 = 0;
 
-    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":235
- *                 # Something's amiss here - if we try to throw an Exception
- *                	# here, we crash.
- *                 if not err == -10000:             # <<<<<<<<<<<<<<
- *                         raise Exception,s
- *                 else:
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":289
+ *             # Something's amiss here - if we try to throw an Exception
+ *             # here, we crash.
+ *             if not err == -10000:             # <<<<<<<<<<<<<<
+ *                 raise Exception(errmsg)
+ *             else:
  */
     __pyx_t_3 = (!(__pyx_v_err == -10000));
     if (__pyx_t_3) {
 
-      /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":236
- *                	# here, we crash.
- *                 if not err == -10000:
- *                         raise Exception,s             # <<<<<<<<<<<<<<
- *                 else:
- *                         print "Unable to open Midi OutputDevice=",OutputDevice," err=",s
- */
-      __Pyx_Raise(__pyx_builtin_Exception, __pyx_v_s, 0);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":290
+ *             # here, we crash.
+ *             if not err == -10000:
+ *                 raise Exception(errmsg)             # <<<<<<<<<<<<<<
+ *             else:
+ *                 print "Unable to open Midi OutputDevice=%i: %s" % (
+ */
+      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+      __Pyx_INCREF(__pyx_v_errmsg);
+      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_errmsg);
+      __Pyx_GIVEREF(__pyx_v_errmsg);
+      __pyx_t_6 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+      __Pyx_Raise(__pyx_t_6, 0, 0);
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L9;
     }
     /*else*/ {
 
-      /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":238
- *                         raise Exception,s
- *                 else:
- *                         print "Unable to open Midi OutputDevice=",OutputDevice," err=",s             # <<<<<<<<<<<<<<
+      /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":293
+ *             else:
+ *                 print "Unable to open Midi OutputDevice=%i: %s" % (
+ *                     output_device, errmsg)             # <<<<<<<<<<<<<<
  * 
  *     def __dealloc__(self):
  */
-      __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-      __Pyx_INCREF(__pyx_kp_8);
-      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_kp_8);
-      __Pyx_GIVEREF(__pyx_kp_8);
-      __Pyx_INCREF(__pyx_v_OutputDevice);
-      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_OutputDevice);
-      __Pyx_GIVEREF(__pyx_v_OutputDevice);
-      __Pyx_INCREF(__pyx_kp_9);
-      PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_kp_9);
-      __Pyx_GIVEREF(__pyx_kp_9);
-      __Pyx_INCREF(__pyx_v_s);
-      PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_s);
-      __Pyx_GIVEREF(__pyx_v_s);
-      if (__Pyx_Print(((PyObject *)__pyx_t_2), 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+      __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_6));
+      __Pyx_INCREF(__pyx_v_output_device);
+      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_output_device);
+      __Pyx_GIVEREF(__pyx_v_output_device);
+      __Pyx_INCREF(__pyx_v_errmsg);
+      PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_errmsg);
+      __Pyx_GIVEREF(__pyx_v_errmsg);
+      __pyx_t_2 = PyNumber_Remainder(__pyx_kp_8, ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
+      if (__Pyx_PrintOne(__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     }
     __pyx_L9:;
     goto __pyx_L8;
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_6);
   __Pyx_AddTraceback("pypm.Output.__init__");
   __pyx_r = -1;
   __pyx_L0:;
-  __Pyx_DECREF(__pyx_v_s);
+  __Pyx_DECREF(__pyx_v_errmsg);
   __Pyx_FinishRefcountContext();
   return __pyx_r;
 }
 
-/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":240
- *                         print "Unable to open Midi OutputDevice=",OutputDevice," err=",s
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":295
+ *                     output_device, errmsg)
  * 
  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
- *         if self.debug: print "Closing MIDI output stream and destroying instance"
- *         #err = Pm_Abort(self.midi)
+ *         """Close midi device if still open when the instance is destroyed."""
+ * 
  */
 
 static void __pyx_pf_4pypm_6Output___dealloc__(PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_4pypm_6Output___dealloc__[] = "Close midi device if still open when the instance is destroyed.";
 static void __pyx_pf_4pypm_6Output___dealloc__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_v_err;
+  PmError __pyx_v_err;
   int __pyx_t_1;
-  PyObject *__pyx_t_2 = NULL;
-  int __pyx_t_3;
-  PmError __pyx_t_4;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
   __Pyx_SetupRefcountContext("__dealloc__");
-  __pyx_v_err = Py_None; __Pyx_INCREF(Py_None);
-
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":241
- * 
- *     def __dealloc__(self):
- *         if self.debug: print "Closing MIDI output stream and destroying instance"             # <<<<<<<<<<<<<<
- *         #err = Pm_Abort(self.midi)
- *         #if err < 0: raise Exception, Pm_GetErrorText(err)
+
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":300
+ *         cdef PmError err
+ * 
+ *         if self.debug:             # <<<<<<<<<<<<<<
+ *             print "Closing MIDI output stream and destroying instance."
+ * 
  */
   __pyx_t_1 = ((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->debug;
   if (__pyx_t_1) {
-    if (__Pyx_PrintOne(__pyx_kp_10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":301
+ * 
+ *         if self.debug:
+ *             print "Closing MIDI output stream and destroying instance."             # <<<<<<<<<<<<<<
+ * 
+ *         if self.midi:
+ */
+    if (__Pyx_PrintOne(__pyx_kp_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":244
- *         #err = Pm_Abort(self.midi)
- *         #if err < 0: raise Exception, Pm_GetErrorText(err)
- *         err = Pm_Close(self.midi)             # <<<<<<<<<<<<<<
- *         if err < 0: raise Exception, Pm_GetErrorText(err)
- * 
- */
-  __pyx_t_2 = PyInt_FromLong(Pm_Close(((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->midi)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __Pyx_DECREF(__pyx_v_err);
-  __pyx_v_err = __pyx_t_2;
-  __pyx_t_2 = 0;
-
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":245
- *         #if err < 0: raise Exception, Pm_GetErrorText(err)
- *         err = Pm_Close(self.midi)
- *         if err < 0: raise Exception, Pm_GetErrorText(err)             # <<<<<<<<<<<<<<
- * 
- * 
- */
-  __pyx_t_2 = PyObject_RichCompare(__pyx_v_err, __pyx_int_0, Py_LT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  if (__pyx_t_3) {
-    __pyx_t_4 = ((PmError)PyInt_AsLong(__pyx_v_err)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_2 = __Pyx_PyBytes_FromString(Pm_GetErrorText(__pyx_t_4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_builtin_Exception, __pyx_t_2, 0);
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":303
+ *             print "Closing MIDI output stream and destroying instance."
+ * 
+ *         if self.midi:             # <<<<<<<<<<<<<<
+ *             err = Pm_Close(self.midi)
+ *             if err < 0:
+ */
+  __pyx_t_2 = (((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->midi != 0);
+  if (__pyx_t_2) {
+
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":304
+ * 
+ *         if self.midi:
+ *             err = Pm_Close(self.midi)             # <<<<<<<<<<<<<<
+ *             if err < 0:
+ *                 raise Exception(Pm_GetErrorText(err))
+ */
+    __pyx_v_err = Pm_Close(((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->midi);
+
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":305
+ *         if self.midi:
+ *             err = Pm_Close(self.midi)
+ *             if err < 0:             # <<<<<<<<<<<<<<
+ *                 raise Exception(Pm_GetErrorText(err))
+ * 
+ */
+    __pyx_t_2 = (__pyx_v_err < 0);
+    if (__pyx_t_2) {
+
+      /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":306
+ *             err = Pm_Close(self.midi)
+ *             if err < 0:
+ *                 raise Exception(Pm_GetErrorText(err))             # <<<<<<<<<<<<<<
+ * 
+ *     def _check_open(self):
+ */
+      __pyx_t_3 = __Pyx_PyBytes_FromString(Pm_GetErrorText(__pyx_v_err)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
+      __Pyx_GIVEREF(__pyx_t_3);
+      __pyx_t_3 = 0;
+      __pyx_t_3 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
+      __Pyx_Raise(__pyx_t_3, 0, 0);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L7;
+    }
+    __pyx_L7:;
     goto __pyx_L6;
   }
   __pyx_L6:;
 
   goto __pyx_L0;
   __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
   __Pyx_AddTraceback("pypm.Output.__dealloc__");
   __pyx_L0:;
-  __Pyx_DECREF(__pyx_v_err);
   __Pyx_FinishRefcountContext();
 }
 
-/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":248
- * 
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":308
+ *                 raise Exception(Pm_GetErrorText(err))
  * 
  *     def _check_open(self):             # <<<<<<<<<<<<<<
- *         """ checks to see if the midi is open, and if not, raises an error.
- *         """
+ *         """Check whether midi device is open, and if not, raises an error.
+ * 
  */
 
 static PyObject *__pyx_pf_4pypm_6Output__check_open(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
-static char __pyx_doc_4pypm_6Output__check_open[] = " checks to see if the midi is open, and if not, raises an error.\n        ";
+static char __pyx_doc_4pypm_6Output__check_open[] = "Check whether midi device is open, and if not, raises an error.\n\n        Internal method, should be used only by other methods of this class.\n\n        ";
 static PyObject *__pyx_pf_4pypm_6Output__check_open(PyObject *__pyx_v_self, PyObject *unused) {
   PyObject *__pyx_r = NULL;
   int __pyx_t_1;
-  int __pyx_t_2;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
   __Pyx_SetupRefcountContext("_check_open");
 
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":252
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":314
+ * 
  *         """
- * 
  *         if self.midi == NULL:             # <<<<<<<<<<<<<<
- *             raise Exception, "midi Output not open."
+ *             raise Exception("midi Output not open.")
  * 
  */
   __pyx_t_1 = (((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->midi == NULL);
   if (__pyx_t_1) {
 
-    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":253
- * 
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":315
+ *         """
  *         if self.midi == NULL:
- *             raise Exception, "midi Output not open."             # <<<<<<<<<<<<<<
+ *             raise Exception("midi Output not open.")             # <<<<<<<<<<<<<<
  * 
  *         if self._aborted:
  */
-    __Pyx_Raise(__pyx_builtin_Exception, __pyx_kp_11, 0);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    __Pyx_INCREF(__pyx_kp_10);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_kp_10);
+    __Pyx_GIVEREF(__pyx_kp_10);
+    __pyx_t_3 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":255
- *             raise Exception, "midi Output not open."
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":317
+ *             raise Exception("midi Output not open.")
  * 
  *         if self._aborted:             # <<<<<<<<<<<<<<
- *             raise Exception, "midi Output aborted.  Need to call Close after Abort."
- * 
- */
-  __pyx_t_2 = ((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->_aborted;
-  if (__pyx_t_2) {
-
-    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":256
- * 
+ *             raise Exception(
+ *                 "midi Output aborted. Need to call Close after Abort.")
+ */
+  __pyx_t_4 = ((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->_aborted;
+  if (__pyx_t_4) {
+
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":319
  *         if self._aborted:
- *             raise Exception, "midi Output aborted.  Need to call Close after Abort."             # <<<<<<<<<<<<<<
+ *             raise Exception(
+ *                 "midi Output aborted. Need to call Close after Abort.")             # <<<<<<<<<<<<<<
  * 
  *     def Close(self):
  */
-    __Pyx_Raise(__pyx_builtin_Exception, __pyx_kp_12, 0);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+    __Pyx_INCREF(__pyx_kp_11);
+    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_11);
+    __Pyx_GIVEREF(__pyx_kp_11);
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
   __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
   __Pyx_AddTraceback("pypm.Output._check_open");
   __pyx_r = NULL;
   __pyx_L0:;
   return __pyx_r;
 }
 
-/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":258
- *             raise Exception, "midi Output aborted.  Need to call Close after Abort."
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":321
+ *                 "midi Output aborted. Need to call Close after Abort.")
  * 
  *     def Close(self):             # <<<<<<<<<<<<<<
- *         """
- * Close()
+ *         """Close the midi output device, flushing any pending buffers.
+ * 
  */
 
 static PyObject *__pyx_pf_4pypm_6Output_Close(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
-static char __pyx_doc_4pypm_6Output_Close[] = "\nClose()\n    closes a midi stream, flushing any pending buffers.\n    (PortMidi attempts to close open streams when the application\n    exits -- this is particularly difficult under Windows.)\n        ";
+static char __pyx_doc_4pypm_6Output_Close[] = "Close the midi output device, flushing any pending buffers.\n\n        PortMidi attempts to close open streams when the application exits --\n        this is particularly difficult under Windows, so it is best to take\n        care to close all devices explicitly.\n\n        ";
 static PyObject *__pyx_pf_4pypm_6Output_Close(PyObject *__pyx_v_self, PyObject *unused) {
-  PyObject *__pyx_v_err;
+  PmError __pyx_v_err;
   PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  int __pyx_t_2;
-  PmError __pyx_t_3;
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
   __Pyx_SetupRefcountContext("Close");
-  __pyx_v_err = Py_None; __Pyx_INCREF(Py_None);
-
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":268
- *         #    return
- * 
- *         err = Pm_Close(self.midi)             # <<<<<<<<<<<<<<
- *         if err < 0:
- *             raise Exception, Pm_GetErrorText(err)
- */
-  __pyx_t_1 = PyInt_FromLong(Pm_Close(((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->midi)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(__pyx_v_err);
-  __pyx_v_err = __pyx_t_1;
-  __pyx_t_1 = 0;
-
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":269
+
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":331
+ *         cdef PmError err
+ * 
+ *         if not self.midi:             # <<<<<<<<<<<<<<
+ *             return
+ * 
+ */
+  __pyx_t_1 = (!(((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->midi != 0));
+  if (__pyx_t_1) {
+
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":332
+ * 
+ *         if not self.midi:
+ *             return             # <<<<<<<<<<<<<<
  * 
  *         err = Pm_Close(self.midi)
- *         if err < 0:             # <<<<<<<<<<<<<<
- *             raise Exception, Pm_GetErrorText(err)
- *         #self.midi = NULL
- */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_err, __pyx_int_0, Py_LT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (__pyx_t_2) {
-
-    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":270
- *         err = Pm_Close(self.midi)
- *         if err < 0:
- *             raise Exception, Pm_GetErrorText(err)             # <<<<<<<<<<<<<<
- *         #self.midi = NULL
- * 
- */
-    __pyx_t_3 = ((PmError)PyInt_AsLong(__pyx_v_err)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_1 = __Pyx_PyBytes_FromString(Pm_GetErrorText(__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_Raise(__pyx_builtin_Exception, __pyx_t_1, 0);
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+    goto __pyx_L0;
     goto __pyx_L5;
   }
   __pyx_L5:;
 
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":334
+ *             return
+ * 
+ *         err = Pm_Close(self.midi)             # <<<<<<<<<<<<<<
+ *         if err < 0:
+ *             raise Exception(Pm_GetErrorText(err))
+ */
+  __pyx_v_err = Pm_Close(((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->midi);
+
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":335
+ * 
+ *         err = Pm_Close(self.midi)
+ *         if err < 0:             # <<<<<<<<<<<<<<
+ *             raise Exception(Pm_GetErrorText(err))
+ * 
+ */
+  __pyx_t_1 = (__pyx_v_err < 0);
+  if (__pyx_t_1) {
+
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":336
+ *         err = Pm_Close(self.midi)
+ *         if err < 0:
+ *             raise Exception(Pm_GetErrorText(err))             # <<<<<<<<<<<<<<
+ * 
+ *         self.midi = NULL
+ */
+    __pyx_t_2 = __Pyx_PyBytes_FromString(Pm_GetErrorText(__pyx_v_err)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
+    __Pyx_GIVEREF(__pyx_t_2);
+    __pyx_t_2 = 0;
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":338
+ *             raise Exception(Pm_GetErrorText(err))
+ * 
+ *         self.midi = NULL             # <<<<<<<<<<<<<<
+ * 
+ *     def Abort(self):
+ */
+  ((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->midi = NULL;
+
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
   __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
   __Pyx_AddTraceback("pypm.Output.Close");
   __pyx_r = NULL;
   __pyx_L0:;
-  __Pyx_DECREF(__pyx_v_err);
   __Pyx_XGIVEREF(__pyx_r);
   __Pyx_FinishRefcountContext();
   return __pyx_r;
 }
 
-/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":274
- * 
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":340
+ *         self.midi = NULL
  * 
  *     def Abort(self):             # <<<<<<<<<<<<<<
- *         """
- * Abort() terminates outgoing messages immediately
+ *         """Terminate outgoing messages immediately.
+ * 
  */
 
 static PyObject *__pyx_pf_4pypm_6Output_Abort(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
-static char __pyx_doc_4pypm_6Output_Abort[] = "\nAbort() terminates outgoing messages immediately\n    The caller should immediately close the output port;\n    this call may result in transmission of a partial midi message.\n    There is no abort for Midi input because the user can simply\n    ignore messages in the buffer and close an input device at\n    any time.\n        ";
+static char __pyx_doc_4pypm_6Output_Abort[] = "Terminate outgoing messages immediately.\n\n        The caller should immediately close the output port after calling this\n        method. This call may result in transmission of a partial midi message.\n        There is no abort for Midi input because the user can simply ignore\n        messages in the buffer and close an input device at any time.\n\n        ";
 static PyObject *__pyx_pf_4pypm_6Output_Abort(PyObject *__pyx_v_self, PyObject *unused) {
-  PyObject *__pyx_v_err;
+  PmError __pyx_v_err;
   PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  int __pyx_t_2;
-  PmError __pyx_t_3;
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
   __Pyx_SetupRefcountContext("Abort");
-  __pyx_v_err = Py_None; __Pyx_INCREF(Py_None);
-
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":286
- *         #    return
- * 
- *         err = Pm_Abort(self.midi)             # <<<<<<<<<<<<<<
- *         if err < 0:
- *             raise Exception, Pm_GetErrorText(err)
- */
-  __pyx_t_1 = PyInt_FromLong(Pm_Abort(((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->midi)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(__pyx_v_err);
-  __pyx_v_err = __pyx_t_1;
-  __pyx_t_1 = 0;
-
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":287
+
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":351
+ *         cdef PmError err
+ * 
+ *         if not self.midi:             # <<<<<<<<<<<<<<
+ *             return
+ * 
+ */
+  __pyx_t_1 = (!(((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->midi != 0));
+  if (__pyx_t_1) {
+
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":352
+ * 
+ *         if not self.midi:
+ *             return             # <<<<<<<<<<<<<<
  * 
  *         err = Pm_Abort(self.midi)
- *         if err < 0:             # <<<<<<<<<<<<<<
- *             raise Exception, Pm_GetErrorText(err)
- * 
- */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_err, __pyx_int_0, Py_LT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (__pyx_t_2) {
-
-    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":288
- *         err = Pm_Abort(self.midi)
- *         if err < 0:
- *             raise Exception, Pm_GetErrorText(err)             # <<<<<<<<<<<<<<
- * 
- *         self._aborted = 1
- */
-    __pyx_t_3 = ((PmError)PyInt_AsLong(__pyx_v_err)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_1 = __Pyx_PyBytes_FromString(Pm_GetErrorText(__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_Raise(__pyx_builtin_Exception, __pyx_t_1, 0);
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+    goto __pyx_L0;
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":290
- *             raise Exception, Pm_GetErrorText(err)
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":354
+ *             return
+ * 
+ *         err = Pm_Abort(self.midi)             # <<<<<<<<<<<<<<
+ *         if err < 0:
+ *             raise Exception(Pm_GetErrorText(err))
+ */
+  __pyx_v_err = Pm_Abort(((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->midi);
+
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":355
+ * 
+ *         err = Pm_Abort(self.midi)
+ *         if err < 0:             # <<<<<<<<<<<<<<
+ *             raise Exception(Pm_GetErrorText(err))
+ * 
+ */
+  __pyx_t_1 = (__pyx_v_err < 0);
+  if (__pyx_t_1) {
+
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":356
+ *         err = Pm_Abort(self.midi)
+ *         if err < 0:
+ *             raise Exception(Pm_GetErrorText(err))             # <<<<<<<<<<<<<<
+ * 
+ *         self._aborted = 1
+ */
+    __pyx_t_2 = __Pyx_PyBytes_FromString(Pm_GetErrorText(__pyx_v_err)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
+    __Pyx_GIVEREF(__pyx_t_2);
+    __pyx_t_2 = 0;
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":358
+ *             raise Exception(Pm_GetErrorText(err))
  * 
  *         self._aborted = 1             # <<<<<<<<<<<<<<
  * 
- * 
+ *     def Write(self, data):
  */
   ((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->_aborted = 1;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
   __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
   __Pyx_AddTraceback("pypm.Output.Abort");
   __pyx_r = NULL;
   __pyx_L0:;
-  __Pyx_DECREF(__pyx_v_err);
   __Pyx_XGIVEREF(__pyx_r);
   __Pyx_FinishRefcountContext();
   return __pyx_r;
 }
 
-/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":293
- * 
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":360
+ *         self._aborted = 1
  * 
  *     def Write(self, data):             # <<<<<<<<<<<<<<
- *         """
- * Write(data)
+ *         """Output a series of MIDI events given by data list n this device.
+ * 
  */
 
 static PyObject *__pyx_pf_4pypm_6Output_Write(PyObject *__pyx_v_self, PyObject *__pyx_v_data); /*proto*/
-static char __pyx_doc_4pypm_6Output_Write[] = "\nWrite(data)\n    output a series of MIDI information in the form of a list:\n         Write([[[status <,data1><,data2><,data3>],timestamp],\n                [[status <,data1><,data2><,data3>],timestamp],...])\n    <data> fields are optional\n    example: choose program change 1 at time 20000 and\n    send note 65 with velocity 100 500 ms later.\n         Write([[[0xc0,0,0],20000],[[0x90,60,100],20500]])\n    notes:\n      1. timestamps will be ignored if latency = 0.\n      2. To get a note to play immediately, send MIDI info with\n         timestamp read from function Time.\n      3. understanding optional data fields:\n           Write([[[0xc0,0,0],20000]]) is equivalent to\n           Write([[[0xc0],20000]])\n        ";
+static char __pyx_doc_4pypm_6Output_Write[] = "Output a series of MIDI events given by data list n this device.\n\n        Usage::\n\n            Write([\n                [[status, data1, data2, data3], timestamp],\n                [[status, data1, data2, data3], timestamp],\n                ...\n            ])\n\n        The data1/2/3 items in each event are optional::\n\n           Write([[[0xc0, 0, 0], 20000]])\n\n        is equivalent to::\n\n           Write([[[0xc0], 20000]])\n\n        Example:\n\n        Send program change 1 at time 20000 and send note 65 with velocity 100\n        at 500 ms later::\n\n             Write([[[0xc0, 0, 0], 20000], [[0x90, 60, 100], 20500]])\n\n        .. notes::\n            1. Timestamps will be ignored if latency == 0.\n\n            2. To get a note to play immediately, send the note on event with\n               the result from the Time() function as the timestamp.\n\n        ";
 static PyObject *__pyx_pf_4pypm_6Output_Write(PyObject *__pyx_v_self, PyObject *__pyx_v_data) {
   PmEvent __pyx_v_buffer[1024];
   PmError __pyx_v_err;
-  int __pyx_v_i;
-  PyObject *__pyx_v_loop1;
+  int __pyx_v_item;
+  int __pyx_v_ev_no;
+  PyObject *__pyx_v_event;
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_1 = 0;
   PyObject *__pyx_2 = 0;
   PyObject *__pyx_t_2 = NULL;
   Py_ssize_t __pyx_t_3;
   int __pyx_t_4;
-  Py_ssize_t __pyx_t_5;
-  Py_ssize_t __pyx_t_6;
+  int __pyx_t_5;
+  int __pyx_t_6;
   PyObject *__pyx_t_7 = NULL;
-  int __pyx_t_8;
+  Py_ssize_t __pyx_t_8;
   PyObject *__pyx_t_9 = NULL;
-  PyObject *__pyx_t_10 = NULL;
-  PmMessage __pyx_t_11;
-  PmTimestamp __pyx_t_12;
+  PmMessage __pyx_t_10;
+  PmTimestamp __pyx_t_11;
+  PyObject *__pyx_t_12 = NULL;
   __Pyx_SetupRefcountContext("Write");
-  __pyx_v_loop1 = Py_None; __Pyx_INCREF(Py_None);
-
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":315
- *         cdef int i
+  __pyx_v_event = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":398
+ *         cdef int ev_no
  * 
  *         self._check_open()             # <<<<<<<<<<<<<<
  * 
- * 
- */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp__check_open); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ *         if len(data) > 1024:
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp__check_open); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":318
- * 
- * 
- *         if len(data) > 1024: raise IndexError, 'maximum list length is 1024'             # <<<<<<<<<<<<<<
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":400
+ *         self._check_open()
+ * 
+ *         if len(data) > 1024:             # <<<<<<<<<<<<<<
+ *             raise IndexError('Maximum event list length is 1024.')
  *         else:
- *             for loop1 in range(len(data)):
- */
-  __pyx_t_3 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ */
+  __pyx_t_3 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_t_4 = (__pyx_t_3 > 1024);
   if (__pyx_t_4) {
-    __Pyx_Raise(__pyx_builtin_IndexError, __pyx_kp_13, 0);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":401
+ * 
+ *         if len(data) > 1024:
+ *             raise IndexError('Maximum event list length is 1024.')             # <<<<<<<<<<<<<<
+ *         else:
+ *             for ev_no, event in enumerate(data):
+ */
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    __Pyx_INCREF(__pyx_kp_12);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_kp_12);
+    __Pyx_GIVEREF(__pyx_kp_12);
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   /*else*/ {
 
-    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":320
- *         if len(data) > 1024: raise IndexError, 'maximum list length is 1024'
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":403
+ *             raise IndexError('Maximum event list length is 1024.')
  *         else:
- *             for loop1 in range(len(data)):             # <<<<<<<<<<<<<<
- *                 if ((len(data[loop1][0]) > 4) |
- *                     (len(data[loop1][0]) < 1)):
- */
-    __pyx_t_5 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ *             for ev_no, event in enumerate(data):             # <<<<<<<<<<<<<<
+ *                 if not event[0]:
+ *                     raise ValueError('No data in event no. %i.' % ev_no)
+ */
+    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
-    __Pyx_GIVEREF(__pyx_t_2);
-    __pyx_t_2 = 0;
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_INCREF(__pyx_v_data);
+    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_data);
+    __Pyx_GIVEREF(__pyx_v_data);
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_enumerate, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
     if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
       __pyx_t_3 = 0; __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1);
     } else {
-      __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
     }
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
       } else {
         __pyx_t_2 = PyIter_Next(__pyx_t_1);
         if (!__pyx_t_2) {
-          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           break;
         }
         __Pyx_GOTREF(__pyx_t_2);
       }
-      __Pyx_DECREF(__pyx_v_loop1);
-      __pyx_v_loop1 = __pyx_t_2;
-      __pyx_t_2 = 0;
-
-      /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":321
+      if (PyTuple_CheckExact(__pyx_t_2) && likely(PyTuple_GET_SIZE(__pyx_t_2) == 2)) {
+        PyObject* tuple = __pyx_t_2;
+        __pyx_2 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_2);
+        __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
+        __pyx_2 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_2);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __pyx_v_ev_no = __pyx_t_5;
+        __Pyx_DECREF(__pyx_v_event);
+        __pyx_v_event = __pyx_2;
+        __pyx_2 = 0;
+      } else {
+        __pyx_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_1);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __pyx_2 = __Pyx_UnpackItem(__pyx_1, 0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_2);
+        __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
+        __pyx_2 = __Pyx_UnpackItem(__pyx_1, 1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_2);
+        if (__Pyx_EndUnpack(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
+        __pyx_v_ev_no = __pyx_t_5;
+        __Pyx_DECREF(__pyx_v_event);
+        __pyx_v_event = __pyx_2;
+        __pyx_2 = 0;
+      }
+
+      /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":404
  *         else:
- *             for loop1 in range(len(data)):
- *                 if ((len(data[loop1][0]) > 4) |             # <<<<<<<<<<<<<<
- *                     (len(data[loop1][0]) < 1)):
- *                     raise IndexError, str(len(data[loop1][0]))+' arguments in event list'
- */
-      __pyx_1 = PyObject_GetItem(__pyx_v_data, __pyx_v_loop1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ *             for ev_no, event in enumerate(data):
+ *                 if not event[0]:             # <<<<<<<<<<<<<<
+ *                     raise ValueError('No data in event no. %i.' % ev_no)
+ *                 if len(event[0]) > 4:
+ */
+      __pyx_1 = __Pyx_GetItemInt(__pyx_v_event, 0, sizeof(long), PyInt_FromLong); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_1);
-      __pyx_2 = __Pyx_GetItemInt(__pyx_1, 0, sizeof(long), PyInt_FromLong); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_2);
+      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
-      __pyx_t_5 = PyObject_Length(__pyx_2); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
-
-      /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":322
- *             for loop1 in range(len(data)):
- *                 if ((len(data[loop1][0]) > 4) |
- *                     (len(data[loop1][0]) < 1)):             # <<<<<<<<<<<<<<
- *                     raise IndexError, str(len(data[loop1][0]))+' arguments in event list'
- *                 buffer[loop1].message = 0
- */
-      __pyx_1 = PyObject_GetItem(__pyx_v_data, __pyx_v_loop1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_1);
-      __pyx_2 = __Pyx_GetItemInt(__pyx_1, 0, sizeof(long), PyInt_FromLong); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_2);
-      __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
-      __pyx_t_6 = PyObject_Length(__pyx_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
-      __pyx_t_4 = ((__pyx_t_5 > 4) | (__pyx_t_6 < 1));
-      if (__pyx_t_4) {
-
-        /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":323
- *                 if ((len(data[loop1][0]) > 4) |
- *                     (len(data[loop1][0]) < 1)):
- *                     raise IndexError, str(len(data[loop1][0]))+' arguments in event list'             # <<<<<<<<<<<<<<
- *                 buffer[loop1].message = 0
- *                 for i in range(len(data[loop1][0])):
- */
-        __pyx_1 = PyObject_GetItem(__pyx_v_data, __pyx_v_loop1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_1);
-        __pyx_2 = __Pyx_GetItemInt(__pyx_1, 0, sizeof(long), PyInt_FromLong); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_2);
-        __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
-        __pyx_t_6 = PyObject_Length(__pyx_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
-        __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = (!__pyx_t_4);
+      if (__pyx_t_6) {
+
+        /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":405
+ *             for ev_no, event in enumerate(data):
+ *                 if not event[0]:
+ *                     raise ValueError('No data in event no. %i.' % ev_no)             # <<<<<<<<<<<<<<
+ *                 if len(event[0]) > 4:
+ *                     raise ValueError('Too many data bytes (%i) in event no. %i.'
+ */
+        __pyx_t_2 = PyInt_FromLong(__pyx_v_ev_no); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_2);
-        __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_7));
-        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2);
-        __Pyx_GIVEREF(__pyx_t_2);
-        __pyx_t_2 = 0;
-        __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_2);
-        __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
-        __pyx_t_7 = PyNumber_Add(__pyx_t_2, __pyx_kp_14); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyNumber_Remainder(__pyx_kp_13, __pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-        __Pyx_Raise(__pyx_builtin_IndexError, __pyx_t_7, 0);
+        __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_7);
+        __Pyx_GIVEREF(__pyx_t_7);
+        __pyx_t_7 = 0;
+        __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+        __Pyx_Raise(__pyx_t_7, 0, 0);
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         goto __pyx_L8;
       }
       __pyx_L8:;
 
-      /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":324
- *                     (len(data[loop1][0]) < 1)):
- *                     raise IndexError, str(len(data[loop1][0]))+' arguments in event list'
- *                 buffer[loop1].message = 0             # <<<<<<<<<<<<<<
- *                 for i in range(len(data[loop1][0])):
- *                     buffer[loop1].message = buffer[loop1].message + ((data[loop1][0][i]&0xFF) << (8*i))
- */
-      __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_loop1); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      (__pyx_v_buffer[__pyx_t_6]).message = 0;
-
-      /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":325
- *                     raise IndexError, str(len(data[loop1][0]))+' arguments in event list'
- *                 buffer[loop1].message = 0
- *                 for i in range(len(data[loop1][0])):             # <<<<<<<<<<<<<<
- *                     buffer[loop1].message = buffer[loop1].message + ((data[loop1][0][i]&0xFF) << (8*i))
- *                 buffer[loop1].timestamp = data[loop1][1]
- */
-      __pyx_1 = PyObject_GetItem(__pyx_v_data, __pyx_v_loop1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_1);
-      __pyx_2 = __Pyx_GetItemInt(__pyx_1, 0, sizeof(long), PyInt_FromLong); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":406
+ *                 if not event[0]:
+ *                     raise ValueError('No data in event no. %i.' % ev_no)
+ *                 if len(event[0]) > 4:             # <<<<<<<<<<<<<<
+ *                     raise ValueError('Too many data bytes (%i) in event no. %i.'
+ *                         % (len(event[0]), ev_no))
+ */
+      __pyx_2 = __Pyx_GetItemInt(__pyx_v_event, 0, sizeof(long), PyInt_FromLong); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_2);
-      __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
-      __pyx_t_6 = PyObject_Length(__pyx_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PyObject_Length(__pyx_2); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
-      for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_6; __pyx_t_8+=1) {
-        __pyx_v_i = __pyx_t_8;
-
-        /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":326
- *                 buffer[loop1].message = 0
- *                 for i in range(len(data[loop1][0])):
- *                     buffer[loop1].message = buffer[loop1].message + ((data[loop1][0][i]&0xFF) << (8*i))             # <<<<<<<<<<<<<<
- *                 buffer[loop1].timestamp = data[loop1][1]
- *                 if self.debug: print loop1," : ",buffer[loop1].message," : ",buffer[loop1].timestamp
- */
-        __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_loop1); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_7 = PyInt_FromLong((__pyx_v_buffer[__pyx_t_5]).message); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = (__pyx_t_8 > 4);
+      if (__pyx_t_6) {
+
+        /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":408
+ *                 if len(event[0]) > 4:
+ *                     raise ValueError('Too many data bytes (%i) in event no. %i.'
+ *                         % (len(event[0]), ev_no))             # <<<<<<<<<<<<<<
+ * 
+ *                 buffer[ev_no].message = 0
+ */
+        __pyx_1 = __Pyx_GetItemInt(__pyx_v_event, 0, sizeof(long), PyInt_FromLong); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_1);
+        __pyx_t_8 = PyObject_Length(__pyx_1); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
+        __pyx_t_7 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
-        __pyx_1 = PyObject_GetItem(__pyx_v_data, __pyx_v_loop1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PyInt_FromLong(__pyx_v_ev_no); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_9));
+        PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7);
+        __Pyx_GIVEREF(__pyx_t_7);
+        PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_2);
+        __Pyx_GIVEREF(__pyx_t_2);
+        __pyx_t_7 = 0;
+        __pyx_t_2 = 0;
+        __pyx_t_2 = PyNumber_Remainder(__pyx_kp_14, ((PyObject *)__pyx_t_9)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
+        __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_9));
+        PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
+        __Pyx_GIVEREF(__pyx_t_2);
+        __pyx_t_2 = 0;
+        __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
+        __Pyx_Raise(__pyx_t_2, 0, 0);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        goto __pyx_L9;
+      }
+      __pyx_L9:;
+
+      /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":410
+ *                         % (len(event[0]), ev_no))
+ * 
+ *                 buffer[ev_no].message = 0             # <<<<<<<<<<<<<<
+ * 
+ *                 for item in range(len(event[0])):
+ */
+      (__pyx_v_buffer[__pyx_v_ev_no]).message = 0;
+
+      /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":412
+ *                 buffer[ev_no].message = 0
+ * 
+ *                 for item in range(len(event[0])):             # <<<<<<<<<<<<<<
+ *                     buffer[ev_no].message += (
+ *                         (event[0][item] & 0xFF) << (8 * item))
+ */
+      __pyx_2 = __Pyx_GetItemInt(__pyx_v_event, 0, sizeof(long), PyInt_FromLong); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_2);
+      __pyx_t_8 = PyObject_Length(__pyx_2); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
+      for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_8; __pyx_t_5+=1) {
+        __pyx_v_item = __pyx_t_5;
+
+        /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":414
+ *                 for item in range(len(event[0])):
+ *                     buffer[ev_no].message += (
+ *                         (event[0][item] & 0xFF) << (8 * item))             # <<<<<<<<<<<<<<
+ * 
+ *                 buffer[ev_no].timestamp = event[1]
+ */
+        __pyx_1 = __Pyx_GetItemInt(__pyx_v_event, 0, sizeof(long), PyInt_FromLong); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_1);
-        __pyx_2 = __Pyx_GetItemInt(__pyx_1, 0, sizeof(long), PyInt_FromLong); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_2 = __Pyx_GetItemInt(__pyx_1, __pyx_v_item, sizeof(int), PyInt_FromLong); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_2);
         __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
-        __pyx_1 = __Pyx_GetItemInt(__pyx_2, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_1);
+        __pyx_t_2 = PyNumber_And(__pyx_2, __pyx_int_0xFF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
         __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
-        __pyx_t_2 = PyNumber_And(__pyx_1, __pyx_int_0xFF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_2);
-        __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
-        __pyx_t_9 = PyInt_FromLong((8 * __pyx_v_i)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_9 = PyInt_FromLong((8 * __pyx_v_item)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_9);
-        __pyx_t_10 = PyNumber_Lshift(__pyx_t_2, __pyx_t_9); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_10);
+        __pyx_t_7 = PyNumber_Lshift(__pyx_t_2, __pyx_t_9); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-        __pyx_t_9 = PyNumber_Add(__pyx_t_7, __pyx_t_10); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_10 = __Pyx_PyInt_AsLong(__pyx_t_7); if (unlikely((__pyx_t_10 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+        /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":413
+ * 
+ *                 for item in range(len(event[0])):
+ *                     buffer[ev_no].message += (             # <<<<<<<<<<<<<<
+ *                         (event[0][item] & 0xFF) << (8 * item))
+ * 
+ */
+        (__pyx_v_buffer[__pyx_v_ev_no]).message += __pyx_t_10;
+      }
+
+      /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":416
+ *                         (event[0][item] & 0xFF) << (8 * item))
+ * 
+ *                 buffer[ev_no].timestamp = event[1]             # <<<<<<<<<<<<<<
+ * 
+ *                 if self.debug:
+ */
+      __pyx_1 = __Pyx_GetItemInt(__pyx_v_event, 1, sizeof(long), PyInt_FromLong); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_1);
+      __pyx_t_11 = __Pyx_PyInt_AsLong(__pyx_1); if (unlikely((__pyx_t_11 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
+      (__pyx_v_buffer[__pyx_v_ev_no]).timestamp = __pyx_t_11;
+
+      /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":418
+ *                 buffer[ev_no].timestamp = event[1]
+ * 
+ *                 if self.debug:             # <<<<<<<<<<<<<<
+ *                     print "%i : %r : %s" % (
+ *                         ev_no, buffer[ev_no].message, buffer[ev_no].timestamp)
+ */
+      __pyx_t_5 = ((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->debug;
+      if (__pyx_t_5) {
+
+        /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":420
+ *                 if self.debug:
+ *                     print "%i : %r : %s" % (
+ *                         ev_no, buffer[ev_no].message, buffer[ev_no].timestamp)             # <<<<<<<<<<<<<<
+ * 
+ *         if self.debug:
+ */
+        __pyx_t_7 = PyInt_FromLong(__pyx_v_ev_no); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __pyx_t_9 = PyInt_FromLong((__pyx_v_buffer[__pyx_v_ev_no]).message); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_9);
-        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
-        __pyx_t_11 = __Pyx_PyInt_AsLong(__pyx_t_9); if (unlikely((__pyx_t_11 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-        __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_loop1); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        (__pyx_v_buffer[__pyx_t_5]).message = __pyx_t_11;
+        __pyx_t_2 = PyInt_FromLong((__pyx_v_buffer[__pyx_v_ev_no]).timestamp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_12));
+        PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_7);
+        __Pyx_GIVEREF(__pyx_t_7);
+        PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_9);
+        __Pyx_GIVEREF(__pyx_t_9);
+        PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_t_2);
+        __Pyx_GIVEREF(__pyx_t_2);
+        __pyx_t_7 = 0;
+        __pyx_t_9 = 0;
+        __pyx_t_2 = 0;
+        __pyx_t_2 = PyNumber_Remainder(__pyx_kp_15, ((PyObject *)__pyx_t_12)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
+        if (__Pyx_PrintOne(__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        goto __pyx_L12;
       }
-
-      /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":327
- *                 for i in range(len(data[loop1][0])):
- *                     buffer[loop1].message = buffer[loop1].message + ((data[loop1][0][i]&0xFF) << (8*i))
- *                 buffer[loop1].timestamp = data[loop1][1]             # <<<<<<<<<<<<<<
- *                 if self.debug: print loop1," : ",buffer[loop1].message," : ",buffer[loop1].timestamp
- *         if self.debug: print "writing to midi buffer"
- */
-      __pyx_2 = PyObject_GetItem(__pyx_v_data, __pyx_v_loop1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_2);
-      __pyx_1 = __Pyx_GetItemInt(__pyx_2, 1, sizeof(long), PyInt_FromLong); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_1);
-      __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
-      __pyx_t_12 = __Pyx_PyInt_AsLong(__pyx_1); if (unlikely((__pyx_t_12 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
-      __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_loop1); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      (__pyx_v_buffer[__pyx_t_6]).timestamp = __pyx_t_12;
-
-      /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":328
- *                     buffer[loop1].message = buffer[loop1].message + ((data[loop1][0][i]&0xFF) << (8*i))
- *                 buffer[loop1].timestamp = data[loop1][1]
- *                 if self.debug: print loop1," : ",buffer[loop1].message," : ",buffer[loop1].timestamp             # <<<<<<<<<<<<<<
- *         if self.debug: print "writing to midi buffer"
- *         err= Pm_Write(self.midi, buffer, len(data))
- */
-      __pyx_t_8 = ((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->debug;
-      if (__pyx_t_8) {
-        __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_loop1); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_9 = PyInt_FromLong((__pyx_v_buffer[__pyx_t_6]).message); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_9);
-        __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_loop1); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_10 = PyInt_FromLong((__pyx_v_buffer[__pyx_t_6]).timestamp); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_10);
-        __pyx_t_7 = PyTuple_New(5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_7));
-        __Pyx_INCREF(__pyx_v_loop1);
-        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_loop1);
-        __Pyx_GIVEREF(__pyx_v_loop1);
-        __Pyx_INCREF(__pyx_kp_15);
-        PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_kp_15);
-        __Pyx_GIVEREF(__pyx_kp_15);
-        PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_9);
-        __Pyx_GIVEREF(__pyx_t_9);
-        __Pyx_INCREF(__pyx_kp_16);
-        PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_kp_16);
-        __Pyx_GIVEREF(__pyx_kp_16);
-        PyTuple_SET_ITEM(__pyx_t_7, 4, __pyx_t_10);
-        __Pyx_GIVEREF(__pyx_t_10);
-        __pyx_t_9 = 0;
-        __pyx_t_10 = 0;
-        if (__Pyx_Print(((PyObject *)__pyx_t_7), 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
-        goto __pyx_L11;
-      }
-      __pyx_L11:;
+      __pyx_L12:;
     }
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   }
   __pyx_L5:;
 
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":329
- *                 buffer[loop1].timestamp = data[loop1][1]
- *                 if self.debug: print loop1," : ",buffer[loop1].message," : ",buffer[loop1].timestamp
- *         if self.debug: print "writing to midi buffer"             # <<<<<<<<<<<<<<
- *         err= Pm_Write(self.midi, buffer, len(data))
- *         if err < 0: raise Exception, Pm_GetErrorText(err)
- */
-  __pyx_t_8 = ((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->debug;
-  if (__pyx_t_8) {
-    if (__Pyx_PrintOne(__pyx_kp_17) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L12;
-  }
-  __pyx_L12:;
-
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":330
- *                 if self.debug: print loop1," : ",buffer[loop1].message," : ",buffer[loop1].timestamp
- *         if self.debug: print "writing to midi buffer"
- *         err= Pm_Write(self.midi, buffer, len(data))             # <<<<<<<<<<<<<<
- *         if err < 0: raise Exception, Pm_GetErrorText(err)
- * 
- */
-  __pyx_t_3 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_v_err = Pm_Write(((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->midi, __pyx_v_buffer, __pyx_t_3);
-
-  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":331
- *         if self.debug: print "writing to midi buffer"
- *         err= Pm_Write(self.midi, buffer, len(data))
- *         if err < 0: raise Exception, Pm_GetErrorText(err)             # <<<<<<<<<<<<<<
- * 
- *     def WriteShort(self, status, data1 = 0, data2 = 0):
- */
-  __pyx_t_4 = (__pyx_v_err < 0);
-  if (__pyx_t_4) {
-    __pyx_t_1 = __Pyx_PyBytes_FromString(Pm_GetErrorText(__pyx_v_err)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_Raise(__pyx_builtin_Exception, __pyx_t_1, 0);
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":422
+ *                         ev_no, buffer[ev_no].message, buffer[ev_no].timestamp)
+ * 
+ *         if self.debug:             # <<<<<<<<<<<<<<
+ *             print "Writing to midi buffer."
+ *         err = Pm_Write(self.midi, buffer, len(data))
+ */
+  __pyx_t_5 = ((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->debug;
+  if (__pyx_t_5) {
+
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":423
+ * 
+ *         if self.debug:
+ *             print "Writing to midi buffer."             # <<<<<<<<<<<<<<
+ *         err = Pm_Write(self.midi, buffer, len(data))
+ *         if err < 0:
+ */
+    if (__Pyx_PrintOne(__pyx_kp_16) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L13;
   }
   __pyx_L13:;
 
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":424
+ *         if self.debug:
+ *             print "Writing to midi buffer."
+ *         err = Pm_Write(self.midi, buffer, len(data))             # <<<<<<<<<<<<<<
+ *         if err < 0:
+ *             raise Exception(Pm_GetErrorText(err))
+ */
+  __pyx_t_3 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_err = Pm_Write(((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->midi, __pyx_v_buffer, __pyx_t_3);
+
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":425
+ *             print "Writing to midi buffer."
+ *         err = Pm_Write(self.midi, buffer, len(data))
+ *         if err < 0:             # <<<<<<<<<<<<<<
+ *             raise Exception(Pm_GetErrorText(err))
+ * 
+ */
+  __pyx_t_6 = (__pyx_v_err < 0);
+  if (__pyx_t_6) {
+
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":426
+ *         err = Pm_Write(self.midi, buffer, len(data))
+ *         if err < 0:
+ *             raise Exception(Pm_GetErrorText(err))             # <<<<<<<<<<<<<<
+ * 
+ *     def WriteShort(self, status, data1=0, data2=0):
+ */
+    __pyx_t_1 = __Pyx_PyBytes_FromString(Pm_GetErrorText(__pyx_v_err)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
+    __Pyx_GIVEREF(__pyx_t_1);
+    __pyx_t_1 = 0;
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L14;
+  }
+  __pyx_L14:;
+
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_2);
   __Pyx_XDECREF(__pyx_t_7);
   __Pyx_XDECREF(__pyx_t_9);
-  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_XDECREF(__pyx_t_12);
   __Pyx_AddTraceback("pypm.Output.Write");
   __pyx_r = NULL;
   __pyx_L0:;
-  __Pyx_DECREF(__pyx_v_loop1);
+  __Pyx_DECREF(__pyx_v_event);
   __Pyx_XGIVEREF(__pyx_r);
   __Pyx_FinishRefcountContext();
   return __pyx_r;