Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, July 13, 2011 8:40 AM
Hi Guys,
Please help me, how to read wav file header information using c# 2.0.
Thanks in Adavanced.
All replies (6)
Thursday, July 28, 2011 4:39 AM âś…Answered
Hi Thanks to all for shown intrest,
I have found alternative way for reading samplerates of wav file.
http://www.codeproject.com/KB/audio-video/Concatenation_Wave_Files.aspx?display=Print
I did relevant changes to provide samplerated instead of mergre (original code was meging)
public double WaveHeaderIN(string spath)
{
FileStream fs = new FileStream(spath, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
length = (int)fs.Length - 8;
fs.Position = 22;
channels = br.ReadInt16();
fs.Position = 24;
samplerate = br.ReadInt32();
fs.Position = 34;
BitsPerSample = br.ReadInt16();
DataLength = (int)fs.Length - 44;
br.Close();
fs.Close();
return samplerate;
}
public void button1_Click(object sender, EventArgs e)
{
string fname = "filepath\Filename";
double result = WaveHeaderIN(fname);
MessageBox.Show(result.ToString());
}
Wednesday, July 13, 2011 10:01 AM
Hope this helps.
Wednesday, July 13, 2011 12:09 PM
@ s4lin4u
it can get complicated. that's not much help. let me explain.
http://www.codeproject.com/KB/audio-video/Concatenation_Wave_Files.aspx pointed out by smirnov is definitely a useful starting point. Code Project articles tend to be well written and thoughtful. Ehab Mohamed Essa's article is particularily useful because of the information about the file format.
What may (or may not) be a problem for you depends on how and where you get the files that you wish to analyze. Perhaps you could say more about that.
Example: your wave file could be created from audio cd's by a number of different programs. Audio cd's sometimes have meta data about the music or spoken word tracks (artist, title, et cetera). That information is buried in sub channels and not all programs that will convert audio tracks to wave files pick up all of the sub channel meta data. For that reason, if the information you are looking for is audio cd meta data, you are better off to read it directly from the cd, although this too is no easy challenge.
A very useful program for reading damaged CD's and DVD's is isobuster. http://www.isobuster.com/ isobuster's help file is worth reading http://www.isobuster.com/help.php, especially the "More Techincal" section and the FAQ.
You may find this article helpful http://www.codeproject.com/KB/cs/csharpripper.aspx.
rgds / g.
Friday, July 15, 2011 5:17 AM
Hi,
My wav file is dictated by handheld dictation(olympus) and looking for read the header information of that. for check wav length.
Thanks in Advanced,
Friday, July 15, 2011 10:52 AM
@ s4lin4u
have you tried contacting Olympus technical support? Ask for their file specification.
also, if you have programs like Nero Kwik Media (free http://www.nero.com/enu/downloads-kwik-media-free-kwik-burn.php *), Windows Media Player, and other programs that play .wav files, you can include your Olympus files in the media applications' libraries and view the meta data that Olympus creates.
* Bonus: Nero gives you Nero Kwik Burn for free; instructions for getting Nero Kwik Burn are at the above link.
another option, although time consuming, is to use the hexadecimal view of editor programs like the free PsPAD (http://www.pspad.com/) to analyze the Olympus file structure. You could do this by comparing a few short voice recordings. Ehab Mohamed Essa's article** mentioned in this thread by smirnov will likely be at least somewhat useful to your understanding the file structure.
** http://www.codeproject.com/KB/audio-video/Concatenation_Wave_Files.aspx
g.
Friday, July 15, 2011 10:54 AM
P.S.: you should load media files into more than one media player because not all media player applications display all of the media files' metadata. Example: I've seen Windows Media Player display no meta data for an audio CD while Nero Kwik Media and isoBuster (http://isobuster.com/) for the same audio cd did display the meta data.