What is the simplest way to get from MIDI to real audio coming out my speakers (sound synthesis) in Python?
Question: I'm starting work on an app that will need to create sound from lots of pre-
loaded ".mid" files.

I'm using Python and Kivy to create an app, as I have made an app already with
these tools and they are the only code I know. The other app I made uses no
sound whatsoever.

Naturally, I want to make sure that the code I write will work cross-platform.

Right now, I'm simply trying to prove that I can create any real sound from a
midi note.

I took this code suggested from another answer to a similar question using
FluidSynth and Mingus:

    
    
    from mingus.midi import fluidsynth
    
    fluidsynth.init('/usr/share/sounds/sf2/FluidR3_GM.sf2',"alsa")
    fluidsynth.play_Note(64,0,100)
    

But I hear nothing and get this error:

    
    
    fluidsynth: warning: Failed to pin the sample data to RAM; swapping is possible.
    

Why do I get this error, how do I fix it, and is this the simplest way or even
right way?


Answer: I could be wrong but I don't think there is a "0" channel which is what you
are passing as your second argument to .play_Note(). Try this:

    
    
    fluidsynth.play_Note(64,1,100)
    

or (from some
[documentation](https://code.google.com/p/mingus/wiki/refMingusMidiFluidsynth))

    
    
    from mingus.containers.note import Note
    n = Note("C", 4)
    n.channel = 1
    n.velocity = 50
    fluidSynth.play_Note(n)
    

UPDATE:

There are references to only channels 1-16 in the source code for that method
with the default channel set to 1:

    
    
    def play_Note(self, note, channel = 1, velocity = 100):
            """Plays a Note object on a channel[1-16] with a \
    velocity[0-127]. You can either specify the velocity and channel \
    here as arguments or you can set the Note.velocity and Note.channel \
    attributes, which will take presedence over the function arguments."""
            if hasattr(note, 'velocity'):
                velocity = note.velocity
            if hasattr(note, 'channel'):
                channel = note.channel
            self.fs.noteon(int(channel), int(note) + 12, int(velocity))
            return True
    

