Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 948
  • Last Modified:

MIDI and mmsystem

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
hanmannis
Asked:
hanmannis
  • 4
  • 3
  • 2
  • +1
1 Solution
 
interCommented:
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
 
ZifNabCommented:
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
 
ZifNabCommented:
Yes Inter, I see that's a possible problem.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
d003303Commented:
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
 
d003303Commented:
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
 
interCommented:
Nice work, no problem friend.
Regards, Igor
0
 
ZifNabCommented:
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
 
d003303Commented:
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
 
ZifNabCommented:
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
 
hanmannisAuthor Commented:
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now