Play 2 sounds simultaneously with multiprocessing in python
Question: I need to play 2 sounds simultaneously, with multiprocessing rather than
threads, to see if it solves a problem where threads play the audio in
sequence rather than in parallel. I am guessing it's due to the Global
Interpreter Lock (GIL) in python.

I added [a question](http://stackoverflow.com/questions/17711672/simultaneous-
record-audio-from-mic-and-play-it-back-with-effect-in-python) 2 days ago, but
my description is overcomplicated. This is the simple version:

The audio gets imported as numpy array. I take this array and play it using
the scikits.audiolab module:

    
    
    import scikits.audiolab as audiolab
    
    # This is how I import my wav file. "frames" is the numpy array, "fs" = sampling 
    # frequency, "encoder" = quantizing at 16 bits
    
    frames, fs, encoder = audiolab.wavread('audio.wav')
    
    # This is how I play my wav file. audiolab plays the frames array at a frequency of 
    # 44100 Hz
    audiolab.play(frames, fs=44100)
    

That's fine, but this is what I need help on: playing 2 files at the same time
using multiprocessing.

    
    
    frames1, fs1, encoder1 = audiolab.wavread('audio1.wav')
    frames2, fs2, encoder2 = audiolab.wavread('audio2.wav')
    
    audiolab.play(frames1, fs=44100)
    audiolab.play(frames2, fs=44100)
    


Answer: The better way to approach this is to use a library that already knows how to
mix audio streams -- two different processes trying to share the audio
hardware is at best a wonky way to address this problem.

Look at [Pygame](http://www.pygame.org/wiki/about) or
[PyAudio](http://people.csail.mit.edu/hubert/pyaudio/) (Python bindings to
[PortAudio](http://www.portaudio.com/)).

