Solved

Getting handle of midi device

Posted on 1997-06-09
3
305 Views
Last Modified: 2010-04-03
I am using MediaPlayer to control midi playback.
I want to control the volume and to do so must(?) use the Win32 call:

midiOutSetVolume

which takes a Handle(HMIDIOUT) as first parameter but MediaPlayer only provides the DeviceID
(which, BTW, was all that was needed under Win16!)

How can I obtain this Handle?

Alan G.
0
Comment
Question by:agauld
  • 2
3 Comments
 

Author Comment

by:agauld
ID: 1336884
Edited text of question
0
 
LVL 1

Accepted Solution

by:
fsanchez earned 100 total points
ID: 1336885
I have executed this code and it worked on my computer, but I'm not sure it will work always. Try it.

uses MMSystem;
...
var
  HandleMidi: HMIDIOUT;
  Capabilities: TMidiOutCaps;
begin
  if(MidiOutGetDevCaps(MediaPlayer1.DeviceID, @Capabilities, sizeof(Capabilities)) = MMSYSERR_NOERROR) and
   ((Capabilities.dwSupport and MIDICAPS_VOLUME) <> 0)
  then
  begin
    { $FFFF means full volume on both channels }
    if MidiOutSetVolume(MediaPlayer1.DeviceID, $FFFF) <> MMSYSERR_NOERROR then
      ShowMessage('Error');
  end
  else
    ShowMessage('Volume not supported');
end;

If it doesn't work, you should use the handle returned by midioutopen, because the MediaPlayer use mci messages (higl level API) and that handle is used only with the low level API. Note that some cards or drivers don't implement midi volume setting.
0
 

Author Comment

by:agauld
ID: 1336886
The answer is good but didn't work for me... I can read the volume but not set it.
Also tried waveOutSetVolume but same result!


0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 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