[LAU] audio collage?

Renato rennabh at gmail.com
Sat Jan 9 06:57:06 EST 2010


On Sat, 09 Jan 2010 12:24:16 +0100
Atte André Jensen <atte.jensen at gmail.com> wrote:

> Renato wrote:
> > Obviously i forgot to attach the file ;)
> 
> I have looked at your script, which unfortunately doesn't work here,
> I get "soxi FAIL formats: no handler for file extension `mp3'".
> Besides that I have a couple of suggestions or thoughts, you might
> want to consider:

ha, I guess the sox you have doesn't handle mp3. does 'play file.mp3'
work? It was the first time I ever used sox so I'm no expert...
probably compile time options?

> 1) It's good practice to output some kind of help or usage message
> when a program is called with no options. Right now I need to look at
> the python code to tell what's going on.

yeah, well it was really meant for personal use so I didn't think of it
first place, but I'll add that

> 2) You should try to avoid wrapping shell commands in os.system calls 
> whenever possible. Obviously the call to sox need to be that way, but 
> "touch" (for your need, that is create empty file) can be implemented
> in python:
> 
>      def touch(self, file):
>          if not os.path.exists(file):
>              f = open(file,"w")
>              f.write('')
>              f.close()
> 
> In general you should try to stick to python buildins, including
> using tempfile.mktemp() for a tmp file instead of handling it
> yourself.

thanks, hadn't thought of defining touch like that and didn't know of
the .mktemp() method

> 3) Although I did this myself, sox is not really nice to wrap in the 
> first place, since it sometimes changes the names of the arguments
> and stuff like that. So your script might not work after the next
> upgrade of sox :-(

uh, this is bad news indeed

> 4) I'm not sure mp3 files are the most obvious file format to work
> with, any specific reason you're not working with simple .wav's?

well, most of my music collection is in mp3... I guess I could prompt
the user for which filetype to look for

> Hope it's ok that I made these suggestions :-)
> 

yeah it's great! You know I haven't still gone through the whole python
tutorial so this is very much an exercise for me, and suggestions are
welcome

renato



More information about the Linux-audio-user mailing list