play a midi file from the interpreter?

E

Elaine Jackson

(How) can you make it so that a function invoked in the python interpreter can
run another program? (Like the webbrowser module does, only not with a web
browser.) If it matters the OS is Windows98 and the specific aim in mind is to
have a function that saves some data as a midi file and then causes the said
midi file to play.
 
M

Max M

Elaine said:
(How) can you make it so that a function invoked in the python interpreter can
run another program? (Like the webbrowser module does, only not with a web
browser.) If it matters the OS is Windows98 and the specific aim in mind is to
have a function that saves some data as a midi file and then causes the said
midi file to play.


Use the popen() call in the os module.

regards Max M
 
E

Elaine Jackson

Could you sketch me a useage example? I'm finding the documentation extremely
sparse. I've heard of 'pipes', but I don't actually know what they are.

| Elaine Jackson wrote:
| > (How) can you make it so that a function invoked in the python interpreter
can
| > run another program? (Like the webbrowser module does, only not with a web
| > browser.) If it matters the OS is Windows98 and the specific aim in mind is
to
| > have a function that saves some data as a midi file and then causes the said
| > midi file to play.
|
|
| Use the popen() call in the os module.
|
| regards Max M
 
M

Max M

Elaine said:
Could you sketch me a useage example? I'm finding the documentation extremely
sparse. I've heard of 'pipes', but I don't actually know what they are.

Basically you just pass popen a string that looks like one typed at the
command prompt:

# untested
# (Eg. I don't know the name of your midi file player
# so I call it playmidifile.exe)

import os
midifilename = 'c:/path/to/midifile.mid'
result = os.popen('playmidifile.exe %s' % midifilename)
print result
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top