By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,066 Members | 1,826 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,066 IT Pros & Developers. It's quick & easy.

ok ok , anyone know anything on this tough question?

P: n/a
ok ok , anyone know anything on this tough question?

How do you determine the length in seconds that a midi file is , or any
audio file for that matter ?

Nov 20 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Thu, 20 Nov 2008 01:08:41 -0800, Jim Rutledge <ji*****@shaw.cawrote:
ok ok , anyone know anything on this tough question?

How do you determine the length in seconds that a midi file is , or any
audio file for that matter ?
There's nothing in C# or .NET that addresses that need directly. So, you
really should be asking the question in a more appropriate forum.

As for the actual question: from what I recall, the Standard MIDI File
format does not include information about the length of the contents.
It's essentially a data stream tailored for the reproduction of MIDI data
coming in from one or more interfaces. So, the only way to know the
length would be to read and parse the entire stream, adding up all the
deltas between MIDI events to determine the total length.

Other audio formats are different. If I recall correctly, WAV and others
include length information in their headers.

For a general Windows solution, you might look at the IMediaDet interface
in DirectShow. I don't recall whether it specifically supports duration
information for media streams, but if there's any general-purpose
solution, I would bet that's the interface where you'd find it. Of
course, that's unmanaged code, but you may want to check out the
DirectShowNet open-source project. You might be able to use that to do
what you want.

Barring that, you're going to have to write your own implementation to do
this, which means that the interesting parts will need to be researched in
a forum more tailored to multimedia issues.

Pete
Nov 20 '08 #2

P: n/a
Peter Duniho wrote:
On Thu, 20 Nov 2008 01:08:41 -0800, Jim Rutledge <ji*****@shaw.ca>
wrote:
>ok ok , anyone know anything on this tough question?

How do you determine the length in seconds that a midi file is , or
any audio file for that matter ?

There's nothing in C# or .NET that addresses that need directly. So,
you really should be asking the question in a more appropriate forum.

As for the actual question: from what I recall, the Standard MIDI File
format does not include information about the length of the contents.
Well, MCI lets you request the status, including length, of a sequencer
(MIDI) file. So MCI might be the way to go.
It's essentially a data stream tailored for the reproduction of MIDI
data coming in from one or more interfaces. So, the only way to know
the length would be to read and parse the entire stream, adding up
all the deltas between MIDI events to determine the total length.

Other audio formats are different. If I recall correctly, WAV and
others include length information in their headers.

For a general Windows solution, you might look at the IMediaDet
interface in DirectShow. I don't recall whether it specifically
supports duration information for media streams, but if there's any
general-purpose solution, I would bet that's the interface where
you'd find it. Of course, that's unmanaged code, but you may want to
check out the DirectShowNet open-source project. You might be able
to use that to do what you want.

Barring that, you're going to have to write your own implementation
to do this, which means that the interesting parts will need to be
researched in a forum more tailored to multimedia issues.

Pete

Nov 20 '08 #3

P: n/a
On Thu, 20 Nov 2008 10:08:53 -0800, Ben Voigt [C++ MVP]
<rb*@nospam.nospamwrote:
Well, MCI lets you request the status, including length, of a sequencer
(MIDI) file. So MCI might be the way to go.
Maybe, if IMediaDet doesn't offer that information.
Nov 20 '08 #4

P: n/a
"Jim Rutledge" <ji*****@shaw.cawrote in message
news:wO******************@newsfe03.iad...
ok ok , anyone know anything on this tough question?

How do you determine the length in seconds that a midi file is , or any
audio file for that matter ?
You might want to take a look at BASS: http://www.un4seen.com/bass.html.
Nov 20 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.