Commits

Anonymous committed 445baee

Merged with trunk revision 2245, lib/midi.py and test/midi_test.py are
not merged.
-Tyler

Comments (0)

Files changed (12)

docs/ref/index.html

 <li><a href="mask.html#pygame.mask.from_surface">pygame.mask.from_surface</a> - <font size=-1>Returns a Mask from the given surface.</font></li>
 <li><a href="mask.html#pygame.mask.from_threshold">pygame.mask.from_threshold</a> - <font size=-1>Creates a mask by thresholding Surfaces</font></li>
 </ul>
-<li><a href="midi.html#pygame.midi">pygame.midi</a> - <font size=-1>send and receive midi messages</font></li>
+<li><a href="midi.html#pygame.midi">pygame.midi</a> - <font size=-1>pygame module for interacting with midi input and output.</font></li>
+<ul>
+<li><a href="midi.html#pygame.midi.Input">pygame.midi.Input</a> - <font size=-1>Input is used to get midi input from midi devices.</font></li>
+<ul>
+<li><a href="midi.html#Input.poll">Input.poll</a> - <font size=-1>returns true if there's data, or false if not.</font></li>
+<li><a href="midi.html#Input.read">Input.read</a> - <font size=-1>reads num_events midi events from the buffer.</font></li>
+</ul>
+<li><a href="midi.html#pygame.midi.MidiException">pygame.midi.MidiException</a> - <font size=-1>exception that pygame.midi functions and classes can raise</font></li>
+<li><a href="midi.html#pygame.midi.Output">pygame.midi.Output</a> - <font size=-1>Output is used to send midi to an output device</font></li>
+<ul>
+<li><a href="midi.html#Output.note_off">Output.note_off</a> - <font size=-1>turns a midi note off.  Note must be on.</font></li>
+<li><a href="midi.html#Output.note_on">Output.note_on</a> - <font size=-1>turns a midi note on.  Note must be off.</font></li>
+<li><a href="midi.html#Output.set_instrument">Output.set_instrument</a> - <font size=-1>select an instrument, with a value between 0 and 127</font></li>
+<li><a href="midi.html#Output.write">Output.write</a> - <font size=-1>writes a list of midi data to the Output</font></li>
+<li><a href="midi.html#Output.write_short">Output.write_short</a> - <font size=-1>write_short(status <, data1><, data2>)</font></li>
+<li><a href="midi.html#Output.write_sys_ex">Output.write_sys_ex</a> - <font size=-1>writes a timestamped system-exclusive midi message.</font></li>
+</ul>
+<li><a href="midi.html#pygame.midi.get_count">pygame.midi.get_count</a> - <font size=-1>gets the number of devices.</font></li>
+<li><a href="midi.html#pygame.midi.get_default_input_id">pygame.midi.get_default_input_id</a> - <font size=-1>gets default input device number</font></li>
+<li><a href="midi.html#pygame.midi.get_default_output_id">pygame.midi.get_default_output_id</a> - <font size=-1>gets default output device number</font></li>
+<li><a href="midi.html#pygame.midi.get_device_info">pygame.midi.get_device_info</a> - <font size=-1> returns information about a midi device</font></li>
+<li><a href="midi.html#pygame.midi.init">pygame.midi.init</a> - <font size=-1>initialize the midi module</font></li>
+<li><a href="midi.html#pygame.midi.midis2events">pygame.midi.midis2events</a> - <font size=-1>converts midi events to pygame events</font></li>
+<li><a href="midi.html#pygame.midi.quit">pygame.midi.quit</a> - <font size=-1>uninitialize the midi module</font></li>
+<li><a href="midi.html#pygame.midi.time">pygame.midi.time</a> - <font size=-1>returns the current time in ms of the PortMidi timer</font></li>
+</ul>
 <li><a href="mixer.html#pygame.mixer">pygame.mixer</a> - <font size=-1>pygame module for loading and playing sounds</font></li>
 <ul>
 <li><a href="mixer.html#pygame.mixer.Channel">pygame.mixer.Channel</a> - <font size=-1>Create a Channel object for controlling playback</font></li>

docs/ref/midi.html

 
 <a name="pygame.midi">
 <big><b>pygame.midi</big></b><br><ul>
-  <i>send and receive midi messages</i><br>
-<p>=== Under Development === </p>
-<p>See <tt>examples\midi.py</tt> for the current status the midi module api. </p>
+  <i>pygame module for interacting with midi input and output.</i><br>
+<ul><small><table>
+  <tr><td><a href="midi.html#pygame.midi.Input">pygame.midi.Input</a> - <font size=-1>Input is used to get midi input from midi devices.</font></td><td>Input is used to get midi input from midi devices.</td></tr>
+  <tr><td><a href="midi.html#pygame.midi.MidiException">pygame.midi.MidiException</a> - <font size=-1>exception that pygame.midi functions and classes can raise</font></td><td>exception that pygame.midi functions and classes can raise</td></tr>
+  <tr><td><a href="midi.html#pygame.midi.Output">pygame.midi.Output</a> - <font size=-1>Output is used to send midi to an output device</font></td><td>Output is used to send midi to an output device</td></tr>
+  <tr><td><a href="midi.html#pygame.midi.get_count">pygame.midi.get_count</a> - <font size=-1>gets the number of devices.</font></td><td>gets the number of devices.</td></tr>
+  <tr><td><a href="midi.html#pygame.midi.get_default_input_id">pygame.midi.get_default_input_id</a> - <font size=-1>gets default input device number</font></td><td>gets default input device number</td></tr>
+  <tr><td><a href="midi.html#pygame.midi.get_default_output_id">pygame.midi.get_default_output_id</a> - <font size=-1>gets default output device number</font></td><td>gets default output device number</td></tr>
+  <tr><td><a href="midi.html#pygame.midi.get_device_info">pygame.midi.get_device_info</a> - <font size=-1> returns information about a midi device</font></td><td> returns information about a midi device</td></tr>
+  <tr><td><a href="midi.html#pygame.midi.init">pygame.midi.init</a> - <font size=-1>initialize the midi module</font></td><td>initialize the midi module</td></tr>
+  <tr><td><a href="midi.html#pygame.midi.midis2events">pygame.midi.midis2events</a> - <font size=-1>converts midi events to pygame events</font></td><td>converts midi events to pygame events</td></tr>
+  <tr><td><a href="midi.html#pygame.midi.quit">pygame.midi.quit</a> - <font size=-1>uninitialize the midi module</font></td><td>uninitialize the midi module</td></tr>
+  <tr><td><a href="midi.html#pygame.midi.time">pygame.midi.time</a> - <font size=-1>returns the current time in ms of the PortMidi timer</font></td><td>returns the current time in ms of the PortMidi timer</td></tr>
+</table></small></ul>
+<p>The midi module can send output to midi devices, and get input from midi devices. It can also list midi devices on the system. </p>
+<p>Including real midi devices, and virtual ones. </p>
+<p>It uses the portmidi library. Is portable to which ever platforms portmidi supports (currently windows, <tt>OSX</tt>, and linux). </p>
+<p>This uses pyportmidi for now, but may use its own bindings at some point in the future. </p>
+<p>New in pygame <tt>1.9.0</tt>. </p>
 <!--COMMENTS:pygame.midi--> &nbsp;<br> 
+
+
+<a name="pygame.midi.Input">
+<big><b>pygame.midi.Input</big></b><br><ul>
+  <i>Input is used to get midi input from midi devices.</i><br>
+  <tt>Input(device_id)</tt><br>
+  <tt>Input(device_id, buffer_size)</tt><br>
+<ul><small><table>
+  <tr><td><a href="midi.html#Input.poll">Input.poll</a> - <font size=-1>returns true if there's data, or false if not.</font></td><td>returns true if there's data, or false if not.</td></tr>
+  <tr><td><a href="midi.html#Input.read">Input.read</a> - <font size=-1>reads num_events midi events from the buffer.</font></td><td>reads num_events midi events from the buffer.</td></tr>
+</table></small></ul>
+<p>buffer_size -the number of input events to be buffered waiting to </p>
+<pre>  be read using Input.read()
+</pre>
+<!--COMMENTS:pygame.midi.Input--> &nbsp;<br> 
+
+
+<a name="Input.poll">
+<big><b>Input.poll</big></b><br><ul>
+  <i>returns true if there's data, or false if not.</i><br>
+  <tt>Input.poll(): return Bool</tt><br>
+<p>raises a MidiException on error. </p>
+<!--COMMENTS:Input.poll--> &nbsp;<br> 
+<br></ul>
+
+
+<a name="Input.read">
+<big><b>Input.read</big></b><br><ul>
+  <i>reads num_events midi events from the buffer.</i><br>
+  <tt>Input.read(num_events): return midi_event_list</tt><br>
+<p>Reads from the Input buffer and gives back midi events. [[[status,data1,data2,data3],timestamp], </p>
+<pre> [[status,data1,data2,data3],timestamp],...]
+</pre>
+<!--COMMENTS:Input.read--> &nbsp;<br> 
+<br></ul>
+<br></ul>
+
+
+<a name="pygame.midi.MidiException">
+<big><b>pygame.midi.MidiException</big></b><br><ul>
+  <i>exception that pygame.midi functions and classes can raise</i><br>
+  <tt>MidiException(errno)</tt><br>
+ &nbsp;<br> 
+<!--COMMENTS:pygame.midi.MidiException--> &nbsp;<br> 
+<br></ul>
+
+
+<a name="pygame.midi.Output">
+<big><b>pygame.midi.Output</big></b><br><ul>
+  <i>Output is used to send midi to an output device</i><br>
+  <tt>Output(device_id)</tt><br>
+  <tt>Output(device_id, latency = 0)</tt><br>
+  <tt>Output(device_id, buffer_size = 4096)</tt><br>
+  <tt>Output(device_id, latency, buffer_size)</tt><br>
+<ul><small><table>
+  <tr><td><a href="midi.html#Output.note_off">Output.note_off</a> - <font size=-1>turns a midi note off.  Note must be on.</font></td><td>turns a midi note off.  Note must be on.</td></tr>
+  <tr><td><a href="midi.html#Output.note_on">Output.note_on</a> - <font size=-1>turns a midi note on.  Note must be off.</font></td><td>turns a midi note on.  Note must be off.</td></tr>
+  <tr><td><a href="midi.html#Output.set_instrument">Output.set_instrument</a> - <font size=-1>select an instrument, with a value between 0 and 127</font></td><td>select an instrument, with a value between 0 and 127</td></tr>
+  <tr><td><a href="midi.html#Output.write">Output.write</a> - <font size=-1>writes a list of midi data to the Output</font></td><td>writes a list of midi data to the Output</td></tr>
+  <tr><td><a href="midi.html#Output.write_short">Output.write_short</a> - <font size=-1>write_short(status <, data1><, data2>)</font></td><td>write_short(status <, data1><, data2>)</td></tr>
+  <tr><td><a href="midi.html#Output.write_sys_ex">Output.write_sys_ex</a> - <font size=-1>writes a timestamped system-exclusive midi message.</font></td><td>writes a timestamped system-exclusive midi message.</td></tr>
+</table></small></ul>
+<p>The buffer_size specifies the number of output events to be buffered waiting for output. (In some cases -- see below -- PortMidi does not buffer output at all and merely passes data to a lower-level <tt>API</tt>, in which case buffersize is <tt>ignored.)</tt> </p>
+<p>latency is the delay in milliseconds applied to timestamps to determine when the output should actually occur. (If latency is < 0, 0 is <tt>assumed.)</tt> </p>
+<p>If latency is zero, timestamps are ignored and all output is delivered immediately. If latency is greater than zero, output is delayed until the message timestamp plus the latency. <tt>(NOTE:</tt> time is measured relative to the time source indicated by time_proc. Timestamps are absolute, not relative delays or <tt>offsets.)</tt> In some cases, PortMidi can obtain better timing than your application by passing timestamps along to the device driver or hardware. Latency may also help you to synchronize midi data to audio data by matching midi latency to the audio buffer latency. </p>
+<!--COMMENTS:pygame.midi.Output--> &nbsp;<br> 
+
+
+<a name="Output.note_off">
+<big><b>Output.note_off</big></b><br><ul>
+  <i>turns a midi note off.  Note must be on.</i><br>
+  <tt>Output.note_off(note, velocity=None, channel = 0)</tt><br>
+<p>Turn a note off in the output stream. The note must already be on for this to work correctly. </p>
+<!--COMMENTS:Output.note_off--> &nbsp;<br> 
+<br></ul>
+
+
+<a name="Output.note_on">
+<big><b>Output.note_on</big></b><br><ul>
+  <i>turns a midi note on.  Note must be off.</i><br>
+  <tt>Output.note_on(note, velocity=None, channel = 0)</tt><br>
+<p>Turn a note on in the output stream. The note must already be off for this to work correctly. </p>
+<!--COMMENTS:Output.note_on--> &nbsp;<br> 
+<br></ul>
+
+
+<a name="Output.set_instrument">
+<big><b>Output.set_instrument</big></b><br><ul>
+  <i>select an instrument, with a value between 0 and 127</i><br>
+  <tt>Output.set_instrument(instrument_id, channel = 0)</tt><br>
+ &nbsp;<br> 
+<!--COMMENTS:Output.set_instrument--> &nbsp;<br> 
+<br></ul>
+
+
+<a name="Output.write">
+<big><b>Output.write</big></b><br><ul>
+  <i>writes a list of midi data to the Output</i><br>
+  <tt>Output.write(data)</tt><br>
+<p>writes series of <tt>MIDI</tt> information in the form of a list: </p>
+<pre>     write([[[status <,data1><,data2><,data3>],timestamp],
+            [[status <,data1><,data2><,data3>],timestamp],...])
+</pre><p><data> fields are optional example: choose program change 1 at time 20000 and send note 65 with velocity 100 500 ms later. </p>
+<pre>     write([[[0xc0,0,0],20000],[[0x90,60,100],20500]])
+</pre><p>notes: </p>
+<pre>  1. timestamps will be ignored if latency = 0.
+  2. To get a note to play immediately, send MIDI info with
+     timestamp read from function Time.
+  3. understanding optional data fields:
+       write([[[0xc0,0,0],20000]]) is equivalent to
+       write([[[0xc0],20000]])
+</pre><p>Can send up to 1024 elements in your data list, otherwise an </p>
+<pre> IndexError exception is raised.
+</pre>
+<!--COMMENTS:Output.write--> &nbsp;<br> 
+<br></ul>
+
+
+<a name="Output.write_short">
+<big><b>Output.write_short</big></b><br><ul>
+  <i>write_short(status <, data1><, data2>)</i><br>
+  <tt>Output.write_short(status)</tt><br>
+  <tt>Output.write_short(status, data1 = 0, data2 = 0)</tt><br>
+<p>output <tt>MIDI</tt> information of 3 bytes or less. data fields are optional status byte could be: </p>
+<pre>     0xc0 = program change
+     0x90 = note on
+     etc.
+     data bytes are optional and assumed 0 if omitted
+</pre><p>example: note 65 on with velocity 100 </p>
+<pre>     write_short(0x90,65,100)
+</pre>
+<!--COMMENTS:Output.write_short--> &nbsp;<br> 
+<br></ul>
+
+
+<a name="Output.write_sys_ex">
+<big><b>Output.write_sys_ex</big></b><br><ul>
+  <i>writes a timestamped system-exclusive midi message.</i><br>
+  <tt>Output.write_sys_ex(when, msg)</tt><br>
+<p>msg - can be a *list* or a *string* when - a timestamp in miliseconds example: </p>
+<pre>  (assuming o is an onput MIDI stream)
+    o.write_sys_ex(0,'\xF0\x7D\x10\x11\x12\x13\xF7')
+  is equivalent to
+    o.write_sys_ex(pygame.midi.time(),
+                   [0xF0,0x7D,0x10,0x11,0x12,0x13,0xF7])
+</pre>
+<!--COMMENTS:Output.write_sys_ex--> &nbsp;<br> 
+<br></ul>
+<br></ul>
+
+
+<a name="pygame.midi.get_count">
+<big><b>pygame.midi.get_count</big></b><br><ul>
+  <i>gets the number of devices.</i><br>
+  <tt>pygame.midi.get_count(): return num_devices</tt><br>
+<p>Device ids range from 0 to get_count() -1 </p>
+<!--COMMENTS:pygame.midi.get_count--> &nbsp;<br> 
+<br></ul>
+
+
+<a name="pygame.midi.get_default_input_id">
+<big><b>pygame.midi.get_default_input_id</big></b><br><ul>
+  <i>gets default input device number</i><br>
+  <tt>pygame.midi.get_default_input_id(): return default_id</tt><br>
+<p>Return the default device <tt>ID</tt> or -1 if there are no devices. The result can be passed to the Input()/Ouput() class. </p>
+<p>On the <tt>PC</tt>, the user can specify a default device by setting an environment variable. For example, to use device #1. </p>
+<pre>    set PM_RECOMMENDED_INPUT_DEVICE=1
+</pre><p>The user should first determine the available device <tt>ID</tt> by using the supplied application "testin" or "testout". </p>
+<p>In general, the registry is a better place for this kind of info, and with <tt>USB</tt> devices that can come and go, using integers is not very reliable for device identification. Under Windows, if <tt>PM_RECOMMENDED_OUTPUT_DEVICE</tt> (or <tt>PM_RECOMMENDED_INPUT_DEVICE)</tt> is <tt>*NOT*</tt> found in the environment, then the default device is obtained by looking for a string in the registry under: </p>
+<pre>    HKEY_LOCAL_MACHINE/SOFTWARE/PortMidi/Recommended_Input_Device
+</pre><p>and HKEY_LOCAL_MACHINE/SOFTWARE/PortMidi/Recommended_Output_Device for a string. The number of the first device with a substring that matches the string exactly is returned. For example, if the string in the registry is <tt>"USB"</tt>, and device 1 is named "In <tt>USB</tt> MidiSport 1x1", then that will be the default input because it contains the string <tt>"USB"</tt>. </p>
+<p>In addition to the name, get_device_info() returns "interf", which is the interface name. (The "interface" is the underlying software system or <tt>API</tt> used by PortMidi to access devices. Examples are MMSystem, DirectX (not implemented), <tt>ALSA</tt>, <tt>OSS</tt> (not implemented), <tt>etc.)</tt> At present, the only Win32 interface is "MMSystem", the only Linux interface is <tt>"ALSA"</tt>, and the only Max <tt>OS</tt> <tt>X</tt> interface is "CoreMIDI". To specify both the interface and the device name in the registry, separate the two with a comma and a space, <tt>e.g.:</tt> </p>
+<pre>    MMSystem, In USB MidiSport 1x1
+</pre><p>In this case, the string before the comma must be a substring of the "interf" string, and the string after the space must be a substring of the "name" name string in order to match the device. </p>
+<p>Note: in the current release, the default is simply the first device (the input or output device with the lowest PmDeviceID). </p>
+<!--COMMENTS:pygame.midi.get_default_input_id--> &nbsp;<br> 
+<br></ul>
+
+
+<a name="pygame.midi.get_default_output_id">
+<big><b>pygame.midi.get_default_output_id</big></b><br><ul>
+  <i>gets default output device number</i><br>
+  <tt>pygame.midi.get_default_output_id(): return default_id</tt><br>
+<p>Return the default device <tt>ID</tt> or -1 if there are no devices. The result can be passed to the Input()/Ouput() class. </p>
+<p>On the <tt>PC</tt>, the user can specify a default device by setting an environment variable. For example, to use device #1. </p>
+<pre>    set PM_RECOMMENDED_OUTPUT_DEVICE=1
+</pre><p>The user should first determine the available device <tt>ID</tt> by using the supplied application "testin" or "testout". </p>
+<p>In general, the registry is a better place for this kind of info, and with <tt>USB</tt> devices that can come and go, using integers is not very reliable for device identification. Under Windows, if <tt>PM_RECOMMENDED_OUTPUT_DEVICE</tt> (or <tt>PM_RECOMMENDED_INPUT_DEVICE)</tt> is <tt>*NOT*</tt> found in the environment, then the default device is obtained by looking for a string in the registry under: </p>
+<pre>    HKEY_LOCAL_MACHINE/SOFTWARE/PortMidi/Recommended_Input_Device
+</pre><p>and HKEY_LOCAL_MACHINE/SOFTWARE/PortMidi/Recommended_Output_Device for a string. The number of the first device with a substring that matches the string exactly is returned. For example, if the string in the registry is <tt>"USB"</tt>, and device 1 is named "In <tt>USB</tt> MidiSport 1x1", then that will be the default input because it contains the string <tt>"USB"</tt>. </p>
+<p>In addition to the name, get_device_info() returns "interf", which is the interface name. (The "interface" is the underlying software system or <tt>API</tt> used by PortMidi to access devices. Examples are MMSystem, DirectX (not implemented), <tt>ALSA</tt>, <tt>OSS</tt> (not implemented), <tt>etc.)</tt> At present, the only Win32 interface is "MMSystem", the only Linux interface is <tt>"ALSA"</tt>, and the only Max <tt>OS</tt> <tt>X</tt> interface is "CoreMIDI". To specify both the interface and the device name in the registry, separate the two with a comma and a space, <tt>e.g.:</tt> </p>
+<pre>    MMSystem, In USB MidiSport 1x1
+</pre><p>In this case, the string before the comma must be a substring of the "interf" string, and the string after the space must be a substring of the "name" name string in order to match the device. </p>
+<p>Note: in the current release, the default is simply the first device (the input or output device with the lowest PmDeviceID). </p>
+<!--COMMENTS:pygame.midi.get_default_output_id--> &nbsp;<br> 
+<br></ul>
+
+
+<a name="pygame.midi.get_device_info">
+<big><b>pygame.midi.get_device_info</big></b><br><ul>
+  <i> returns information about a midi device</i><br>
+  <tt>pygame.midi.get_device_info(an_id): return (interf, name, input, output, opened)</tt><br>
+<p>interf - a text string describing the device interface, eg <tt>'ALSA'</tt>. name - a text string for the name of the device, eg 'Midi Through Port-0' input - 0, or 1 if the device is an input device. output - 0, or 1 if the device is an output device. opened - 0, or 1 if the device is opened. </p>
+<p>If the id is out of range, the function returns None. </p>
+<!--COMMENTS:pygame.midi.get_device_info--> &nbsp;<br> 
+<br></ul>
+
+
+<a name="pygame.midi.init">
+<big><b>pygame.midi.init</big></b><br><ul>
+  <i>initialize the midi module</i><br>
+  <tt>pygame.midi.init(): return None</tt><br>
+<p>Call the initialisation function before using the midi module. </p>
+<p>It is safe to call this more than once. </p>
+<!--COMMENTS:pygame.midi.init--> &nbsp;<br> 
+<br></ul>
+
+
+<a name="pygame.midi.midis2events">
+<big><b>pygame.midi.midis2events</big></b><br><ul>
+  <i>converts midi events to pygame events</i><br>
+  <tt>pygame.midi.midis2events(midis, device_id): return [Event, ...]</tt><br>
+<p>Takes a sequence of midi events and returns list of pygame events. </p>
+<!--COMMENTS:pygame.midi.midis2events--> &nbsp;<br> 
+<br></ul>
+
+
+<a name="pygame.midi.quit">
+<big><b>pygame.midi.quit</big></b><br><ul>
+  <i>uninitialize the midi module</i><br>
+  <tt>pygame.midi.quit(): return None</tt><br>
+<p>Called automatically atexit if you don't call it. </p>
+<p>It is safe to call this function more than once. </p>
+<!--COMMENTS:pygame.midi.quit--> &nbsp;<br> 
+<br></ul>
+
+
+<a name="pygame.midi.time">
+<big><b>pygame.midi.time</big></b><br><ul>
+  <i>returns the current time in ms of the PortMidi timer</i><br>
+  <tt>pygame.midi.time(): return time</tt><br>
+<p>The time is reset to 0, when the module is inited. </p>
+<!--COMMENTS:pygame.midi.time--> &nbsp;<br> 
+<br></ul>
 <br></ul>
 
 </body></html>
 
 
     if device_id is None:
