Commits

illume committed 68ca9ad

midi, no abort on dealloc by default. have explicit close/abort available.

Comments (0)

Files changed (3)

 portmidi supports (currently windows, OSX, and linux).
 
 This uses pyportmidi for now, but may use its own bindings at some
-point in the future.
+point in the future.  The pyportmidi bindings are included with pygame.
 
 New in pygame 1.9.0.
 """
         atexit.register(quit)
 
 
-
 def quit():
     """uninitialize the midi module
     pygame.midi.quit(): return None
     Note: in the current release, the default is simply the first device
     (the input or output device with the lowest PmDeviceID).
     """
+    _check_init()
     return _pypm.GetDefaultOutputDeviceID()
 
 
 
     If the id is out of range, the function returns None.
     """
+    _check_init()
     return _pypm.GetDeviceInfo(an_id) 
 
 
         The buffer_size specifies the number of input events to be buffered 
         waiting to be read using Input.read().
         """
+        _check_init()
  
         if device_id == -1:
             raise MidiException("Device id is -1, not a valid output id.  -1 usually means there were no default Output devices.")
 
 
 
+    def _check_open(self):
+        if self._input is None:
+            raise MidiException("midi not open.")
 
 
 
+    def close(self):
+        """ closes a midi stream, flushing any pending buffers.
+        Input.close(): return None
 
-
+        PortMidi attempts to close open streams when the application
+        exits -- this is particularly difficult under Windows.
+        """
+        _check_init()
+        if not (self._input is None):
+            self._input.Close()
+        self._input = None
 
 
 
         [[[status,data1,data2,data3],timestamp],
          [[status,data1,data2,data3],timestamp],...]
         """
+        _check_init()
+        self._check_open()
         return self._input.Read(num_events)
 
 
 
         raises a MidiException on error.
         """
+        _check_init()
+        self._check_open()
+
         r = self._input.Poll()
         if r == _pypm.TRUE:
             return True
         the audio buffer latency.
         """
      
+        _check_init()
+        self._aborted = 0
+
         if device_id == -1:
             raise MidiException("Device id is -1, not a valid output id.  -1 usually means there were no default Output devices.")
             
         else:
             raise MidiException("Device id invalid, out of range.")
 
+    def _check_open(self):
+        if self._output is None:
+            raise MidiException("midi not open.")
+
+        if self._aborted:
+            raise MidiException("midi aborted.")
+
+
+    def close(self):
+        """ closes a midi stream, flushing any pending buffers.
+        Output.close(): return None
+
+        PortMidi attempts to close open streams when the application
+        exits -- this is particularly difficult under Windows.
+        """
+        _check_init()
+        if not (self._output is None):
+            self._output.Close()
+        self._output = None
+
+    def abort(self):
+        """ terminates outgoing messages immediately
+        Output.abort(): return None
+
+        The caller should immediately close the output port;
+        this call may result in transmission of a partial midi message.
+        There is no abort for Midi input because the user can simply
+        ignore messages in the buffer and close an input device at
+        any time.
+        """
+
+        _check_init()
+        if self._output:
+            self._output.Abort()
+        self._aborted = 1
+
+
+
 
 
     def write(self, data):
         Can send up to 1024 elements in your data list, otherwise an 
          IndexError exception is raised.
         """
+        _check_init()
+        self._check_open()
+
         self._output.Write(data)
 
 
         example: note 65 on with velocity 100
              write_short(0x90,65,100)
         """
+        _check_init()
+        self._check_open()
         self._output.WriteShort(status, data1, data2)
 
 
             o.write_sys_ex(pygame.midi.time(),
                            [0xF0,0x7D,0x10,0x11,0x12,0x13,0xF7])
         """
+        _check_init()
+        self._check_open()
         self._output.WriteSysEx(when, msg)
 
 
-/* Generated by Cython 0.11.2 on Sun May 24 23:05:02 2009 */
+/* Generated by Cython 0.11.2 on Mon Jun  1 16:21:31 2009 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
 
 /* Type declarations */
 
-/* "pygame/trunk/src/pypm.pyx":193
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":201
  *     return Pm_Channel(chan-1)
  * 
  * cdef class Output:             # <<<<<<<<<<<<<<
   int i;
   PmStream *midi;
   int debug;
+  int _aborted;
 };
 
-/* "pygame/trunk/src/pypm.pyx":322
- *             pass                    # win32 machine crashes w/ multiple SysEx
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":394
+ * 
  * 
  * cdef class Input:             # <<<<<<<<<<<<<<
  *     """
 int __pyx_module_is_main_pypm = 0;
 
 /* Implementation of pypm */
-static char __pyx_k_3[] = "0.03";
+static char __pyx_k_3[] = "0.05";
 static PyObject *__pyx_int_0x1;
 static PyObject *__pyx_int_0x2;
 static PyObject *__pyx_int_0x4;
 static PyObject *__pyx_kp___init__;
 static char __pyx_k___dealloc__[] = "__dealloc__";
 static PyObject *__pyx_kp___dealloc__;
+static char __pyx_k__check_open[] = "_check_open";
+static PyObject *__pyx_kp__check_open;
+static char __pyx_k_Close[] = "Close";
+static PyObject *__pyx_kp_Close;
+static char __pyx_k_Abort[] = "Abort";
+static PyObject *__pyx_kp_Abort;
 static char __pyx_k_Write[] = "Write";
 static PyObject *__pyx_kp_Write;
 static char __pyx_k_WriteShort[] = "WriteShort";
 static PyObject *__pyx_kp_IndexError;
 static char __pyx_k_range[] = "range";
 static PyObject *__pyx_kp_range;
-static char __pyx_k_17[] = "B";
-static PyObject *__pyx_kp_17;
+static char __pyx_k_19[] = "B";
+static PyObject *__pyx_kp_19;
 static char __pyx_k_tostring[] = "tostring";
 static PyObject *__pyx_kp_tostring;
 static char __pyx_k_append[] = "append";
 static char __pyx_k_10[] = "Closing MIDI output stream and destroying instance";
 static PyObject *__pyx_kp_11;
 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 char __pyx_k_11[] = "maximum list length is 1024";
