Which library for audio playback ?

Discussion in 'Python' started by Jérôme, Dec 29, 2011.

  1. Jérôme

    Jérôme Guest

    I'm writing a small application that plays sound through the speakers. The
    sounds are juste sine waves of arbitrary frequency I create in the code, not
    sample .wav files.

    I didn't expect the choice for an audio library to be that complicated. There
    are several libraries, and none of them seems to be *the* reference.

    Searching the web, I found these resources :

    http://wiki.python.org/moin/Audio
    http://wiki.python.org/moin/PythonInMusic

    * I privileged ALSA to OSS as I read elsewhere that OSS is deprecated, or on
    its way to be. (And JACK is not widely installed, apart from specific
    applications (audio work).)

    * Then, I picked the alsaaudio library (http://pyalsaaudio.sourceforge.net/).
    I don't remember exactly why. I think the project had the most recent
    updates. I don't think any project claims to be (let alone aims at being)
    complete.

    I'm wondering if I made a sensible choice.

    There are other libraries, including the following two that are platform
    independent :

    * PyAudiere (http://pyaudiere.org/), OSS , not packaged for debian
    * PyAudio (http://people.csail.mit.edu/hubert/pyaudio/)

    What solution would you recommend ?

    Are there other criterions I should take into account ?

    Thanks.

    --
    Jérôme
     
    Jérôme, Dec 29, 2011
    #1
    1. Advertising

  2. On 12/29/11 05:55 , Jérôme wrote:
    > I'm writing a small application that plays sound through the speakers. The
    > sounds are juste sine waves of arbitrary frequency I create in the code, not
    > sample .wav files.
    >
    > I didn't expect the choice for an audio library to be that complicated. There
    > are several libraries, and none of them seems to be *the* reference.
    >
    > Searching the web, I found these resources :
    >
    > http://wiki.python.org/moin/Audio
    > http://wiki.python.org/moin/PythonInMusic
    >
    > * I privileged ALSA to OSS as I read elsewhere that OSS is deprecated, or on
    > its way to be. (And JACK is not widely installed, apart from specific
    > applications (audio work).)
    >
    > * Then, I picked the alsaaudio library (http://pyalsaaudio.sourceforge.net/).
    > I don't remember exactly why. I think the project had the most recent
    > updates. I don't think any project claims to be (let alone aims at being)
    > complete.
    >
    > I'm wondering if I made a sensible choice.
    >
    > There are other libraries, including the following two that are platform
    > independent :
    >
    > * PyAudiere (http://pyaudiere.org/), OSS , not packaged for debian
    > * PyAudio (http://people.csail.mit.edu/hubert/pyaudio/)
    >
    > What solution would you recommend ?
    >
    > Are there other criterions I should take into account ?
    >
    > Thanks.
    >


    I made a similar survey of available libraries recently. I'm interested
    in MIDI also, though, primarily on mac.

    There doesn't seem to be any definitive audio library for linux,
    although several, (jack, oss, alsa), exist. (My impression is similar
    to yours, OSS is obsolete. Jack may be the better library technically,
    but is not as widely ported or available as ALSA.)

    There is a definitive library for both audio and MIDI on mac - core
    audio. There really aren't any competitors.

    There is also a definitive library for windows, although I don't use
    windows. It's the open source one with low latency that everyone in the
    professional world uses to replace windows because, (surprise!), windows
    isn't capable of coping.

    I have found python libraries for each of these, although some are very
    low level libraries, basically just wrapping something even lower. If
    anyone has done an integrated "full solution" for linux or mac, I didn't
    find it. The closest I found was PortMIDI and PortAudio which appear to
    have ports for all three platforms as well as one or two sets of python
    bindings and seem to be high enough level to be both useful and
    productive. The hard part there is that PortMIDI and PortAudio come in
    source, which requires a bit of hunting to track down prerequisites, etc.

    Please keep us posted as I'm chasing a similar problem.

    --rich
     
    K Richard Pixley, Dec 31, 2011
    #2
    1. Advertising

  3. Jérôme

    Jérôme Guest

    Fri, 30 Dec 2011 17:17:51 -0800
    K Richard Pixley a écrit:

    > I made a similar survey of available libraries recently. I'm interested
    > in MIDI also, though, primarily on mac.
    >
    > There doesn't seem to be any definitive audio library for linux,
    > although several, (jack, oss, alsa), exist. (My impression is similar
    > to yours, OSS is obsolete. Jack may be the better library technically,
    > but is not as widely ported or available as ALSA.)
    >
    > There is a definitive library for both audio and MIDI on mac - core
    > audio. There really aren't any competitors.
    >
    > There is also a definitive library for windows, although I don't use
    > windows. It's the open source one with low latency that everyone in the
    > professional world uses to replace windows because, (surprise!), windows
    > isn't capable of coping.
    >
    > I have found python libraries for each of these, although some are very
    > low level libraries, basically just wrapping something even lower. If
    > anyone has done an integrated "full solution" for linux or mac, I didn't
    > find it. The closest I found was PortMIDI and PortAudio which appear to
    > have ports for all three platforms as well as one or two sets of python
    > bindings and seem to be high enough level to be both useful and
    > productive. The hard part there is that PortMIDI and PortAudio come in
    > source, which requires a bit of hunting to track down prerequisites, etc.
    >
    > Please keep us posted as I'm chasing a similar problem.


    Hi.

    Looking at it again, I've narrowed down to the following few :

    ossaudiodev
    http://docs.python.org/library/ossaudiodev.html
    Linux only but included in python

    pygame
    http://www.pygame.org/docs/ref/mixer.html#pygame.mixer.Sound
    Most occurring answer on forums and mailing-lists on the net for this
    question. Might be a little overkill...

    PortAudio
    http://people.csail.mit.edu/hubert/pyaudio/
    http://www.portaudio.com/
    Cross-platform, packaged for debian. Could fit my needs as well.

    Generally, the examples I find are about opening and playing a wavefile. I
    guess I'm gonna have to work a little to feed them a homegrown sinewave of
    arbitrary frequency.

    Regarding PortAudio,
    python /usr/share/doc/python-pyaudio/examples/system_info.py (and other
    examples) yield complaints about jack not being running. I assume they could
    be tweaked to use ALSA instead.

    I haven't had time to dig any further. If I come up with something, I'll keep
    you posted.

    Thanks for your answer.

    --
    Jérôme
     
    Jérôme, Dec 31, 2011
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vladislavf
    Replies:
    3
    Views:
    4,616
    vladislavf
    Jul 6, 2006
  2. Arsalan
    Replies:
    0
    Views:
    348
    Arsalan
    Nov 2, 2004
  3. Peter Burns

    Audio File Playback

    Peter Burns, Nov 3, 2005, in forum: Ruby
    Replies:
    1
    Views:
    96
    Daniel Amelang
    Nov 3, 2005
  4. John Reiter

    Video playback library?

    John Reiter, Aug 19, 2007, in forum: Ruby
    Replies:
    6
    Views:
    90
    John Joyce
    Aug 20, 2007
  5. Replies:
    1
    Views:
    145
Loading...

Share This Page