Thread: [DirectPython] Examples
Status: Inactive
Brought to you by:
hsalo
From: Jeffrey B. <jef...@ea...> - 2006-07-11 01:11:21
|
Are there any examples of how to use DirectPython to produce sound? It appears that all the programs in directpy\samples are for graphical operations. Also, I will need audio codecs. I don't know DirectSound, but I assume that it provides only hooks for codecs, not the codecs themselves. If that is true, is it possible to find decoders packaged for DirectSound for ogg, WMA, AAC, and MP3? -- Jeffrey Barish |
From: Heikki S. <ho...@gm...> - 2006-07-11 14:49:07
|
> -----Original Message----- > From: dir...@li...=20 > [mailto:dir...@li...]=20 > On Behalf Of Jeffrey Barish > Sent: 11. hein=E4kuuta 2006 4:11 > To: dir...@li... > Subject: [DirectPython] Examples >=20 > Are there any examples of how to use DirectPython to produce=20 > sound? It appears that all the programs in directpy\samples=20 > are for graphical operations. >=20 > Also, I will need audio codecs. I don't know DirectSound,=20 > but I assume that it provides only hooks for codecs, not the=20 > codecs themselves. If that is true, is it possible to find=20 > decoders packaged for DirectSound for ogg, WMA, AAC, and MP3? > -- > Jeffrey Barish >=20 >=20 > -------------------------------------------------------------- > ----------- > Using Tomcat but need to do more? Need to support web=20 > services, security? > Get stuff done quickly with pre-integrated technology to make=20 > your job easier Download IBM WebSphere Application Server=20 > v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057& > dat=3D121642 > _______________________________________________ > directpython-general mailing list > dir...@li... > https://lists.sourceforge.net/lists/listinfo/directpython-general >=20 There are currently only two samples that use sounds: = sampleShipEffects.py uses the d3d.Sound (with 3D effect in newer versions) and samplewx.py = uses the d3d.Media. The objects are pretty simple to use, so there really is = not that much to show.=20 The Media-object (uses DirectShow) can play pretty much anything if = corrent codecs (or filters) are registered. Sound (uses DirectSound) can only = play .wav files. Googling for "directshow filter/codec <wanted format>" will probably find quite a few of them. The codecs are usually .exe-files = that will register themself when installed. After this the Media should be = able to play the formats that the codec supports. There are some bad codecs out there, so if possible try to get some information about them. Also note that .mp3 (and some other formats too) = is supported directly by the DirectShow so there is usually no need to = install any codecs in order to play them.=20 -- Heikki Salo |
From: Jeffrey B. <jef...@ea...> - 2006-07-11 17:38:38
|
On Tuesday 11 July 2006 08:45, Heikki Salo wrote: > There are currently only two samples that use sounds: sampleShipEffects.py > uses the d3d.Sound (with 3D effect in newer versions) and samplewx.py uses > the d3d.Media. The objects are pretty simple to use, so there really is not > that much to show. > > The Media-object (uses DirectShow) can play pretty much anything if corrent > codecs (or filters) are registered. Sound (uses DirectSound) can only play > .wav files. Googling for "directshow filter/codec <wanted format>" will > probably find quite a few of them. The codecs are usually .exe-files that > will register themself when installed. After this the Media should be able > to play the formats that the codec supports. > > There are some bad codecs out there, so if possible try to get some > information about them. Also note that .mp3 (and some other formats too) is > supported directly by the DirectShow so there is usually no need to install > any codecs in order to play them. > > -- > Heikki Salo Thank you for your quick response. I found sampleShipEffects.py. Emulating the code therein for playing a sound, I tried: >>> import d3d >>> snd = d3d.Sound(u'c:/windows/media/tada.wav', True) Traceback (most recent call last): File "<pyshell#1>", line 1, in ? snd = d3d.Sound(u'c:/windows/media/tada.wav', True) Error: An invalid parameter was passed to the returning function Also, when I try to run sampleShipEffects, it fails with: Traceback (most recent call last): File "C:\Python24\Lib\site-packages\directpy\samples\sampleShipEffects.py", line 156, in ? frame = SceneSample2(u"Ship and effects") File "C:\Python24\lib\site-packages\directpy\d3dx.py", line 572, in __init__ fullscreen, CREATE.HARDWARE) RuntimeError: Failed to create a device I found an ogg decoder at Free-Codecs.com (which seems actually to be from illiminable). I have installed it, so I hope that once I get past these startup glitches, I will be able to play an ogg file using DirectPython. Also, where do I find documentation for the DirectSound and DirectShow sound-related objects? Besides playing a sound file, there are few more functions that I need: I need to be able to get the current position (time) of playback while a sound file is playing. I need to be able to specify a starting time for play. And I need to be able to stop (or pause) playback. Are those operations possible with DirectX? In case it matters, I am on Windows XP running Python 2.4.3. -- Jeffrey Barish |
From: Heikki S. <ho...@gm...> - 2006-07-11 20:38:10
|
=20 > -----Original Message----- > From: dir...@li...=20 > [mailto:dir...@li...]=20 > On Behalf Of Jeffrey Barish > Sent: 11. hein=E4kuuta 2006 20:39 > To: dir...@li... > Subject: Re: [DirectPython] Examples >=20 > On Tuesday 11 July 2006 08:45, Heikki Salo wrote: > > There are currently only two samples that use sounds:=20 > > sampleShipEffects.py uses the d3d.Sound (with 3D effect in newer=20 > > versions) and samplewx.py uses the d3d.Media. The objects=20 > are pretty=20 > > simple to use, so there really is not that much to show. > > > > The Media-object (uses DirectShow) can play pretty much anything if=20 > > corrent codecs (or filters) are registered. Sound (uses=20 > DirectSound)=20 > > can only play .wav files. Googling for "directshow filter/codec=20 > > <wanted format>" will probably find quite a few of them. The codecs=20 > > are usually .exe-files that will register themself when installed.=20 > > After this the Media should be able to play the formats=20 > that the codec supports. > > > > There are some bad codecs out there, so if possible try to get some=20 > > information about them. Also note that .mp3 (and some other formats=20 > > too) is supported directly by the DirectShow so there is usually no=20 > > need to install any codecs in order to play them. > > > > -- > > Heikki Salo > Thank you for your quick response. >=20 > I found sampleShipEffects.py. Emulating the code therein for=20 > playing a sound, I tried: >=20 > >>> import d3d > >>> snd =3D d3d.Sound(u'c:/windows/media/tada.wav', True) > Traceback (most recent call last): > File "<pyshell#1>", line 1, in ? > snd =3D d3d.Sound(u'c:/windows/media/tada.wav', True) > Error: An invalid parameter was passed to the returning function >=20 Sound needs an active focus window. d3d.showWindow(SHOW.SHOW) or d3d.createDevice() will create one. And you can remove the second = argument if you are not playing 3D sounds, it might help.=20 Media can play sounds (.wav is ok) without a visible window, so call d3d.showWindow(SHOW.HIDE) before creating the Media-object and you = should be able to play them. This is probably the better way. > Also, when I try to run sampleShipEffects, it fails with: >=20 > Traceback (most recent call last): > File=20 > "C:\Python24\Lib\site-packages\directpy\samples\sampleShipEffects.py", > line 156, in ? > frame =3D SceneSample2(u"Ship and effects") > File "C:\Python24\lib\site-packages\directpy\d3dx.py", line=20 > 572, in __init__ > fullscreen, CREATE.HARDWARE) > RuntimeError: Failed to create a device >=20 You probably have a pretty old (or maybe some cheap integrated) = card/driver. Try to replace HARDWARE with SOFTWARE. If that fails, try with "SOFTWARE = | NOCAPCHECK" (an old version of DP had a bug in the detection code which might cause this, but it has been already fixed in newer releases). > I found an ogg decoder at Free-Codecs.com (which seems=20 > actually to be from illiminable). I have installed it, so I=20 > hope that once I get past these startup glitches, I will be=20 > able to play an ogg file using DirectPython. >=20 I have played .ogg's with DirectPython, so that should not be a problem. > Also, where do I find documentation for the DirectSound and=20 > DirectShow sound-related objects? Besides playing a sound=20 > file, there are few more functions that I need: I need to be=20 > able to get the current position (time) of playback while a=20 > sound file is playing. I need to be able to specify a=20 > starting time for play. And I need to be able to stop (or=20 > pause) playback. =20 > Are those operations possible with DirectX? >=20 The documentation can be accessed through the shortcut placed somewhere = in your Start-menu (DirectPython -> Documentation). And yes, you should be = able to do those things with d3d.Media. -- Heikki Salo > In case it matters, I am on Windows XP running Python 2.4.3. > -- > Jeffrey Barish >=20 >=20 > -------------------------------------------------------------- > ----------- > Using Tomcat but need to do more? Need to support web=20 > services, security? > Get stuff done quickly with pre-integrated technology to make=20 > your job easier > Download IBM WebSphere Application Server v.1.0.1 based on=20 > Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057& dat=3D121642 |