-static char __pyx_k_12[] = " arguments in event list";
-static char __pyx_k_13[] = " : ";
-static char __pyx_k_14[] = " : ";
-static char __pyx_k_15[] = "writing to midi buffer";
 static PyObject *__pyx_kp_16;
-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[] = "MIDI input opened.";
-static PyObject *__pyx_kp_19;
-static char __pyx_k_19[] = "Closing MIDI input stream and destroying instance";
+static char __pyx_k_18[] = "Writing to MIDI buffer";
 static PyObject *__pyx_kp_20;
+static char __pyx_k_20[] = "MIDI input opened.";
 static PyObject *__pyx_kp_21;
-static char __pyx_k_20[] = "maximum buffer length is 1024";
-static char __pyx_k_21[] = "minimum buffer length is 1";
-
-/* "pygame/trunk/src/pypm.pyx":124
+static char __pyx_k_21[] = "Closing MIDI input stream and destroying instance";
+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
  * 
  * def Initialize():             # <<<<<<<<<<<<<<
   __Pyx_SetupRefcountContext("Initialize");
   __pyx_self = __pyx_self;
 
-  /* "pygame/trunk/src/pypm.pyx":128
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":136
  * Initialize: call this first
  *     """
  *     Pm_Initialize()             # <<<<<<<<<<<<<<
  */
   Pm_Initialize();
 
-  /* "pygame/trunk/src/pypm.pyx":129
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":137
  *     """
  *     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]/             # <<<<<<<<<<<<<<
   return __pyx_r;
 }
 
-/* "pygame/trunk/src/pypm.pyx":131
+/* "/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]/
  * 
  * def Terminate():             # <<<<<<<<<<<<<<
   __Pyx_SetupRefcountContext("Terminate");
   __pyx_self = __pyx_self;
 
-  /* "pygame/trunk/src/pypm.pyx":137
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":145
  * done with MIDI, your system may crash.
  *     """
  *     Pm_Terminate()             # <<<<<<<<<<<<<<
   return __pyx_r;
 }
 
-/* "pygame/trunk/src/pypm.pyx":139
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":147
  *     Pm_Terminate()
  * 
  * def GetDefaultInputDeviceID():             # <<<<<<<<<<<<<<
   __Pyx_SetupRefcountContext("GetDefaultInputDeviceID");
   __pyx_self = __pyx_self;
 
-  /* "pygame/trunk/src/pypm.pyx":140
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":148
  * 
  * def GetDefaultInputDeviceID():
  *     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 = 140; __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 = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
   return __pyx_r;
 }
 
-/* "pygame/trunk/src/pypm.pyx":142
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":150
  *     return Pm_GetDefaultInputDeviceID()
  * 
  * def GetDefaultOutputDeviceID():             # <<<<<<<<<<<<<<
   __Pyx_SetupRefcountContext("GetDefaultOutputDeviceID");
   __pyx_self = __pyx_self;
 
-  /* "pygame/trunk/src/pypm.pyx":143
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":151
  * 
  * def GetDefaultOutputDeviceID():
  *     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 = 143; __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 = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
   return __pyx_r;
 }
 
-/* "pygame/trunk/src/pypm.pyx":145
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":153
  *     return Pm_GetDefaultOutputDeviceID()
  * 
  * def CountDevices():             # <<<<<<<<<<<<<<
   __Pyx_SetupRefcountContext("CountDevices");
   __pyx_self = __pyx_self;
 
-  /* "pygame/trunk/src/pypm.pyx":146
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":154
  * 
  * def CountDevices():
  *     return Pm_CountDevices()             # <<<<<<<<<<<<<<
  * def GetDeviceInfo(i):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(Pm_CountDevices()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __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 = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
   return __pyx_r;
 }
 
-/* "pygame/trunk/src/pypm.pyx":148
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":156
  *     return Pm_CountDevices()
  * 
  * def GetDeviceInfo(i):             # <<<<<<<<<<<<<<
   __Pyx_SetupRefcountContext("GetDeviceInfo");
   __pyx_self = __pyx_self;
 
-  /* "pygame/trunk/src/pypm.pyx":160
+  /* "/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 = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __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;}
   __pyx_v_info = ((PmDeviceInfo *)Pm_GetDeviceInfo(__pyx_t_1));
 
-  /* "pygame/trunk/src/pypm.pyx":162
+  /* "/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             # <<<<<<<<<<<<<<
   __pyx_t_2 = (__pyx_v_info != NULL);
   if (__pyx_t_2) {
     __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 = 162; __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 = 170; __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 = 162; __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 = 170; __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 = 162; __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 = 170; __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 = 162; __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 = 170; __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 = 162; __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 = 170; __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 = 162; __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 = 170; __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);
   }
   /*else*/ {
 
-    /* "pygame/trunk/src/pypm.pyx":163
+    /* "/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             # <<<<<<<<<<<<<<
   return __pyx_r;
 }
 
-/* "pygame/trunk/src/pypm.pyx":165
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":173
  *     else: return
  * 
  * def Time():             # <<<<<<<<<<<<<<
   __Pyx_SetupRefcountContext("Time");
   __pyx_self = __pyx_self;
 
-  /* "pygame/trunk/src/pypm.pyx":170
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":178
  * 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 = 170; __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 = 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;
 }
 
-/* "pygame/trunk/src/pypm.pyx":172
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":180
  *     return Pt_Time()
  * 
  * def GetErrorText(err):             # <<<<<<<<<<<<<<
   __Pyx_SetupRefcountContext("GetErrorText");
   __pyx_self = __pyx_self;
 
-  /* "pygame/trunk/src/pypm.pyx":177
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":185
  * messages translated from error numbers
  *     """
  *     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 = 177; __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 = 177; __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 = 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_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
   return __pyx_r;
 }
 
-/* "pygame/trunk/src/pypm.pyx":179
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":187
  *     return Pm_GetErrorText(err)
  * 
  * def Channel(chan):             # <<<<<<<<<<<<<<
   __Pyx_SetupRefcountContext("Channel");
   __pyx_self = __pyx_self;
 
-  /* "pygame/trunk/src/pypm.pyx":191
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":199
  *       all numbered from 0 to 15 instead of 1 to 16.
  *     """
  *     return Pm_Channel(chan-1)             # <<<<<<<<<<<<<<
  * cdef class Output:
  */
   __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 = 191; __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 = 199; __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 = 191; __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 = 199; __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 = 191; __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 = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
   return __pyx_r;
 }
 
