944,172 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 14946
  • C# RSS
You are currently viewing page 1 of this multi-page discussion thread
Jul 19th, 2006
0

Getting Audio File Length in C#

Expand 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...
C# Syntax (Toggle Plain Text)
  1.  
  2. int seconds = myFile.AudioLength();

Any help would be appreciated

Mike
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mkamioner is offline Offline
1 posts
since Jul 2006
Jul 4th, 2007
0

Re: Getting Audio File Length in C#

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



Click to Expand / Collapse  Quote originally posted by mkamioner ...
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...
C# Syntax (Toggle Plain Text)
  1.  
  2. int seconds = myFile.AudioLength();

Any help would be appreciated

Mike
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jose.rtl is offline Offline
1 posts
since Jul 2007
Oct 7th, 2009
-1

Getting Audio file duration(.dss)

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sanjay092 is offline Offline
6 posts
since Mar 2009
Oct 7th, 2009
0
Re: Getting Audio File Length in C#
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.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
ctrl-alt-del is offline Offline
65 posts
since Jul 2008
Oct 9th, 2009
0
Re: Getting Audio File Length in C#
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sanjay092 is offline Offline
6 posts
since Mar 2009
Oct 9th, 2009
0
Re: Getting Audio File Length in C#
I saw on this calculation on the web, but I don't have a .dss file to test it with...

C# Syntax (Toggle Plain Text)
  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. }
Reputation Points: 341
Solved Threads: 233
Posting Shark
DdoubleD is offline Offline
984 posts
since Jul 2009
Oct 10th, 2009
0

time duration of .DSS audio file

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sanjay092 is offline Offline
6 posts
since Mar 2009
Oct 10th, 2009
0
Re: Getting Audio File Length in C#
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)
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
ctrl-alt-del is offline Offline
65 posts
since Jul 2008
Oct 10th, 2009
0
Re: Getting Audio File Length in C#
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sanjay092 is offline Offline
6 posts
since Mar 2009
Oct 10th, 2009
0
Re: Getting Audio File Length in C#
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.
Reputation Points: 341
Solved Threads: 233
Posting Shark
DdoubleD is offline Offline
984 posts
since Jul 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: database and setup project
Next Thread in C# Forum Timeline: Naming Convention





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC