<p>
Pygame Midi documentation:<br />
    <a href="https://www.pygame.org/docs/ref/midi.html">https://www.pygame.org/docs/ref/midi.html</a>
</p>
<p>
Pygame Mailing List:<br />
    <a href="https://www.pygame.org/wiki/info">https://www.pygame.org/wiki/info</a>
</p>
<p>
Midi.py sample from pygame example folder: <br />
    <a href="https://bitbucket.org/pygame/pygame/src/25e3f2cee879/examples/midi.py">https://bitbucket.org/pygame/pygame/src/25e3f2cee879/examples/midi.py</a>
</p>
<p>
Sampler/Sound Looper made from python, pygame and midi:<br />
    <a href="https://www.pygame.org/project-BadPenni+-+MIDI+Triggered+Sound+Looper-1734-.html">https://www.pygame.org/project-BadPenni+-+MIDI+Triggered+Sound+Looper-1734-.html</a>  <br />
</p>
<p>
Sample values that populate midi_events variable:<br />
</p>
<p>
     Middle C note key press (notice the data1 is 60 and data2 is 127)<br />
     &lt;Event(34-Unknown {'status': 144, 'vice_id': 2, 'timestamp': 6701, 'data1': 60, 'data3': 0, 'data2': 127})&gt;<br />
</p>
<p>
     Middle C note key release (notice the data1 is 60 and data2 is 0)<br />
     &lt;Event(34-Unknown {'status': 128, 'vice_id': 2, 'timestamp': 6764, 'data1': 60, 'data3': 0, 'data2': 0})&gt;<br />
</p>
<p>
     Middle C# note key press (notice the data1 is now 61)<br />
     &lt;Event(34-Unknown {'status': 144, 'vice_id': 2, 'timestamp': 206684, 'data1': 61, 'data3': 0, 'data2': 127})&gt;<br />
</p>
<p>
Python code snippet that pulls the note number from the midi_events list and appends an "off" string if it is a key release. <br />
</p>
<pre>
    if str(midi_events[0][0][2]) != "0":
        midinote = str(midi_events[0][0][1])
    else:
        midinote = str(midi_events[0][0][1]) + "off"
</pre>
<p>
Controlling sounds with if statements and our midinote variable:<br />
</p>
<pre>
    distbassrollloop = pygame.mixer.Sound("7FullCircleDistBassRollLoop.wav")
    distsnarerollloop = pygame.mixer.Sound("7FullCircleDistSnareRollLoop.wav")
    distbass = pygame.mixer.Sound("7FullCircleDistBassPad.wav")
    distsnare = pygame.mixer.Sound("7FullCircleDistSnare.wav")

    if midinote == "48":
        distbass.play()

    if midinote == "49":
        distbassrollloop.play(1000)

    if midinote == "49off":
        distbassrollloop.stop()

    if midinote == "50":
        distsnare.play()

    if midinote == "51":
        distsnarerollloop.play(1000)

    if midinote == "51off":
        distsnarerollloop.stop()
</pre>
<p>
Contact info:<br />
</p>
<p>
    bgryderclock on Google+:<br />
    <a href="https://plus.google.com/u/0/114032638902983586355">https://plus.google.com/u/0/114032638902983586355</a>
</p>
<p>
    bgryderclock on Twitter:<br />
    <a href="https://twitter.com/bgryderclock">https://twitter.com/bgryderclock</a>
</p>
<p>
    bgryderclock on Identica:<br />
    <a href="https://identi.ca/bgryderclock">https://identi.ca/bgryderclock</a>
</p>
<h2>Links</h2>
<ul>
<li><a href="https://www.pygame.org/docs/ref/midi.html">https://www.pygame.org/docs/ref/midi.html</a></li>
<li><a href="https://www.pygame.org/wiki/info">https://www.pygame.org/wiki/info</a></li>
<li><a href="https://bitbucket.org/pygame/pygame/src/25e3f2cee879/examples/midi.py">https://bitbucket.org/pygame/pygame/src/25e3f2cee879/examples/midi.py</a></li>
<li><a href="https://www.pygame.org/project-BadPenni+-+MIDI+Triggered+Sound+Looper-1734-.html">https://www.pygame.org/project-BadPenni+-+MIDI+Triggered+Sound+Looper-1734-.html</a></li>
<li><a href="https://plus.google.com/u/0/114032638902983586355">https://plus.google.com/u/0/114032638902983586355</a></li>
<li><a href="https://twitter.com/bgryderclock">https://twitter.com/bgryderclock</a></li>
<li><a href="https://identi.ca/bgryderclock">https://identi.ca/bgryderclock</a></li>
</ul>