-/* "pygame/trunk/src/pypm.pyx":205
- *     cdef int debug
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":214
+ *     cdef int _aborted
  * 
  *     def __init__(self, OutputDevice, latency=0):             # <<<<<<<<<<<<<<
  * 
       }
     }
     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 = 205; __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 = 214; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_OutputDevice = values[0];
     __pyx_v_latency = values[1];
   }
   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 = 205; __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 = 214; __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);
 
-  /* "pygame/trunk/src/pypm.pyx":211
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":220
  *         cdef PmTimeProcPtr PmPtr
  * 
  *         self.i = OutputDevice             # <<<<<<<<<<<<<<
  *         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 = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __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;
 
-  /* "pygame/trunk/src/pypm.pyx":212
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":221
  * 
  *         self.i = OutputDevice
  *         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
+ *         self.debug = 0
+ *         self._aborted = 0             # <<<<<<<<<<<<<<
  * 
  *         if latency == 0:
  */
-  ((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->debug = 0;
-
-  /* "pygame/trunk/src/pypm.pyx":214
- *         self.debug = 0
+  ((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->_aborted = 0;
+
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":224
+ *         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 = 214; __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 = 224; __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 = 214; __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 = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (__pyx_t_3) {
 
-    /* "pygame/trunk/src/pypm.pyx":215
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":225
  * 
  *         if latency == 0:
  *             PmPtr = NULL             # <<<<<<<<<<<<<<
   }
   /*else*/ {
 
-    /* "pygame/trunk/src/pypm.pyx":217
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":227
  *             PmPtr = NULL
  *         else:
  *             PmPtr = <PmTimeProcPtr>&Pt_Time             # <<<<<<<<<<<<<<
   }
   __pyx_L6:;
 
-  /* "pygame/trunk/src/pypm.pyx":218
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":228
  *         else:
  *             PmPtr = <PmTimeProcPtr>&Pt_Time
  *         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 = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__Pyx_PrintOne(__pyx_kp_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L7;
   }
   __pyx_L7:;
 
-  /* "pygame/trunk/src/pypm.pyx":220
+  /* "/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)             # <<<<<<<<<<<<<<
  *         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 = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __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);
 
-  /* "pygame/trunk/src/pypm.pyx":221
+  /* "/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)
  *         if err < 0:             # <<<<<<<<<<<<<<
   __pyx_t_3 = (__pyx_v_err < 0);
   if (__pyx_t_3) {
 
-    /* "pygame/trunk/src/pypm.pyx":222
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":232
  *         err = Pm_OpenOutput(&(self.midi), self.i, NULL, 0, PmPtr, NULL, 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 = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __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;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_v_s);
     __pyx_v_s = __pyx_t_2;
     __pyx_t_2 = 0;
 
-    /* "pygame/trunk/src/pypm.pyx":225
+    /* "/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:             # <<<<<<<<<<<<<<
     __pyx_t_3 = (!(__pyx_v_err == -10000));
     if (__pyx_t_3) {
 
-      /* "pygame/trunk/src/pypm.pyx":226
+      /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":236
  *                	# here, we crash.
  *                 if not err == -10000:
  *                         raise Exception,s             # <<<<<<<<<<<<<<
  *                         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 = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L9;
     }
     /*else*/ {
 
-      /* "pygame/trunk/src/pypm.pyx":228
+      /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":238
  *                         raise Exception,s
  *                 else:
  *                         print "Unable to open Midi OutputDevice=",OutputDevice," err=",s             # <<<<<<<<<<<<<<
  * 
  *     def __dealloc__(self):
  */
-      __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __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_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 = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      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_L9:;
   return __pyx_r;
 }
 
-/* "pygame/trunk/src/pypm.pyx":230
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":240
  *                         print "Unable to open Midi OutputDevice=",OutputDevice," err=",s
  * 
  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
  *         if self.debug: print "Closing MIDI output stream and destroying instance"
- *         err = Pm_Abort(self.midi)
+ *         #err = Pm_Abort(self.midi)
  */
 
 static void __pyx_pf_4pypm_6Output___dealloc__(PyObject *__pyx_v_self); /*proto*/
   __Pyx_SetupRefcountContext("__dealloc__");
   __pyx_v_err = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "pygame/trunk/src/pypm.pyx":231
+  /* "/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)
+ *         #err = Pm_Abort(self.midi)
+ *         #if err < 0: raise Exception, Pm_GetErrorText(err)
  */
   __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 = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__Pyx_PrintOne(__pyx_kp_10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "pygame/trunk/src/pypm.pyx":232
- *     def __dealloc__(self):
- *         if self.debug: print "Closing MIDI output stream and destroying instance"
- *         err = Pm_Abort(self.midi)             # <<<<<<<<<<<<<<
+  /* "/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)
- *         err = Pm_Close(self.midi)
+ * 
  */
-  __pyx_t_2 = PyInt_FromLong(Pm_Abort(((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->midi)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __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;
 
-  /* "pygame/trunk/src/pypm.pyx":233
- *         if self.debug: print "Closing MIDI output stream and destroying instance"
- *         err = Pm_Abort(self.midi)
+  /* "/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)             # <<<<<<<<<<<<<<
- *         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 = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __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 = 233; __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 = 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 = 233; __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 = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __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 = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "pygame/trunk/src/pypm.pyx":234
- *         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 = 234; __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;
-
-  /* "pygame/trunk/src/pypm.pyx":235
- *         if err < 0: raise Exception, Pm_GetErrorText(err)
- *         err = Pm_Close(self.midi)
- *         if err < 0: raise Exception, Pm_GetErrorText(err)             # <<<<<<<<<<<<<<
- * 
- *     def Write(self, data):
- */
-  __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 = 235; __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 = 235; __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 = 235; __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 = 235; __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 = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L7;
-  }
-  __pyx_L7:;
-
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_2);
   __Pyx_FinishRefcountContext();
 }
 
-/* "pygame/trunk/src/pypm.pyx":237
- *         if err < 0: raise Exception, Pm_GetErrorText(err)
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":248
+ * 
+ * 
+ *     def _check_open(self):             # <<<<<<<<<<<<<<
+ *         """ checks to see if the midi 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 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;
+  __Pyx_SetupRefcountContext("_check_open");
+
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":252
+ *         """
+ * 
+ *         if self.midi == NULL:             # <<<<<<<<<<<<<<
+ *             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
+ * 
+ *         if self.midi == NULL:
+ *             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;}
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":255
+ *             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
+ * 
+ *         if self._aborted:
+ *             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;}
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("pypm.Output._check_open");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_FinishRefcountContext();
+  return __pyx_r;
+}
+
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":258
+ *             raise Exception, "midi Output aborted.  Need to call Close after Abort."
+ * 
+ *     def Close(self):             # <<<<<<<<<<<<<<
+ *         """
+ * Close()
+ */
+
+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 PyObject *__pyx_pf_4pypm_6Output_Close(PyObject *__pyx_v_self, PyObject *unused) {
+  PyObject *__pyx_v_err;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  PmError __pyx_t_3;
+  __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
+ * 
+ *         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;}
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __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
+ * 
+ * 
+ *     def Abort(self):             # <<<<<<<<<<<<<<
+ *         """
+ * Abort() terminates 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 PyObject *__pyx_pf_4pypm_6Output_Abort(PyObject *__pyx_v_self, PyObject *unused) {
+  PyObject *__pyx_v_err;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  PmError __pyx_t_3;
+  __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
+ * 
+ *         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;}
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":290
+ *             raise Exception, Pm_GetErrorText(err)
+ * 
+ *         self._aborted = 1             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  ((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_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
+ * 
  * 
  *     def Write(self, data):             # <<<<<<<<<<<<<<
  *         """
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_1 = 0;
   PyObject *__pyx_2 = 0;
-  Py_ssize_t __pyx_t_1;
-  int __pyx_t_2;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
   Py_ssize_t __pyx_t_3;
-  PyObject *__pyx_t_4 = NULL;
-  PyObject *__pyx_t_5 = NULL;
+  int __pyx_t_4;
+  Py_ssize_t __pyx_t_5;
   Py_ssize_t __pyx_t_6;
   PyObject *__pyx_t_7 = NULL;
   int __pyx_t_8;
   __Pyx_SetupRefcountContext("Write");
   __pyx_v_loop1 = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "pygame/trunk/src/pypm.pyx":259
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":315
  *         cdef int i
  * 
+ *         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;}
+  __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_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'             # <<<<<<<<<<<<<<
  *         else:
  *             for loop1 in range(len(data)):
  */
-  __pyx_t_1 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_2 = (__pyx_t_1 > 1024);
-  if (__pyx_t_2) {
-    __Pyx_Raise(__pyx_builtin_IndexError, __pyx_kp_11, 0);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __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 = 318; __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;}
     goto __pyx_L5;
   }
   /*else*/ {
 
-    /* "pygame/trunk/src/pypm.pyx":261
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":320
  *         if len(data) > 1024: raise IndexError, 'maximum list length is 1024'
  *         else:
  *             for loop1 in range(len(data)):             # <<<<<<<<<<<<<<
  *                 if ((len(data[loop1][0]) > 4) |
  *                     (len(data[loop1][0]) < 1)):
  */
-    __pyx_t_3 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
-    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
-    __Pyx_GIVEREF(__pyx_t_4);
-    __pyx_t_4 = 0;
-    __pyx_t_4 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_4);
-    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
-    if (PyList_CheckExact(__pyx_t_4) || PyTuple_CheckExact(__pyx_t_4)) {
-      __pyx_t_1 = 0; __pyx_t_5 = __pyx_t_4; __Pyx_INCREF(__pyx_t_5);
+    __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;}
+    __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_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_1 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_5);
+      __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_GOTREF(__pyx_t_1);
     }
-    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     for (;;) {
-      if (likely(PyList_CheckExact(__pyx_t_5))) {
-        if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_5)) break;
-        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_4); __pyx_t_1++;
-      } else if (likely(PyTuple_CheckExact(__pyx_t_5))) {
-        if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
-        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_4); __pyx_t_1++;
+      if (likely(PyList_CheckExact(__pyx_t_1))) {
+        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
+        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++;
+      } else if (likely(PyTuple_CheckExact(__pyx_t_1))) {
+        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++;
       } else {
-        __pyx_t_4 = PyIter_Next(__pyx_t_5);
-        if (!__pyx_t_4) {
-          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __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;}
           break;
         }
-        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_GOTREF(__pyx_t_2);
       }
       __Pyx_DECREF(__pyx_v_loop1);
-      __pyx_v_loop1 = __pyx_t_4;
-      __pyx_t_4 = 0;
-
-      /* "pygame/trunk/src/pypm.pyx":262
+      __pyx_v_loop1 = __pyx_t_2;
+      __pyx_t_2 = 0;
+
+      /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":321
  *         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 = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __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;}
       __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 = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __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_DECREF(__pyx_1); __pyx_1 = 0;
-      __pyx_t_3 = PyObject_Length(__pyx_2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __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;
 
-      /* "pygame/trunk/src/pypm.pyx":263
+      /* "/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 = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __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 = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __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 = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __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_2 = ((__pyx_t_3 > 4) | (__pyx_t_6 < 1));
-      if (__pyx_t_2) {
-
-        /* "pygame/trunk/src/pypm.pyx":264
+      __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 = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __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 = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __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 = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __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_4 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_4);
-        __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __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_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_4);
-        __Pyx_GIVEREF(__pyx_t_4);
-        __pyx_t_4 = 0;
-        __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_4);
+        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_4, __pyx_kp_12); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __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_GOTREF(__pyx_t_7);
-        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
         __Pyx_Raise(__pyx_builtin_IndexError, __pyx_t_7, 0);
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         goto __pyx_L8;
       }
       __pyx_L8:;
 
-      /* "pygame/trunk/src/pypm.pyx":265
+      /* "/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 = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __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;
 
-      /* "pygame/trunk/src/pypm.pyx":266
+      /* "/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 = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __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 = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __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;}
       __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 = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __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_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;
 
-        /* "pygame/trunk/src/pypm.pyx":267
+        /* "/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_3 = __Pyx_PyIndex_AsSsize_t(__pyx_v_loop1); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_7 = PyInt_FromLong((__pyx_v_buffer[__pyx_t_3]).message); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __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_GOTREF(__pyx_t_7);
-        __pyx_1 = PyObject_GetItem(__pyx_v_data, __pyx_v_loop1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __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_GOTREF(__pyx_1);
-        __pyx_2 = __Pyx_GetItemInt(__pyx_1, 0, sizeof(long), PyInt_FromLong); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __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_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 = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __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_DECREF(__pyx_2); __pyx_2 = 0;
-        __pyx_t_4 = PyNumber_And(__pyx_1, __pyx_int_0xFF); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_4);
+        __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 = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __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_GOTREF(__pyx_t_9);
-        __pyx_t_10 = PyNumber_Lshift(__pyx_t_4, __pyx_t_9); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __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_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __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 = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __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_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 = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __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_3 = __Pyx_PyIndex_AsSsize_t(__pyx_v_loop1); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        (__pyx_v_buffer[__pyx_t_3]).message = __pyx_t_11;
+        __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;
       }
 
-      /* "pygame/trunk/src/pypm.pyx":268
+      /* "/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 = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __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 = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __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 = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __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 = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __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;
 
-      /* "pygame/trunk/src/pypm.pyx":269
+      /* "/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             # <<<<<<<<<<<<<<
  */
       __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 = 269; __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 = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __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 = 269; __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 = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __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 = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __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_13);
