Solved

Getting handle of midi device

Posted on 1997-06-09
3
306 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

732 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