I am trying to develop a wxPython application for which I would like to
open a sound file
play said sound file from a to b (e.g. from 10 to 15 seconds into the sound file)
do this across different platforms
without having to install and call external programs
Now I have done my fair share of googling around for this, and I would really appreciate some help. The obvious first choice seems to be wx.Sound. However…
Works fine with a smaller sound file (110 KB). However, when I try to open and play a sound file that is bigger (27 MB), I get the weirdest error - instead of hearing the sound file play, what gets played is the Mac sound for screen shots. If I try clicking on the “play” button repeatedly, the whole application crashes with a “Segmentation fault: 11” error.
However… wx.media.MediaCtrl.Load() does not load anything - small files, big files, .mp3 files, .wav files, … I can’t get it to load the file, much less play the sound.
Can anybody please offer some help? What’s going wrong here, or what would be any alternatives to accomplish what I am trying to do? I am at my wits’ end, and any input would be GREATLY appreciated.
I am trying to develop a wxPython application for which I would like to
open a sound file
play said sound file from a to b (e.g. from 10 to 15 seconds into the sound file)
do this across different platforms
without having to install and call external programs
Now I have done my fair share of googling around for this, and I would really appreciate some help. The obvious first choice seems to be wx.Sound. However…
Works fine with a smaller sound file (110 KB). However, when I try to open and play a sound file that is bigger (27 MB), I get the weirdest error - instead of hearing the sound file play, what gets played is the Mac sound for screen shots. If I try clicking on the “play” button repeatedly, the whole application crashes with a “Segmentation fault: 11” error.
However… wx.media.MediaCtrl.Load() does not load anything - small files, big files, .mp3 files, .wav files, … I can’t get it to load the file, much less play the sound.
Can anybody please offer some help? What’s going wrong here, or what would be any alternatives to accomplish what I am trying to do? I am at my wits’ end, and any input would be GREATLY appreciated.
Thanks!!!
Ingrid
I have to admit, the MediaCtrl in wxPython is rather lacking. I think it depends more on the backend it is using on the OS, but still. I had issues getting it to work when I wrote that article you mentioned. I have yet to find a reliable Python sound player. The closest I got was using the mplayerCtrl, a 3rd party wxPython widget which wraps mplayer, a cross platform media player. I wrote about using it here:
It plays both audio and video files. You might also check out the following:
I am trying to develop a wxPython application for which I would
like to
open a sound file
play said sound file from a to b (e.g. from 10 to 15 seconds
into the sound file)
do this across different platforms
without having to install and call external programs
Now I have done my fair share of googling around for this, and
I would really appreciate some help. The obvious first choice
seems to be wx.Sound. However…
I tried out this example:
Works fine with a smaller sound file (110 KB). However, when I
try to open and play a sound file that is bigger (27 MB), I get
the weirdest error - instead of hearing the sound file play,
what gets played is the Mac sound for screen shots. If I try
clicking on the “play” button repeatedly, the whole application
crashes with a “Segmentation fault: 11” error.
My next attempt was using wx.media.MediaCtrl, as in this example:
However… wx.media. MediaCtrl.Load() does not load anything
small files, big files, .mp3 files, .wav files, … I can’t
get it to load the file, much less play the sound.
Can anybody please offer some help? What's going wrong here,
or what would be any alternatives to accomplish what I am
trying to do? I am at my wits’ end, and any input would be
GREATLY appreciated.
Hi Ingrid,
I use wxMediaCtrl for video and audio and it works great for many
different formats.
I'd suggest you attach a simple application for us all to look at.
See . It’s hard to say
what might be wrong based on the limited information you’re
provided.
David
thanks for your suggestions. mplayerCtrl looks great, except - it requires that users install mplayer first, right? Unfortunately, my ultimate goal is to eventually turn my program into a standalone application that other people can use without having to worry about installing packages, modules, other program components, … so I don’t want to use anything that requires the installation of other software.
I have attempted using several other audio packages, including pyglet and pyaudio. I have run into errors with everything I have tried so far, unfortunately. And of course, I would prefer to use a simple solution, if possible. It’s not like I’m trying to do some crazy audio manipulations here, I just want to play a sound file. wxMediaCtrl looks like it would be the perfect thing for this, if I could only get it to work!
I will take a look at audiere, though. And maybe keep trying those other packages one more time…
Thanks for your help! (And by the way, your blog is fantastic - it has already helped me a lot!)
Ingrid
···
Am Donnerstag, 27. Juni 2013 07:58:31 UTC-7 schrieb Mike Driscoll:
Hi Ingrid,
On Wednesday, June 26, 2013 11:47:13 PM UTC-5, Ingrid wrote:
Hi,
I am trying to develop a wxPython application for which I would like to
open a sound file
play said sound file from a to b (e.g. from 10 to 15 seconds into the sound file)
do this across different platforms
without having to install and call external programs
Now I have done my fair share of googling around for this, and I would really appreciate some help. The obvious first choice seems to be wx.Sound. However…
Works fine with a smaller sound file (110 KB). However, when I try to open and play a sound file that is bigger (27 MB), I get the weirdest error - instead of hearing the sound file play, what gets played is the Mac sound for screen shots. If I try clicking on the “play” button repeatedly, the whole application crashes with a “Segmentation fault: 11” error.
However… wx.media.MediaCtrl.Load() does not load anything - small files, big files, .mp3 files, .wav files, … I can’t get it to load the file, much less play the sound.
Can anybody please offer some help? What’s going wrong here, or what would be any alternatives to accomplish what I am trying to do? I am at my wits’ end, and any input would be GREATLY appreciated.
Thanks!!!
Ingrid
I have to admit, the MediaCtrl in wxPython is rather lacking. I think it depends more on the backend it is using on the OS, but still. I had issues getting it to work when I wrote that article you mentioned. I have yet to find a reliable Python sound player. The closest I got was using the mplayerCtrl, a 3rd party wxPython widget which wraps mplayer, a cross platform media player. I wrote about using it here:
thanks for your answers! Here is a sample program using wx.MediaCtrl that illustrates the problem:
On my Mac (OS 10.8.4, Python 2.7.2, wx 2.9.4.0), all the attempts at "Load" return False, so nothing ever happens.
On my Windows machine (Windows XP, Python 2.7.4, wx 2.8.12.1), all the "Load" attempts return True, but after that, nothing happens either.
Hi Ingrid,
I have your sample working on Windows. Haven't tried it on Mac yet.
The first thing I did was add an explicit backend. In the wx.MediaCtrl call, add the szBackend parameter with wx.media.MEDIABACKEND_WMP10 for Windows and wx.media.MEDIABACKEND_QUICKTIME for OS X (and some formats on Windows that require the QuickTime player rather than Windows Media Player).
The second thing I did was to comment out the ret2 and ret3 lines in your onClick method. You were successfully loading the file with the ret1 line, then breaking that with the ret2 and ret3 lines that tried to load the file differently and essentially cancelled the ret1's successful load.
I changed the media file name to point to a file on my computer. Did you correct that?
David
···
On 06/27/2013 01:14 PM, Ingrid wrote:
Hi David,
thank you so much for your help! Unfortunately, I just tried your code out on my Mac, and it doesn't work. Load still returns False for me.
Ingrid
Am Donnerstag, 27. Juni 2013 11:08:11 UTC-7 schrieb David:
> Hi Mike and David,
>
> thanks for your answers! Here is a sample program using
wx.MediaCtrl
> that illustrates the problem:
>
> On my Mac (OS 10.8.4, Python 2.7.2, wx 2.9.4.0), all the
attempts at
> "Load" return False, so nothing ever happens.
>
> On my Windows machine (Windows XP, Python 2.7.4, wx 2.8.12.1),
all the
> "Load" attempts return True, but after that, nothing happens
either.
Hi again,
Just confirmed that the same changes work on OS X.
The revised sample code is attached.
David
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
First, I'd check to make sure the file is specified correctly. Check os.path.exists(filename).
Second, I'd check to make sure the file plays in the QuickTime player outside of Python. (I'm surprised how often corrupt files are the issue for my customers.)
Third, my system specs are a bit different than yours. OS X 10.7.5, Python 2.6.7, wxPython 2.9.5.0.b20130318. I suppose that *could* be the issue, but I doubt it.
David
···
It does work on Windows, though. Yay and many thanks!!!
Am Donnerstag, 27. Juni 2013 11:08:11 UTC-7 schrieb David:
> Hi Mike and David,
>
> thanks for your answers! Here is a sample program using
wx.MediaCtrl
> that illustrates the problem:
>
> On my Mac (OS 10.8.4, Python 2.7.2, wx 2.9.4.0), all the
attempts at
> "Load" return False, so nothing ever happens.
>
> On my Windows machine (Windows XP, Python 2.7.4, wx 2.8.12.1),
all the
> "Load" attempts return True, but after that, nothing happens
either.
Hi again,
Just confirmed that the same changes work on OS X.
The revised sample code is attached.
David
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
I'm sorry to say I don't know what more to tell you. We have one "It doesn't work for me" and one "It works for me" so far.
I guess we have to wait for a couple more Mac users to try the sample program earlier in this thread to see if others can recreate the problem you're running into and come up with suggestions for you.
David
···
I just opened the file in the QuickTime player. No problems opening and playing it.
Am Donnerstag, 27. Juni 2013 11:26:06 UTC-7 schrieb David:
Hi Ingrid,
For your Mac:
First, I'd check to make sure the file is specified correctly. Check os.path.exists(filename).
Second, I'd check to make sure the file plays in the QuickTime
player outside of Python. (I'm surprised how often corrupt files
are the issue for my customers.)
Third, my system specs are a bit different than yours. OS X
10.7.5, Python 2.6.7, wxPython 2.9.5.0.b20130318. I suppose that
*could* be the issue, but I doubt it.
David
It does work on Windows, though. Yay and many thanks!!!
Am Donnerstag, 27. Juni 2013 11:08:11 UTC-7 schrieb David:
> Hi Mike and David,
>
> thanks for your answers! Here is a sample program using
wx.MediaCtrl
> that illustrates the problem:
>
> On my Mac (OS 10.8.4, Python 2.7.2, wx 2.9.4.0), all the
attempts at
> "Load" return False, so nothing ever happens.
>
> On my Windows machine (Windows XP, Python 2.7.4, wx
2.8.12.1), all the
> "Load" attempts return True, but after that, nothing
happens either.
Hi again,
Just confirmed that the same changes work on OS X.
The revised sample code is attached.
David
-- You received this message because you are subscribed to the
Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to wxpython-user...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out
<https://groups.google.com/groups/opt_out>\.
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
On Thursday, June 27, 2013 12:57:33 PM UTC-5, Ingrid wrote:
Hi Mike,
thanks for your suggestions. mplayerCtrl looks great, except - it requires that users install mplayer first, right? Unfortunately, my ultimate goal is to eventually turn my program into a standalone application that other people can use without having to worry about installing packages, modules, other program components, … so I don’t want to use anything that requires the installation of other software.
I’m not entirely sure, but I suspect you could include the mplayerCtrl in your distribution so your users wouldn’t have to install anything. Hopefully David or Robin will be able to help you get the regular MediaCtrl to work though. Maybe I need to try it again myself as it may have improved on 2.9 vs. 2.8.
I’d also be interested in this Ingrid. I’ve been looking into
using Python to create music practice files for
choral singing. I’ve been working with MIDI input and output and
midi files (as well as ABC format files). One of the
things I’d like to do is be able to take any audio file, and make
playback tags to play from point a to point b (possibly
interjecting voiceovers between clips, etc.)
Also to synchronize midi files with MP3(or other format) music.
Rufus
···
On 6/27/2013 12:47 AM, Ingrid wrote:
Hi,
I am trying to develop a wxPython application for which I would
like to
open a sound file
play said sound file from a to b (e.g. from 10 to 15 seconds
into the sound file)
do this across different platforms
without having to install and call external programs
Now I have done my fair share of googling around for this, and
I would really appreciate some help. The obvious first choice
seems to be wx.Sound. However…
I tried out this example:
Works fine with a smaller sound file (110 KB). However, when I
try to open and play a sound file that is bigger (27 MB), I get
the weirdest error - instead of hearing the sound file play,
what gets played is the Mac sound for screen shots. If I try
clicking on the “play” button repeatedly, the whole application
crashes with a “Segmentation fault: 11” error.
My next attempt was using wx.media.MediaCtrl, as in this example:
However… wx.media. MediaCtrl.Load() does not load anything
small files, big files, .mp3 files, .wav files, … I can’t
get it to load the file, much less play the sound.
Can anybody please offer some help? What's going wrong here,
or what would be any alternatives to accomplish what I am
trying to do? I am at my wits’ end, and any input would be
GREATLY appreciated.
Thanks!!!
Ingrid
–
You received this message because you are subscribed to the Google
Groups “wxPython-users” group.
To unsubscribe from this group and stop receiving emails from it,
Works on OSX 10.6.8 with Python 2.7.3 and wx 2.8.12.1
Cheers
···
Am 27.06.13 21:35, schrieb Ingrid:
David,
I know. I am really stumped by this. Hopefully somebody else can
come up with an explanation/solution.
I really appreciate all the help you've given me, though! It's great
to know that at least I'm not making any stupid/obvious mistakes.
Many thanks,
Ingrid
Am Donnerstag, 27. Juni 2013 12:00:18 UTC-7 schrieb David:
Ingrid,
I'm sorry to say I don't know what more to tell you. We have one
"It doesn't work for me" and one "It works for me" so far.
I guess we have to wait for a couple more Mac users to try the
sample program earlier in this thread to see if others can
recreate the problem you're running into and come up with
suggestions for you.
David
I just opened the file in the QuickTime player. No problems
opening and playing it.
Am Donnerstag, 27. Juni 2013 11:26:06 UTC-7 schrieb David:
Hi Ingrid,
For your Mac:
First, I'd check to make sure the file is specified
correctly. Check os.path.exists(filename).
Second, I'd check to make sure the file plays in the
QuickTime player outside of Python. (I'm surprised how often
corrupt files are the issue for my customers.)
Third, my system specs are a bit different than yours. OS X
10.7.5, Python 2.6.7, wxPython 2.9.5.0.b20130318. I suppose
that *could* be the issue, but I doubt it.
David
It does work on Windows, though. Yay and many thanks!!!
Am Donnerstag, 27. Juni 2013 11:08:11 UTC-7 schrieb David:
> Hi Mike and David,
>
> thanks for your answers! Here is a sample program
using wx.MediaCtrl
> that illustrates the problem:
>
> On my Mac (OS 10.8.4, Python 2.7.2, wx 2.9.4.0), all
the attempts at
> "Load" return False, so nothing ever happens.
>
> On my Windows machine (Windows XP, Python 2.7.4, wx
2.8.12.1), all the
> "Load" attempts return True, but after that, nothing
happens either.
Hi again,
Just confirmed that the same changes work on OS X.
--
You received this message because you are subscribed to the
Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to wxpython-user...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out
<https://groups.google.com/groups/opt_out>\.
--
You received this message because you are subscribed to the Google
Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.