-        PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_kp_13);
-        __Pyx_GIVEREF(__pyx_kp_13);
+        __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_14);
-        PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_kp_14);
-        __Pyx_GIVEREF(__pyx_kp_14);
+        __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 = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        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_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   }
   __pyx_L5:;
 
-  /* "pygame/trunk/src/pypm.pyx":270
+  /* "/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"             # <<<<<<<<<<<<<<
  */
   __pyx_t_8 = ((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->debug;
   if (__pyx_t_8) {
-    if (__Pyx_PrintOne(__pyx_kp_15) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    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:;
 
-  /* "pygame/trunk/src/pypm.pyx":271
+  /* "/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_1 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __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_1);
-
-  /* "pygame/trunk/src/pypm.pyx":272
+  __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_2 = (__pyx_v_err < 0);
-  if (__pyx_t_2) {
-    __pyx_t_5 = __Pyx_PyBytes_FromString(Pm_GetErrorText(__pyx_v_err)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_5);
-    __Pyx_Raise(__pyx_builtin_Exception, __pyx_t_5, 0);
-    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __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;}
     goto __pyx_L13;
   }
   __pyx_L13:;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_1);
   __Pyx_XDECREF(__pyx_2);
-  __Pyx_XDECREF(__pyx_t_4);
-  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
   __Pyx_XDECREF(__pyx_t_7);
   __Pyx_XDECREF(__pyx_t_9);
   __Pyx_XDECREF(__pyx_t_10);
   return __pyx_r;
 }
 
-/* "pygame/trunk/src/pypm.pyx":274
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":333
  *         if err < 0: raise Exception, Pm_GetErrorText(err)
  * 
  *     def WriteShort(self, status, data1 = 0, data2 = 0):             # <<<<<<<<<<<<<<
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "WriteShort") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "WriteShort") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_status = values[0];
     __pyx_v_data1 = values[1];
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("WriteShort", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("WriteShort", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("pypm.Output.WriteShort");
   return NULL;
   __pyx_L4_argument_unpacking_done:;
 
-  /* "pygame/trunk/src/pypm.pyx":290
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":348
+ *         cdef PmEvent buffer[1]
  *         cdef PmError err
+ *         self._check_open()             # <<<<<<<<<<<<<<
+ * 
+ *         buffer[0].timestamp = Pt_Time()
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp__check_open); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __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 = 348; __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":350
+ *         self._check_open()
  * 
  *         buffer[0].timestamp = Pt_Time()             # <<<<<<<<<<<<<<
  *         buffer[0].message = ((((data2) << 16) & 0xFF0000) | (((data1) << 8) & 0xFF00) | ((status) & 0xFF))
  */
   (__pyx_v_buffer[0]).timestamp = Pt_Time();
 
-  /* "pygame/trunk/src/pypm.pyx":291
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":351
  * 
  *         buffer[0].timestamp = Pt_Time()
  *         buffer[0].message = ((((data2) << 16) & 0xFF0000) | (((data1) << 8) & 0xFF00) | ((status) & 0xFF))             # <<<<<<<<<<<<<<
  *         if self.debug: print "Writing to MIDI buffer"
  *         err = Pm_Write(self.midi, buffer, 1) # stream, buffer, length
  */
-  __pyx_t_1 = PyNumber_Lshift(__pyx_v_data2, __pyx_int_16); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyNumber_Lshift(__pyx_v_data2, __pyx_int_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_1 = PyNumber_And(__pyx_t_2, __pyx_int_0xFF0000); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_0xFF0000); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyNumber_Lshift(__pyx_v_data1, __pyx_int_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyNumber_And(__pyx_t_2, __pyx_int_0xFF00); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyNumber_Or(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyNumber_Lshift(__pyx_v_data1, __pyx_int_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_3 = PyNumber_And(__pyx_t_1, __pyx_int_0xFF00); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = PyNumber_And(__pyx_v_status, __pyx_int_0xFF); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyNumber_Or(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyNumber_Or(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyNumber_And(__pyx_v_status, __pyx_int_0xFF); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_2 = PyNumber_Or(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = __Pyx_PyInt_AsLong(__pyx_t_1); if (unlikely((__pyx_t_4 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_4 = __Pyx_PyInt_AsLong(__pyx_t_2); if (unlikely((__pyx_t_4 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   (__pyx_v_buffer[0]).message = __pyx_t_4;
 
-  /* "pygame/trunk/src/pypm.pyx":292
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":352
  *         buffer[0].timestamp = Pt_Time()
  *         buffer[0].message = ((((data2) << 16) & 0xFF0000) | (((data1) << 8) & 0xFF00) | ((status) & 0xFF))
  *         if self.debug: print "Writing to MIDI buffer"             # <<<<<<<<<<<<<<
  */
   __pyx_t_5 = ((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->debug;
   if (__pyx_t_5) {
-    if (__Pyx_PrintOne(__pyx_kp_16) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__Pyx_PrintOne(__pyx_kp_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "pygame/trunk/src/pypm.pyx":293
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":353
  *         buffer[0].message = ((((data2) << 16) & 0xFF0000) | (((data1) << 8) & 0xFF00) | ((status) & 0xFF))
  *         if self.debug: print "Writing to MIDI buffer"
  *         err = Pm_Write(self.midi, buffer, 1) # stream, buffer, length             # <<<<<<<<<<<<<<
  */
   __pyx_v_err = Pm_Write(((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->midi, __pyx_v_buffer, 1);
 
-  /* "pygame/trunk/src/pypm.pyx":294
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":354
  *         if self.debug: print "Writing to MIDI buffer"
  *         err = Pm_Write(self.midi, buffer, 1) # stream, buffer, length
  *         if err < 0 : raise Exception, Pm_GetErrorText(err)             # <<<<<<<<<<<<<<
  */
   __pyx_t_6 = (__pyx_v_err < 0);
   if (__pyx_t_6) {
-    __pyx_t_2 = __Pyx_PyBytes_FromString(Pm_GetErrorText(__pyx_v_err)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __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 = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_PyBytes_FromString(Pm_GetErrorText(__pyx_v_err)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __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 = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L7;
   }
   __pyx_L7:;
   return __pyx_r;
 }
 
-/* "pygame/trunk/src/pypm.pyx":296
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":356
  *         if err < 0 : raise Exception, Pm_GetErrorText(err)
  * 
  *     def WriteSysEx(self, when, msg):             # <<<<<<<<<<<<<<
       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_msg);
       if (likely(values[1])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("WriteSysEx", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("WriteSysEx", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "WriteSysEx") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "WriteSysEx") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_when = values[0];
     __pyx_v_msg = values[1];
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("WriteSysEx", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("WriteSysEx", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("pypm.Output.WriteSysEx");
   return NULL;
   __pyx_L4_argument_unpacking_done:;
   __Pyx_INCREF(__pyx_v_msg);
 
-  /* "pygame/trunk/src/pypm.pyx":312
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":372
  *         cdef PtTimestamp CurTime
  * 
+ *         self._check_open()             # <<<<<<<<<<<<<<
+ * 
+ *         if type(msg) is list:
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp__check_open); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __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 = 372; __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":374
+ *         self._check_open()
+ * 
  *         if type(msg) is list:             # <<<<<<<<<<<<<<
  *             msg = array.array('B',msg).tostring() # Markus Pfaff contribution
  *         cmsg = msg
  */
-  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
   __Pyx_INCREF(__pyx_v_msg);
-  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_msg);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_msg);
   __Pyx_GIVEREF(__pyx_v_msg);
-  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)&PyType_Type)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-  __pyx_t_3 = (__pyx_t_2 == ((PyObject *)((PyObject*)&PyList_Type)));
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)&PyType_Type)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+  __pyx_t_3 = (__pyx_t_1 == ((PyObject *)((PyObject*)&PyList_Type)));
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (__pyx_t_3) {
 
-    /* "pygame/trunk/src/pypm.pyx":313
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":375
  * 
  *         if type(msg) is list:
  *             msg = array.array('B',msg).tostring() # Markus Pfaff contribution             # <<<<<<<<<<<<<<
  *         cmsg = msg
  * 
  */
-    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_array); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_array); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_1);
-    __pyx_t_2 = PyObject_GetAttr(__pyx_1, __pyx_kp_array); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_1, __pyx_kp_array); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
+    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    __Pyx_INCREF(__pyx_kp_19);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_kp_19);
+    __Pyx_GIVEREF(__pyx_kp_19);
+    __Pyx_INCREF(__pyx_v_msg);
+    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_msg);
+    __Pyx_GIVEREF(__pyx_v_msg);
+    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+    __pyx_t_2 = PyObject_GetAttr(__pyx_t_4, __pyx_kp_tostring); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
-    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-    __Pyx_INCREF(__pyx_kp_17);
-    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_17);
-    __Pyx_GIVEREF(__pyx_kp_17);
-    __Pyx_INCREF(__pyx_v_msg);
-    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_msg);
-    __Pyx_GIVEREF(__pyx_v_msg);
-    __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_kp_tostring); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_4);
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_v_msg);
     __pyx_v_msg = __pyx_t_4;
     __pyx_t_4 = 0;
   }
   __pyx_L6:;
 
-  /* "pygame/trunk/src/pypm.pyx":314
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":376
  *         if type(msg) is list:
  *             msg = array.array('B',msg).tostring() # Markus Pfaff contribution
  *         cmsg = msg             # <<<<<<<<<<<<<<
  * 
  *         CurTime = Pt_Time()
  */
-  __pyx_t_5 = __Pyx_PyBytes_AsString(__pyx_v_msg); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_PyBytes_AsString(__pyx_v_msg); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_cmsg = __pyx_t_5;
 
-  /* "pygame/trunk/src/pypm.pyx":316
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":378
  *         cmsg = msg
  * 
  *         CurTime = Pt_Time()             # <<<<<<<<<<<<<<
  */
   __pyx_v_CurTime = Pt_Time();
 
-  /* "pygame/trunk/src/pypm.pyx":317
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":379
  * 
  *         CurTime = Pt_Time()
  *         err = Pm_WriteSysEx(self.midi, when, <unsigned char *> cmsg)             # <<<<<<<<<<<<<<
  *         if err < 0 : raise Exception, Pm_GetErrorText(err)
  *         while Pt_Time() == CurTime: # wait for SysEx to go thru or...my
  */
-  __pyx_t_6 = __Pyx_PyInt_AsLong(__pyx_v_when); if (unlikely((__pyx_t_6 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = __Pyx_PyInt_AsLong(__pyx_v_when); if (unlikely((__pyx_t_6 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_err = Pm_WriteSysEx(((struct __pyx_obj_4pypm_Output *)__pyx_v_self)->midi, __pyx_t_6, ((unsigned char *)__pyx_v_cmsg));
 
-  /* "pygame/trunk/src/pypm.pyx":318
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":380
  *         CurTime = Pt_Time()
  *         err = Pm_WriteSysEx(self.midi, when, <unsigned char *> cmsg)
  *         if err < 0 : raise Exception, Pm_GetErrorText(err)             # <<<<<<<<<<<<<<
  */
   __pyx_t_3 = (__pyx_v_err < 0);
   if (__pyx_t_3) {
-    __pyx_t_4 = __Pyx_PyBytes_FromString(Pm_GetErrorText(__pyx_v_err)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_PyBytes_FromString(Pm_GetErrorText(__pyx_v_err)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_Raise(__pyx_builtin_Exception, __pyx_t_4, 0);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L7;
   }
   __pyx_L7:;
 
-  /* "pygame/trunk/src/pypm.pyx":319
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":381
  *         err = Pm_WriteSysEx(self.midi, when, <unsigned char *> cmsg)
  *         if err < 0 : raise Exception, Pm_GetErrorText(err)
  *         while Pt_Time() == CurTime: # wait for SysEx to go thru or...my             # <<<<<<<<<<<<<<
   return __pyx_r;
 }
 
-/* "pygame/trunk/src/pypm.pyx":332
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":404
  *     cdef int i
  * 
  *     def __init__(self, InputDevice, buffersize=4096):             # <<<<<<<<<<<<<<
       }
     }
     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 = 332; __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 = 404; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_InputDevice = values[0];
     __pyx_v_buffersize = values[1];
   }
   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 = 332; __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 = 404; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("pypm.Input.__init__");
   return -1;
   __pyx_L4_argument_unpacking_done:;
 
-  /* "pygame/trunk/src/pypm.pyx":334
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":406
  *     def __init__(self, InputDevice, buffersize=4096):
  *         cdef PmError err
  *         self.i = InputDevice             # <<<<<<<<<<<<<<
  *         self.debug = 0
  *         err= Pm_OpenInput(&(self.midi),self.i,NULL,buffersize,&Pt_Time,NULL)
  */
-  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_InputDevice); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_InputDevice); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   ((struct __pyx_obj_4pypm_Input *)__pyx_v_self)->i = __pyx_t_1;
 
-  /* "pygame/trunk/src/pypm.pyx":335
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":407
  *         cdef PmError err
  *         self.i = InputDevice
  *         self.debug = 0             # <<<<<<<<<<<<<<
  */
   ((struct __pyx_obj_4pypm_Input *)__pyx_v_self)->debug = 0;
 
-  /* "pygame/trunk/src/pypm.pyx":336
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":408
  *         self.i = InputDevice
  *         self.debug = 0
  *         err= Pm_OpenInput(&(self.midi),self.i,NULL,buffersize,&Pt_Time,NULL)             # <<<<<<<<<<<<<<
  *         if err < 0: raise Exception, Pm_GetErrorText(err)
  *         if self.debug: print "MIDI input opened."
  */
-  __pyx_t_2 = __Pyx_PyInt_AsLong(__pyx_v_buffersize); if (unlikely((__pyx_t_2 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyInt_AsLong(__pyx_v_buffersize); if (unlikely((__pyx_t_2 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_err = Pm_OpenInput((&((struct __pyx_obj_4pypm_Input *)__pyx_v_self)->midi), ((struct __pyx_obj_4pypm_Input *)__pyx_v_self)->i, NULL, __pyx_t_2, (&Pt_Time), NULL);
 
-  /* "pygame/trunk/src/pypm.pyx":337
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":409
  *         self.debug = 0
  *         err= Pm_OpenInput(&(self.midi),self.i,NULL,buffersize,&Pt_Time,NULL)
  *         if err < 0: raise Exception, Pm_GetErrorText(err)             # <<<<<<<<<<<<<<
  */
   __pyx_t_3 = (__pyx_v_err < 0);
   if (__pyx_t_3) {
-    __pyx_t_4 = __Pyx_PyBytes_FromString(Pm_GetErrorText(__pyx_v_err)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_PyBytes_FromString(Pm_GetErrorText(__pyx_v_err)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_Raise(__pyx_builtin_Exception, __pyx_t_4, 0);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "pygame/trunk/src/pypm.pyx":338
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":410
  *         err= Pm_OpenInput(&(self.midi),self.i,NULL,buffersize,&Pt_Time,NULL)
  *         if err < 0: raise Exception, Pm_GetErrorText(err)
  *         if self.debug: print "MIDI input opened."             # <<<<<<<<<<<<<<
  */
   __pyx_t_1 = ((struct __pyx_obj_4pypm_Input *)__pyx_v_self)->debug;
   if (__pyx_t_1) {
-    if (__Pyx_PrintOne(__pyx_kp_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__Pyx_PrintOne(__pyx_kp_20) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L7;
   }
   __pyx_L7:;
   return __pyx_r;
 }
 
-/* "pygame/trunk/src/pypm.pyx":340
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":412
  *         if self.debug: print "MIDI input opened."
  * 
  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
   PyObject *__pyx_t_3 = NULL;
   __Pyx_SetupRefcountContext("__dealloc__");
 
-  /* "pygame/trunk/src/pypm.pyx":342
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":414
  *     def __dealloc__(self):
  *         cdef PmError err
  *         if self.debug: print "Closing MIDI input stream and destroying instance"             # <<<<<<<<<<<<<<
- * 	# DO NOT CALL Pm_Abort on Inputs!
- *         # err = Pm_Abort(self.midi)
+ * 
+ *         err = Pm_Close(self.midi)
  */
   __pyx_t_1 = ((struct __pyx_obj_4pypm_Input *)__pyx_v_self)->debug;
   if (__pyx_t_1) {
-    if (__Pyx_PrintOne(__pyx_kp_19) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__Pyx_PrintOne(__pyx_kp_21) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "pygame/trunk/src/pypm.pyx":346
- *         # err = Pm_Abort(self.midi)
- *         # if err < 0: raise Exception, Pm_GetErrorText(err)
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":416
+ *         if self.debug: print "Closing MIDI input stream and destroying instance"
+ * 
  *         err = Pm_Close(self.midi)             # <<<<<<<<<<<<<<
- *         if err < 0: raise Exception, Pm_GetErrorText(err)
- * 
+ *         if err < 0:
+ *             raise Exception, Pm_GetErrorText(err)
  */
   __pyx_v_err = Pm_Close(((struct __pyx_obj_4pypm_Input *)__pyx_v_self)->midi);
 
-  /* "pygame/trunk/src/pypm.pyx":347
- *         # if err < 0: raise Exception, Pm_GetErrorText(err)
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":417
+ * 
  *         err = Pm_Close(self.midi)
- *         if err < 0: raise Exception, Pm_GetErrorText(err)             # <<<<<<<<<<<<<<
+ *         if err < 0:             # <<<<<<<<<<<<<<
+ *             raise Exception, Pm_GetErrorText(err)
  * 
- *     def SetFilter(self, filters):
  */
   __pyx_t_2 = (__pyx_v_err < 0);
   if (__pyx_t_2) {
-    __pyx_t_3 = __Pyx_PyBytes_FromString(Pm_GetErrorText(__pyx_v_err)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":418
+ *         err = Pm_Close(self.midi)
+ *         if err < 0:
+ *             raise Exception, Pm_GetErrorText(err)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+    __pyx_t_3 = __Pyx_PyBytes_FromString(Pm_GetErrorText(__pyx_v_err)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_Raise(__pyx_builtin_Exception, __pyx_t_3, 0);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
   __Pyx_FinishRefcountContext();
 }
 
-/* "pygame/trunk/src/pypm.pyx":349
- *         if err < 0: raise Exception, Pm_GetErrorText(err)
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":422
+ * 
+ * 
+ *     def _check_open(self):             # <<<<<<<<<<<<<<
+ *         """ checks to see if the midi is open, and if not, raises an error.
+ *         """
+ */
+
+static PyObject *__pyx_pf_4pypm_5Input__check_open(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
+static char __pyx_doc_4pypm_5Input__check_open[] = " checks to see if the midi is open, and if not, raises an error.\n        ";
+static PyObject *__pyx_pf_4pypm_5Input__check_open(PyObject *__pyx_v_self, PyObject *unused) {
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  __Pyx_SetupRefcountContext("_check_open");
+
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":426
+ *         """
+ * 
+ *         if self.midi == NULL:             # <<<<<<<<<<<<<<
+ *             raise Exception, "midi Input not open."
+ * 
+ */
+  __pyx_t_1 = (((struct __pyx_obj_4pypm_Input *)__pyx_v_self)->midi == NULL);
+  if (__pyx_t_1) {
+
+    /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":427
+ * 
+ *         if self.midi == NULL:
+ *             raise Exception, "midi Input not open."             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+    __Pyx_Raise(__pyx_builtin_Exception, __pyx_kp_22, 0);
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("pypm.Input._check_open");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_FinishRefcountContext();
+  return __pyx_r;
+}
+
+/* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":430
+ * 
+ * 
+ *     def Close(self):             # <<<<<<<<<<<<<<
+ *         """
+ * Close()
+ */
+
+static PyObject *__pyx_pf_4pypm_5Input_Close(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
+static char __pyx_doc_4pypm_5Input_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 PyObject *__pyx_pf_4pypm_5Input_Close(PyObject *__pyx_v_self, PyObject *unused) {
+  PyObject *__pyx_v_err;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  PmError __pyx_t_3;
+  __Pyx_SetupRefcountContext("Close");
+  __pyx_v_err = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/home/rene/dev/pygame/pygame/trunk/src/pypm.pyx":440
+ *         #    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_Input *)__pyx_v_self)->midi)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __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":441
+ * 
+ *         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 = 441; __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 = 441; __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":442
+ *         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 = 442; __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 = 442; __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 = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("pypm.Input.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":447
+ * 
  * 
  *     def SetFilter(self, filters):             # <<<<<<<<<<<<<<
  *         """