* analyze a .wav or .mp3 file
@ Terry Klarich
` Hart Larry
` Chris Brannon
0 siblings, 2 replies; 9+ messages in thread
From: Terry Klarich @ UTC (permalink / raw)
To: Linux for blind general discussion
Hello All:
I would like to see if anyone has an idea how to analyze a wav or mp3 file in a shell script to see if there is any audio present;
or, it is a blank file.
The story:
I have used a script for several years called xmonline to listen to xmradio over the internet. Actually, I mostly used it to
record shows I wanted to listen to later. Since, the original script used mplayer to play the stream, I modified the script to
write to a file on disk. It worked well and I could listen to those shows on xm I had to miss for one reason or another. (my own
xm audio recorder.
Recently, XM has changed their interface such that the xmonline script will no longer work. I originally thought I cold use
firefox, and the analysis of the network trafic to write a new script. Using curl as the xmonline script did, I am able to get
logged into the site. But, when I dig out the stream and try and play it with mplayer, it doesn't work. I know I'm missing some
simple little cookie or authorization parameter. (Who knows)
Basically, I have given up on the streaming approach for now. And, will use the brute force method. I have my xmradio hooked up
via a sound card. I am able to listen to xm on my computer with aplay just fine. I even have a lirc config file that will turn
and off the unit and change channels. Works great.
My problem is I have no way of knowing if the unit is on or off. There is only a power toggle ir code. If there was a power-on,
my problems would be over.
To get around this problem, I will first record a 10 second clip and see if there is anything there or not. If there isn't, I know
the unit is off.
So, does anyone know a way to discover if there is any audio in a wav or mp3 file using a shell script running in the background?
Any suggestions wellcome.
THANKS!
Terry
P.S.
If anyone wants my failed xmrip script, they are welcome to see what they can do with it.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: analyze a .wav or .mp3 file
analyze a .wav or .mp3 file Terry Klarich
@ ` Hart Larry
` Chris Brannon
1 sibling, 0 replies; 9+ messages in thread
From: Hart Larry @ UTC (permalink / raw)
To: Linux for blind general discussion
Well, Terry, an obvious question, what happens if you type file before its
name? also, if you do an
ls -l before its name, it will give you size
Hope that helps
Hart
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: analyze a .wav or .mp3 file
analyze a .wav or .mp3 file Terry Klarich
` Hart Larry
@ ` Chris Brannon
` Tim Chase
1 sibling, 1 reply; 9+ messages in thread
From: Chris Brannon @ UTC (permalink / raw)
To: Linux for blind general discussion
Terry Klarich wrote:
> I would like to see if anyone has an idea how to analyze a wav or mp3 file in
> a shell script to see if there is any audio present;
> or, it is a blank file.
The command-line syntax of sox changed.
As of version 14.3.0, it is sox whatever.wav -n stat, instead of -e stat.
Here's some sample output generated by an audio file of mine.
Note that the data is written to stderr.
Samples read: 215560756
Length (seconds): 9775.998005
Scaled by: 2147483647.0
Maximum amplitude: 1.000000
Minimum amplitude: -1.000000
Midline amplitude: -0.000000
Mean norm: 0.073211
Mean amplitude: -0.000002
RMS amplitude: 0.119737
Maximum delta: 1.026207
Minimum delta: 0.000000
Mean delta: 0.019383
RMS delta: 0.035299
Rough frequency: 1034
Volume adjustment: 1.000
The volume adjustment number always seemed helpful when looking for a blank
file. It is much greater than 1.00 if the file contains silence.
The other statistics are probably useful as well, but I don't know very
much about digital audio.
-- Chris
PS. I think that you and I have a few common acquaintances outside of the net.
I caught mention of your name several times when I was pursuing an undergrad
CS degree.
73 DE KB5KZZ
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: analyze a .wav or .mp3 file
` Chris Brannon
@ ` Tim Chase
` Geoff Shang
0 siblings, 1 reply; 9+ messages in thread
From: Tim Chase @ UTC (permalink / raw)
To: Linux for blind general discussion
Chris Brannon wrote:
> As of version 14.3.0, it is sox whatever.wav -n stat, instead of -e stat.
[snip]
> The volume adjustment number always seemed helpful when looking for a blank
> file. It is much greater than 1.00 if the file contains silence.
> The other statistics are probably useful as well, but I don't know very
> much about digital audio.
I was about to fire off a similar email, but Chris beat me to the
punch. If you just want the volume adjustment, you can add "-v"
at the end of the command:
sox my_file.wav -n stat -v
and all it reports is the volume number with no extra
information. Can be useful for scripting purposes too.
-tim
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: analyze a .wav or .mp3 file
` Tim Chase
@ ` Geoff Shang
0 siblings, 0 replies; 9+ messages in thread
From: Geoff Shang @ UTC (permalink / raw)
To: Linux for blind general discussion
On Mon, 11 Jan 2010, Tim Chase wrote:
> I was about to fire off a similar email, but Chris beat me to the punch. If
> you just want the volume adjustment, you can add "-v" at the end of the
> command:
>
> sox my_file.wav -n stat -v
>
> and all it reports is the volume number with no extra information. Can be
> useful for scripting purposes too.
My suggestion also.
One thing to keep in mind - at least the versions I've used send this
number to stderr instead of stdout. No idea why, but if you want to use
it in a script, you need to keep this in mind, assuming it hasn't changed.
Geoff.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: analyze a .wav or .mp3 file
@ Martin McCormick
` Terry Klarich
0 siblings, 1 reply; 9+ messages in thread
From: Martin McCormick @ UTC (permalink / raw)
To: Linux for blind general discussion, Terry Klarich
Terry Klarich writes:
> I would like to see if anyone has an idea how to analyze a wav or mp3
> file in a shell script to see if there is any audio present;
> or, it is a blank file.
My thanks to someone a couple of yers ago who suggested this
when I asked a similar question. It is slightly inaccurate as to
the time of mp3 files but it failry close.
#! /bin/sh
sox $1 -e stat
I believe it will handle several formats of files.
Martin McCormick WB5AGZ Stillwater, OK
Systems Engineer
OSU Information Technology Department Telecommunications Services Group
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: analyze a .wav or .mp3 file
Martin McCormick
@ ` Terry Klarich
0 siblings, 0 replies; 9+ messages in thread
From: Terry Klarich @ UTC (permalink / raw)
To: Linux for blind general discussion
Hey All:
Thanks to all for all the good responses. I found them both very helpful and informative.
I will be using:
sox testfile.wav -n stat -v
It is very simple and reliable. An empty file has a value of 180.00... 183.00. Files containing valid audio have anything from
1.00 to about 15.00 (it seams).
I'll continue to work on streaming xm though.
Hey All:
Thanks to all for all the good responses. I found them both very helpful and informative.
I will be using:
sox testfile.wav -n stat -v
It is very simple and reliable. An empty file has a value of 180.00... 183.00. Files containing valid audio have anything from
1.00 to about 15.00 (it seams).
I'll continue to work on streaming xm though.
Terry
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: analyze a .wav or .mp3 file
@ Martin McCormick
0 siblings, 0 replies; 9+ messages in thread
From: Martin McCormick @ UTC (permalink / raw)
To: Linux for blind general discussion
I just tried it and it will tell you if a .wav file is silent
but it didn't work on a mp3 so I was a bit mistaken. I think the
sox man page says it can handle mp3's if you have certain
libraries. It definitely worked on a 10-second sample of
stereophonic silence. Actually, it just has 0's for the
maximum, minimum and average levels so you might pipe that
through another decision to get a silence detector.
Mplayer will convert mp3's to wav files.
Martin
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: analyze a .wav or .mp3 file
@ Martin McCormick
0 siblings, 0 replies; 9+ messages in thread
From: Martin McCormick @ UTC (permalink / raw)
To: Linux for blind general discussion, Chris Brannon
Thanks for the syntax reminder. I wrote that shell script before
the change. I also need to change another shell script that used
the stretch command. sox reminds me every time that I need to
fix that. One of these days, a new version of sox will not work
at all.
Martin
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~ UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
analyze a .wav or .mp3 file Terry Klarich
` Hart Larry
` Chris Brannon
` Tim Chase
` Geoff Shang
Martin McCormick
` Terry Klarich
Martin McCormick
Martin McCormick
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).