I would like to know how I can start an audio without having to enter the Pyglet loop. My question is based on the fact that I'm already using a loop, for Pygame. Unfortunately, with the latter, I found the fact that it has an inaccurate control with regard to the volume of the audio. So I wanted to use Pyglet to play it. The fact is that I can not allow myself to start a loop with Pyglet, because it blocks the script, so, returning to the question, how can I use the audio playback event independently?
Asked
Active
Viewed 114 times
0
-
1I strongly suggest you do NOT mix these two languages. The main reason being, they essentially have the same functionalities. If you only need audio support, use [pyaudio](https://pypi.python.org/pypi/PyAudio) for instance. Some examples can be found here: https://stackoverflow.com/questions/26673746/playing-mp3-files-with-pyaudio/26759539#26759539. But to answer your question, how tp "playback event independently". You can't. You need to enter Pyglet's event loop in one way or another. There's some ways to get around the blocking, for instance, run the audio in a separate thread. Bad idea tho – Torxed Jan 13 '18 at 00:33
-
Here's actually a few better ones that I've combined before: https://stackoverflow.com/questions/16325794/how-to-play-music-through-python-with-mpg321/16326257#16326257 and I'm marking this question as a duplicate of this thread because, to be honest, they do make more sense to use these frameworks, rather than a entire second OpenGL library just to call a non-GL-related operation. And if all else, use threads. – Torxed Jan 13 '18 at 00:55
-
I wanted to use Pyglet because I had read that it could play 3D audio and I was interested. At first I went to the PySonic module, but unfortunately the last update is for Python 2.3 and I'm using Python 3.4. I had posted a question about which audio module I could use to get certain results, but I did not get any answers, so I tried to arrange. – BlackFenix06 Jan 13 '18 at 13:49
-
If you're considering still using Pyglet, I'm tempted to recommend you to rewrite the entire thing you're doing in Pyglet. It's going to take a bit longer, you'll learn a few things along the way - but ultimately it's going to be a much better code base. IMO. – Torxed Jan 13 '18 at 14:45
-
In addition to the main site of Pyglet, you know by chance another site where I can find references to examples on the use of Pyglet? Unfortunately, turning on the web, I did not find much ... – BlackFenix06 Jan 13 '18 at 15:27