LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get Audio file information

Hi!

 

I been trying to get information about an audio file like Duration, size, format, Bit Rate, etc.

I been trying using Shell32.dll in different languages like C#, C++, Visual basic, etc. and of course LabView.

 

do anybody have an Idea?

 

I search inside the forum for a possible sample but no luck.

Thank you guys.

 

0 Kudos
Message 1 of 8
(2,675 Views)

Hi Luis,

 

I been trying using Shell32.dll in different languages like C#, C++, Visual basic, etc.

What have you tried so far? Had any luck with those languages?

 

and of course LabView. do anybody have an Idea?

You may load WAV files using the Sound file functions. Then you can determine duration from sample rate and sample count…

Best regards,
GerdW


using LV2020 on Win8.1+cRIO
0 Kudos
Message 2 of 8
(2,666 Views)

Every sound file format has... well... a different format!!!  I believe most (all?) sound files have a header at the beginning describing everything you just mentioned - and probably a lot more stuff than you'll ever want to know about it.  These headers are mostly (all?) in plain text so you should be able to make a parser for whatever sound files you want to parse.  Click here for more info.  (Hey, you were just about to ask me where you could find all this info, right?)

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 8
(2,659 Views)

Following GerdW's suggestion, I can tell you that on my Windows 10 PC, the Windows Startup .WAV file has 9584 samples per channel, sampled at 44100 samples/sec for 2 channels and 16 bits/sample.  If we assume most of the file is data, 2 channels * 2 bytes/sample * 9584 samples = 38,168 bytes -- Windows reports the file size as 38,380, pretty close (there is probably embedded meta-data).  But LabVIEW can definitely get you the data files, the number of channels, the data format, and the sampling rate, all you should need.

 

Go try it out!

 

Bob Schor

0 Kudos
Message 4 of 8
(2,644 Views)

Thanks everybody.

1.- I tried using LabView and other languages, but no luck in any.

2.- we normally have many different formats (MP3, WAV, etc), and every format have different characteristics of Bit Rate, duration size, etc.

3.- I tried to use the "Headers" information inside very file, but can't fine the header.

 

I need that information to use it inside a database, and the user can choose any audio file in any format.

 

 

0 Kudos
Message 5 of 8
(2,636 Views)

Hi Luis,

 

you can try to use tools from some packages like ffdshow/FFmpeg. I would start with ffprobe

Best regards,
GerdW


using LV2020 on Win8.1+cRIO
0 Kudos
Message 6 of 8
(2,624 Views)

Now you've done it - you've made me go and look the stuff up.  😉

 

Seems like, at least for mp3 files, the file is broken up into frames and each frame has a header.  (This explains why many mp3 players keep a running dialog that has all those audio parameters.  I thought they calculated it on the fly.  I guess they just read the headers and display the information.  What a letdown.)

 

What you will have to do for each mp3 file is parse all the frames, get all the headers, then decide what to do with them.  I think usually all the frame information is averaged over all the headers.  It shouldn't be very difficult.  Read the file, look for headers on the fly.  Parse them out as you find them.  Do something with them once you've parsed them all.

 

You might then consider writing an ID3 tag and prefixing the file with it.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 8
(2,622 Views)

Some code for parsing the ID3v1 tags can be found on LAVA.

 

https://lavag.org/files/file/44-mp3-id3v1-tags/

 

As for V2 (more common) you'll likely need a DLL, or a very deep understanding of the format.  I'd also recommend looking into command line calls to something like VLC.

0 Kudos
Message 8 of 8
(2,533 Views)