Solved

Getting handle of midi device

Posted on 1997-06-09
3
297 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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 my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

757 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