Solved

MIDI and mmsystem

Posted on 1998-04-27
10
922 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
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 Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

840 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