-        input_id = pygame.midi.get_default_input_device_id()
+        input_id = pygame.midi.get_default_input_id()
     else:
         input_id = device_id
 
     _print_device_info()
 
     if device_id is None:
-        port = pygame.midi.get_default_output_device_id()
+        port = pygame.midi.get_default_device_id()
     else:
         port = device_id
 
 pygame.midi
-send and receive midi messages
+pygame module for interacting with midi input and output.
 
-=== Under Development ===
+The midi module can send output to midi devices, and get input
+from midi devices.  It can also list midi devices on the system.
 
-See examples\midi.py for the current status the midi module api.
+Including real midi devices, and virtual ones.
+
+It uses the portmidi library.  Is portable to which ever platforms
+portmidi supports (currently windows, OSX, and linux).
+
+This uses pyportmidi for now, but may use its own bindings at some
+point in the future.
+
+New in pygame 1.9.0.
+
+<SECTION>
+
+
+
+Input
+Input is used to get midi input from midi devices.
+Input(device_id)
+Input(device_id, buffer_size)
+
+buffer_size -the number of input events to be buffered waiting to 
+  be read using Input.read() 
+<SECTION>
+
+
+
+poll
+returns true if there's data, or false if not.
+Input.poll(): return Bool
+
+raises a MidiException on error.
 <END>
+
+
+
+read
+reads num_events midi events from the buffer.
+Input.read(num_events): return midi_event_list
+
+Reads from the Input buffer and gives back midi events.
+[[[status,data1,data2,data3],timestamp],
+ [[status,data1,data2,data3],timestamp],...]
+<END>
+<END>
+
+
+
+MidiException
+exception that pygame.midi functions and classes can raise
+MidiException(errno)
+<END>
+
+
+
+Output
+Output is used to send midi to an output device
+Output(device_id)
+Output(device_id, latency = 0)
+Output(device_id, buffer_size = 4096)
+Output(device_id, latency, buffer_size)
+
+The buffer_size specifies the number of output events to be 
+buffered waiting for output.  (In some cases -- see below -- 
+PortMidi does not buffer output at all and merely passes data 
+to a lower-level API, in which case buffersize is ignored.)
+
+latency is the delay in milliseconds applied to timestamps to determine
+when the output should actually occur. (If latency is < 0, 0 is 
+assumed.)
+
+If latency is zero, timestamps are ignored and all output is delivered
+immediately. If latency is greater than zero, output is delayed until
+the message timestamp plus the latency. (NOTE: time is measured 
+relative to the time source indicated by time_proc. Timestamps are 
+absolute, not relative delays or offsets.) In some cases, PortMidi 
+can obtain better timing than your application by passing timestamps 
+along to the device driver or hardware. Latency may also help you 
+to synchronize midi data to audio data by matching midi latency to 
+the audio buffer latency.
+<SECTION>
+
+
+
+note_off
+turns a midi note off.  Note must be on.
+Output.note_off(note, velocity=None, channel = 0)
+
+Turn a note off in the output stream.  The note must already
+be on for this to work correctly.
+<END>
+
+
+
+note_on
+turns a midi note on.  Note must be off.
+Output.note_on(note, velocity=None, channel = 0)
+
+Turn a note on in the output stream.  The note must already
+be off for this to work correctly.
+<END>
+
+
+
+set_instrument
+select an instrument, with a value between 0 and 127
+Output.set_instrument(instrument_id, channel = 0)
+<END>
+
+
+
+write
+writes a list of midi data to the Output
+Output.write(data)
+
+writes series of MIDI information in the form of a list:
+     write([[[status <,data1><,data2><,data3>],timestamp],
+            [[status <,data1><,data2><,data3>],timestamp],...])
+<data> fields are optional
+example: choose program change 1 at time 20000 and
+send note 65 with velocity 100 500 ms later.
+     write([[[0xc0,0,0],20000],[[0x90,60,100],20500]])
+notes:
+  1. timestamps will be ignored if latency = 0.
+  2. To get a note to play immediately, send MIDI info with
+     timestamp read from function Time.
+  3. understanding optional data fields:
+       write([[[0xc0,0,0],20000]]) is equivalent to
+       write([[[0xc0],20000]])
+
+Can send up to 1024 elements in your data list, otherwise an 
+ IndexError exception is raised.
+<END>
+
+
+
+write_short
+write_short(status <, data1><, data2>)
+Output.write_short(status)
+Output.write_short(status, data1 = 0, data2 = 0)
+
+output MIDI information of 3 bytes or less.
+data fields are optional
+status byte could be:
+     0xc0 = program change
+     0x90 = note on
+     etc.
+     data bytes are optional and assumed 0 if omitted
+example: note 65 on with velocity 100
+     write_short(0x90,65,100)
+<END>
+
+
+
+write_sys_ex
+writes a timestamped system-exclusive midi message.
+Output.write_sys_ex(when, msg)
+
+msg - can be a *list* or a *string*
+when - a timestamp in miliseconds
+example:
+  (assuming o is an onput MIDI stream)
+    o.write_sys_ex(0,'\xF0\x7D\x10\x11\x12\x13\xF7')
+  is equivalent to
+    o.write_sys_ex(pygame.midi.time(),
+                   [0xF0,0x7D,0x10,0x11,0x12,0x13,0xF7])
+<END>
+<END>
+
+
+
+get_count
+gets the number of devices.
+pygame.midi.get_count(): return num_devices
+
+
+Device ids range from 0 to get_count() -1
+<END>
+
+
+
+get_default_input_id
+gets default input device number
+pygame.midi.get_default_input_id(): return default_id
+
+
+Return the default device ID or -1 if there are no devices.
+The result can be passed to the Input()/Ouput() class.
+
+On the PC, the user can specify a default device by
+setting an environment variable. For example, to use device #1.
+
+    set PM_RECOMMENDED_INPUT_DEVICE=1
+
+The user should first determine the available device ID by using
+the supplied application "testin" or "testout".
+
+In general, the registry is a better place for this kind of info,
+and with USB devices that can come and go, using integers is not
+very reliable for device identification. Under Windows, if
+PM_RECOMMENDED_OUTPUT_DEVICE (or PM_RECOMMENDED_INPUT_DEVICE) is
+*NOT* found in the environment, then the default device is obtained
+by looking for a string in the registry under:
+    HKEY_LOCAL_MACHINE/SOFTWARE/PortMidi/Recommended_Input_Device
+and HKEY_LOCAL_MACHINE/SOFTWARE/PortMidi/Recommended_Output_Device
+for a string. The number of the first device with a substring that
+matches the string exactly is returned. For example, if the string
+in the registry is "USB", and device 1 is named
+"In USB MidiSport 1x1", then that will be the default
+input because it contains the string "USB".
+
+In addition to the name, get_device_info() returns "interf", which
+is the interface name. (The "interface" is the underlying software
+system or API used by PortMidi to access devices. Examples are
+MMSystem, DirectX (not implemented), ALSA, OSS (not implemented), etc.)
+At present, the only Win32 interface is "MMSystem", the only Linux
+interface is "ALSA", and the only Max OS X interface is "CoreMIDI".
+To specify both the interface and the device name in the registry,
+separate the two with a comma and a space, e.g.:
+    MMSystem, In USB MidiSport 1x1
+In this case, the string before the comma must be a substring of
+the "interf" string, and the string after the space must be a
+substring of the "name" name string in order to match the device.
+
+Note: in the current release, the default is simply the first device
+(the input or output device with the lowest PmDeviceID).
+<END>
+
+
+
+get_default_output_id
+gets default output device number
+pygame.midi.get_default_output_id(): return default_id
+
+
+Return the default device ID or -1 if there are no devices.
+The result can be passed to the Input()/Ouput() class.
+
+On the PC, the user can specify a default device by
+setting an environment variable. For example, to use device #1.
+
+    set PM_RECOMMENDED_OUTPUT_DEVICE=1
+
+The user should first determine the available device ID by using
+the supplied application "testin" or "testout".
+
+In general, the registry is a better place for this kind of info,
+and with USB devices that can come and go, using integers is not
+very reliable for device identification. Under Windows, if
+PM_RECOMMENDED_OUTPUT_DEVICE (or PM_RECOMMENDED_INPUT_DEVICE) is
+*NOT* found in the environment, then the default device is obtained
+by looking for a string in the registry under:
+    HKEY_LOCAL_MACHINE/SOFTWARE/PortMidi/Recommended_Input_Device
+and HKEY_LOCAL_MACHINE/SOFTWARE/PortMidi/Recommended_Output_Device
+for a string. The number of the first device with a substring that
+matches the string exactly is returned. For example, if the string
+in the registry is "USB", and device 1 is named
+"In USB MidiSport 1x1", then that will be the default
+input because it contains the string "USB".
+
+In addition to the name, get_device_info() returns "interf", which
+is the interface name. (The "interface" is the underlying software
+system or API used by PortMidi to access devices. Examples are
+MMSystem, DirectX (not implemented), ALSA, OSS (not implemented), etc.)
+At present, the only Win32 interface is "MMSystem", the only Linux
+interface is "ALSA", and the only Max OS X interface is "CoreMIDI".
+To specify both the interface and the device name in the registry,
+separate the two with a comma and a space, e.g.:
+    MMSystem, In USB MidiSport 1x1
+In this case, the string before the comma must be a substring of
+the "interf" string, and the string after the space must be a
+substring of the "name" name string in order to match the device.
+
+Note: in the current release, the default is simply the first device
+(the input or output device with the lowest PmDeviceID).
+<END>
+
+
+
+get_device_info
+ returns information about a midi device
+pygame.midi.get_device_info(an_id): return (interf, name, input, output, opened) 
+
+interf - a text string describing the device interface, eg 'ALSA'.
+name - a text string for the name of the device, eg 'Midi Through Port-0'
+input - 0, or 1 if the device is an input device.
+output - 0, or 1 if the device is an output device.
+opened - 0, or 1 if the device is opened.
+
+If the id is out of range, the function returns None.
+<END>
+
+
+
+init
+initialize the midi module
+pygame.midi.init(): return None
+
+Call the initialisation function before using the midi module.
+
+It is safe to call this more than once.
+<END>
+
+
+
+midis2events
+converts midi events to pygame events
+pygame.midi.midis2events(midis, device_id): return [Event, ...]
+
+Takes a sequence of midi events and returns list of pygame events.
+<END>
+
+
+
+quit
+uninitialize the midi module
+pygame.midi.quit(): return None
+
+
+Called automatically atexit if you don't call it.
+
+It is safe to call this function more than once.
+<END>
+
+
+
+time
+returns the current time in ms of the PortMidi timer
+pygame.midi.time(): return time
+
+The time is reset to 0, when the module is inited.
+<END>
+
+
+
 if sys.version_info >= (3, 0, 0):
     python3_skip = ['scrap',
                     '_camera',
-                    'pypm',
-                    'movieext',
                     '_numericsurfarray',
                     '_numericsndarray',
                     ]
     return ret;
 }
 
+
+/*
+returns the number of connected components.
+returns -2 on memory allocation error.
+Allocates memory for components.
+
+*/
 static int get_connected_components(bitmask_t *mask, bitmask_t ***components, int min)
 {
     unsigned int *image, *ufind, *largest, *buf;
     /* allocate enough space for the maximum possible connected components */
     /* the union-find array. see wikipedia for info on union find */
     ufind = (unsigned int *) malloc(sizeof(int)*(w/2 + 1)*(h/2 + 1));
-    if(!ufind) { return -2; }
+    if(!ufind) { 
+        free(image);
+        return -2; 
+    }
 
     largest = (unsigned int *) malloc(sizeof(int)*(w/2 + 1)*(h/2 + 1));
-    if(!largest) { return -2; }
+    if(!largest) { 
+        free(image);
+        free(ufind);
+        return -2; 
+    }
 
     /* do the initial labelling */
     label = cc_label(mask, image, ufind, largest);
 
     /* allocate space for the mask array */
     comps = (bitmask_t **) malloc(sizeof(bitmask_t *) * (relabel +1));
-    if(!comps) { return -2; }
+    if(!comps) { 
+        free(image);
+        free(ufind);
+        free(largest);
+        return -2; 
+    }
 
     /* create the empty masks */
     for (x = 1; x <= relabel; x++) {
    This implementation also tracks the number of pixels in each label, finding
    the biggest one while flattening the union-find equivalence array.  It then
    writes an output mask containing only the largest connected component. */
+
+
+/*
+returns -2 on memory allocation error.
+*/
 static int largest_connected_comp(bitmask_t* input, bitmask_t* output, int ccx, int ccy)
 {
     unsigned int *image, *ufind, *largest, *buf;
 
 #define DOC_MASKGETBOUNDINGRECTS "Mask.get_bounding_rects() -> Rects\nReturns a list of bounding rects of regions of set pixels."
 
-#define DOC_PYGAMEMIDI "send and receive midi messages"
+#define DOC_PYGAMEMIDI "pygame module for interacting with midi input and output."
+
+#define DOC_PYGAMEMIDIINPUT "Input(device_id)\nInput(device_id, buffer_size)\nInput is used to get midi input from midi devices."
+
+#define DOC_INPUTPOLL "Input.poll(): return Bool\nreturns true if there's data, or false if not."
+
+#define DOC_INPUTREAD "Input.read(num_events): return midi_event_list\nreads num_events midi events from the buffer."
+
+#define DOC_PYGAMEMIDIMIDIEXCEPTION "MidiException(errno)\nexception that pygame.midi functions and classes can raise"
+
+#define DOC_PYGAMEMIDIOUTPUT "Output(device_id)\nOutput(device_id, latency = 0)\nOutput(device_id, buffer_size = 4096)\nOutput(device_id, latency, buffer_size)\nOutput is used to send midi to an output device"
+
+#define DOC_OUTPUTNOTEOFF "Output.note_off(note, velocity=None, channel = 0)\nturns a midi note off.  Note must be on."
+
+#define DOC_OUTPUTNOTEON "Output.note_on(note, velocity=None, channel = 0)\nturns a midi note on.  Note must be off."
+
+#define DOC_OUTPUTSETINSTRUMENT "Output.set_instrument(instrument_id, channel = 0)\nselect an instrument, with a value between 0 and 127"
+
+#define DOC_OUTPUTWRITE "Output.write(data)\nwrites a list of midi data to the Output"
+
+#define DOC_OUTPUTWRITESHORT "Output.write_short(status)\nOutput.write_short(status, data1 = 0, data2 = 0)\nwrite_short(status <, data1><, data2>)"
+
+#define DOC_OUTPUTWRITESYSEX "Output.write_sys_ex(when, msg)\nwrites a timestamped system-exclusive midi message."
+
+#define DOC_PYGAMEMIDIGETCOUNT "pygame.midi.get_count(): return num_devices\ngets the number of devices."
+
+#define DOC_PYGAMEMIDIGETDEFAULTINPUTID "pygame.midi.get_default_input_id(): return default_id\ngets default input device number"
+
+#define DOC_PYGAMEMIDIGETDEFAULTOUTPUTID "pygame.midi.get_default_output_id(): return default_id\ngets default output device number"
+
+#define DOC_PYGAMEMIDIGETDEVICEINFO "pygame.midi.get_device_info(an_id): return (interf, name, input, output, opened)\n returns information about a midi device"
+
+#define DOC_PYGAMEMIDIINIT "pygame.midi.init(): return None\ninitialize the midi module"
+
+#define DOC_PYGAMEMIDIMIDIS2EVENTS "pygame.midi.midis2events(midis, device_id): return [Event, ...]\nconverts midi events to pygame events"
+
+#define DOC_PYGAMEMIDIQUIT "pygame.midi.quit(): return None\nuninitialize the midi module"
+
+#define DOC_PYGAMEMIDITIME "pygame.midi.time(): return time\nreturns the current time in ms of the PortMidi timer"
 
 #define DOC_PYGAMEMIXER "pygame module for loading and playing sounds"
 
 
 
 pygame.midi
- send and receive midi messages
+ pygame module for interacting with midi input and output.
+
+
+
+pygame.midi.Input
+ Input(device_id)
+Input(device_id, buffer_size)
+Input is used to get midi input from midi devices.
+
+
+
+Input.poll
+ Input.poll(): return Bool
+returns true if there's data, or false if not.
+
+
+
+Input.read
+ Input.read(num_events): return midi_event_list
+reads num_events midi events from the buffer.
+
+
+
+pygame.midi.MidiException
+ MidiException(errno)
+exception that pygame.midi functions and classes can raise
+
+
+
+pygame.midi.Output
+ Output(device_id)
+Output(device_id, latency = 0)
+Output(device_id, buffer_size = 4096)
+Output(device_id, latency, buffer_size)
+Output is used to send midi to an output device
+
+
+
+Output.note_off
+ Output.note_off(note, velocity=None, channel = 0)
+turns a midi note off.  Note must be on.
+
+
+
+Output.note_on
+ Output.note_on(note, velocity=None, channel = 0)
+turns a midi note on.  Note must be off.
+
+
+
+Output.set_instrument
+ Output.set_instrument(instrument_id, channel = 0)
+select an instrument, with a value between 0 and 127
+
+
+
+Output.write
+ Output.write(data)
+writes a list of midi data to the Output
+
+
+
+Output.write_short
+ Output.write_short(status)
+Output.write_short(status, data1 = 0, data2 = 0)
+write_short(status <, data1><, data2>)
+
+
+
+Output.write_sys_ex
+ Output.write_sys_ex(when, msg)
+writes a timestamped system-exclusive midi message.
+
+
+
+pygame.midi.get_count
+ pygame.midi.get_count(): return num_devices
+gets the number of devices.
+
+
+
+pygame.midi.get_default_input_id
+ pygame.midi.get_default_input_id(): return default_id
+gets default input device number
+
+
+
+pygame.midi.get_default_output_id
+ pygame.midi.get_default_output_id(): return default_id
+gets default output device number
+
+
+
+pygame.midi.get_device_info
+ pygame.midi.get_device_info(an_id): return (interf, name, input, output, opened)
+ returns information about a midi device
+
+
+
+pygame.midi.init
+ pygame.midi.init(): return None
+initialize the midi module
+
+
+
+pygame.midi.midis2events
+ pygame.midi.midis2events(midis, device_id): return [Event, ...]
+converts midi events to pygame events
+
+
+
+pygame.midi.quit
+ pygame.midi.quit(): return None
+uninitialize the midi module
+
+
+
+pygame.midi.time
+ pygame.midi.time(): return time
+returns the current time in ms of the PortMidi timer
 
 
 
-/* 0.9.7 on Fri Feb  6 11:12:52 2009 */
+/* Generated by Cython 0.11.2 on Sun May 24 23:05:02 2009 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
 #include "structmember.h"
+#ifndef Py_PYTHON_H
+    #error Python headers needed to compile C extensions, please install development version of Python.
+#endif
 #ifndef PY_LONG_LONG
   #define PY_LONG_LONG LONG_LONG
 #endif
+#ifndef DL_EXPORT
+  #define DL_EXPORT(t) t
+#endif
+#if PY_VERSION_HEX < 0x02040000
+  #define METH_COEXIST 0
+  #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
+#endif
 #if PY_VERSION_HEX < 0x02050000
   typedef int Py_ssize_t;
   #define PY_SSIZE_T_MAX INT_MAX
   #define PY_SSIZE_T_MIN INT_MIN
+  #define PY_FORMAT_SIZE_T ""
   #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
-  #define PyInt_AsSsize_t(o)	PyInt_AsLong(o)
+  #define PyInt_AsSsize_t(o)   PyInt_AsLong(o)
+  #define PyNumber_Index(o)    PyNumber_Int(o)
+  #define PyIndex_Check(o)     PyNumber_Check(o)
 #endif
-#ifndef WIN32
+#if PY_VERSION_HEX < 0x02060000
+  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
+  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
+  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
+  #define PyVarObject_HEAD_INIT(type, size) \
+          PyObject_HEAD_INIT(type) size,
+  #define PyType_Modified(t)
+
+  typedef struct {
+       void *buf;
+       PyObject *obj;
+       Py_ssize_t len;
+       Py_ssize_t itemsize;
+       int readonly;
+       int ndim;
+       char *format;
+       Py_ssize_t *shape;
+       Py_ssize_t *strides;
+       Py_ssize_t *suboffsets;
+       void *internal;
+  } Py_buffer;
+
+  #define PyBUF_SIMPLE 0
+  #define PyBUF_WRITABLE 0x0001
+  #define PyBUF_FORMAT 0x0004
+  #define PyBUF_ND 0x0008
+  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
+  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
+  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
+  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
+  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
+
+#endif
+#if PY_MAJOR_VERSION < 3
+  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
+#else
+  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define Py_TPFLAGS_CHECKTYPES 0
+  #define Py_TPFLAGS_HAVE_INDEX 0
+#endif
+#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
+  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define PyBaseString_Type            PyUnicode_Type
+  #define PyString_Type                PyBytes_Type
+  #define PyString_CheckExact          PyBytes_CheckExact
+  #define PyInt_Type                   PyLong_Type
+  #define PyInt_Check(op)              PyLong_Check(op)
+  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
+  #define PyInt_FromString             PyLong_FromString
+  #define PyInt_FromUnicode            PyLong_FromUnicode
+  #define PyInt_FromLong               PyLong_FromLong
+  #define PyInt_FromSize_t             PyLong_FromSize_t
+  #define PyInt_FromSsize_t            PyLong_FromSsize_t
+  #define PyInt_AsLong                 PyLong_AsLong
+  #define PyInt_AS_LONG                PyLong_AS_LONG
+  #define PyInt_AsSsize_t              PyLong_AsSsize_t
+  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
+  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
+  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
+#else
+  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
+  #define PyBytes_Type                 PyString_Type
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define PyMethod_New(func, self, klass) PyInstanceMethod_New(func)
+#endif
+#if !defined(WIN32) && !defined(MS_WINDOWS)
   #ifndef __stdcall
     #define __stdcall
   #endif
   #ifndef __cdecl
     #define __cdecl
   #endif
+  #ifndef __fastcall
+    #define __fastcall
+  #endif
+#else
+  #define _USE_MATH_DEFINES
+#endif
+#if PY_VERSION_HEX < 0x02050000
+  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
+  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
+  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
+#else
+  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
+  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
+  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
+#endif
+#if PY_VERSION_HEX < 0x02050000
+  #define __Pyx_NAMESTR(n) ((char *)(n))
+  #define __Pyx_DOCSTR(n)  ((char *)(n))
+#else
+  #define __Pyx_NAMESTR(n) (n)
+  #define __Pyx_DOCSTR(n)  (n)
 #endif
 #ifdef __cplusplus
 #define __PYX_EXTERN_C extern "C"
 #define __PYX_EXTERN_C extern
 #endif
 #include <math.h>
+#define __PYX_HAVE_API__pypm
 #include "portmidi.h"
 #include "porttime.h"
-
-
-typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/
-typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
-
+#define __PYX_USE_C99_COMPLEX defined(_Complex_I)
+
+
+#ifdef __GNUC__
+#define INLINE __inline__
+#elif _WIN32
+#define INLINE __inline
+#else
+#define INLINE 
+#endif
+
+typedef struct {PyObject **p; char *s; long n; char is_unicode; char intern; char is_identifier;} __Pyx_StringTabEntry; /*proto*/
+
+
+
+static int __pyx_skip_dispatch = 0;
+
+
+/* Type Conversion Predeclarations */
+
+#if PY_MAJOR_VERSION < 3
+#define __Pyx_PyBytes_FromString          PyString_FromString
+#define __Pyx_PyBytes_FromStringAndSize   PyString_FromStringAndSize
+#define __Pyx_PyBytes_AsString            PyString_AsString
+#else
+#define __Pyx_PyBytes_FromString          PyBytes_FromString
+#define __Pyx_PyBytes_FromStringAndSize   PyBytes_FromStringAndSize
+#define __Pyx_PyBytes_AsString            PyBytes_AsString
+#endif
+
+#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
+static INLINE int __Pyx_PyObject_IsTrue(PyObject*);
+static INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
+
+#if !defined(T_PYSSIZET)
+#if PY_VERSION_HEX < 0x02050000
+#define T_PYSSIZET T_INT
+#elif !defined(T_LONGLONG)
+#define T_PYSSIZET \
+        ((sizeof(Py_ssize_t) == sizeof(int))  ? T_INT  : \
+        ((sizeof(Py_ssize_t) == sizeof(long)) ? T_LONG : -1))
+#else
+#define T_PYSSIZET \
+        ((sizeof(Py_ssize_t) == sizeof(int))          ? T_INT      : \
+        ((sizeof(Py_ssize_t) == sizeof(long))         ? T_LONG     : \
+        ((sizeof(Py_ssize_t) == sizeof(PY_LONG_LONG)) ? T_LONGLONG : -1)))
+#endif
+#endif
+
+#if !defined(T_SIZET)
+#if !defined(T_ULONGLONG)
+#define T_SIZET \
+        ((sizeof(size_t) == sizeof(unsigned int))  ? T_UINT  : \
+        ((sizeof(size_t) == sizeof(unsigned long)) ? T_ULONG : -1))
+#else
+#define T_SIZET \
+        ((sizeof(size_t) == sizeof(unsigned int))          ? T_UINT      : \
+        ((sizeof(size_t) == sizeof(unsigned long))         ? T_ULONG     : \
+        ((sizeof(size_t) == sizeof(unsigned PY_LONG_LONG)) ? T_ULONGLONG : -1)))
+#endif
+#endif
+
+static INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
+static INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
+static INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
+
+#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
+
+
+#ifdef __GNUC__
+/* Test for GCC > 2.95 */
+#if __GNUC__ > 2 ||               (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) 
+#define likely(x)   __builtin_expect(!!(x), 1)
+#define unlikely(x) __builtin_expect(!!(x), 0)
+#else /* __GNUC__ > 2 ... */
+#define likely(x)   (x)
+#define unlikely(x) (x)
+#endif /* __GNUC__ > 2 ... */
+#else /* __GNUC__ */
+#define likely(x)   (x)
+#define unlikely(x) (x)
+#endif /* __GNUC__ */
+    
 static PyObject *__pyx_m;
 static PyObject *__pyx_b;
+static PyObject *__pyx_empty_tuple;
 static int __pyx_lineno;
-static char *__pyx_filename;
-static char **__pyx_f;
+static int __pyx_clineno = 0;
+static const char * __pyx_cfilenm= __FILE__;
+static const char *__pyx_filename;
+static const char **__pyx_f;
+
+
+#ifdef CYTHON_REFNANNY
+typedef struct {
+  void (*INCREF)(void*, PyObject*, int);
+  void (*DECREF)(void*, PyObject*, int);
+  void (*GOTREF)(void*, PyObject*, int);
+  void (*GIVEREF)(void*, PyObject*, int);
+  void* (*NewContext)(const char*, int, const char*);
+  void (*FinishContext)(void**);
+} __Pyx_RefnannyAPIStruct;
+static __Pyx_RefnannyAPIStruct *__Pyx_Refnanny = NULL;
+#define __Pyx_ImportRefcountAPI(name)   (__Pyx_RefnannyAPIStruct *) PyCObject_Import((char *)name, (char *)"RefnannyAPI")
+#define __Pyx_INCREF(r) __Pyx_Refnanny->INCREF(__pyx_refchk, (PyObject *)(r), __LINE__)
+#define __Pyx_DECREF(r) __Pyx_Refnanny->DECREF(__pyx_refchk, (PyObject *)(r), __LINE__)
+#define __Pyx_GOTREF(r) __Pyx_Refnanny->GOTREF(__pyx_refchk, (PyObject *)(r), __LINE__)
+#define __Pyx_GIVEREF(r) __Pyx_Refnanny->GIVEREF(__pyx_refchk, (PyObject *)(r), __LINE__)
+#define __Pyx_XDECREF(r) if((r) == NULL) ; else __Pyx_DECREF(r)
+#define __Pyx_SetupRefcountContext(name)   void* __pyx_refchk = __Pyx_Refnanny->NewContext((name), __LINE__, __FILE__)
+#define __Pyx_FinishRefcountContext()   __Pyx_Refnanny->FinishContext(&__pyx_refchk)
+#else
+#define __Pyx_INCREF(r) Py_INCREF(r)
+#define __Pyx_DECREF(r) Py_DECREF(r)
+#define __Pyx_GOTREF(r)
+#define __Pyx_GIVEREF(r)
+#define __Pyx_XDECREF(r) Py_XDECREF(r)
+#define __Pyx_SetupRefcountContext(name)
+#define __Pyx_FinishRefcountContext()
+#endif /* CYTHON_REFNANNY */
+#define __Pyx_XGIVEREF(r) if((r) == NULL) ; else __Pyx_GIVEREF(r)
+#define __Pyx_XGOTREF(r) if((r) == NULL) ; else __Pyx_GOTREF(r)
+
+static void __Pyx_RaiseDoubleKeywordsError(
+    const char* func_name, PyObject* kw_name); /*proto*/
+
+static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
+    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
+
+static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/
+
+
+static INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
+    PyObject *r;
+    if (!j) return NULL;
+    r = PyObject_GetItem(o, j);
+    Py_DECREF(j);
+    return r;
+}
+
+
+#define __Pyx_GetItemInt_List(o, i, size, to_py_func) ((size <= sizeof(Py_ssize_t)) ? \
+                                                    __Pyx_GetItemInt_List_Fast(o, i, size <= sizeof(long)) : \
+                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
+
+static INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, int fits_long) {
+    if (likely(o != Py_None)) {
+        if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
+            PyObject *r = PyList_GET_ITEM(o, i);
+            Py_INCREF(r);
+            return r;
+        }
+        else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
+            PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
+            Py_INCREF(r);
+            return r;
+        }
+    }
+    return __Pyx_GetItemInt_Generic(o, fits_long ? PyInt_FromLong(i) : PyLong_FromLongLong(i));
+}
+
+#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) ((size <= sizeof(Py_ssize_t)) ? \
+                                                    __Pyx_GetItemInt_Tuple_Fast(o, i, size <= sizeof(long)) : \
+                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
+
+static INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, int fits_long) {
+    if (likely(o != Py_None)) {
+        if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
+            PyObject *r = PyTuple_GET_ITEM(o, i);
+            Py_INCREF(r);
+            return r;
+        }
+        else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
+            PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
+            Py_INCREF(r);
+            return r;
+        }
+    }
+    return __Pyx_GetItemInt_Generic(o, fits_long ? PyInt_FromLong(i) : PyLong_FromLongLong(i));
+}
+
+
+#define __Pyx_GetItemInt(o, i, size, to_py_func) ((size <= sizeof(Py_ssize_t)) ? \
+                                                    __Pyx_GetItemInt_Fast(o, i, size <= sizeof(long)) : \
+                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
+
+static INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int fits_long) {
+    PyObject *r;
+    if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
+        r = PyList_GET_ITEM(o, i);
+        Py_INCREF(r);
+    }
+    else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
+        r = PyTuple_GET_ITEM(o, i);
+        Py_INCREF(r);
+    }
+    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0))) {
+        r = PySequence_GetItem(o, i);
+    }
+    else {
+        r = __Pyx_GetItemInt_Generic(o, fits_long ? PyInt_FromLong(i) : PyLong_FromLongLong(i));
+    }
+    return r;
+}
 
 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
 
