Solved

MIDI and mmsystem

Posted on 1998-04-27
10
908 Views
Last Modified: 2012-06-27
I'm interestin about midi programmin and have made som high level mci-calls, but when I try to call functions from mmsystem.lib file it usualy gives me many error messages. Example: I put mmsystem to uses clause and definie pointer to PMidiInGetDevCapsA (var mincaps: PMidiInGetDevCapsA;) but when Imake a call  mincaps.pMid it gives me accessibility error.  
0
Comment
Question by:hanmannis
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 5

Expert Comment

by:inter
ID: 1337369
Hi,
I am not sure but, may be you forget to initialize the memory associated with is such as
 New(mincaps); then call it safely. After you are done with is Dispose(mincaps);
Igor
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337370
Hanmannis,

Don't you've to use MinCaps^.pMid?

PS. I don't find PMidiInGetDevCapsA... Which version of Delphi are you using?

Regards, Zif.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337371
Yes Inter, I see that's a possible problem.
0
 
LVL 4

Accepted Solution

by:
d003303 earned 100 total points
ID: 1337372
PMidiInGetDevCapsA ?? pMid ??
The declaration of the function is
function midiInGetDevCapsA(DeviceID: UINT; lpCaps: PMidiInCapsA; uSize: UINT): MMRESULT; stdcall;
and the structure of PMidiInCapsA is declared as
  PMidiInCapsA = ^TMidiInCapsA;
  TMidiInCapsA = record
    wMid: Word;                  { manufacturer ID }
    wPid: Word;                  { product ID }
    vDriverVersion: MMVERSION;   { version of the driver }
    szPname: array[0..MAXPNAMELEN-1] of AnsiChar;  { product name (NULL terminated string) }
    dwSupport: DWORD;            { functionality supported by driver }
  end;

Maybe you just forgot to get memory for the pointer struct. This will work :

procedure TForm1.Button1Click(Sender: TObject);
var MyCaps : PMidiInCapsA;
    FRes   : MMRESULT;
begin
  New(MyCaps);
  FRes := midiInGetDevCapsA(0, MyCaps, SizeOf(TMidiInCapsA));
  if FRes = MMSYSERR_NOERROR then
   begin
     MessageDlg(Format('MIDI In Driver vendor: %s', [MyCaps^.szPname]), mtInformation, [mbOk], 0);
   end;
  Dispose(MyCaps);
end;

0
 
LVL 4

Expert Comment

by:d003303
ID: 1337373
Yo inter, Zif,
I havent' seen all your comments in the meantime. The question was empty when I was submitting my answer, sorry ! Yeah, you both were absolutely right.
This is real Windows multithreading ! It works perfectly in parallel, but every thread does exaclty the same thing ;-)

Cheers,
Slash/d003303
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 5

Expert Comment

by:inter
ID: 1337374
Nice work, no problem friend.
Regards, Igor
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337375
Hi all,

You're right d003303. Besides, don't you think it would be really interesting if they could split the points? That way multiple persons could give advise and help to come to a good and well-thought answer. I read they were trying to built something like I proposed, but I haven't heard anything about it anymore... Ok, I quit, before I spoil this thread.

Regards, ZiF.



0
 
LVL 4

Expert Comment

by:d003303
ID: 1337376
Yo !
Zif, right, splitting points would be realy nice ! That would eliminate the feeling of <stealing> somebodys commented idea to implemet it in your own answer.

CU,
Slash/d003303
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337377
Yep, that's correct, because sometimes, you don't know the answer right away, but with the help of a piece of source of somebody else, you can solve it. This way, I think, both should receive some points. ZiF.
0
 

Author Comment

by:hanmannis
ID: 1337378
Thank you from your answer! I think that you were right about getting memory for the pointer struct. By the way, I'm using Delphi 3.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now