I've seen most of the questions on this topic but almost all of them are outdated. (This is not a dupe)
My requirement is a preferably light weight library for simply playing audio files such as mp3,etc from Python (2.7)
These are the libraries that I've so far looked into and I'm listing what are the things that are stopping me from using each of them:
PyMedia: it was last updated in Feb, 2006
Mp3Play: supports only XP and was last updated in 2008.
I've also tried Pyglet but even this doesn't look good.
Also heard that wx has support for mp3 and I'm trying it. Any comments about the same?
Which reliable lightweight library do others use these days?
PS: please post one library only per answer
I'm not sure what your issue is with pyglet. Playing an mp3 using that couldn't be simpler:
import pyglet
sound = pyglet.media.load('mysound.mp3', streaming=False)
sound.play()
pyglet.app.run()
pyglet is well-maintained, cross-platform, and very small for a multimedia library.
I know this is late but anyway...
Try just_playback. It's a wrapper around miniaudio that can read multiple file formats including mp3 and provides playback control functionality like pausing, resuming, seeking and setting the playback volume.
Related
Looking at 4-note polyphony, where notes are sampled audio (wav/mp3/ogg files). Is there some asynchronous audio library where I can tell the library to play an audio file (to completion, or a certain length), without blocking ? While the previous audio segment is still playing, I could invoke the library again to play another note, also without blocking. Thus I achieve polyphony, and can play upto 4-note chords ?
I am looking for an approach suitable for a very low end ARM9 (260MHz) + 64MB RAM type of device, running Linux. I am trying to keep the software as lean as possible, and thus cannot imagine putting a full-scale software synth on it. Also the user interaction of my simple 4-note polyphony, "poor-man's synth", needs to be programmatically achieved.
Only decent options I've found so far, seems to be SDL, but not clear how well it might fit my needs and meets the low-eright constraints.
Edit:
Found this SO Q&A but I am hoping that there is a more elegant solution, that has emerged in the 3 years since.
There is a list if Python sound/music libraries at https://wiki.python.org/moin/PythonInMusic; several of these appear to suit your needs (in the section Music programming in Python). Those with MIDI support may be particularly useful (there is also a section MIDI Mania), but others may also meet your needs.
I am learning Pyprocessing. It comes with the regular processing platform that originally was written in Java. Many of the example projects that come bundled with processing have also been written in Python but not any of the audio libraries/examples.
I tried searching google but haven't found anything as of yet.
Does anyone know of a good resource where I can learn to do basic things with the audio library in pyprocessing such as playing audio and filtering audio?
I've used pyaudio and SWMixer for basic audio needs on a project.
Other python-audio resources I found useful at the time:
Scott W Harden's blog post on FFT analysis in Python (lots of neat things there)
PyAudioMixer
python-sounddevice
I hadn't used these exhaustively though to be able to advise on which one is most stable and easy to use.
I am using python inside another application (CINEMA 4D) create a nice connection to out issue tracker (Jira) inside the application. Rationale behind this is to make it really easy for our plugin users to report and track bugs and have things like machine specs, screenshots or attaching scene files (including textures) automatically.
So far it as been a really smooth ride and the integration is coming along great. I started grabbing the icons for issue priorities, projects, issue types, etc. from Jira as well so they can be displayed for better overview. To read the image files I am using CINEMA 4D functionality that is available inside its python binding.
The problem now is, that most icons from Jira come in GIF format and the CINEMA 4D SDK doesn't read GIF files directly (actually it does read them, but only through a back door so users can load them, but I can't use that functionality through Python or the SDK). So I need another way to read the GIF files.
There are a few questions on stackoverflow that go into this direction, but they all seem to recommend PIL. This doesn't feel like the right solution for a few reasons:
While that looks nice, it's not part of the standard distribution and seems to be really only maintained for Windows (even though there are builds for Mac OS X).
It also seems to install itself into the current system installation of Python, but CINEMA 4D comes with its own, so I'd have to rip it apart and distribute it with my plugin.
And then it is quite large, while I really only want a compact script to have a compact solution (preferably out of the box, but that doesn't seem to be an option)
I was wondering if there is a simpler or at least more compact way. Since GIF seems to be a relatively simple file format, I am wondering if there may even be a simple parser as a python function/class.
I found a link where somebody disassembles a gif files embedded frames, but doesn't actually grab the image contents: Python, how i can get gif frames
I'm fine with putting in some time on my own, and I would've already been coding away if the file format was something uncompressed, but I am a little reluctant since the compression seems to raise the bar slightly.
I have video files written in avi format and I would like to analyze these videos using Python. For that I would like to represent every frame of the video as a 2D matrix.
How can I do that? Google search gives me PyMedia as a way to go? Is it really the best choice or there some other approaches that I should to considered?
If the PyMedia is a good choice, could anybody pleas to give me a link where I can get exe files to install the module on Windows from binaries?
By the way, is it a good idea, in general, to use Python for these purposes? I like Python very much because of its simplicity and I prefer to use it, but if it is really not suitable for analysis of video, I am ready to use something else.
ADDED
Some people claim that PyMedia is "dead". Is it true?
Yeah, the latest news on the PyMedia web site is dated 01 Feb 2006. That's a pretty bad sign.
The most active and up-to-date open project for manipulating video is ffmpeg. Apparently there is a recently updated python wrapper for it: http://code.google.com/p/pyffmpeg/
In general Python is much too slow for doing any sort of pixel analysis of video. Therefore there will be practically zero libraries of any reasonable level of quality and support for helping at the pixel level of granularity. There are well supported libraries for working at an image level of granularity though. PIL seems to be a popular choice: http://www.pythonware.com/products/pil/
I am building an application in pyQt4 and I want it to be able to play audio files. I was considering doing this through pyMedia as I could not get anywhere with the documentation, although the QAudio classes did initially look promising. It is important that the solution be cross-platform. Does anyone have any suggestions?
As alex said, Phonon looks like your best bet because you can use it with Pyqt. You can find lots of examples of using phonon using google. This one, http://forum.kde.org/viewtopic.php?f=14&t=84275, for example is a command line tool to play audio using phonon. You might also want to take a look at the QSound class. QAudioInput looks interesting for adding support for a mike.
I hope this helps.
P.S.:
The riverbank site does mention the phonon module :)
I found a question on using Phonon + Pyqt - Play mp3 using Python, PyQt, and Phonon
Use Phonon ( http://phonon.kde.org/ ). I used it from Java with success, so I expect it will work even better in Python/Linux.
This might also help:
http://0pointer.de/blog/projects/guide-to-sound-apis.html