-static int __Pyx_PrintItem(PyObject *); /*proto*/
-static int __Pyx_PrintNewline(void); /*proto*/
+static int __Pyx_Print(PyObject *, int); /*proto*/
+#if PY_MAJOR_VERSION >= 3
+static PyObject* __pyx_print = 0;
+static PyObject* __pyx_print_kwargs = 0;
+#endif
+
+static int __Pyx_PrintOne(PyObject *o); /*proto*/
+
+static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
 
 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
 
-static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
-
-static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/
+static INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
+static INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
+
+static INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
+    if (likely(PyList_CheckExact(L))) {
+        if (PyList_Append(L, x) < 0) return NULL;
+        Py_INCREF(Py_None);
+        return Py_None; /* this is just to have an accurate signature */
+    }
+    else {
+        PyObject *r, *m;
+        m = __Pyx_GetAttrString(L, "append");
+        if (!m) return NULL;
+        r = PyObject_CallFunctionObjArgs(m, x, NULL);
+        Py_DECREF(m);
+        return r;
+    }
+}
+
+static INLINE int __Pyx_StrEq(const char *, const char *); /*proto*/
+
+static INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
+
+static INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);
+
+static INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);
+
+static INLINE char __Pyx_PyInt_AsChar(PyObject *);
+
+static INLINE short __Pyx_PyInt_AsShort(PyObject *);
+
+static INLINE int __Pyx_PyInt_AsInt(PyObject *);
+
+static INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);
+
+static INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);
+
+static INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);
+
+static INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);
+
+static INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);
+
+static INLINE long __Pyx_PyInt_AsLong(PyObject *);
+
+static INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);
+
+static INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);
+
+static INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);
+
+static void __Pyx_AddTraceback(const char *funcname); /*proto*/
 
 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
 
