Getting Audio File Length in C#

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2006
Posts: 1
Reputation: mkamioner is an unknown quantity at this point 
Solved Threads: 0
mkamioner mkamioner is offline Offline
Newbie Poster

Getting Audio File Length in C#

 
0
  #1
Jul 19th, 2006
Hi All

I am looking to be able to get the length of any audio file in seconds. Formats are WAV, MP3 and DSS. Is there anything like this...
  1.  
  2. int seconds = myFile.AudioLength();

Any help would be appreciated

Mike
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 1
Reputation: jose.rtl is an unknown quantity at this point 
Solved Threads: 0
jose.rtl jose.rtl is offline Offline
Newbie Poster

Re: Getting Audio File Length in C#

 
0
  #2
Jul 4th, 2007
Hey hi !

I'm trying to do the same thing to try to see the lenght of an audio file. Did you ever knew how to do it. All I know is how to get the bytes size of the file but don't know how to get the time thanks.

Jose



Originally Posted by mkamioner View Post
Hi All

I am looking to be able to get the length of any audio file in seconds. Formats are WAV, MP3 and DSS. Is there anything like this...
  1.  
  2. int seconds = myFile.AudioLength();

Any help would be appreciated

Mike
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 6
Reputation: sanjay092 is an unknown quantity at this point 
Solved Threads: 0
sanjay092 sanjay092 is offline Offline
Newbie Poster

Getting Audio file duration(.dss)

 
-1
  #3
Oct 7th, 2009
please help to find duration of audio file which is in .dss format. I am able to find duration of .mp3 format file but not able to find .dss file's duration. For Mp3 format m using wmp.dll, but this is not able to find .dss file duration.

pls help me ..... its urgent
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 47
Reputation: ctrl-alt-del is an unknown quantity at this point 
Solved Threads: 0
ctrl-alt-del ctrl-alt-del is offline Offline
Light Poster
 
0
  #4
Oct 7th, 2009
well, I don't remember the exact details, but maybe you can use windows properties for this?
I know there is a way to access the properties of a file under windows. If you were to access the time detail form the soundfile... that might work. Not sure if it would help for .dss files since I'm not sure windows will know what to do with those.

Hope this helps at least a little.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 6
Reputation: sanjay092 is an unknown quantity at this point 
Solved Threads: 0
sanjay092 sanjay092 is offline Offline
Newbie Poster
 
0
  #5
Oct 9th, 2009
thanks ctrl+alt+del for help,
please help me to explore your idea(if possible pls provide an example).

i am using wmp.dll for duration of voice file. this dll has property(durationstring). but it is useful for only .mp3 file. i need .dss file duration. if posibble pls help me.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 903
Reputation: DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough 
Solved Threads: 144
DdoubleD DdoubleD is offline Offline
Posting Shark
 
0
  #6
Oct 9th, 2009
I saw on this calculation on the web, but I don't have a .dss file to test it with...

  1. public static long GetDSSDuration(string fileName)
  2. {
  3. FileInfo fi = new FileInfo(fileName);
  4. long size = fi.Length;
  5.  
  6. long length = (long)(((size * 1.1869) - ((size / 1054) * 210)) / 1054);
  7.  
  8. if (length > 1000)
  9. {
  10. length = (long)(length * (0.61 + ((length / 100) * 0.0005)));
  11. }
  12. else
  13. {
  14. length = (long)(length * (0.61 + ((length / 100) * 0.0015)));
  15. }
  16.  
  17. return length;
  18. }
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 6
Reputation: sanjay092 is an unknown quantity at this point 
Solved Threads: 0
sanjay092 sanjay092 is offline Offline
Newbie Poster

time duration of .DSS audio file

 
0
  #7
Oct 10th, 2009
hello doubleD, really thanks for ur code, i all most reached to result but not accurate. its showing length in second, when m converting into minutes (divide by 60) its not showing accurate time. me trying to understand these formula. if there is any others solution pls help me.

thanks again
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 47
Reputation: ctrl-alt-del is an unknown quantity at this point 
Solved Threads: 0
ctrl-alt-del ctrl-alt-del is offline Offline
Light Poster
 
0
  #8
Oct 10th, 2009
Assuming that the formula outputs time in seconds, all you would have to do is put "length = length / 60;" just before "return length" and that should work fine. (his/her solution is far better then mine since it actually calculates the value for the audiofile, I don't think windows recognizes .dss files, so it won't have any detailed info on it either)
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 6
Reputation: sanjay092 is an unknown quantity at this point 
Solved Threads: 0
sanjay092 sanjay092 is offline Offline
Newbie Poster
 
0
  #9
Oct 10th, 2009
thanks ctrl_alt+del, i did same as u telling. its all most correct, but it not showing accurate duration of .dss file. difference is in 10 to 30 second.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 903
Reputation: DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough 
Solved Threads: 144
DdoubleD DdoubleD is offline Offline
Posting Shark
 
0
  #10
Oct 10th, 2009
How many seconds duration is the dss file(s) that is off by 10 - 30 seconds? Also, do you have many dss files of varying durations? If you do, and the calculation varies proportionately to an increase in duration, you could adjust the calculation to accommodate a better approximation.

EDIT: Also, be sure you are not truncating/rounding the time when calculating minutes in the divide by 60 division...
Last edited by DdoubleD; Oct 10th, 2009 at 8:38 am.
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC