Subject: Re: [ecasound] ecalength
From: S. Massy (email@example.com)
Date: Thu May 10 2001 - 20:57:11 EEST
On Thu, 26 Apr 2001, Kai Vehmanen wrote:
> On Wed, 4 Apr 2001, S. Massy wrote:
> > I've scribbled this little "program" to make it easy to retrieve the
> > length of a file from the command line. I post it here in the hope
> > that it might be useful to others too. Please note that I'm _not_ a
> > professional programmer, so be nice. :) Please post it back if you
> > bring any improvement to it.
> Actually I've been thinking about adding something like this to ecatools.
> I think 'ecalength' would fit to the current util set quite well. And it
> would be good to have a few ECI apps (both C and Python apps) in the
> ecatools set, just to show that not everything needs to be C++ and use
> libecasound directly.
> Few suggestions:
> - add support for new ai-* and ao-* commands sets ;)
Done... It was badly needed, of course.
> - usign the recently added ai-get-format/ao-get-format to
> also fetch audio format information
That was an excelent idea, I added it as well.
> - have separate switches for printing individual values;
> ie. by default ecalength/ecafile/ecasomething would
> print all info, but with..
> -l -> print only length in seconds
> -b -> print only sample resolution (bits)
> ... -> and son on
> Using the separate switches, you could easily use ecalength in scripts
> ('echo File length is `ecalength -l $1` seconds.´).
Ok, here's the approach I took: The default behaviour is still the
exact same as it was except that there's a -t switch to have the
summed length, for when you have multiple files. If the -f switch is
specified the format string is printed as well. Now the -s switch
takes you in "script mode" (a sophisticated term to say that it
becomes script friendly). The default behaviour in -s mode is to print
the length in seconds, but if the -m switch is specified while in -s
mode you will have the time in minutes/seconds. If you specify the -f
switch in -s mode the info given now is the format string (think of it
as a "submode" to script mode). If you're in -sf mode you can have the
different parameters of the format string given to you. For example
-sfr will give you the file's sampling rate. I also made it possible
to set the assumed format (for headerless files). If switches are
specified out of their context (say you specify -r without -sf) they
are just ignored.
So, as an example, suppose that you just finished recording that guitar
take in a .raw file sampled at 48 khz and you want to know how long it is
in minutes and seconds, and nothing more, you would do:
$ ecalength -sma:16,2,48000 guittake.raw
I also tried to make it script friendly by giving different exit status.
-2 = One of the files could not be processed by ecasound.
-1 = One of the files couldn't be opened.
0 = Everything's fine.
1 = Nothing was done, error in command-line, etc.
Well, that's about it I think, you can get it at:
Warning: You might very well find my coding style unreadable, I tend to code
as I write... Oh well, I suppose writers make bad coders and coders bad
> > BTW, it would be really nice if it was possible to pass the command
> > and the argument separately. I believe there's already a version of
> > this for floats, couldn't there be one for strings as well? Or have I
> > just missed something?
> Even the float-thing is a bit messy, but it was desperately needed (you
> need quite a few bytes to textually represent 64bit floating point
> values). So at least now, I'd like to avoid adding any new ECI calls. But
> I have to think about this some more...
Well, it is not THAT much of an annoyance but it would certainly be nicer if
the args could be passed directly.
> Audio software for Linux!
> To unsubscribe send message 'unsubscribe' in the body of the
> message to <firstname.lastname@example.org>.
-- To unsubscribe send message 'unsubscribe' in the body of the message to <email@example.com>.
This archive was generated by hypermail 2b28 : Thu May 10 2001 - 20:57:15 EEST