-static void __Pyx_AddTraceback(char *funcname); /*proto*/
-
-/* Declarations from pypm */
+/* Type declarations */
+
+/* "pygame/trunk/src/pypm.pyx":193
+ *     return Pm_Channel(chan-1)
+ * 
+ * cdef class Output:             # <<<<<<<<<<<<<<
+ *     """
+ * class Output:
+ */
 
 struct __pyx_obj_4pypm_Output {
   PyObject_HEAD
   int debug;
 };
 
+/* "pygame/trunk/src/pypm.pyx":322
+ *             pass                    # win32 machine crashes w/ multiple SysEx
+ * 
+ * cdef class Input:             # <<<<<<<<<<<<<<
+ *     """
+ * class Input:
+ */
+
 struct __pyx_obj_4pypm_Input {
   PyObject_HEAD
   PmStream *midi;
   int debug;
   int i;
 };
-
-
+/* Module declarations from pypm */
 
 static PyTypeObject *__pyx_ptype_4pypm_Output = 0;
 static PyTypeObject *__pyx_ptype_4pypm_Input = 0;
-static PyObject *__pyx_k3;
-static PyObject *__pyx_k4;
-static PyObject *__pyx_k5;
-static PyObject *__pyx_k6;
-
+#define __Pyx_MODULE_NAME "pypm"
+int __pyx_module_is_main_pypm = 0;
 
 /* Implementation of pypm */
-
-static char __pyx_k1[] = "0.03";
-
-static PyObject *__pyx_n___version__;
-static PyObject *__pyx_n_array;
-static PyObject *__pyx_n_FILT_ACTIVE;
-static PyObject *__pyx_n_FILT_SYSEX;
-static PyObject *__pyx_n_FILT_CLOCK;
-static PyObject *__pyx_n_FILT_PLAY;
-static PyObject *__pyx_n_FILT_F9;
-static PyObject *__pyx_n_FILT_TICK;
-static PyObject *__pyx_n_FILT_FD;
-static PyObject *__pyx_n_FILT_UNDEFINED;
-static PyObject *__pyx_n_FILT_RESET;
-static PyObject *__pyx_n_FILT_REALTIME;
-static PyObject *__pyx_n_FILT_NOTE;
-static PyObject *__pyx_n_FILT_CHANNEL_AFTERTOUCH;
-static PyObject *__pyx_n_FILT_POLY_AFTERTOUCH;
-static PyObject *__pyx_n_FILT_AFTERTOUCH;
-static PyObject *__pyx_n_FILT_PROGRAM;
-static PyObject *__pyx_n_FILT_CONTROL;
-static PyObject *__pyx_n_FILT_PITCHBEND;
-static PyObject *__pyx_n_FILT_MTC;
-static PyObject *__pyx_n_FILT_SONG_POSITION;
-static PyObject *__pyx_n_FILT_SONG_SELECT;
-static PyObject *__pyx_n_FILT_TUNE;
-static PyObject *__pyx_n_FALSE;
-static PyObject *__pyx_n_TRUE;
-
-static PyObject *__pyx_k1p;
-
-static PyObject *__pyx_f_4pypm_Initialize(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_k_3[] = "0.03";
+static PyObject *__pyx_int_0x1;
+static PyObject *__pyx_int_0x2;
+static PyObject *__pyx_int_0x4;
+static PyObject *__pyx_int_0x8;
+static PyObject *__pyx_int_0x10;
+static PyObject *__pyx_int_0x20;
+static PyObject *__pyx_int_0x30;
+static PyObject *__pyx_int_0x40;
+static PyObject *__pyx_int_0x7F;
+static PyObject *__pyx_int_0x80;
+static PyObject *__pyx_int_0x100;
+static PyObject *__pyx_int_0x200;
+static PyObject *__pyx_int_0x300;
+static PyObject *__pyx_int_0x400;
+static PyObject *__pyx_int_0x800;
+static PyObject *__pyx_int_0x1000;
+static PyObject *__pyx_int_0x2000;
+static PyObject *__pyx_int_0x4000;
+static PyObject *__pyx_int_0x8000;
+static PyObject *__pyx_int_0x10000;
+static PyObject *__pyx_int_0;
+static PyObject *__pyx_int_1;
+static PyObject *__pyx_int_4096;
+static PyObject *__pyx_int_0xFF;
+static PyObject *__pyx_int_16;
+static PyObject *__pyx_int_0xFF0000;
+static PyObject *__pyx_int_8;
+static PyObject *__pyx_int_0xFF00;
+static PyObject *__pyx_int_1024;
+static char __pyx_k___main__[] = "__main__";
+static PyObject *__pyx_kp___main__;
+static char __pyx_k___init__[] = "__init__";
+static PyObject *__pyx_kp___init__;
+static char __pyx_k___dealloc__[] = "__dealloc__";
+static PyObject *__pyx_kp___dealloc__;
+static char __pyx_k_Write[] = "Write";
+static PyObject *__pyx_kp_Write;
+static char __pyx_k_WriteShort[] = "WriteShort";
+static PyObject *__pyx_kp_WriteShort;
+static char __pyx_k_WriteSysEx[] = "WriteSysEx";
+static PyObject *__pyx_kp_WriteSysEx;
+static char __pyx_k_SetFilter[] = "SetFilter";
+static PyObject *__pyx_kp_SetFilter;
+static char __pyx_k_SetChannelMask[] = "SetChannelMask";
+static PyObject *__pyx_kp_SetChannelMask;
+static char __pyx_k_Poll[] = "Poll";
+static PyObject *__pyx_kp_Poll;
+static char __pyx_k_Read[] = "Read";
+static PyObject *__pyx_kp_Read;
+static char __pyx_k_i[] = "i";
+static PyObject *__pyx_kp_i;
+static char __pyx_k_err[] = "err";
+static PyObject *__pyx_kp_err;
+static char __pyx_k_chan[] = "chan";
+static PyObject *__pyx_kp_chan;
+static char __pyx_k_OutputDevice[] = "OutputDevice";
+static PyObject *__pyx_kp_OutputDevice;
+static char __pyx_k_latency[] = "latency";
+static PyObject *__pyx_kp_latency;
+static char __pyx_k_data[] = "data";
+static PyObject *__pyx_kp_data;
+static char __pyx_k_status[] = "status";
+static PyObject *__pyx_kp_status;
+static char __pyx_k_1[] = "data1";
+static PyObject *__pyx_kp_1;
+static char __pyx_k_2[] = "data2";
+static PyObject *__pyx_kp_2;
+static char __pyx_k_when[] = "when";
+static PyObject *__pyx_kp_when;
+static char __pyx_k_msg[] = "msg";
+static PyObject *__pyx_kp_msg;
+static char __pyx_k_InputDevice[] = "InputDevice";
+static PyObject *__pyx_kp_InputDevice;
+static char __pyx_k_buffersize[] = "buffersize";
+static PyObject *__pyx_kp_buffersize;
+static char __pyx_k_filters[] = "filters";
+static PyObject *__pyx_kp_filters;
+static char __pyx_k_mask[] = "mask";
+static PyObject *__pyx_kp_mask;
+static char __pyx_k_length[] = "length";
+static PyObject *__pyx_kp_length;
+static char __pyx_k___version__[] = "__version__";
+static PyObject *__pyx_kp___version__;
+static char __pyx_k_array[] = "array";
+static PyObject *__pyx_kp_array;
+static char __pyx_k_FILT_ACTIVE[] = "FILT_ACTIVE";
+static PyObject *__pyx_kp_FILT_ACTIVE;
+static char __pyx_k_FILT_SYSEX[] = "FILT_SYSEX";
+static PyObject *__pyx_kp_FILT_SYSEX;
+static char __pyx_k_FILT_CLOCK[] = "FILT_CLOCK";
+static PyObject *__pyx_kp_FILT_CLOCK;
+static char __pyx_k_FILT_PLAY[] = "FILT_PLAY";
+static PyObject *__pyx_kp_FILT_PLAY;
+static char __pyx_k_4[] = "FILT_F9";
+static PyObject *__pyx_kp_4;
+static char __pyx_k_FILT_TICK[] = "FILT_TICK";
+static PyObject *__pyx_kp_FILT_TICK;
+static char __pyx_k_FILT_FD[] = "FILT_FD";
+static PyObject *__pyx_kp_FILT_FD;
+static char __pyx_k_FILT_UNDEFINED[] = "FILT_UNDEFINED";
+static PyObject *__pyx_kp_FILT_UNDEFINED;
+static char __pyx_k_FILT_RESET[] = "FILT_RESET";
+static PyObject *__pyx_kp_FILT_RESET;
+static char __pyx_k_FILT_REALTIME[] = "FILT_REALTIME";
+static PyObject *__pyx_kp_FILT_REALTIME;
+static char __pyx_k_FILT_NOTE[] = "FILT_NOTE";
+static PyObject *__pyx_kp_FILT_NOTE;
+static char __pyx_k_5[] = "FILT_CHANNEL_AFTERTOUCH";
+static PyObject *__pyx_kp_5;
+static char __pyx_k_6[] = "FILT_POLY_AFTERTOUCH";
+static PyObject *__pyx_kp_6;
+static char __pyx_k_FILT_AFTERTOUCH[] = "FILT_AFTERTOUCH";
+static PyObject *__pyx_kp_FILT_AFTERTOUCH;
+static char __pyx_k_FILT_PROGRAM[] = "FILT_PROGRAM";
+static PyObject *__pyx_kp_FILT_PROGRAM;
+static char __pyx_k_FILT_CONTROL[] = "FILT_CONTROL";
+static PyObject *__pyx_kp_FILT_CONTROL;
+static char __pyx_k_FILT_PITCHBEND[] = "FILT_PITCHBEND";
+static PyObject *__pyx_kp_FILT_PITCHBEND;
+static char __pyx_k_FILT_MTC[] = "FILT_MTC";
+static PyObject *__pyx_kp_FILT_MTC;
+static char __pyx_k_FILT_SONG_POSITION[] = "FILT_SONG_POSITION";
+static PyObject *__pyx_kp_FILT_SONG_POSITION;
+static char __pyx_k_FILT_SONG_SELECT[] = "FILT_SONG_SELECT";
+static PyObject *__pyx_kp_FILT_SONG_SELECT;
+static char __pyx_k_FILT_TUNE[] = "FILT_TUNE";
+static PyObject *__pyx_kp_FILT_TUNE;
+static char __pyx_k_FALSE[] = "FALSE";
+static PyObject *__pyx_kp_FALSE;
+static char __pyx_k_TRUE[] = "TRUE";
+static PyObject *__pyx_kp_TRUE;
+static char __pyx_k_Exception[] = "Exception";
+static PyObject *__pyx_kp_Exception;
+static char __pyx_k_IndexError[] = "IndexError";
+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_tostring[] = "tostring";
+static PyObject *__pyx_kp_tostring;
+static char __pyx_k_append[] = "append";
+static PyObject *__pyx_kp_append;
+static PyObject *__pyx_kp_3;
+static PyObject *__pyx_builtin_Exception;
+static PyObject *__pyx_builtin_IndexError;
+static PyObject *__pyx_builtin_range;
+static PyObject *__pyx_kp_7;
+static PyObject *__pyx_kp_8;
+static PyObject *__pyx_kp_9;
+static char __pyx_k_7[] = "Opening Midi Output";
+static char __pyx_k_8[] = "Unable to open Midi OutputDevice=";
+static char __pyx_k_9[] = " err=";
+static PyObject *__pyx_kp_10;
+static char __pyx_k_10[] = "Closing MIDI output stream and destroying instance";
+static PyObject *__pyx_kp_11;
+static PyObject *__pyx_kp_12;
+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_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 PyObject *__pyx_kp_20;
+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
+ * TRUE=1
+ * 
+ * def Initialize():             # <<<<<<<<<<<<<<
+ *     """
+ * Initialize: call this first
+ */
+
+static PyObject *__pyx_pf_4pypm_Initialize(PyObject *__pyx_self, PyObject *unused); /*proto*/
 static char __pyx_doc_4pypm_Initialize[] = "\nInitialize: call this first\n    ";
-static PyObject *__pyx_f_4pypm_Initialize(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
-  PyObject *__pyx_r;
-  static char *__pyx_argnames[] = {0};
-  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
-
-  /* "/home/rsd/dev/pygame/src/pypm.pyx":128 */
+static PyObject *__pyx_pf_4pypm_Initialize(PyObject *__pyx_self, PyObject *unused) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_SetupRefcountContext("Initialize");
+  __pyx_self = __pyx_self;
+
+  /* "pygame/trunk/src/pypm.pyx":128
+ * Initialize: call this first
+ *     """
+ *     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]/
+ * 
+ */
   Pm_Initialize();
 
-  /* "/home/rsd/dev/pygame/src/pypm.pyx":129 */
-  Pt_Start(1,NULL,NULL);
-
-  __pyx_r = Py_None; Py_INCREF(Py_None);
+  /* "pygame/trunk/src/pypm.pyx":129
+ *     """
+ *     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]/             # <<<<<<<<<<<<<<
+ * 
+ * def Terminate():
+ */
+  Pt_Start(1, NULL, NULL);
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_FinishRefcountContext();
   return __pyx_r;
 }
 
-static PyObject *__pyx_f_4pypm_Terminate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+/* "pygame/trunk/src/pypm.pyx":131
+ *     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():             # <<<<<<<<<<<<<<
+ *     """
+ * Terminate: call this to clean up Midi streams when done.
+ */
+
+static PyObject *__pyx_pf_4pypm_Terminate(PyObject *__pyx_self, PyObject *unused); /*proto*/
 static char __pyx_doc_4pypm_Terminate[] = "\nTerminate: call this to clean up Midi streams when done.\nIf you do not call this on Windows machines when you are\ndone with MIDI, your system may crash.\n    ";
-static PyObject *__pyx_f_4pypm_Terminate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
-  PyObject *__pyx_r;
-  static char *__pyx_argnames[] = {0};
-  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
+static PyObject *__pyx_pf_4pypm_Terminate(PyObject *__pyx_self, PyObject *unused) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_SetupRefcountContext("Terminate");
+  __pyx_self = __pyx_self;
+
+  /* "pygame/trunk/src/pypm.pyx":137
+ * done with MIDI, your system may crash.
+ *     """
+ *     Pm_Terminate()             # <<<<<<<<<<<<<<
+ * 
+ * def GetDefaultInputDeviceID():
+ */
   Pm_Terminate();
 
-  __pyx_r = Py_None; Py_INCREF(Py_None);
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_FinishRefcountContext();
   return __pyx_r;
 }
 
-static PyObject *__pyx_f_4pypm_GetDefaultInputDeviceID(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_4pypm_GetDefaultInputDeviceID(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
-  PyObject *__pyx_r;
-  PyObject *__pyx_1 = 0;
-  static char *__pyx_argnames[] = {0};
-  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
-  __pyx_1 = PyInt_FromLong(Pm_GetDefaultInputDeviceID()); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; goto __pyx_L1;}
-  __pyx_r = __pyx_1;
-  __pyx_1 = 0;
+/* "pygame/trunk/src/pypm.pyx":139
+ *     Pm_Terminate()
+ * 
+ * def GetDefaultInputDeviceID():             # <<<<<<<<<<<<<<
+ *     return Pm_GetDefaultInputDeviceID()
+ * 
+ */
+
+static PyObject *__pyx_pf_4pypm_GetDefaultInputDeviceID(PyObject *__pyx_self, PyObject *unused); /*proto*/
+static PyObject *__pyx_pf_4pypm_GetDefaultInputDeviceID(PyObject *__pyx_self, PyObject *unused) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_SetupRefcountContext("GetDefaultInputDeviceID");
+  __pyx_self = __pyx_self;
+
+  /* "pygame/trunk/src/pypm.pyx":140
+ * 
+ * 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_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
   goto __pyx_L0;
 
-  __pyx_r = Py_None; Py_INCREF(Py_None);
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
-  __pyx_L1:;
-  Py_XDECREF(__pyx_1);
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
   __Pyx_AddTraceback("pypm.GetDefaultInputDeviceID");
-  __pyx_r = 0;
+  __pyx_r = NULL;
   __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_FinishRefcountContext();
   return __pyx_r;
 }
 
-static PyObject *__pyx_f_4pypm_GetDefaultOutputDeviceID(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_4pypm_GetDefaultOutputDeviceID(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
-  PyObject *__pyx_r;
-  PyObject *__pyx_1 = 0;
-  static char *__pyx_argnames[] = {0};
-  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
-  __pyx_1 = PyInt_FromLong(Pm_GetDefaultOutputDeviceID()); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; goto __pyx_L1;}
-  __pyx_r = __pyx_1;
-  __pyx_1 = 0;
+/* "pygame/trunk/src/pypm.pyx":142
+ *     return Pm_GetDefaultInputDeviceID()
+ * 
+ * def GetDefaultOutputDeviceID():             # <<<<<<<<<<<<<<
+ *     return Pm_GetDefaultOutputDeviceID()
+ * 
+ */
+
+static PyObject *__pyx_pf_4pypm_GetDefaultOutputDeviceID(PyObject *__pyx_self, PyObject *unused); /*proto*/
+static PyObject *__pyx_pf_4pypm_GetDefaultOutputDeviceID(PyObject *__pyx_self, PyObject *unused) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_SetupRefcountContext("GetDefaultOutputDeviceID");
+  __pyx_self = __pyx_self;
+
+  /* "pygame/trunk/src/pypm.pyx":143
+ * 
+ * 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_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
   goto __pyx_L0;
 
-  __pyx_r = Py_None; Py_INCREF(Py_None);
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
-  __pyx_L1:;
-  Py_XDECREF(__pyx_1);
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
   __Pyx_AddTraceback("pypm.GetDefaultOutputDeviceID");
-  __pyx_r = 0;
+  __pyx_r = NULL;
   __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_FinishRefcountContext();
   return __pyx_r;
 }
 
-static PyObject *__pyx_f_4pypm_CountDevices(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_4pypm_CountDevices(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
-  PyObject *__pyx_r;
-  PyObject *__pyx_1 = 0;
-  static char *__pyx_argnames[] = {0};
-  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
-  __pyx_1 = PyInt_FromLong(Pm_CountDevices()); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; goto __pyx_L1;}
-  __pyx_r = __pyx_1;
-  __pyx_1 = 0;
+/* "pygame/trunk/src/pypm.pyx":145
+ *     return Pm_GetDefaultOutputDeviceID()
+ * 
+ * def CountDevices():             # <<<<<<<<<<<<<<
+ *     return Pm_CountDevices()
+ * 
+ */
+
+static PyObject *__pyx_pf_4pypm_CountDevices(PyObject *__pyx_self, PyObject *unused); /*proto*/
+static PyObject *__pyx_pf_4pypm_CountDevices(PyObject *__pyx_self, PyObject *unused) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_SetupRefcountContext("CountDevices");
+  __pyx_self = __pyx_self;
+
+  /* "pygame/trunk/src/pypm.pyx":146
+ * 
+ * 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_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
   goto __pyx_L0;
 
-  __pyx_r = Py_None; Py_INCREF(Py_None);
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
-  __pyx_L1:;
-  Py_XDECREF(__pyx_1);
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
   __Pyx_AddTraceback("pypm.CountDevices");
-  __pyx_r = 0;
+  __pyx_r = NULL;
   __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_FinishRefcountContext();
   return __pyx_r;
 }
 
-static PyObject *__pyx_f_4pypm_GetDeviceInfo(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+/* "pygame/trunk/src/pypm.pyx":148
+ *     return Pm_CountDevices()
+ * 
+ * def GetDeviceInfo(i):             # <<<<<<<<<<<<<<
+ *     """
+ * GetDeviceInfo(<device number>): returns 5 parameters
+ */
+
+static PyObject *__pyx_pf_4pypm_GetDeviceInfo(PyObject *__pyx_self, PyObject *__pyx_v_i); /*proto*/
 static char __pyx_doc_4pypm_GetDeviceInfo[] = "\nGetDeviceInfo(<device number>): returns 5 parameters\n  - underlying MIDI API\n  - device name\n  - TRUE iff input is available\n  - TRUE iff output is available\n  - TRUE iff device stream is already open\n    ";
-static PyObject *__pyx_f_4pypm_GetDeviceInfo(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
-  PyObject *__pyx_v_i = 0;
+static PyObject *__pyx_pf_4pypm_GetDeviceInfo(PyObject *__pyx_self, PyObject *__pyx_v_i) {
   PmDeviceInfo *__pyx_v_info;
-  PyObject *__pyx_r;
-  PmDeviceID __pyx_1;
-  int __pyx_2;
-  PyObject *__pyx_3 = 0;
-  PyObject *__pyx_4 = 0;
-  PyObject *__pyx_5 = 0;
-  PyObject *__pyx_6 = 0;
-  PyObject *__pyx_7 = 0;
-  PyObject *__pyx_8 = 0;
-  static char *__pyx_argnames[] = {"i",0};
-  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_i)) return 0;
-  Py_INCREF(__pyx_v_i);
-
-  /* "/home/rsd/dev/pygame/src/pypm.pyx":160 */
-  __pyx_1 = PyInt_AsLong(__pyx_v_i); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; goto __pyx_L1;}
-  __pyx_v_info = ((PmDeviceInfo *)Pm_GetDeviceInfo(__pyx_1));
-
-  /* "/home/rsd/dev/pygame/src/pypm.pyx":162 */
-  __pyx_2 = (__pyx_v_info != NULL);
-  if (__pyx_2) {
-    __pyx_3 = PyString_FromString(__pyx_v_info->interf); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; goto __pyx_L1;}
-    __pyx_4 = PyString_FromString(__pyx_v_info->name); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; goto __pyx_L1;}
-    __pyx_5 = PyInt_FromLong(__pyx_v_info->input); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; goto __pyx_L1;}
-    __pyx_6 = PyInt_FromLong(__pyx_v_info->output); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; goto __pyx_L1;}
-    __pyx_7 = PyInt_FromLong(__pyx_v_info->opened); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; goto __pyx_L1;}
-    __pyx_8 = PyTuple_New(5); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; goto __pyx_L1;}
-    PyTuple_SET_ITEM(__pyx_8, 0, __pyx_3);
-    PyTuple_SET_ITEM(__pyx_8, 1, __pyx_4);
-    PyTuple_SET_ITEM(__pyx_8, 2, __pyx_5);
-    PyTuple_SET_ITEM(__pyx_8, 3, __pyx_6);
-    PyTuple_SET_ITEM(__pyx_8, 4, __pyx_7);
-    __pyx_3 = 0;
-    __pyx_4 = 0;
-    __pyx_5 = 0;
-    __pyx_6 = 0;
-    __pyx_7 = 0;
-    __pyx_r = __pyx_8;
-    __pyx_8 = 0;
+  PyObject *__pyx_r = NULL;
+  PmDeviceID __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  __Pyx_SetupRefcountContext("GetDeviceInfo");
+  __pyx_self = __pyx_self;
+
+  /* "pygame/trunk/src/pypm.pyx":160
+ * 
+ *     # 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_v_info = ((PmDeviceInfo *)Pm_GetDeviceInfo(__pyx_t_1));
+
+  /* "pygame/trunk/src/pypm.pyx":162
+ *     info = <PmDeviceInfo *>Pm_GetDeviceInfo(i)
+ * 
+ *     if info <> NULL: return info.interf, info.name, info.input, info.output, info.opened             # <<<<<<<<<<<<<<
+ *     else: return
+ * 
+ */
+  __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_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_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_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_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_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_GOTREF(((PyObject *)__pyx_t_8));
+    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3);
+    __Pyx_GIVEREF(__pyx_t_3);
+    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_4);
+    PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_5);
+    __Pyx_GIVEREF(__pyx_t_5);
+    PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_6);
+    __Pyx_GIVEREF(__pyx_t_6);
+    PyTuple_SET_ITEM(__pyx_t_8, 4, __pyx_t_7);
+    __Pyx_GIVEREF(__pyx_t_7);
+    __pyx_t_3 = 0;
+    __pyx_t_4 = 0;
+    __pyx_t_5 = 0;
+    __pyx_t_6 = 0;
+    __pyx_t_7 = 0;
+    __pyx_r = ((PyObject *)__pyx_t_8);
+    __pyx_t_8 = 0;
     goto __pyx_L0;
-    goto __pyx_L2;
+    goto __pyx_L5;
   }
   /*else*/ {
-    __pyx_r = Py_None; Py_INCREF(Py_None);
+
+    /* "pygame/trunk/src/pypm.pyx":163
+ * 
+ *     if info <> NULL: return info.interf, info.name, info.input, info.output, info.opened
+ *     else: return             # <<<<<<<<<<<<<<
+ * 
+ * def Time():
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
     goto __pyx_L0;
   }
-  __pyx_L2:;
-
-  __pyx_r = Py_None; Py_INCREF(Py_None);
+  __pyx_L5:;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
-  __pyx_L1:;
-  Py_XDECREF(__pyx_3);
-  Py_XDECREF(__pyx_4);
-  Py_XDECREF(__pyx_5);
-  Py_XDECREF(__pyx_6);
-  Py_XDECREF(__pyx_7);
-  Py_XDECREF(__pyx_8);
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
   __Pyx_AddTraceback("pypm.GetDeviceInfo");
-  __pyx_r = 0;
+  __pyx_r = NULL;
   __pyx_L0:;
-  Py_DECREF(__pyx_v_i);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_FinishRefcountContext();
   return __pyx_r;
 }
 
-static PyObject *__pyx_f_4pypm_Time(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+/* "pygame/trunk/src/pypm.pyx":165
+ *     else: return
+ * 
+ * def Time():             # <<<<<<<<<<<<<<
+ *     """
+ * Time() returns the current time in ms
+ */
+
+static PyObject *__pyx_pf_4pypm_Time(PyObject *__pyx_self, PyObject *unused); /*proto*/
 static char __pyx_doc_4pypm_Time[] = "\nTime() returns the current time in ms\nof the PortMidi timer\n    ";
-static PyObject *__pyx_f_4pypm_Time(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
-  PyObject *__pyx_r;
-  PyObject *__pyx_1 = 0;
-  static char *__pyx_argnames[] = {0};
-  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
-  __pyx_1 = PyInt_FromLong(Pt_Time()); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; goto __pyx_L1;}
-  __pyx_r = __pyx_1;
-  __pyx_1 = 0;
+static PyObject *__pyx_pf_4pypm_Time(PyObject *__pyx_self, PyObject *unused) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_SetupRefcountContext("Time");
+  __pyx_self = __pyx_self;
+
+  /* "pygame/trunk/src/pypm.pyx":170
+ * 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_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
   goto __pyx_L0;
 
-  __pyx_r = Py_None; Py_INCREF(Py_None);
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
-  __pyx_L1:;
-  Py_XDECREF(__pyx_1);
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
   __Pyx_AddTraceback("pypm.Time");
-  __pyx_r = 0;
+  __pyx_r = NULL;
   __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_FinishRefcountContext();
   return __pyx_r;
 }
 
-static PyObject *__pyx_f_4pypm_GetErrorText(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+/* "pygame/trunk/src/pypm.pyx":172
+ *     return Pt_Time()
+ * 
+ * def GetErrorText(err):             # <<<<<<<<<<<<<<
+ *     """
+ * GetErrorText(<err num>) returns human-readable error
+ */
+
+static PyObject *__pyx_pf_4pypm_GetErrorText(PyObject *__pyx_self, PyObject *__pyx_v_err); /*proto*/
 static char __pyx_doc_4pypm_GetErrorText[] = "\nGetErrorText(<err num>) returns human-readable error\nmessages translated from error numbers\n    ";
-static PyObject *__pyx_f_4pypm_GetErrorText(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
-  PyObject *__pyx_v_err = 0;
-  PyObject *__pyx_r;
-  PmError __pyx_1;
-  PyObject *__pyx_2 = 0;
-  static char *__pyx_argnames[] = {"err",0};
-  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_err)) return 0;
-  Py_INCREF(__pyx_v_err);
-  __pyx_1 = ((PmError)PyInt_AsLong(__pyx_v_err)); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}
-  __pyx_2 = PyString_FromString(Pm_GetErrorText(__pyx_1)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}
-  __pyx_r = __pyx_2;
-  __pyx_2 = 0;
+static PyObject *__pyx_pf_4pypm_GetErrorText(PyObject *__pyx_self, PyObject *__pyx_v_err) {
+  PyObject *__pyx_r = NULL;
+  PmError __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_SetupRefcountContext("GetErrorText");
+  __pyx_self = __pyx_self;
+
+  /* "pygame/trunk/src/pypm.pyx":177
+ * 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_GOTREF(__pyx_t_2);
+  __pyx_r = __pyx_t_2;
+  __pyx_t_2 = 0;
   goto __pyx_L0;
 
-  __pyx_r = Py_None; Py_INCREF(Py_None);
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
-  __pyx_L1:;
-  Py_XDECREF(__pyx_2);
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
   __Pyx_AddTraceback("pypm.GetErrorText");
-  __pyx_r = 0;
+  __pyx_r = NULL;
   __pyx_L0:;
-  Py_DECREF(__pyx_v_err);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_FinishRefcountContext();
   return __pyx_r;
 }
 
-static PyObject *__pyx_f_4pypm_Channel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+/* "pygame/trunk/src/pypm.pyx":179
+ *     return Pm_GetErrorText(err)
+ * 
+ * def Channel(chan):             # <<<<<<<<<<<<<<
+ *     """
+ * Channel(<chan>) is used with ChannelMask on input MIDI streams.
+ */
+
+static PyObject *__pyx_pf_4pypm_Channel(PyObject *__pyx_self, PyObject *__pyx_v_chan); /*proto*/
 static char __pyx_doc_4pypm_Channel[] = "\nChannel(<chan>) is used with ChannelMask on input MIDI streams.\nExample: to receive input on channels 1 and 10 on a MIDI\n         stream called MidiIn:\nMidiIn.SetChannelMask(pypm.Channel(1) | pypm.Channel(10))\n\nnote: PyPortMidi Channel function has been altered from\n      the original PortMidi c call to correct for what\n      seems to be a bug --- i.e. channel filters were\n      all numbered from 0 to 15 instead of 1 to 16.\n    ";
-static PyObject *__pyx_f_4pypm_Channel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
-  PyObject *__pyx_v_chan = 0;
-  PyObject *__pyx_r;
-  PyObject *__pyx_1 = 0;
-  PyObject *__pyx_2 = 0;
-  int __pyx_3;
-  static char *__pyx_argnames[] = {"chan",0};
-  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_chan)) return 0;
-  Py_INCREF(__pyx_v_chan);
-  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; goto __pyx_L1;}
-  __pyx_2 = PyNumber_Subtract(__pyx_v_chan, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; goto __pyx_L1;}
-  Py_DECREF(__pyx_1); __pyx_1 = 0;
-  __pyx_3 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; goto __pyx_L1;}
-  Py_DECREF(__pyx_2); __pyx_2 = 0;
-  __pyx_1 = PyInt_FromLong(Pm_Channel(__pyx_3)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; goto __pyx_L1;}
-  __pyx_r = __pyx_1;
-  __pyx_1 = 0;
+static PyObject *__pyx_pf_4pypm_Channel(PyObject *__pyx_self, PyObject *__pyx_v_chan) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  __Pyx_SetupRefcountContext("Channel");
+  __pyx_self = __pyx_self;
+
+  /* "pygame/trunk/src/pypm.pyx":191
+ *       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_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_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_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;