Hi,
I am trying to make pygame play music on windows. This simple program:
import pygame,time
pygame.init()
print "Mixer settings", pygame.mixer.ge t_init()
print "Mixer channels", pygame.mixer.ge t_num_channels( )
pygame.mixer.mu sic.set_volume( 1.0)
pygame.mixer.mu sic.load('file1 .mp3)
print "Play"
pygame.mixer.mu sic.play()
while pygame.mixer.mu sic.get_busy():
print "Playing", pygame.mixer.mu sic.get_pos()
time.sleep(1)
print "Done"
seems to work. It runs the loop and prints values that look like ms into the
file. After a reasonable time corresponding to the length of "file1.mp3" the
loop is exited and the program ends.
The same thing happens for .mp3 files, .ogg files and .wav files.
Fine. The only problem is that there is no sound :-).
What am I doing wrong? pyGame example games do play sound, but I have not
found an example that uses music.
My ultimate goal is to build a MP3 jukebox that runs on Windows and Linux. I
have chosen pyGame as I am making a graphical Frontend using OpenGL. I have
also tried to look at pymad (which I could not get to work on Windows, no
C-Compiler on this machine and I could not find binaries) and audiere (no
skipping, at least in the python binding. A feature I would like to have.)
Ciao, MM
--
Marian Aldenhövel, Rosenhain 23, 53123 Bonn. +49 228 624013. http://www.marian-aldenhoevel.de
"Wir brauchen keine Opposition, wir sind bereits Demokraten." 12 16130
Marian Aldenhövel wrote: Hi,
I am trying to make pygame play music on windows. This simple
program: import pygame,time pygame.init() print "Mixer settings", pygame.mixer.ge t_init() print "Mixer channels", pygame.mixer.ge t_num_channels( ) pygame.mixer.mu sic.set_volume( 1.0) pygame.mixer.mu sic.load('file1 .mp3) print "Play" pygame.mixer.mu sic.play()
while pygame.mixer.mu sic.get_busy(): print "Playing", pygame.mixer.mu sic.get_pos() time.sleep(1)
print "Done"
seems to work. It runs the loop and prints values that look like ms
into the file. After a reasonable time corresponding to the length of
"file1.mp3" the loop is exited and the program ends.
The same thing happens for .mp3 files, .ogg files and .wav files.
Fine. The only problem is that there is no sound :-).
What am I doing wrong? pyGame example games do play sound, but I have
not found an example that uses music.
My ultimate goal is to build a MP3 jukebox that runs on Windows and
Linux. I have chosen pyGame as I am making a graphical Frontend using OpenGL.
I have also tried to look at pymad (which I could not get to work on
Windows, no C-Compiler on this machine and I could not find binaries) and audiere
(no skipping, at least in the python binding. A feature I would like to
have.) Ciao, MM -- Marian Aldenhövel, Rosenhain 23, 53123 Bonn. +49 228 624013. http://www.marian-aldenhoevel.de "Wir brauchen keine Opposition, wir sind bereits Demokraten."
Hello Marian,
First thing out i must tell you that pygame is ok for games but the
music quality is sometimes sketchy, you must set the bit rate to get
good sound quality and there are many other pitfalls. Search the net.
You are not the first to try and build a jukebox out of pygame ;)
Py> import pygame
Py> pygame.mixer.in it()
Py> pygame.mixer.mu sic.load('c:/everyday.mp3')
Py> pygame.mixer.pl ay()
Py> pygame.mixer.mu sic.fadeout(400 0)
You have a typo in the code you posted that may be your problem.
M.E.Farmer
Hi, Search the net. You are not the first to try and build a jukebox out of pygame ;)
I did find a few, yes.
Currently this is a toy project as I am learning the language, so early
success means more to me than perfect results. And, as I said, I do not really
have an alternative.
Maybe some way to remote control another player would be in order. Leave it
to software that is specialized and all. But I would want something that runs
on Windows and Linux which narrows down my options.
You have a typo in the code you posted that may be your problem.
You are refering to the missing ' in the filename?
pygame.mixer.mu sic.load('file1 .mp3)
No, that's not the problem. I did paste working code but I then edited out the
full absolute path that I had coded into the program and introduced the error.
I also tried your sample but no difference. Must be something on my system
as it does seem to play...
Ciao, MM
--
Marian Aldenhövel, Rosenhain 23, 53123 Bonn. +49 228 624013. http://www.marian-aldenhoevel.de
"Wir brauchen keine Opposition, wir sind bereits Demokraten."
Marian Aldenhövel wrote: Hi,
I am trying to make pygame play music on windows. This simple program:
import pygame,time pygame.init() print "Mixer settings", pygame.mixer.ge t_init() print "Mixer channels", pygame.mixer.ge t_num_channels( ) pygame.mixer.mu sic.set_volume( 1.0) pygame.mixer.mu sic.load('file1 .mp3) print "Play" pygame.mixer.mu sic.play()
while pygame.mixer.mu sic.get_busy(): print "Playing", pygame.mixer.mu sic.get_pos() time.sleep(1)
print "Done"
I tried this exact same code (except the mp3 filename, of course) on my
machine and it worked fine. ActivePython 2.3.4 and Pygame 1.6. Could it
be a hardware problem?
-greg
Marian Aldenhövel wrote: Maybe some way to remote control another player would be in order. Leave it to software that is specialized and all. But I would want something that runs on Windows and Linux which narrows down my options.
Perhaps Zinf? http://www.zinf.org/
--
Daniel Bickett
dbickett at gmail.com http://heureusement.org/
Hello again,
Sorry you have had no success. I would suspect it is your system
setup.
Seems the code is working. I didn't think you had the typo problem,
just mentioned it because it says somewhere in the docs that if the
mixer has problems with file loading it would result in a proxy object
that supported the play and stop commands.
Please post your os name and version, Python version, Pygame version,
etc.
Some genius out there might know how to fix it.
Also you can try and look for another sound package, like maybe pyFMOD
;)
Home of FMOD http://www.fmod.org/
and the Python bindings http://sourceforge.net/projects/uncassist
the people who wrote pyFMOD (lots of stuff there) http://www.cs.unc.edu/~parente/tech/tr01.shtml
Hth,
M.E.Farmer
Hi, Please post your os name and version, Python version, Pygame version,
German Windows XP Home, 2.3.4, 1.6
Also you can try and look for another sound package
I will. Until I find something suitable I will just build a dummy class
that has the commands I need, I can later interface that to whatever I
really use. Should I ever get to that point - as I said, this is a toy
project and they tend to die suddenly :-).
Ciao, MM
--
Marian Aldenhövel, Rosenhain 23, 53123 Bonn. +49 228 624013. http://www.marian-aldenhoevel.de
"Wir brauchen keine Opposition, wir sind bereits Demokraten."
Hi, Could it be a hardware problem?
I don't think so. I can play sounds on this machine and I can also play
this very file using Windows Media Player. I suspect it's software, but
I do not know at which level the problem may lie.
Ciao, MM
--
Marian Aldenhövel, Rosenhain 23, 53123 Bonn. +49 228 624013. http://www.marian-aldenhoevel.de
"Wir brauchen keine Opposition, wir sind bereits Demokraten."
Hi, Perhaps Zinf?
I could not find anything about remote-controlling it. Did not install
it, however.
Ciao, MM
--
Marian Aldenhövel, Rosenhain 23, 53123 Bonn. +49 228 624013. http://www.marian-aldenhoevel.de
"Wir brauchen keine Opposition, wir sind bereits Demokraten."
Just curious what is not suitable about FMOD ?
It seems to be exactly what you are looking for.
Cross platform, free, great sound, python bindings, no compiler needed.
M.E.Farmer This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: AnsNum |
last post by:
hello,
when I start this program, the movie doesn't play smoothly, anybody has an
idea ?
(I use windowsXP)
import pygame
from pygame.display import flip
from pygame.locals import *
pygame.init()
|
by: JDR |
last post by:
Would anyone happen to know of a way to strip out the joystick module of
Pygame? I've written a console based application that doesn't need X,
mixer, fonts, etc. and I can't get my application to run without X11 libs
installed.
I've been searching google for the past hour without luck. If anyone knows
of any good informational sites, please let me know. I'll keep digging
through Python's docs.
Thanks!
|
by: maxime |
last post by:
Hi, I try to develop a game in python and pygame.
In my game I play a music (.mid with pygame.mixer.music) but sometime
I need to accelerate it but I don't see how to do that with pygame. Is
it possible? If not, do you know an other python music lib that do
that?
Thanks a lot
|
by: exodus |
last post by:
As a fun little task to gain more knowledge of python, i decided to try to mimick the ipod UI with it. here's what i've got so far
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# generated by wxGlade 0.5 on Sat Oct 27 15:46:36 2007
import wx, os, pygame
pygame.init()
class MyFrame2(wx.MDIChildFrame):
|
by: Woot4Moo |
last post by:
Hey guys I am running Windows XP and am having an issue with a game
that my team has created. Whenever an audio file is played it creates
a very distorted, crackly sound. Any ideas what could be the issue?
Thanks
| |
by: zswartz |
last post by:
Hi All, I've been stuck here for some time now and can't figure this out. If ANYONE can assist me, that would be AMAZING!!
I have Windows XP, with Python 25 and Pygame for python 25. I am also coding this in Eclipse
-----------------------------------------
My music files are:
D:\My Documents\School Work\Comp 523\Projects\MediaPlayer\MediaPlayer\src\MediaPlayer\Music\one.mp3
-----------------------------------------
My Project files...
|
by: globalrev |
last post by:
im doing this :
http://www.learningpython.com/2006/03/12/creating-a-game-in-python-using-pygame-part-one/
and when closing the program the window stays up and doesnt respond. i
tried adding this:
http://www.pygame.org/wiki/FrequentlyAskedQuestions
bu it doesnt work, or maybe im doing it wrong.
heres the code without the added tutorial exit:
|
by: globalrev |
last post by:
import pygame
pygame.mixer.music.load(example1.mp3)
pygame.mixer.music.play(loops=1, start=0.0)
Traceback (most recent call last):
File "C:\Python25\myPrograms\pygameProgs\musicexp.py", line 3, in
<module>
pygame.mixer.music.load(example1.mp3)
|
by: globalrev |
last post by:
http://www.pygame.org/docs/ref/mixer.html
import pygame
#pygame.mixer.init(frequency=22050, size=-16, channels=2,
buffer=3072) //it complained abiout words=
so i guess its only the nbrs should be there//
pygame.mixer.init(22050, -16, 2, 3072)
pygame.mixer.music.load("example1.mp3")
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |