Midi Files: finding the length?

DrSlue
DrSlue used Ask the Experts™
on
Hi guys. I need to know how to call the length of a midi file, so that i can create some other functions for a program that i am making for a few of my friends.
 I'm fairly new to VB, so i don't know too much of the complex stuff, but here goes. I'm using a system (i believe it's called API) to play the midi files, and the syntax is like this:
i = mciSendString("play mid1 from 0", 0&, 0, 0)
Is it possible to call the length of a midi while using this method? Any help would be much appreciated!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
VK

Commented:
Hello DrSlue,

do you mean the length of the music or the length of the midi-file ?

v.k.
VK

Commented:
If you mean the length of the music then try this:

1. Add a reference to the ActiveX-Control MCI32.OCX (Microsoft Multimedia Control).
2. Insert an instance of the Control on a form.
3. Try this

Private Sub Form_Load()
   MMControl1.Notify = False
   MMControl1.Wait = True
   MMControl1.Shareable = False
   MMControl1.DeviceType = "Sequencer"
   MMControl1.FileName = "C:\WINDOWS\MEDIA\PASSPORT.MID"
   MMControl1.Command = "Open"
   Debug.Print MMControl1.Length
End Sub

v.k.

Author

Commented:
Thanks! I'm finally getting some sort of output, but i was wondering what exactly that is outputting it in (unit wise).
I'm using this code:
MMControl1.Wait = True
  MMControl1.Shareable = False
  MMControl1.DeviceType = "Sequencer"
  MMControl1.FileName = midi & ".mid"
  MMControl1.Command = "Open"
  lblLength.Caption = MMControl1.Length

Where midi is the current song playing e.g:
midi = "z64epona"
i = mciSendString("open " & midi & ".mid type sequencer alias mid1", 0&, 0, 0)

It displays it as being "660", but when i load it up in winamp to check, it displays it as 108 Seconds (1:48min).
SO could you or someone else please explain this a bit further.
Author of the Year 2009

Commented:
Hi DrSlue,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.

DrSlue, Please DO NOT accept THIS comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
Question placed in PAQ

Computer101
E-E Admin

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial